diff --git a/Cargo.lock b/Cargo.lock index 0c7ca4269b57f..1f7a476e954ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3585,60 +3585,6 @@ package name = " -cloudabi -" -version -= -" -0 -. -1 -. -0 -" -source -= -" -registry -+ -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -crates -. -io -- -index -" -checksum -= -" -4344512281c643ae7638bbabc3af17a11307803ec8f0fcad9fae512a8bf36467 -" -dependencies -= -[ -" -bitflags -" -] -[ -[ -package -] -] -name -= -" cmake " version @@ -20901,7 +20847,7 @@ version . 8 . -0 +1 " source = @@ -20929,7 +20875,7 @@ index checksum = " -c361aa727dd08437f2f1447be8b59a33b0edd15e0fcee698f935613d9efbca9b +d7c6d9b8427445284a09c55be860a15855ab580a417ccad9da88f5a06787ced0 " dependencies = @@ -20938,14 +20884,11 @@ dependencies cfg - if -0 -. 1 . -10 -" -" -cloudabi +0 +. +0 " " instant @@ -24900,7 +24843,7 @@ version . 24 . -1 +2 " source = @@ -24928,7 +24871,7 @@ index checksum = " -7e3d4791ab5517217f51216a84a688b53c1ebf7988736469c538d02f46ddba68 +d5f38ee71cbab2c827ec0ac24e76f82eca723cee92c509a65f67dee393c25112 " dependencies = @@ -27016,9 +26959,9 @@ version " 1 . -4 +3 . -2 +0 " source = @@ -27046,7 +26989,7 @@ index checksum = " -fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252 +05720e22615919e4734f6a99ceae50d00226c3c5aca406e102ebc33298214e0a " dependencies = diff --git a/servo/components/style/Cargo.toml b/servo/components/style/Cargo.toml index 903d4a70fe1e7..6a824efbd86a6 100644 --- a/servo/components/style/Cargo.toml +++ b/servo/components/style/Cargo.toml @@ -587,12 +587,32 @@ smallbitvec . 0 " +# +See +https +: +/ +/ +github +. +com +/ +servo +/ +rust +- +smallvec +/ +issues +/ +243 smallvec = " += 1 . -0 +3 " static_prefs = diff --git a/third_party/rust/cloudabi/.cargo-checksum.json b/third_party/rust/cloudabi/.cargo-checksum.json deleted file mode 100644 index 7cde6f90f91a4..0000000000000 --- a/third_party/rust/cloudabi/.cargo-checksum.json +++ /dev/null @@ -1,33 +0,0 @@ -{ -" -files -" -: -{ -" -Cargo -. -toml -" -: -" -8f287443ede083f9f2816bccdd6a23f0b58e70337315c06a34a9ae06029242d1 -" -" -cloudabi -. -rs -" -: -" -5660f8ac289098a3fc9b39df2c8ec1f218bbbd8a98ec38b17f24a1dd8fbc0bdb -" -} -" -package -" -: -" -4344512281c643ae7638bbabc3af17a11307803ec8f0fcad9fae512a8bf36467 -" -} diff --git a/third_party/rust/cloudabi/Cargo.toml b/third_party/rust/cloudabi/Cargo.toml deleted file mode 100644 index 275f88ed8eaf1..0000000000000 --- a/third_party/rust/cloudabi/Cargo.toml +++ /dev/null @@ -1,261 +0,0 @@ -# -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 -= -" -cloudabi -" -version -= -" -0 -. -1 -. -0 -" -authors -= -[ -" -Nuxi -( -https -: -/ -/ -nuxi -. -nl -/ -) -and -contributors -" -] -description -= -" -Low -level -interface -to -CloudABI -. -Contains -all -syscalls -and -related -types -. -" -homepage -= -" -https -: -/ -/ -cloudabi -. -org -/ -" -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 -. -2 -. -1 -" -optional -= -true -[ -features -] -default -= -[ -" -bitflags -" -] diff --git a/third_party/rust/cloudabi/cloudabi.rs b/third_party/rust/cloudabi/cloudabi.rs deleted file mode 100644 index 9b0c6935ca2a7..0000000000000 --- a/third_party/rust/cloudabi/cloudabi.rs +++ /dev/null @@ -1,26389 +0,0 @@ -/ -/ -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 -: -/ -/ -! -/ -/ -! -- -[ -FreeBSD -] -( -https -: -/ -/ -cloudabi -. -org -/ -run -/ -freebsd -/ -) -/ -/ -! -- -[ -Linux -] -( -https -: -/ -/ -cloudabi -. -org -/ -run -/ -linux -/ -) -/ -/ -! -- -[ -macOS -] -( -https -: -/ -/ -cloudabi -. -org -/ -run -/ -macos -/ -) -/ -/ -! -/ -/ -! -# -# -Specification -of -the -ABI -/ -/ -! -/ -/ -! -The -entire -ABI -is -specified -in -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 -) -] -# -[ -cfg -( -feature -= -" -bitflags -" -) -] -use -bitflags -: -: -bitflags -; -/ -/ -Minimal -implementation -of -bitflags -! -in -case -we -can -' -t -depend -on -the -bitflags -/ -/ -crate -. -Only -implements -bits -( -) -and -a -from_bits_unchecked -( -) -. -# -[ -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 -const -fn -bits -( -& -self -) -- -> -type -{ -self -. -bits -} -pub -const -unsafe -fn -from_bits_unchecked -( -bits -: -type -) -- -> -Self -{ -name -{ -bits -} -} -} -} -} -/ -/ -/ -File -or -memory -access -pattern -advisory -information -. -# -[ -repr -( -u8 -) -] -# -[ -derive -( -Copy -Clone -Eq -PartialEq -Hash -Debug -) -] -# -[ -non_exhaustive -] -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 -} -/ -/ -/ -Enumeration -describing -the -kind -of -value -stored -in -[ -auxv -] -( -struct -. -auxv -. -html -) -. -# -[ -repr -( -u32 -) -] -# -[ -derive -( -Copy -Clone -Eq -PartialEq -Hash -Debug -) -] -# -[ -non_exhaustive -] -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 -} -/ -/ -/ -Identifiers -for -clocks -. -# -[ -repr -( -u32 -) -] -# -[ -derive -( -Copy -Clone -Eq -PartialEq -Hash -Debug -) -] -# -[ -non_exhaustive -] -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 -} -/ -/ -/ -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 -) -] -# -[ -non_exhaustive -] -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 -} -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 -) -] -# -[ -non_exhaustive -] -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 -} -/ -/ -/ -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 -) -] -# -[ -non_exhaustive -] -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 -} -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 -) -] -# -[ -non_exhaustive -] -pub -enum -scope -{ -/ -/ -/ -The -object -is -stored -in -private -memory -. -PRIVATE -= -4 -/ -/ -/ -The -object -is -stored -in -shared -memory -. -SHARED -= -8 -} -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 -) -] -# -[ -non_exhaustive -] -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 -} -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 -) -] -# -[ -non_exhaustive -] -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 -} -/ -/ -/ -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 -] -( -struct -. -auxv -. -html -# -structfield -. -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 -] -( -struct -. -auxv -. -html -# -structfield -. -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 -: -: -< -auxv -> -( -) -8 -) -; -assert_eq -! -( -core -: -: -mem -: -: -align_of -: -: -< -auxv -> -( -) -4 -) -; -let -mut -obj -= -auxv -{ -a_type -: -auxtype -: -: -ARGDATA -union -: -auxv_union -{ -a_val -: -0 -} -} -; -let -base -= -& -obj -as -* -const -_ -as -usize -; -assert_eq -! -( -& -obj -. -a_type -as -* -const -_ -as -usize -- -base -0 -) -; -obj -. -union -. -a_val -= -0 -; -unsafe -{ -assert_eq -! -( -& -obj -. -union -. -a_val -as -* -const -_ -as -usize -- -base -4 -) -; -} -obj -. -union -. -a_ptr -= -0 -as -* -mut -( -) -; -unsafe -{ -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 -: -: -< -auxv -> -( -) -16 -) -; -assert_eq -! -( -core -: -: -mem -: -: -align_of -: -: -< -auxv -> -( -) -8 -) -; -let -mut -obj -= -auxv -{ -a_type -: -auxtype -: -: -ARGDATA -union -: -auxv_union -{ -a_val -: -0 -} -} -; -let -base -= -& -obj -as -* -const -_ -as -usize -; -assert_eq -! -( -& -obj -. -a_type -as -* -const -_ -as -usize -- -base -0 -) -; -obj -. -union -. -a_val -= -0 -; -unsafe -{ -assert_eq -! -( -& -obj -. -union -. -a_val -as -* -const -_ -as -usize -- -base -8 -) -; -} -obj -. -union -. -a_ptr -= -0 -as -* -mut -( -) -; -unsafe -{ -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 -: -: -< -ciovec -> -( -) -8 -) -; -assert_eq -! -( -core -: -: -mem -: -: -align_of -: -: -< -ciovec -> -( -) -4 -) -; -let -obj -= -ciovec -{ -buf -: -( -0 -as -* -const -_ -0 -) -} -; -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 -: -: -< -ciovec -> -( -) -16 -) -; -assert_eq -! -( -core -: -: -mem -: -: -align_of -: -: -< -ciovec -> -( -) -8 -) -; -let -obj -= -ciovec -{ -buf -: -( -0 -as -* -const -_ -0 -) -} -; -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 -: -: -< -dirent -> -( -) -24 -) -; -assert_eq -! -( -core -: -: -mem -: -: -align_of -: -: -< -dirent -> -( -) -8 -) -; -let -obj -= -dirent -{ -d_next -: -dircookie -( -0 -) -d_ino -: -inode -( -0 -) -d_namlen -: -0 -d_type -: -filetype -: -: -UNKNOWN -} -; -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 -r -# -type -: -eventtype -pub -union -: -event_union -} -/ -/ -/ -A -union -inside -event -. -# -[ -repr -( -C -) -] -# -[ -derive -( -Copy -Clone -) -] -pub -union -event_union -{ -/ -/ -/ -Used -when -[ -type -] -( -struct -. -event -. -html -# -structfield -. -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 -] -( -struct -. -event -. -html -# -structfield -. -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 -: -: -< -event -> -( -) -32 -) -; -assert_eq -! -( -core -: -: -mem -: -: -align_of -: -: -< -event -> -( -) -8 -) -; -let -mut -obj -= -event -{ -userdata -: -0 -error -: -errno -: -: -SUCCESS -r -# -type -: -eventtype -: -: -CLOCK -union -: -event_union -{ -fd_readwrite -: -event_fd_readwrite -{ -nbytes -: -0 -unused -: -[ -0 -; -4 -] -flags -: -eventrwflags -: -: -HANGUP -} -} -} -; -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 -. -r -# -type -as -* -const -_ -as -usize -- -base -10 -) -; -obj -. -union -. -fd_readwrite -= -event_fd_readwrite -{ -nbytes -: -0 -unused -: -[ -0 -; -4 -] -flags -: -eventrwflags -: -: -HANGUP -} -; -unsafe -{ -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 -) -; -} -obj -. -union -. -proc_terminate -= -event_proc_terminate -{ -unused -: -[ -0 -; -4 -] -signal -: -signal -: -: -ABRT -exitcode -: -0 -} -; -unsafe -{ -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 -: -: -< -fdstat -> -( -) -24 -) -; -assert_eq -! -( -core -: -: -mem -: -: -align_of -: -: -< -fdstat -> -( -) -8 -) -; -let -obj -= -fdstat -{ -fs_filetype -: -filetype -: -: -UNKNOWN -fs_flags -: -fdflags -: -: -APPEND -fs_rights_base -: -rights -: -: -FD_DATASYNC -fs_rights_inheriting -: -rights -: -: -FD_DATASYNC -} -; -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 -: -: -< -filestat -> -( -) -56 -) -; -assert_eq -! -( -core -: -: -mem -: -: -align_of -: -: -< -filestat -> -( -) -8 -) -; -let -obj -= -filestat -{ -st_dev -: -device -( -0 -) -st_ino -: -inode -( -0 -) -st_filetype -: -filetype -: -: -UNKNOWN -st_nlink -: -0 -st_size -: -0 -st_atim -: -0 -st_mtim -: -0 -st_ctim -: -0 -} -; -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 -: -: -< -iovec -> -( -) -8 -) -; -assert_eq -! -( -core -: -: -mem -: -: -align_of -: -: -< -iovec -> -( -) -4 -) -; -let -obj -= -iovec -{ -buf -: -( -0 -as -* -mut -_ -0 -) -} -; -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 -: -: -< -iovec -> -( -) -16 -) -; -assert_eq -! -( -core -: -: -mem -: -: -align_of -: -: -< -iovec -> -( -) -8 -) -; -let -obj -= -iovec -{ -buf -: -( -0 -as -* -mut -_ -0 -) -} -; -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 -: -: -< -lookup -> -( -) -8 -) -; -assert_eq -! -( -core -: -: -mem -: -: -align_of -: -: -< -lookup -> -( -) -4 -) -; -let -obj -= -lookup -{ -fd -: -fd -( -0 -) -flags -: -lookupflags -: -: -SYMLINK_FOLLOW -} -; -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 -: -: -< -recv_in -> -( -) -20 -) -; -assert_eq -! -( -core -: -: -mem -: -: -align_of -: -: -< -recv_in -> -( -) -4 -) -; -let -obj -= -recv_in -{ -ri_data -: -( -0 -as -* -const -_ -0 -) -ri_fds -: -( -0 -as -* -mut -_ -0 -) -ri_flags -: -riflags -: -: -PEEK -} -; -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 -: -: -< -recv_in -> -( -) -40 -) -; -assert_eq -! -( -core -: -: -mem -: -: -align_of -: -: -< -recv_in -> -( -) -8 -) -; -let -obj -= -recv_in -{ -ri_data -: -( -0 -as -* -const -_ -0 -) -ri_fds -: -( -0 -as -* -mut -_ -0 -) -ri_flags -: -riflags -: -: -PEEK -} -; -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 -: -: -< -recv_out -> -( -) -52 -) -; -assert_eq -! -( -core -: -: -mem -: -: -align_of -: -: -< -recv_out -> -( -) -4 -) -; -let -obj -= -recv_out -{ -ro_datalen -: -0 -ro_fdslen -: -0 -ro_unused -: -[ -0 -; -40 -] -ro_flags -: -roflags -: -: -FDS_TRUNCATED -} -; -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 -: -: -< -recv_out -> -( -) -64 -) -; -assert_eq -! -( -core -: -: -mem -: -: -align_of -: -: -< -recv_out -> -( -) -8 -) -; -let -obj -= -recv_out -{ -ro_datalen -: -0 -ro_fdslen -: -0 -ro_unused -: -[ -0 -; -40 -] -ro_flags -: -roflags -: -: -FDS_TRUNCATED -} -; -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 -: -: -< -send_in -> -( -) -20 -) -; -assert_eq -! -( -core -: -: -mem -: -: -align_of -: -: -< -send_in -> -( -) -4 -) -; -let -obj -= -send_in -{ -si_data -: -( -0 -as -* -const -_ -0 -) -si_fds -: -( -0 -as -* -const -_ -0 -) -si_flags -: -siflags -: -: -DEFAULT -} -; -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 -: -: -< -send_in -> -( -) -40 -) -; -assert_eq -! -( -core -: -: -mem -: -: -align_of -: -: -< -send_in -> -( -) -8 -) -; -let -obj -= -send_in -{ -si_data -: -( -0 -as -* -const -_ -0 -) -si_fds -: -( -0 -as -* -const -_ -0 -) -si_flags -: -siflags -: -: -DEFAULT -} -; -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 -: -: -< -send_out -> -( -) -4 -) -; -assert_eq -! -( -core -: -: -mem -: -: -align_of -: -: -< -send_out -> -( -) -4 -) -; -let -obj -= -send_out -{ -so_datalen -: -0 -} -; -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 -: -: -< -send_out -> -( -) -8 -) -; -assert_eq -! -( -core -: -: -mem -: -: -align_of -: -: -< -send_out -> -( -) -8 -) -; -let -obj -= -send_out -{ -so_datalen -: -0 -} -; -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 -r -# -type -: -eventtype -pub -union -: -subscription_union -} -/ -/ -/ -A -union -inside -subscription -. -# -[ -repr -( -C -) -] -# -[ -derive -( -Copy -Clone -) -] -pub -union -subscription_union -{ -/ -/ -/ -Used -when -[ -type -] -( -struct -. -subscription -. -html -# -structfield -. -type -) -is -[ -CLOCK -] -( -enum -. -eventtype -. -html -# -variant -. -CLOCK -) -. -pub -clock -: -subscription_clock -/ -/ -/ -Used -when -[ -type -] -( -struct -. -subscription -. -html -# -structfield -. -type -) -is -[ -CONDVAR -] -( -enum -. -eventtype -. -html -# -variant -. -CONDVAR -) -. -pub -condvar -: -subscription_condvar -/ -/ -/ -Used -when -[ -type -] -( -struct -. -subscription -. -html -# -structfield -. -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 -] -( -struct -. -subscription -. -html -# -structfield -. -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 -] -( -struct -. -subscription -. -html -# -structfield -. -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 -: -: -< -subscription -> -( -) -56 -) -; -assert_eq -! -( -core -: -: -mem -: -: -align_of -: -: -< -subscription -> -( -) -8 -) -; -let -mut -obj -= -subscription -{ -userdata -: -0 -unused -: -0 -r -# -type -: -eventtype -: -: -CLOCK -union -: -subscription_union -{ -clock -: -subscription_clock -{ -identifier -: -0 -clock_id -: -clockid -: -: -MONOTONIC -timeout -: -0 -precision -: -0 -flags -: -subclockflags -: -: -ABSTIME -} -} -} -; -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 -. -r -# -type -as -* -const -_ -as -usize -- -base -10 -) -; -obj -. -union -. -clock -= -subscription_clock -{ -identifier -: -0 -clock_id -: -clockid -: -: -MONOTONIC -timeout -: -0 -precision -: -0 -flags -: -subclockflags -: -: -ABSTIME -} -; -unsafe -{ -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 -) -; -} -obj -. -union -. -condvar -= -subscription_condvar -{ -condvar -: -0 -as -* -mut -condvar -lock -: -0 -as -* -mut -lock -condvar_scope -: -scope -: -: -PRIVATE -lock_scope -: -scope -: -: -PRIVATE -} -; -unsafe -{ -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 -) -; -} -obj -. -union -. -fd_readwrite -= -subscription_fd_readwrite -{ -fd -: -fd -( -0 -) -flags -: -subrwflags -: -: -POLL -} -; -unsafe -{ -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 -) -; -} -obj -. -union -. -lock -= -subscription_lock -{ -lock -: -0 -as -* -mut -lock -lock_scope -: -scope -: -: -PRIVATE -} -; -unsafe -{ -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 -) -; -} -obj -. -union -. -proc_terminate -= -subscription_proc_terminate -{ -fd -: -fd -( -0 -) -} -; -unsafe -{ -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 -: -: -< -subscription -> -( -) -56 -) -; -assert_eq -! -( -core -: -: -mem -: -: -align_of -: -: -< -subscription -> -( -) -8 -) -; -let -mut -obj -= -subscription -{ -userdata -: -0 -unused -: -0 -r -# -type -: -eventtype -: -: -CLOCK -union -: -subscription_union -{ -clock -: -subscription_clock -{ -identifier -: -0 -clock_id -: -clockid -: -: -MONOTONIC -timeout -: -0 -precision -: -0 -flags -: -subclockflags -: -: -ABSTIME -} -} -} -; -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 -. -r -# -type -as -* -const -_ -as -usize -- -base -10 -) -; -obj -. -union -. -clock -= -subscription_clock -{ -identifier -: -0 -clock_id -: -clockid -: -: -MONOTONIC -timeout -: -0 -precision -: -0 -flags -: -subclockflags -: -: -ABSTIME -} -; -unsafe -{ -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 -) -; -} -obj -. -union -. -condvar -= -subscription_condvar -{ -condvar -: -0 -as -* -mut -condvar -lock -: -0 -as -* -mut -lock -condvar_scope -: -scope -: -: -PRIVATE -lock_scope -: -scope -: -: -PRIVATE -} -; -unsafe -{ -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 -) -; -} -obj -. -union -. -fd_readwrite -= -subscription_fd_readwrite -{ -fd -: -fd -( -0 -) -flags -: -subrwflags -: -: -POLL -} -; -unsafe -{ -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 -) -; -} -obj -. -union -. -lock -= -subscription_lock -{ -lock -: -0 -as -* -mut -lock -lock_scope -: -scope -: -: -PRIVATE -} -; -unsafe -{ -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 -) -; -} -obj -. -union -. -proc_terminate -= -subscription_proc_terminate -{ -fd -: -fd -( -0 -) -} -; -unsafe -{ -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 -: -: -< -tcb -> -( -) -4 -) -; -assert_eq -! -( -core -: -: -mem -: -: -align_of -: -: -< -tcb -> -( -) -4 -) -; -let -obj -= -tcb -{ -parent -: -0 -as -* -mut -( -) -} -; -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 -: -: -< -tcb -> -( -) -8 -) -; -assert_eq -! -( -core -: -: -mem -: -: -align_of -: -: -< -tcb -> -( -) -8 -) -; -let -obj -= -tcb -{ -parent -: -0 -as -* -mut -( -) -} -; -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 -: -: -< -threadattr -> -( -) -16 -) -; -assert_eq -! -( -core -: -: -mem -: -: -align_of -: -: -< -threadattr -> -( -) -4 -) -; -let -obj -= -threadattr -{ -entry_point -: -{ -extern -" -C -" -fn -f -( -_ -: -tid -_ -: -* -mut -( -) -) -- -> -( -) -{ -} -f -} -stack -: -( -0 -as -* -mut -_ -0 -) -argument -: -0 -as -* -mut -( -) -} -; -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 -: -: -< -threadattr -> -( -) -32 -) -; -assert_eq -! -( -core -: -: -mem -: -: -align_of -: -: -< -threadattr -> -( -) -8 -) -; -let -obj -= -threadattr -{ -entry_point -: -{ -extern -" -C -" -fn -f -( -_ -: -tid -_ -: -* -mut -( -) -) -- -> -( -) -{ -} -f -} -stack -: -( -0 -as -* -mut -_ -0 -) -argument -: -0 -as -* -mut -( -) -} -; -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/rust/parking_lot_core/.cargo-checksum.json b/third_party/rust/parking_lot_core/.cargo-checksum.json index 8a60c76dc6552..0a87a9372c78a 100644 --- a/third_party/rust/parking_lot_core/.cargo-checksum.json +++ b/third_party/rust/parking_lot_core/.cargo-checksum.json @@ -11,7 +11,7 @@ toml " : " -f1e6b94b0b13664976a1ebeef3163f4560077e17b9254593f7c566c653fbcc93 +5c6baed932139022eb9544cb9b2ea8434bd1dc4add567257bbc0245f52efaa85 " " LICENSE @@ -40,7 +40,7 @@ rs " : " -058dddad16d91c8d0160fa2a78bb5f7c2f801f2fd9770fc387c5843395bf0379 +7baf09034aafc28f7dbb1550cdde89221e4eb5dfda51b55aeb652ee8710c715d " " src @@ -51,7 +51,7 @@ rs " : " -586fa7ff7ee77c19dcea83310135709f0beda3a3395c4b305217b67e83e6b410 +58125667bd78399e8753b6bd8acef84f180f369f0bc174c573887176bab9f9d3 " " src @@ -69,19 +69,6 @@ src / thread_parker / -cloudabi -. -rs -" -: -" -dba5efaf7538c3d8731e9ef9aa41bb48aaa1721c61acb64eb224b38edf12b663 -" -" -src -/ -thread_parker -/ generic . rs @@ -114,7 +101,7 @@ rs " : " -347fe878b616ec69eeffc188475920b47b3d802756565d32e004fc342eea771f +9c675b7690bbde62e88d946fad218623d423edccff4e01e8e52b116d815c695c " " src @@ -179,7 +166,7 @@ rs " : " -85f2d7e9982ef64f077fc6ee2e10f81027d556b08c5618e86913c137571e377e +cf761157803256b18205e747bc99e30b18d5410c27121fa9595e12cb51bb6bef " " src @@ -254,6 +241,6 @@ package " : " -c361aa727dd08437f2f1447be8b59a33b0edd15e0fcee698f935613d9efbca9b +d7c6d9b8427445284a09c55be860a15855ab580a417ccad9da88f5a06787ced0 " } diff --git a/third_party/rust/parking_lot_core/Cargo.toml b/third_party/rust/parking_lot_core/Cargo.toml index 3a81c997d0019..d5321b991bc10 100644 --- a/third_party/rust/parking_lot_core/Cargo.toml +++ b/third_party/rust/parking_lot_core/Cargo.toml @@ -127,7 +127,7 @@ version . 8 . -0 +1 " authors = @@ -237,11 +237,11 @@ if version = " -0 -. 1 . -10 +0 +. +0 " [ dependencies @@ -284,8 +284,6 @@ version " 1 . -4 -. 0 " [ @@ -339,35 +337,6 @@ target_os = \ " -cloudabi -\ -" -) -" -. -dependencies -. -cloudabi -] -version -= -" -0 -. -1 -. -0 -" -[ -target -. -" -cfg -( -target_os -= -\ -" redox \ " diff --git a/third_party/rust/parking_lot_core/src/lib.rs b/third_party/rust/parking_lot_core/src/lib.rs index accaf8667782d..df7b7a25a0139 100644 --- a/third_party/rust/parking_lot_core/src/lib.rs +++ b/third_party/rust/parking_lot_core/src/lib.rs @@ -545,30 +545,6 @@ stdsimd ) ) ] -# -! -[ -cfg_attr -( -all -( -feature -= -" -nightly -" -target_os -= -" -cloudabi -" -) -feature -( -thread_local -) -) -] mod parking_lot ; diff --git a/third_party/rust/parking_lot_core/src/parking_lot.rs b/third_party/rust/parking_lot_core/src/parking_lot.rs index 6fbcbb79c60cf..f151f0d74549b 100644 --- a/third_party/rust/parking_lot_core/src/parking_lot.rs +++ b/third_party/rust/parking_lot_core/src/parking_lot.rs @@ -118,12 +118,6 @@ word_lock WordLock ; use -cfg_if -: -: -cfg_if -; -use core : : @@ -170,234 +164,6 @@ time : Duration ; -cfg_if -! -{ -if -# -[ -cfg -( -all -( -target_arch -= -" -wasm32 -" -target_os -= -" -unknown -" -target_vendor -= -" -unknown -" -) -) -] -{ -use -core -: -: -ops -: -: -Add -; -# -[ -derive -( -Copy -Clone -PartialEq -Eq -PartialOrd -Ord -Debug -Hash -) -] -struct -DummyInstant -( -Duration -) -; -impl -DummyInstant -{ -pub -fn -now -( -) -- -> -DummyInstant -{ -DummyInstant -: -: -zero -( -) -} -const -fn -zero -( -) -- -> -DummyInstant -{ -DummyInstant -( -Duration -: -: -from_secs -( -0 -) -) -} -} -impl -Add -< -Duration -> -for -DummyInstant -{ -type -Output -= -DummyInstant -; -fn -add -( -self -_rhs -: -Duration -) -- -> -DummyInstant -{ -DummyInstant -: -: -zero -( -) -} -} -/ -/ -Use -dummy -implementation -for -Instant -on -wasm32 -. -The -reason -for -this -is -/ -/ -that -Instant -: -: -now -( -) -will -always -panic -because -time -is -currently -not -implemented -/ -/ -on -wasm32 -- -unknown -- -unknown -. -/ -/ -See -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -rust -/ -blob -/ -master -/ -src -/ -libstd -/ -sys -/ -wasm -/ -time -. -rs -type -InstantType -= -DummyInstant -; -} -else -{ -/ -/ -Otherwise -use -instant -: -: -Instant -type -InstantType -= -Instant -; -} -} static NUM_THREADS : @@ -636,7 +402,7 @@ leading_zeros let now = -InstantType +Instant : : now @@ -793,7 +559,7 @@ new ( timeout : -InstantType +Instant seed : u32 @@ -875,7 +641,7 @@ be set timeout : -InstantType +Instant / / the @@ -902,7 +668,7 @@ new ( timeout : -InstantType +Instant seed : u32 @@ -949,7 +715,7 @@ bool let now = -InstantType +Instant : : now diff --git a/third_party/rust/parking_lot_core/src/thread_parker/cloudabi.rs b/third_party/rust/parking_lot_core/src/thread_parker/cloudabi.rs deleted file mode 100644 index d6053c1bac1bc..0000000000000 --- a/third_party/rust/parking_lot_core/src/thread_parker/cloudabi.rs +++ /dev/null @@ -1,1929 +0,0 @@ -/ -/ -Copyright -2016 -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 -cloudabi -as -abi -; -use -core -: -: -{ -cell -: -: -Cell -mem -: -: -{ -self -MaybeUninit -} -sync -: -: -atomic -: -: -{ -AtomicU32 -Ordering -} -} -; -use -instant -: -: -Instant -; -use -std -: -: -{ -convert -: -: -TryFrom -thread -} -; -extern -" -C -" -{ -# -[ -thread_local -] -static -__pthread_thread_id -: -abi -: -: -tid -; -} -struct -Lock -{ -lock -: -AtomicU32 -} -impl -Lock -{ -pub -fn -new -( -) -- -> -Self -{ -Lock -{ -lock -: -AtomicU32 -: -: -new -( -abi -: -: -LOCK_UNLOCKED -. -0 -) -} -} -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -See -Lock -: -: -lock -. -unsafe -fn -try_lock -( -& -self -) -- -> -Option -< -LockGuard -> -{ -/ -/ -Attempt -to -acquire -the -lock -. -if -let -Err -( -old -) -= -self -. -lock -. -compare_exchange -( -abi -: -: -LOCK_UNLOCKED -. -0 -__pthread_thread_id -. -0 -| -abi -: -: -LOCK_WRLOCKED -. -0 -Ordering -: -: -Acquire -Ordering -: -: -Relaxed -) -{ -/ -/ -Failure -. -Crash -upon -recursive -acquisition -. -debug_assert_ne -! -( -old -& -! -abi -: -: -LOCK_KERNEL_MANAGED -. -0 -__pthread_thread_id -. -0 -| -abi -: -: -LOCK_WRLOCKED -. -0 -" -Attempted -to -recursive -write -- -lock -a -lock -" -) -; -None -} -else -{ -Some -( -LockGuard -{ -lock -: -& -self -. -lock -} -) -} -} -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -This -method -is -unsafe -because -the -LockGuard -has -a -raw -pointer -into -this -Lock -/ -/ -/ -that -it -will -access -on -drop -to -unlock -the -lock -. -So -make -sure -the -LockGuard -goes -/ -/ -/ -out -of -scope -before -the -Lock -it -came -from -moves -or -goes -out -of -scope -. -pub -unsafe -fn -lock -( -& -self -) -- -> -LockGuard -{ -self -. -try_lock -( -) -. -unwrap_or_else -( -| -| -{ -/ -/ -Call -into -the -kernel -to -acquire -a -write -lock -. -let -subscription -= -abi -: -: -subscription -{ -r -# -type -: -abi -: -: -eventtype -: -: -LOCK_WRLOCK -union -: -abi -: -: -subscription_union -{ -lock -: -abi -: -: -subscription_lock -{ -lock -: -self -. -ptr -( -) -lock_scope -: -abi -: -: -scope -: -: -PRIVATE -} -} -. -. -mem -: -: -zeroed -( -) -} -; -let -mut -event -= -MaybeUninit -: -: -< -abi -: -: -event -> -: -: -uninit -( -) -; -let -mut -nevents -: -usize -= -0 -; -let -ret -= -abi -: -: -poll -( -& -subscription -event -. -as_mut_ptr -( -) -1 -& -mut -nevents -) -; -debug_assert_eq -! -( -ret -abi -: -: -errno -: -: -SUCCESS -) -; -debug_assert_eq -! -( -event -. -assume_init -( -) -. -error -abi -: -: -errno -: -: -SUCCESS -) -; -LockGuard -{ -lock -: -& -self -. -lock -} -} -) -} -fn -ptr -( -& -self -) -- -> -* -mut -abi -: -: -lock -{ -& -self -. -lock -as -* -const -AtomicU32 -as -* -mut -abi -: -: -lock -} -} -struct -LockGuard -{ -lock -: -* -const -AtomicU32 -} -impl -LockGuard -{ -fn -ptr -( -& -self -) -- -> -* -mut -abi -: -: -lock -{ -self -. -lock -as -* -mut -abi -: -: -lock -} -} -impl -Drop -for -LockGuard -{ -fn -drop -( -& -mut -self -) -{ -let -lock -= -unsafe -{ -& -* -self -. -lock -} -; -debug_assert_eq -! -( -lock -. -load -( -Ordering -: -: -Relaxed -) -& -! -abi -: -: -LOCK_KERNEL_MANAGED -. -0 -unsafe -{ -__pthread_thread_id -. -0 -} -| -abi -: -: -LOCK_WRLOCKED -. -0 -" -This -lock -is -not -write -- -locked -by -this -thread -" -) -; -if -! -lock -. -compare_exchange -( -unsafe -{ -__pthread_thread_id -. -0 -} -| -abi -: -: -LOCK_WRLOCKED -. -0 -abi -: -: -LOCK_UNLOCKED -. -0 -Ordering -: -: -Release -Ordering -: -: -Relaxed -) -. -is_ok -( -) -{ -/ -/ -Lock -is -managed -by -kernelspace -. -Call -into -the -kernel -/ -/ -to -unblock -waiting -threads -. -let -ret -= -unsafe -{ -abi -: -: -lock_unlock -( -self -. -lock -as -* -mut -abi -: -: -lock -abi -: -: -scope -: -: -PRIVATE -) -} -; -debug_assert_eq -! -( -ret -abi -: -: -errno -: -: -SUCCESS -) -; -} -} -} -struct -Condvar -{ -condvar -: -AtomicU32 -} -impl -Condvar -{ -pub -fn -new -( -) -- -> -Self -{ -Condvar -{ -condvar -: -AtomicU32 -: -: -new -( -abi -: -: -CONDVAR_HAS_NO_WAITERS -. -0 -) -} -} -pub -fn -wait -( -& -self -lock -: -& -LockGuard -) -{ -unsafe -{ -let -subscription -= -abi -: -: -subscription -{ -r -# -type -: -abi -: -: -eventtype -: -: -CONDVAR -union -: -abi -: -: -subscription_union -{ -condvar -: -abi -: -: -subscription_condvar -{ -condvar -: -self -. -ptr -( -) -condvar_scope -: -abi -: -: -scope -: -: -PRIVATE -lock -: -lock -. -ptr -( -) -lock_scope -: -abi -: -: -scope -: -: -PRIVATE -} -} -. -. -mem -: -: -zeroed -( -) -} -; -let -mut -event -= -MaybeUninit -: -: -< -abi -: -: -event -> -: -: -uninit -( -) -; -let -mut -nevents -: -usize -= -0 -; -let -ret -= -abi -: -: -poll -( -& -subscription -event -. -as_mut_ptr -( -) -1 -& -mut -nevents -) -; -debug_assert_eq -! -( -ret -abi -: -: -errno -: -: -SUCCESS -) -; -debug_assert_eq -! -( -event -. -assume_init -( -) -. -error -abi -: -: -errno -: -: -SUCCESS -) -; -} -} -/ -/ -/ -Waits -for -a -signal -on -the -condvar -. -/ -/ -/ -Returns -false -if -it -times -out -before -anyone -notified -us -. -pub -fn -wait_timeout -( -& -self -lock -: -& -LockGuard -timeout -: -abi -: -: -timestamp -) -- -> -bool -{ -unsafe -{ -let -subscriptions -= -[ -abi -: -: -subscription -{ -r -# -type -: -abi -: -: -eventtype -: -: -CONDVAR -union -: -abi -: -: -subscription_union -{ -condvar -: -abi -: -: -subscription_condvar -{ -condvar -: -self -. -ptr -( -) -condvar_scope -: -abi -: -: -scope -: -: -PRIVATE -lock -: -lock -. -ptr -( -) -lock_scope -: -abi -: -: -scope -: -: -PRIVATE -} -} -. -. -mem -: -: -zeroed -( -) -} -abi -: -: -subscription -{ -r -# -type -: -abi -: -: -eventtype -: -: -CLOCK -union -: -abi -: -: -subscription_union -{ -clock -: -abi -: -: -subscription_clock -{ -clock_id -: -abi -: -: -clockid -: -: -MONOTONIC -timeout -. -. -mem -: -: -zeroed -( -) -} -} -. -. -mem -: -: -zeroed -( -) -} -] -; -let -mut -events -= -MaybeUninit -: -: -< -[ -abi -: -: -event -; -2 -] -> -: -: -uninit -( -) -; -let -mut -nevents -: -usize -= -0 -; -let -ret -= -abi -: -: -poll -( -subscriptions -. -as_ptr -( -) -events -. -as_mut_ptr -( -) -as -* -mut -_ -2 -& -mut -nevents -) -; -debug_assert_eq -! -( -ret -abi -: -: -errno -: -: -SUCCESS -) -; -let -events -= -events -. -assume_init -( -) -; -for -i -in -0 -. -. -nevents -{ -debug_assert_eq -! -( -events -[ -i -] -. -error -abi -: -: -errno -: -: -SUCCESS -) -; -if -events -[ -i -] -. -r -# -type -= -= -abi -: -: -eventtype -: -: -CONDVAR -{ -return -true -; -} -} -} -false -} -pub -fn -notify -( -& -self -) -{ -let -ret -= -unsafe -{ -abi -: -: -condvar_signal -( -self -. -ptr -( -) -abi -: -: -scope -: -: -PRIVATE -1 -) -} -; -debug_assert_eq -! -( -ret -abi -: -: -errno -: -: -SUCCESS -) -; -} -fn -ptr -( -& -self -) -- -> -* -mut -abi -: -: -condvar -{ -& -self -. -condvar -as -* -const -AtomicU32 -as -* -mut -abi -: -: -condvar -} -} -/ -/ -Helper -type -for -putting -a -thread -to -sleep -until -some -other -thread -wakes -it -up -pub -struct -ThreadParker -{ -should_park -: -Cell -< -bool -> -lock -: -Lock -condvar -: -Condvar -} -impl -super -: -: -ThreadParkerT -for -ThreadParker -{ -type -UnparkHandle -= -UnparkHandle -; -const -IS_CHEAP_TO_CONSTRUCT -: -bool -= -true -; -fn -new -( -) -- -> -ThreadParker -{ -ThreadParker -{ -should_park -: -Cell -: -: -new -( -false -) -lock -: -Lock -: -: -new -( -) -condvar -: -Condvar -: -: -new -( -) -} -} -unsafe -fn -prepare_park -( -& -self -) -{ -self -. -should_park -. -set -( -true -) -; -} -unsafe -fn -timed_out -( -& -self -) -- -> -bool -{ -/ -/ -We -need -to -grab -the -lock -here -because -another -thread -may -be -/ -/ -concurrently -executing -UnparkHandle -: -: -unpark -which -is -done -without -/ -/ -holding -the -queue -lock -. -let -_guard -= -self -. -lock -. -lock -( -) -; -self -. -should_park -. -get -( -) -} -unsafe -fn -park -( -& -self -) -{ -let -guard -= -self -. -lock -. -lock -( -) -; -while -self -. -should_park -. -get -( -) -{ -self -. -condvar -. -wait -( -& -guard -) -; -} -} -unsafe -fn -park_until -( -& -self -timeout -: -Instant -) -- -> -bool -{ -let -guard -= -self -. -lock -. -lock -( -) -; -while -self -. -should_park -. -get -( -) -{ -if -let -Some -( -duration_left -) -= -timeout -. -checked_duration_since -( -Instant -: -: -now -( -) -) -{ -if -let -Ok -( -nanos_left -) -= -abi -: -: -timestamp -: -: -try_from -( -duration_left -. -as_nanos -( -) -) -{ -self -. -condvar -. -wait_timeout -( -& -guard -nanos_left -) -; -} -else -{ -/ -/ -remaining -timeout -overflows -an -abi -: -: -timestamp -. -Sleep -indefinitely -self -. -condvar -. -wait -( -& -guard -) -; -} -} -else -{ -/ -/ -We -timed -out -return -false -; -} -} -true -} -unsafe -fn -unpark_lock -( -& -self -) -- -> -UnparkHandle -{ -let -_lock_guard -= -self -. -lock -. -lock -( -) -; -UnparkHandle -{ -thread_parker -: -self -_lock_guard -} -} -} -pub -struct -UnparkHandle -{ -thread_parker -: -* -const -ThreadParker -_lock_guard -: -LockGuard -} -impl -super -: -: -UnparkHandleT -for -UnparkHandle -{ -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 -( -) -; -} -} -# -[ -inline -] -pub -fn -thread_yield -( -) -{ -thread -: -: -yield_now -( -) -; -} diff --git a/third_party/rust/parking_lot_core/src/thread_parker/mod.rs b/third_party/rust/parking_lot_core/src/thread_parker/mod.rs index 21532cd6ae70d..61b12f5ef4674 100644 --- a/third_party/rust/parking_lot_core/src/thread_parker/mod.rs +++ b/third_party/rust/parking_lot_core/src/thread_parker/mod.rs @@ -702,42 +702,6 @@ imp ; } else -if -# -[ -cfg -( -all -( -feature -= -" -nightly -" -target_os -= -" -cloudabi -" -) -) -] -{ -# -[ -path -= -" -cloudabi -. -rs -" -] -mod -imp -; -} -else { # [ diff --git a/third_party/rust/parking_lot_core/src/thread_parker/wasm_atomic.rs b/third_party/rust/parking_lot_core/src/thread_parker/wasm_atomic.rs index 2a446ed92b4ea..48de32d5b6cc1 100644 --- a/third_party/rust/parking_lot_core/src/thread_parker/wasm_atomic.rs +++ b/third_party/rust/parking_lot_core/src/thread_parker/wasm_atomic.rs @@ -87,6 +87,12 @@ those terms . use +cfg_if +: +: +cfg_if +; +use core : : @@ -117,6 +123,15 @@ use std : : +time +: +: +Duration +; +use +std +: +: { convert : @@ -125,6 +140,161 @@ TryFrom thread } ; +cfg_if +! +{ +if +# +[ +cfg +( +all +( +target_arch += +" +wasm32 +" +target_os += +" +unknown +" +target_vendor += +" +unknown +" +) +) +] +{ +/ +/ +This +function +serves +as +a +polyfill +for +Instant +: +: +checked_duration_since +which +is +/ +/ +currently +not +implemented +for +wasm32 +- +unknown +- +unknown +. +/ +/ +TODO +: +Remove +this +shim +once +it +fn +checked_duration_since_now +( +other +: +Instant +) +- +> +Option +< +Duration +> +{ +let +now += +Instant +: +: +now +( +) +; +if +other +< +now +{ +None +} +else +{ +Some +( +other +. +duration_since +( +now +) +) +} +} +} +else +{ +/ +/ +If +we +are +not +targeting +wasm32 +we +can +use +the +native +checked_duration_since +. +fn +checked_duration_since_now +( +timeout +: +Instant +) +- +> +Option +< +Duration +> +{ +timeout +. +checked_duration_since +( +Instant +: +: +now +( +) +) +} +} +} / / Helper @@ -296,12 +466,10 @@ PARKED let r = -unsafe -{ wasm32 : : -i32_atomic_wait +memory_atomic_wait32 ( self . @@ -312,7 +480,6 @@ PARKED - 1 ) -} ; / / @@ -407,16 +574,9 @@ Some left ) = -timeout -. -checked_duration_since -( -Instant -: -: -now +checked_duration_since_now ( -) +timeout ) { let @@ -447,12 +607,10 @@ max_value let r = -unsafe -{ wasm32 : : -i32_atomic_wait +memory_atomic_wait32 ( self . @@ -462,7 +620,6 @@ ptr PARKED nanos_left ) -} ; debug_assert ! @@ -611,12 +768,10 @@ self let num_notified = -unsafe -{ wasm32 : : -atomic_notify +memory_atomic_notify ( self . @@ -627,7 +782,6 @@ mut i32 1 ) -} ; debug_assert ! diff --git a/third_party/rust/rusqlite/.cargo-checksum.json b/third_party/rust/rusqlite/.cargo-checksum.json index f8c863b9a65f3..8c22cad7ed371 100644 --- a/third_party/rust/rusqlite/.cargo-checksum.json +++ b/third_party/rust/rusqlite/.cargo-checksum.json @@ -11,7 +11,7 @@ toml " : " -56285617b69a9e2ea1d922620fb2ba960cb487fcececd016ef41dcb9c850f53a +a68dc0863956a747f6526f566355c2f176dc1f0e522742ee1b4fe83f56dce905 " " Changelog @@ -36,7 +36,7 @@ md " : " -1730524868f2391f2501f3e8f1516e4cc63dc5e93b4d7dfb211ad8f3de460dac +2265be99f12cc6805897266a26fb27227e4bb226293f3952de6edc4e2e47b8ef " " appveyor @@ -648,6 +648,6 @@ package " : " -7e3d4791ab5517217f51216a84a688b53c1ebf7988736469c538d02f46ddba68 +d5f38ee71cbab2c827ec0ac24e76f82eca723cee92c509a65f67dee393c25112 " } diff --git a/third_party/rust/rusqlite/Cargo.toml b/third_party/rust/rusqlite/Cargo.toml index c080a4179e931..98fa07a8f85af 100644 --- a/third_party/rust/rusqlite/Cargo.toml +++ b/third_party/rust/rusqlite/Cargo.toml @@ -127,7 +127,7 @@ version . 24 . -1 +2 " authors = @@ -555,7 +555,7 @@ version " 1 . -4 +0 " [ dependencies diff --git a/third_party/rust/rusqlite/README.md b/third_party/rust/rusqlite/README.md index b7451b7ba7063..04ba0cda9273a 100644 --- a/third_party/rust/rusqlite/README.md +++ b/third_party/rust/rusqlite/README.md @@ -1865,7 +1865,7 @@ version . 24 . -1 +2 " features = diff --git a/third_party/rust/smallvec/.cargo-checksum.json b/third_party/rust/smallvec/.cargo-checksum.json index 95bd6edd07e7a..2b00803d6c42f 100644 --- a/third_party/rust/smallvec/.cargo-checksum.json +++ b/third_party/rust/smallvec/.cargo-checksum.json @@ -11,7 +11,7 @@ toml " : " -13560b491e0ed99fe7d16ecef0f728bc57058c007563170d7d644f3bb2433fff +45e745963490153700d8392f914b159019420aa81d8ae80241771769199cf65b " " LICENSE @@ -49,62 +49,36 @@ rs " : " -7425b60d83d01a0bcedb5855ec8652fb1089194da5b5d8f7d7d9072c8ea9d133 +9dca7122a3dcb2c099e49807e4d3b8f01d9220e2b3db0a54e9901ee74392866f " " -scripts -/ -run_miri -. -sh -" -: -" -0d0b8c54c73fa9da1217d29ed0984f8328dd9fb61bb5a02db44458c360cdc3c4 -" -" -src -/ lib . rs " : " -bb8aef09a9c7a43d225dfd99063261b89ebd6835ced4e2dfe696f1c3eaf9b9d2 -" -" -src -/ -specialization -. -rs -" -: -" -46433586203399251cba496d67b88d34e1be3c2b591986b77463513da1c66471 +45aa4cd721dd8e649b79c443b9d12b8ff0f9e4dd4188e604b2d6b36b8ceb1c71 " " -src +scripts / -tests +run_miri . -rs +sh " : " -1c4763444139813d335d33f9eda8b8b719da60a2b13ddcb44e1a6cc278c319cc +2e83d153efc16cbc3c41589e306faa0624c8b9a0feecea3baae6e34f4563ac42 " " -tests -/ -macro +specialization . rs " : " -22ad4f6f104a599fdcba19cad8834105b8656b212fb6c7573a427d447f5db14f +46433586203399251cba496d67b88d34e1be3c2b591986b77463513da1c66471 " } " @@ -112,6 +86,6 @@ package " : " -fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252 +05720e22615919e4734f6a99ceae50d00226c3c5aca406e102ebc33298214e0a " } diff --git a/third_party/rust/smallvec/Cargo.toml b/third_party/rust/smallvec/Cargo.toml index de4728ae27ef0..7898dd1f31f4c 100644 --- a/third_party/rust/smallvec/Cargo.toml +++ b/third_party/rust/smallvec/Cargo.toml @@ -125,18 +125,24 @@ version " 1 . -4 +3 . -2 +0 " authors = [ " -The -Servo -Project -Developers +Simon +Sapin +< +simon +. +sapin +exyr +. +org +> " ] description @@ -238,6 +244,21 @@ rust smallvec " [ +lib +] +name += +" +smallvec +" +path += +" +lib +. +rs +" +[ dependencies . serde @@ -250,11 +271,6 @@ version optional = true -default -- -features -= -false [ dev - diff --git a/third_party/rust/smallvec/benches/bench.rs b/third_party/rust/smallvec/benches/bench.rs index e2818e4960b5b..08cb2da2a8c45 100644 --- a/third_party/rust/smallvec/benches/bench.rs +++ b/third_party/rust/smallvec/benches/bench.rs @@ -7,14 +7,6 @@ test ) ] # -! -[ -allow -( -deprecated -) -] -# [ macro_use ] diff --git a/third_party/rust/smallvec/src/lib.rs b/third_party/rust/smallvec/lib.rs similarity index 71% rename from third_party/rust/smallvec/src/lib.rs rename to third_party/rust/smallvec/lib.rs index 2f512a47703a3..4e3d65c59e785 100644 --- a/third_party/rust/smallvec/src/lib.rs +++ b/third_party/rust/smallvec/lib.rs @@ -216,45 +216,6 @@ features # # # -serde -/ -/ -! -/ -/ -! -When -this -optional -dependency -is -enabled -SmallVec -implements -the -serde -: -: -Serialize -and -/ -/ -! -serde -: -: -Deserialize -traits -. -/ -/ -! -/ -/ -! -# -# -# write / / @@ -470,43 +431,6 @@ now / / ! -Tracking -issue -: -[ -rust -- -lang -/ -rust -# -55149 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -rust -/ -issues -/ -55149 -) -/ -/ -! -/ -/ -! # # # @@ -571,43 +495,6 @@ sizes / / ! -Tracking -issue -: -[ -rust -- -lang -/ -rust -# -44580 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -rust -/ -issues -/ -44580 -) -/ -/ -! -/ -/ -! # # # @@ -695,43 +582,6 @@ types / / ! -Tracking -issue -: -[ -rust -- -lang -/ -rust -# -31844 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -rust -/ -issues -/ -31844 -) -/ -/ -! -/ -/ -! # # # @@ -828,43 +678,6 @@ escape hatch ) . -/ -/ -! -/ -/ -! -Tracking -issue -: -[ -rust -- -lang -/ -rust -# -34761 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -rust -/ -issues -/ -34761 -) # ! [ @@ -896,9 +709,9 @@ feature " specialization " -allow +feature ( -incomplete_features +specialization ) ) ] @@ -910,11 +723,11 @@ cfg_attr feature = " -specialization +may_dangle " feature ( -specialization +dropck_eyepatch ) ) ] @@ -926,11 +739,11 @@ cfg_attr feature = " -may_dangle +const_generics " -feature +allow ( -dropck_eyepatch +incomplete_features ) ) ] @@ -946,7 +759,7 @@ const_generics " feature ( -min_const_generics +const_generics ) ) ] @@ -989,28 +802,6 @@ extern crate std ; -# -[ -cfg -( -test -) -] -mod -tests -; -use -alloc -: -: -alloc -: -: -{ -Layout -LayoutErr -} -; use alloc : @@ -1115,7 +906,6 @@ ops : { self -Range RangeBounds } ; @@ -1690,9 +1480,6 @@ count 0usize ( + -crate -: -: smallvec ! ( @@ -1702,13 +1489,6 @@ x ) * ; -# -[ -allow -( -unused_mut -) -] let mut vec @@ -2047,17 +1827,6 @@ Test / / / -# -[ -doc -( -hidden -) -] -# -[ -deprecated -] pub trait ExtendFromSlice @@ -2093,13 +1862,6 @@ T ) ; } -# -[ -allow -( -deprecated -) -] impl < T @@ -2140,471 +1902,171 @@ other ) } } -/ -/ -/ -Error -type -for -APIs -with -fallible -heap -allocation -# -[ -derive +unsafe +fn +deallocate +< +T +> ( -Debug +ptr +: +* +mut +T +capacity +: +usize ) -] -pub -enum -CollectionAllocErr -{ -/ -/ -/ -Overflow -usize -: -: -MAX -or -other -error -during -size -computation -CapacityOverflow -/ -/ -/ -The -allocator -return -an -error -AllocErr -{ -/ -/ -/ -The -layout -that -was -passed -to -the -allocator -layout -: -Layout -} -} -impl -From -< -LayoutErr -> -for -CollectionAllocErr -{ -fn -from -( -_ -: -LayoutErr -) -- -> -Self { -CollectionAllocErr -: -: -CapacityOverflow -} -} -fn -infallible -< -T -> -( -result +let +_vec : -Result +Vec < T -CollectionAllocErr -> -) -- > -T -{ -match -result -{ -Ok -( -x -) = -> -x -Err -( -CollectionAllocErr +Vec : : -CapacityOverflow -) -= -> -panic -! +from_raw_parts ( -" +ptr +0 capacity -overflow -" -) -Err -( -CollectionAllocErr -: -: -AllocErr -{ -layout -} ) -= -> -alloc -: -: -alloc -: -: -handle_alloc_error -( -layout -) -} +; +/ +/ +Let +it +drop +. } / / / -FIXME -: -use -Layout -: -: -array -when -we -require +An +iterator +that +removes +the +items +from a -Rust -version -where -it -s -stable +SmallVec +and +yields +them +by +value +. / / / -https -: / / -github +/ +Returned +from +[ +SmallVec +: +: +drain +] +[ +1 +] . -com / -rust -- -lang / -rust / -issues / -55724 -fn -layout_array +/ +/ +[ +1 +] +: +struct +. +SmallVec +. +html +# +method +. +drain +pub +struct +Drain < +' +a T -> -( -n : -usize -) -- -> -Result -< -Layout -CollectionAllocErr +' +a ++ +Array > { -let -size -= -mem +tail_start +: +usize +tail_len : +usize +iter : -size_of +slice : : +Iter < +' +a T -> -( -) -. -checked_mul -( -n -) -. -ok_or -( -CollectionAllocErr : : -CapacityOverflow -) -? -; -let -align -= -mem +Item +> +vec : +NonNull +< +SmallVec +< +T +> +> +} +impl +< +' +a +T : -align_of +' +a ++ +Array +> +fmt : : +Debug +for +Drain < +' +a T > -( -) -; -Layout -: -: -from_size_align -( -size -align -) -. -map_err -( -| -_ -| -CollectionAllocErr -: -: -CapacityOverflow -) -} -unsafe -fn -deallocate -< -T -> -( -ptr -: -* -mut -T -capacity -: -usize -) -{ -/ -/ -This -unwrap -should -succeed -since -the -same -did -when -allocating -. -let -layout -= -layout_array -: -: -< -T -> -( -capacity -) -. -unwrap -( -) -; -alloc -: -: -alloc -: -: -dealloc -( -ptr -as -* -mut -u8 -layout -) -} -/ -/ -/ -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 -+ -Array -> -{ -tail_start -: -usize -tail_len -: -usize -iter -: -slice -: -: -Iter -< -' -a -T -: -: -Item -> -vec -: -NonNull -< -SmallVec -< -T -> -> -} -impl -< -' -a -T -: -' -a -+ -Array -> -fmt -: -: -Debug -for -Drain -< -' -a -T -> -where -T +where +T : : Item @@ -4119,10 +3581,10 @@ If capacity < = -Self +A : : -inline_capacity +size ( ) then @@ -4154,10 +3616,10 @@ use If capacity > -Self +A : : -inline_capacity +size ( ) then @@ -4530,10 +3992,10 @@ capacity ) < = -Self +A : : -inline_capacity +size ( ) . @@ -4654,10 +4116,10 @@ capacity ) < = -Self +A : : -inline_capacity +size ( ) { @@ -5396,32 +4858,17 @@ inline [ inline ] +pub fn -inline_capacity +inline_size ( +& +self ) - > usize { -if -mem -: -: -size_of -: -: -< -A -: -: -Item -> -( -) -> -0 -{ A : : @@ -5429,193 +4876,6 @@ size ( ) } -else -{ -/ -/ -For -zero -- -size -items -code -like -ptr -. -add -( -offset -) -always -returns -the -same -pointer -. -/ -/ -Therefore -all -items -are -at -the -same -address -/ -/ -and -any -array -size -has -capacity -for -infinitely -many -items -. -/ -/ -The -capacity -is -limited -by -the -bit -width -of -the -length -field -. -/ -/ -/ -/ -Vec -also -does -this -: -/ -/ -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -rust -/ -blob -/ -1 -. -44 -. -0 -/ -src -/ -liballoc -/ -raw_vec -. -rs -# -L186 -/ -/ -/ -/ -In -our -case -this -also -ensures -that -a -smallvec -of -zero -- -size -items -never -spills -/ -/ -and -we -never -try -to -allocate -zero -bytes -which -std -: -: -alloc -: -: -alloc -disallows -. -core -: -: -usize -: -: -MAX -} -} -/ -/ -/ -The -maximum -number -of -elements -this -vector -can -hold -inline -# -[ -inline -] -pub -fn -inline_size -( -& -self -) -- -> -usize -{ -Self -: -: -inline_capacity -( -) -} / / / @@ -5819,10 +5079,10 @@ inline self . capacity -Self +A : : -inline_capacity +size ( ) ) @@ -5919,10 +5179,10 @@ mut self . capacity -Self +A : : -inline_capacity +size ( ) ) @@ -5966,10 +5226,10 @@ self . capacity > -Self +A : : -inline_capacity +size ( ) } @@ -6528,16 +5788,6 @@ vector ' s length -/ -/ -/ -or -if -the -capacity -computation -overflows -usize . pub fn @@ -6551,72 +5801,6 @@ new_cap usize ) { -infallible -( -self -. -try_grow -( -new_cap -) -) -} -/ -/ -/ -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 -try_grow -( -& -mut -self -new_cap -: -usize -) -- -> -Result -< -( -) -CollectionAllocErr -> -{ unsafe { let @@ -6667,11 +5851,6 @@ if unspilled { return -Ok -( -( -) -) ; } self @@ -6713,12 +5892,6 @@ capacity = len ; -deallocate -( -ptr -cap -) -; } else if @@ -6728,77 +5901,32 @@ new_cap cap { let -layout +mut +vec = -layout_array -: -: -< -A +Vec : : -Item -> +with_capacity ( new_cap ) -? ; -debug_assert -! -( -layout +let +new_alloc += +vec . -size +as_mut_ptr ( ) -> -0 -) -; -let -new_alloc -; -if -unspilled -{ -new_alloc -= -NonNull -: -: -new -( -alloc -: -: -alloc -: -: -alloc -( -layout -) -) -. -ok_or -( -CollectionAllocErr -: -: -AllocErr -{ -layout -} -) -? -. -cast -( -) -. -as_ptr -( +; +mem +: +: +forget +( +vec ) ; ptr @@ -6811,98 +5939,6 @@ new_alloc len ) ; -} -else -{ -/ -/ -This -should -never -fail -since -the -same -succeeded -/ -/ -when -previously -allocating -ptr -. -let -old_layout -= -layout_array -: -: -< -A -: -: -Item -> -( -cap -) -? -; -let -new_ptr -= -alloc -: -: -alloc -: -: -realloc -( -ptr -as -* -mut -u8 -old_layout -layout -. -size -( -) -) -; -new_alloc -= -NonNull -: -: -new -( -new_ptr -) -. -ok_or -( -CollectionAllocErr -: -: -AllocErr -{ -layout -} -) -? -. -cast -( -) -. -as_ptr -( -) -; -} self . data @@ -6922,12 +5958,24 @@ capacity = new_cap ; +if +unspilled +{ +return +; } -Ok -( +} +else +{ +return +; +} +deallocate ( +ptr +cap ) -) +; } } / @@ -6964,71 +6012,60 @@ reallocations / / / -Panics -if +If the +new capacity -computation -overflows +would +overflow usize -. -# -[ -inline -] -pub -fn -reserve -( -& -mut -self -additional -: +then +it +will +be +set +to usize -) -{ -infallible -( -self -. -try_reserve +: +: +max_value ( -additional -) ) -} / / / -Reserve -capacity -for +instead +. +( +This +means +that +inserting additional -more +new elements +is +not +guaranteed to be -inserted -. -/ / / / -/ -/ -May -reserve -more -space -to -avoid -frequent -reallocations +possible +after +calling +this +function . +) +# +[ +inline +] pub fn -try_reserve +reserve ( & mut @@ -7037,14 +6074,6 @@ additional : usize ) -- -> -Result -< -( -) -CollectionAllocErr -> { / / @@ -7097,18 +6126,9 @@ if cap - len -> -= +< additional { -return -Ok -( -( -) -) -; -} let new_cap = @@ -7127,21 +6147,24 @@ usize checked_next_power_of_two ) . -ok_or +unwrap_or ( -CollectionAllocErr +usize : : -CapacityOverflow +max_value +( +) ) -? ; self . -try_grow +grow ( new_cap ) +; +} } / / @@ -7184,108 +6207,62 @@ additional usize ) { -infallible +let ( +_ +& +mut +len +cap +) += self . -try_reserve_exact +triple_mut +( +) +; +if +cap +- +len +< +additional +{ +match +len +. +checked_add ( additional ) -) -} -/ -/ -/ -Reserve -the -minimum -capacity -for -additional -more -elements -to -be -inserted -. -pub -fn -try_reserve_exact -( -& -mut -self -additional -: -usize -) -- -> -Result -< -( -) -CollectionAllocErr -> { -let +Some ( -_ -& -mut -len cap ) = +> self . -triple_mut +grow ( -) -; -if cap -- -len -> -= -additional -{ -return -Ok -( -( ) -) -; -} -let -new_cap +None = -len -. -checked_add -( -additional -) -. -ok_or -( -CollectionAllocErr -: -: -CapacityOverflow -) -? -; -self -. -try_grow +> +panic +! ( -new_cap +" +reserve_exact +overflow +" ) } +} +} / / / @@ -8241,19 +7218,14 @@ old_len ) ; let -start +mut +ptr = self . as_mut_ptr ( ) -; -let -mut -ptr -= -start . add ( @@ -8308,32 +7280,8 @@ self . set_len ( -0 -) -; -let -mut -guard -= -DropOnPanic -{ -start -skip -: -index -. -. -( index -+ -lower_size_bound ) -len -: -old_len -+ -lower_size_bound -} ; let mut @@ -8385,18 +7333,13 @@ reserve 1 ) ; -let -start +ptr = self . as_mut_ptr ( ) -; -ptr -= -start . add ( @@ -8429,28 +7372,6 @@ old_len index ) ; -guard -. -start -= -start -; -guard -. -len -+ -= -1 -; -guard -. -skip -. -end -+ -= -1 -; } ptr : @@ -8461,29 +7382,12 @@ cur element ) ; -guard -. -skip -. -start -+ -= -1 -; num_added + = 1 ; } -mem -: -: -forget -( -guard -) -; if num_added < @@ -8531,90 +7435,6 @@ num_added ) ; } -struct -DropOnPanic -< -T -> -{ -start -: -* -mut -T -skip -: -Range -< -usize -> -len -: -usize -} -impl -< -T -> -Drop -for -DropOnPanic -< -T -> -{ -fn -drop -( -& -mut -self -) -{ -for -i -in -0 -. -. -self -. -len -{ -if -! -self -. -skip -. -contains -( -& -i -) -{ -unsafe -{ -ptr -: -: -drop_in_place -( -self -. -start -. -add -( -i -) -) -; -} -} -} -} -} } / / @@ -8894,19 +7714,6 @@ size ( ) { -/ -/ -Note -: -A -: -: -size -not -Self -: -: -inline_capacity Err ( self @@ -9428,19 +8235,20 @@ b / / / -Resizes -the +Creates +a +SmallVec +directly +from +the +raw +components +of +another +/ +/ +/ SmallVec -in -- -place -so -that -len -is -equal -to -new_len . / / @@ -9448,138 +8256,139 @@ new_len / / / -If -new_len -is -greater -than -len -the -SmallVec -is -extended -by -the -difference -with -each +# +Safety / / / -additional -slot -filled -with +/ +/ +/ +This +is +highly +unsafe +due +to the -result +number of -calling -the -closure -f -. -The -return -values -from -f +invariants +that +aren +' +t / / / +checked +: / -will -end -up -in -the -SmallVec -in -the -order -they +/ +/ +/ +/ +/ +* +ptr +needs +to have been -generated -. +previously +allocated +via +SmallVec +for +its / / / +spilled +storage +( +at +least +it +' +s +highly +likely +to +be +incorrect +if +it / / / -If -new_len -is -less -than -len -the -SmallVec -is -simply -truncated +wasn +' +t +) . / / / +* +ptr +' +s +A +: +: +Item +type +needs +to +be +the +same +size +and +alignment +that +/ +/ +/ +it +was +allocated +with / / / -This -method -uses -a -closure +* +length +needs to -create -new -values -on -every -push +be +less +than +or +equal +to +capacity . -If -you -' -d -rather -Clone -a -given / / / -value -use -resize -. -If -you -want +* +capacity +needs to -use +be the -Default -trait -to -generate -values -you -can -pass +capacity +that +the +pointer +was +allocated / / / -Default -: -: -default -( -) -as -the -second -argument +with . / / @@ -9587,101 +8396,183 @@ argument / / / -Added -for -std -: -: -vec -: -: -Vec -compatibility -( -added -in -Rust -1 -. -33 -. -0 -) +Violating +these +may +cause +problems +like +corrupting +the +allocator +' +s / / / +internal +data +structures +. / / / / / / -# -use -smallvec -: -: -{ -smallvec -SmallVec -} -; +Additionally +capacity +must +be +greater +than +the +amount +of +inline / / / -let -mut -vec -: +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 +/ +/ +/ +/ +/ +/ +/ +/ +/ +# +# [ -_ -; -4 +macro_use ] -> -= +extern +crate smallvec -! -[ -1 -2 -3 -] ; / / / -vec -. -resize_with -( -5 -Default +# +use +smallvec : : -default -) +SmallVec ; / / / -assert_eq -! -( -& -* -vec -& -[ -1 -2 -3 -0 -0 -] -) +use +std +: +: +mem +; +/ +/ +/ +use +std +: +: +ptr ; / / @@ -9689,1096 +8580,1003 @@ vec / / / +fn +main +( +) +{ +/ +/ +/ let mut -vec +v : SmallVec < [ _ ; -4 +1 ] > = smallvec ! [ +1 +2 +3 ] ; / / / +/ +/ +/ +/ +/ +Pull +out +the +important +parts +of +v +. +/ +/ +/ let -mut p = -1 +v +. +as_mut_ptr +( +) ; / / / -vec +let +len += +v . -resize_with +len ( -4 -| -| -{ -p -* -= -2 -; -p -} ) ; / / / -assert_eq -! +let +cap += +v +. +capacity ( -& -* -vec -& -[ -2 -4 -8 -16 -] ) ; / / / -pub -fn -resize_with -< -F -> +let +spilled += +v +. +spilled ( -& -mut -self -new_len -: -usize -f -: -F -) -where -F -: -FnMut -( -) -- -> -A -: -: -Item -{ -let -old_len -= -self -. -len -( -) -; -if -old_len -< -new_len -{ -let -mut -f -= -f -; -let -additional -= -new_len -- -old_len -; -self -. -reserve -( -additional -) -; -for -_ -in -0 -. -. -additional -{ -self -. -push -( -f -( -) -) -; -} -} -else -if -old_len -> -new_len -{ -self -. -truncate -( -new_len ) ; -} -} -/ / / -Creates -a -SmallVec -directly -from -the -raw -components -of -another / / / -SmallVec -. -/ / +unsafe +{ / / / / -# -Safety / +Forget +all +about +v +. +The +heap +allocation +that +stored +the / / / / / -This -is -highly -unsafe -due -to -the -number -of -invariants -that -aren +three +values +won ' t +be +deallocated +. / / / -checked +mem : +: +forget +( +v +) +; / / / / / / -* -ptr -needs -to -have -been -previously -allocated -via -SmallVec -for -its -/ / / -spilled -storage -( -at -least -it -' -s -highly -likely -to -be -incorrect -if -it +Overwrite +memory +with +[ +4 +5 +6 +] +. / / / -wasn -' -t -) -. / / / -* -ptr -' -s -A -: -: -Item -type -needs -to -be -the -same -size -and -alignment -that / / / -it -was -allocated -with / +This +is +only +safe +if +spilled +is +true +! +Otherwise +we +are / / -* -length -needs -to -be -less -than -or -equal -to -capacity -. / / / -* -capacity -needs -to -be +writing +into the -capacity -that +old +SmallVec +' +s +inline +storage +on the -pointer -was -allocated / / / -with +/ +/ +stack . / / / +assert +! +( +spilled +) +; / / / -Violating -these -may -cause -problems -like -corrupting -the -allocator -' -s +for +i +in +0 +. +. +len +{ / / / -internal -data -structures +ptr +: +: +write +( +p . +add +( +i +) +4 ++ +i +) +; / / / +} / / / -Additionally -capacity -must -be -greater -than -the -amount -of -inline -/ / / -storage -A -has -; -that -is -the -new -SmallVec -must -need -to -spill -over / / / +Put +everything +back +together into -heap -allocated -storage -. -This -condition -is -asserted -against -. -/ +a +SmallVec +with +a +different / / / / / -The -ownership +amount of -ptr -is -effectively -transferred -to -the -/ -/ -/ -SmallVec +inline +storage +but 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 +is +still +less +than +cap . / / / -/ -/ -/ -# -Examples -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -# -[ -macro_use -] -extern -crate -smallvec -; -/ -/ -/ -# -use -smallvec +let +rebuilt += +SmallVec : : -SmallVec +< +[ +_ ; -/ -/ -/ -use -std +2 +] +> : : -mem +from_raw_parts +( +p +len +cap +) ; / / / -use -std -: -: -ptr +assert_eq +! +( +& +* +rebuilt +& +[ +4 +5 +6 +] +) ; / / / +} / / / +} +# +[ +inline +] +pub +unsafe fn -main +from_raw_parts ( -) -{ -/ -/ -/ -let +ptr +: +* mut -v +A +: +: +Item +length : +usize +capacity +: +usize +) +- +> SmallVec < -[ -_ -; -1 -] +A > -= -smallvec +{ +assert ! -[ -1 -2 -3 -] -; -/ -/ +( +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 +. / / / -Pull -out -the -important -parts -of -v -. / / / +For +slices +of +Copy +types +this +is +more +efficient +than +SmallVec +: +: +from +( +slice +) +. +pub +fn +from_slice +( +slice +: +& +[ +A +: +: +Item +] +) +- +> +Self +{ let -p +len = -v +slice . -as_mut_ptr +len ( ) ; -/ -/ -/ -let +if len +< = -v -. +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 -cap +mut +b = -v +slice . -capacity +to_vec ( ) ; -/ -/ -/ let -spilled +( +ptr +cap +) = -v +( +b . -spilled +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 / / / -unsafe -{ +elements +toward +the +back +. / / / / / -Forget -all -about -v -. -The -heap -allocation -that -stored -the -/ / -/ -/ -/ -three -values -won -' -t -be -deallocated +For +slices +of +Copy +types +this +is +more +efficient +than +insert . -/ -/ -/ -mem +pub +fn +insert_from_slice +( +& +mut +self +index : +usize +slice : -forget -( -v -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Overwrite -memory -with +& [ -4 -5 -6 +A +: +: +Item ] +) +{ +self . -/ -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -is -only -safe -if -spilled -is -true -! -Otherwise -we -are -/ -/ -/ -/ -/ -writing -into -the -old -SmallVec -' -s -inline -storage -on -the -/ -/ -/ -/ -/ -stack +reserve +( +slice . -/ -/ -/ +len +( +) +) +; +let +len += +self +. +len +( +) +; assert ! ( -spilled +index +< += +len ) ; -/ -/ -/ -for -i -in -0 +unsafe +{ +let +slice_ptr += +slice +. +as_ptr +( +) +; +let +ptr += +self . +as_mut_ptr +( +) . -len -{ -/ -/ -/ +add +( +index +) +; ptr : : -write +copy ( -p +ptr +ptr . add ( -i +slice +. +len +( ) -4 +) +len +- +index +) +; +ptr +: +: +copy_nonoverlapping +( +slice_ptr +ptr +slice +. +len +( +) +) +; +self +. +set_len +( +len + -i +slice +. +len +( +) ) ; -/ -/ -/ +} } / / / -/ -/ -/ -/ -/ -Put -everything -back -together -into -a -SmallVec -with +Copy +elements +from a -different +slice +and +append +them +to +the +vector +. / / / / / -amount +/ +For +slices of -inline -storage -but -which +Copy +types +this is -still -less +more +efficient than -cap +extend . -/ -/ -/ -let -rebuilt -= -SmallVec -: -: -< -[ -_ -; -2 -] -> -: -: -from_raw_parts -( -p -len -cap -) -; -/ -/ -/ -assert_eq -! -( -& -* -rebuilt -& -[ -4 -5 -6 -] -) -; -/ -/ -/ -} -/ -/ -/ -} # [ inline ] pub -unsafe fn -from_raw_parts +extend_from_slice ( -ptr -: -* +& mut +self +slice +: +& +[ A : : Item -length -: -usize -capacity -: -usize +] ) -- -> -SmallVec -< -A -> { -assert -! -( -capacity -> -Self -: -: -inline_capacity +let +len += +self +. +len ( ) -) ; -SmallVec -{ -capacity -data -: -SmallVecData -: -: -from_heap +self +. +insert_from_slice ( -ptr -length +len +slice ) +; } } -/ -/ -/ -Returns -a -raw -pointer -to -the -vector -' -s -buffer -. -pub -fn -as_ptr -( -& -self -) -- +impl +< +A +: +Array > -* -const +SmallVec +< +A +> +where A : : Item +: +Clone { / / -We -shadow -the -slice -method -of +/ +Resizes the -same -name +vector +so +that +its +length +is +equal to -avoid -going -through +len +. / / -deref -which -creates -an -intermediate -reference -that -may -place / / -additional -safety -constraints -on +/ +/ +If +len +is +less +than the -contents -of +current +length the -slice -. -self -. -triple -( -) +vector +simply +truncated . -0 -} / / / -Returns -a -raw -mutable -pointer +/ +/ +/ +If +len +is +greater +than +the +current +length +value +is +appended to the +/ +/ +/ vector -' -s -buffer +until +its +length +equals +len . pub fn -as_mut_ptr +resize ( & mut self -) -- -> -* -mut +len +: +usize +value +: A : : Item +) { -/ -/ -We -shadow -the -slice -method -of -the -same -name -to -avoid -going -through -/ -/ -deref_mut -which -creates -an -intermediate -reference -that -may -place -/ -/ -additional -safety -constraints -on -the -contents -of -the -slice +let +old_len += +self . +len +( +) +; +if +len +> +old_len +{ self . -triple_mut +extend +( +repeat ( +value ) . -0 -} +take +( +len +- +old_len +) +) +; } -impl -< -A -: -Array -> -SmallVec -< -A -> -where -A -: -: -Item -: -Copy +else { +self +. +truncate +( +len +) +; +} +} / / / -Copy -the -elements -from -a -slice -into +Creates a -new SmallVec +with +n +copies +of +elem . / / @@ -10786,234 +9584,234 @@ SmallVec / / / -For -slices -of -Copy -types -this -is -more -efficient -than +use +smallvec +: +: +SmallVec +; +/ +/ +/ +/ +/ +/ +let +v += SmallVec : : -from +< +[ +char +; +128 +] +> +: +: +from_elem ( -slice +' +d +' +2 ) -. +; +/ +/ +/ +assert_eq +! +( +v +SmallVec +: +: +from_buf +( +[ +' +d +' +' +d +' +] +) +) +; +/ +/ +/ pub fn -from_slice +from_elem ( -slice +elem : -& -[ A : : Item -] +n +: +usize ) - > Self { -let -len -= -slice -. -len -( -) -; if -len -< -= -Self +n +> +A : : -inline_capacity +size ( ) { -SmallVec -{ -capacity -: -len -data -: -SmallVecData -: -: -from_inline +vec +! +[ +elem +; +n +] +. +into ( -unsafe +) +} +else { let mut -data +v += +SmallVec +: : -MaybeUninit < A > -= -MaybeUninit : : -uninit +new ( ) ; -ptr -: -: -copy_nonoverlapping -( -slice -. -as_ptr +unsafe +{ +let ( +ptr +len_ptr +_ ) -data += +v . -as_mut_ptr +triple_mut ( ) -as -* +; +let mut -A +local_len += +SetLenOnDrop : : -Item -len +new +( +len_ptr ) ; -data -} -) -} -} -else -{ -let -mut -b -= -slice +for +i +in +0 . -to_vec -( -) -; -let -( +. +n +{ +: +: +core +: +: ptr -cap -) -= +: +: +write ( -b +ptr . -as_mut_ptr +add ( +i ) -b +elem . -capacity +clone ( ) ) ; -mem -: -: -forget +local_len +. +increment_len ( -b +1 ) ; -SmallVec -{ -capacity +} +} +v +} +} +} +impl +< +A : -cap -data +Array +> +ops : -SmallVecData : +Deref +for +SmallVec +< +A +> +{ +type +Target += +[ +A : -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 +: +Item +] +; +# +[ +inline +] fn -insert_from_slice +deref ( & -mut self -index -: -usize -slice -: +) +- +> & [ A @@ -11021,158 +9819,132 @@ A : Item ] -) { -self -. -reserve +unsafe +{ +let ( -slice -. +ptr len -( -) +_ ) -; -let -len = self . -len +triple ( ) ; -assert -! +slice +: +: +from_raw_parts ( -index -< -= +ptr len ) -; -unsafe +} +} +} +impl +< +A +: +Array +> +ops +: +: +DerefMut +for +SmallVec +< +A +> { -let -slice_ptr -= -slice -. -as_ptr +# +[ +inline +] +fn +deref_mut ( +& +mut +self ) -; +- +> +& +mut +[ +A +: +: +Item +] +{ +unsafe +{ let +( ptr +& +mut +len +_ +) = self . -as_mut_ptr -( -) -. -add +triple_mut ( -index ) ; -ptr +slice : : -copy +from_raw_parts_mut ( ptr -ptr -. -add -( -slice -. -len -( -) -) 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 -. +} +impl +< +A +: +Array +> +AsRef +< +[ +A +: +: +Item +] +> +for +SmallVec +< +A +> +{ # [ inline ] -pub fn -extend_from_slice +as_ref ( & -mut self -slice -: +) +- +> & [ A @@ -11180,25 +9952,8 @@ A : Item ] -) { -let -len -= -self -. -len -( -) -; self -. -insert_from_slice -( -len -slice -) -; } } impl @@ -11207,667 +9962,485 @@ A : Array > -SmallVec +AsMut < -A -> -where +[ A : : Item -: -Clone +] +> +for +SmallVec +< +A +> { -/ -/ -/ -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 +# +[ +inline +] fn -resize +as_mut ( & mut self -len +) +- +> +& +mut +[ +A : -usize -value : +Item +] +{ +self +} +} +impl +< +A +: +Array +> +Borrow +< +[ A : : Item -) +] +> +for +SmallVec +< +A +> { -let -old_len -= -self -. -len +# +[ +inline +] +fn +borrow ( +& +self ) -; -if -len +- > -old_len +& +[ +A +: +: +Item +] { self -. -extend -( -repeat -( -value -) -. -take -( -len -- -old_len -) -) -; -} -else -{ -self -. -truncate -( -len -) -; } } -/ -/ -/ -Creates -a -SmallVec -with -n -copies -of -elem -. -/ -/ -/ -/ -/ -/ -use -smallvec -: +impl +< +A : -SmallVec -; -/ -/ -/ -/ -/ -/ -let -v -= -SmallVec +Array +> +BorrowMut +< +[ +A : : +Item +] +> +for +SmallVec < +A +> +{ +# [ -char -; -128 +inline ] +fn +borrow_mut +( +& +mut +self +) +- > +& +mut +[ +A : : -from_elem +Item +] +{ +self +} +} +# +[ +cfg ( -' -d -' -2 +feature += +" +write +" ) -; -/ -/ -/ -assert_eq -! -( -v -SmallVec +] +impl +< +A +: +Array +< +Item += +u8 +> +> +io : : -from_buf -( +Write +for +SmallVec +< +A +> +{ +# [ -' -d -' -' -d -' +inline ] -) -) -; -/ -/ -/ -pub fn -from_elem +write ( -elem -: -A -: -: -Item -n +& +mut +self +buf : -usize +& +[ +u8 +] ) - > -Self -{ -if -n -> -Self +io : : -inline_capacity +Result +< +usize +> +{ +self +. +extend_from_slice ( +buf ) -{ -vec -! -[ -elem ; -n -] +Ok +( +buf . -into +len ( ) +) } -else -{ -let +# +[ +inline +] +fn +write_all +( +& mut -v -= -SmallVec -: +self +buf : -< -A +& +[ +u8 +] +) +- > +io : : -new +Result +< ( ) -; -unsafe +> { -let -( -ptr -len_ptr -_ -) -= -v +self . -triple_mut +extend_from_slice ( +buf ) ; -let -mut -local_len -= -SetLenOnDrop -: -: -new +Ok +( ( -len_ptr ) -; -for -i -in -0 -. -. -n -{ -: -: -core -: -: -ptr -: -: -write -( -ptr -. -add -( -i -) -elem -. -clone -( -) -) -; -local_len -. -increment_len -( -1 ) -; -} -} -v -} } -} -impl -< -A -: -Array -> -ops -: -: -Deref -for -SmallVec -< -A -> -{ -type -Target -= -[ -A -: -: -Item -] -; # [ inline ] fn -deref +flush ( & +mut self ) - > -& -[ -A +io : : -Item -] -{ -unsafe -{ -let +Result +< ( -ptr -len -_ ) -= -self -. -triple +> +{ +Ok ( -) -; -slice -: -: -from_raw_parts ( -ptr -len +) ) } } -} +# +[ +cfg +( +feature += +" +serde +" +) +] impl < A : Array > -ops -: -: -DerefMut +Serialize for SmallVec < A > +where +A +: +: +Item +: +Serialize { -# -[ -inline -] fn -deref_mut +serialize +< +S +: +Serializer +> ( & -mut self +serializer +: +S ) - > -& -mut -[ -A +Result +< +S : : -Item -] -{ -unsafe +Ok +S +: +: +Error +> { let -( -ptr -& mut -len -_ -) +state = +serializer +. +serialize_seq +( +Some +( self . -triple_mut +len ( ) +) +) +? ; -slice -: -: -from_raw_parts_mut +for +item +in +self +{ +state +. +serialize_element ( -ptr -len +& +item ) +? +; } +state +. +end +( +) } } +# +[ +cfg +( +feature += +" +serde +" +) +] impl < +' +de A : Array > -AsRef +Deserialize < -[ -A -: -: -Item -] +' +de > for SmallVec < A > -{ -# -[ -inline -] -fn -as_ref -( -& -self -) -- -> -& -[ +where A : : Item -] -{ -self -} -} -impl -< -A : -Array +Deserialize +< +' +de > -AsMut +{ +fn +deserialize < -[ -A -: +D : -Item -] -> -for -SmallVec +Deserializer < -A +' +de +> > -{ -# -[ -inline -] -fn -as_mut ( -& -mut -self +deserializer +: +D ) - > -& -mut -[ -A -: -: -Item -] -{ -self -} -} -impl -< -A -: -Array -> -Borrow +Result < -[ -A +Self +D : : -Item -] -> -for -SmallVec -< -A +Error > { +deserializer +. +deserialize_seq +( +SmallVecVisitor +{ +phantom +: +PhantomData +} +) +} +} # [ -inline -] -fn -borrow +cfg ( -& -self +feature += +" +serde +" ) -- -> -& -[ -A -: -: -Item ] -{ -self -} -} -impl +struct +SmallVecVisitor < A -: -Array > -BorrowMut -< -[ -A -: +{ +phantom : -Item -] -> -for -SmallVec +PhantomData < A > -{ -# -[ -inline -] -fn -borrow_mut -( -& -mut -self -) -- -> -& -mut -[ -A -: -: -Item -] -{ -self -} } # [ @@ -11876,141 +10449,168 @@ cfg feature = " -write +serde " ) ] impl < +' +de A : Array +> +Visitor < -Item -= -u8 +' +de > +for +SmallVecVisitor +< +A > -io +where +A : : -Write -for +Item +: +Deserialize +< +' +de +> +{ +type +Value += SmallVec < A > -{ -# -[ -inline -] +; fn -write +expecting ( & -mut self -buf +formatter : & -[ -u8 -] +mut +fmt +: +: +Formatter +< +' +_ +> ) - > -io +fmt : : Result -< -usize -> { -self -. -extend_from_slice -( -buf -) -; -Ok -( -buf +formatter . -len +write_str ( -) +" +a +sequence +" ) } -# -[ -inline -] fn -write_all +visit_seq +< +B +> ( -& -mut self -buf +mut +seq : -& -[ -u8 -] +B ) - > -io +Result +< +Self : : -Result +Value +B +: +: +Error +> +where +B +: +SeqAccess < -( -) +' +de > { -self -. -extend_from_slice +let +len += +seq +. +size_hint ( -buf ) -; -Ok -( +. +unwrap_or ( +0 ) -) -} -# -[ -inline -] -fn -flush -( -& +; +let mut -self -) -- -> -io +values += +SmallVec : : -Result -< +with_capacity ( +len ) -> -{ -Ok +; +while +let +Some +( +value +) += +seq +. +next_element ( +) +? +{ +values +. +push ( +value ) +; +} +Ok +( +values ) } } @@ -12021,99 +10621,48 @@ cfg feature = " -serde +specialization " ) ] -impl +trait +SpecFrom < A : Array +S > -Serialize -for -SmallVec -< -A -> -where -A -: -: -Item -: -Serialize { fn -serialize -< -S -: -Serializer -> +spec_from ( -& -self -serializer +slice : S ) - > -Result +SmallVec < -S -: -: -Ok -S -: -: -Error +A > -{ -let -mut -state -= -serializer -. -serialize_seq -( -Some -( -self -. -len -( -) -) -) -? -; -for -item -in -self -{ -state -. -serialize_element -( -& -item -) -? ; } -state -. -end +# +[ +cfg ( +feature += +" +specialization +" ) -} -} +] +mod +specialization +; # [ cfg @@ -12121,22 +10670,30 @@ cfg feature = " -serde +specialization " ) ] impl < ' -de +a A : Array > -Deserialize +SpecFrom < +A +& ' -de +a +[ +A +: +: +Item +] > for SmallVec @@ -12149,102 +10706,65 @@ A : Item : -Deserialize -< -' -de -> +Copy { +# +[ +inline +] fn -deserialize -< -D +spec_from +( +slice : -Deserializer -< +& ' -de -> -> -( -deserializer +a +[ +A : -D +: +Item +] ) - > -Result +SmallVec < -Self -D -: -: -Error +A > { -deserializer -. -deserialize_seq -( -SmallVecVisitor -{ -phantom +SmallVec : -PhantomData -} +: +from_slice +( +slice ) } } -# -[ -cfg -( -feature -= -" -serde -" -) -] -struct -SmallVecVisitor +impl < +' +a A -> -{ -phantom : -PhantomData +Array +> +From < +& +' +a +[ A -> -} -# -[ -cfg -( -feature -= -" -serde -" -) -] -impl -< -' -de -A -: -Array -> -Visitor -< -' -de +: +: +Item +] > for -SmallVecVisitor +SmallVec < A > @@ -12254,143 +10774,62 @@ A : Item : -Deserialize -< -' -de -> +Clone { -type -Value -= -SmallVec -< -A -> -; -fn -expecting +# +[ +cfg ( -& -self -formatter -: -& -mut -fmt -: -: -Formatter -< -' -_ -> -) -- -> -fmt -: -: -Result -{ -formatter -. -write_str +not ( +feature += " -a -sequence +specialization " ) -} +) +] +# +[ +inline +] fn -visit_seq -< -B -> +from ( -self -mut -seq -: -B -) -- -> -Result -< -Self -: +slice : -Value -B +& +' +a +[ +A : : -Error +Item +] +) +- > -where -B -: -SeqAccess +SmallVec < -' -de +A > { -let -len -= -seq -. -size_hint -( -) +slice . -unwrap_or -( -0 -) -; -let -mut -values -= -SmallVec -: -: -with_capacity -( -len -) -; -while -let -Some +iter ( -value ) -= -seq . -next_element +cloned ( ) -? -{ -values . -push -( -value -) -; -} -Ok +collect ( -values ) } -} # [ cfg @@ -12402,21 +10841,24 @@ specialization " ) ] -trait -SpecFrom -< -A -: -Array -S -> -{ +# +[ +inline +] fn -spec_from +from ( slice : -S +& +' +a +[ +A +: +: +Item +] ) - > @@ -12424,265 +10866,46 @@ SmallVec < A > -; -} -# -[ -cfg -( -feature -= -" -specialization -" -) -] -mod -specialization -; -# -[ -cfg +{ +SmallVec +: +: +spec_from ( -feature -= -" -specialization -" +slice ) -] +} +} impl < -' -a A : Array > -SpecFrom +From +< +Vec < -A -& -' -a -[ A : : Item -] +> > for SmallVec < A > -where -A -: -: -Item -: -Copy { # [ inline ] fn -spec_from +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 -. -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 : Vec < @@ -12880,13 +11103,6 @@ index ] } } -# -[ -allow -( -deprecated -) -] impl < A @@ -13508,18 +11724,47 @@ SmallVec A > { +let +mut +new_vector += SmallVec : : -from +with_capacity ( self . -as_slice +len +( +) +) +; +for +element +in +self +. +iter +( +) +{ +new_vector +. +push +( +( +* +element +) +. +clone ( ) ) } +new_vector +} } impl < @@ -14797,362 +13042,7578 @@ fn new ( len -: -& -' -a -mut -usize +: +& +' +a +mut +usize +) +- +> +Self +{ +SetLenOnDrop +{ +local_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 +; +} +} +# +[ +cfg +( +feature += +" +const_generics +" +) +] +unsafe +impl +< +T +const +N +: +usize +> +Array +for +[ +T +; +N +] +{ +type +Item += +T +; +fn +size +( +) +- +> +usize +{ +N +} +} +# +[ +cfg +( +not +( +feature += +" +const_generics +" +) +) +] +macro_rules +! +impl_array +( +( +( +size +: +expr +) ++ +) += +> +{ +( +unsafe +impl +< +T +> +Array +for +[ +T +; +size +] +{ +type +Item += +T +; +fn +size +( +) +- +> +usize +{ +size +} +} +) ++ +} +) +; +# +[ +cfg +( +not +( +feature += +" +const_generics +" +) +) +] +impl_array +! +( +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +20 +24 +32 +36 +0x40 +0x60 +0x80 +0x100 +0x200 +0x400 +0x600 +0x800 +0x1000 +0x2000 +0x4000 +0x6000 +0x8000 +0x10000 +0x20000 +0x40000 +0x60000 +0x80000 +0x10_0000 +) +; +/ +/ +/ +Convenience +trait +for +constructing +a +SmallVec +pub +trait +ToSmallVec +< +A +: +Array +> +{ +/ +/ +/ +Construct +a +new +SmallVec +from +a +slice +. +fn +to_smallvec +( +& +self +) +- +> +SmallVec +< +A +> +; +} +impl +< +A +: +Array +> +ToSmallVec +< +A +> +for +[ +A +: +: +Item +] +where +A +: +: +Item +: +Copy +{ +# +[ +inline +] +fn +to_smallvec +( +& +self +) +- +> +SmallVec +< +A +> +{ +SmallVec +: +: +from_slice +( +self +) +} +} +# +[ +cfg +( +test +) +] +mod +tests +{ +use +crate +: +: +SmallVec +; +use +std +: +: +iter +: +: +FromIterator +; +use +alloc +: +: +borrow +: +: +ToOwned +; +use +alloc +: +: +boxed +: +: +Box +; +use +alloc +: +: +rc +: +: +Rc +; +use +alloc +: +: +{ +vec +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 +) +; +let +old_capacity += +v +. +capacity +( +) +; +assert_eq +! +( +v +. +drain +( +1 +. +. +) +. +collect +: +: +< +Vec +< +_ +> +> +( +) +& +[ +4 +5 +] +) +; +/ +/ +drain +should +not +change +the +capacity +assert_eq +! +( +v +. +capacity +( +) +old_capacity +) +; +} +# +[ +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 +drain_forget +( +) +{ +let +mut +v +: +SmallVec +< +[ +u8 +; +1 +] +> += +smallvec +! +[ +0 +1 +2 +3 +4 +5 +6 +7 +] +; +std +: +: +mem +: +: +forget +( +v +. +drain +( +2 +. +. +5 +) +) +; +assert_eq +! +( +v +. +len +( +) +2 +) +; +} +# +[ +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 +] +) +; +} +# +[ +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 +) +; +} +# +[ +test +] +fn +test_hash +( +) +{ +use +std +: +: +collections +: +: +hash_map +: +: +DefaultHasher +; +use +std +: +: +hash +: +: +Hash +; +{ +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 +( +. +. +2 +) +. +len +( +) +2 +) +; +assert_eq +! +( +vec +. +into_iter +( +) +. +len +( +) +1 +) +; +} +# +[ +test +] +fn +test_into_iter_as_slice +( +) +{ +let +vec += +SmallVec +: +: +< +[ +u32 +; +2 +] +> +: +: +from +( +& +[ +1 +2 +3 +] +[ +. +. +] +) +; +let +mut +iter += +vec +. +clone +( +) +. +into_iter +( +) +; +assert_eq +! +( +iter +. +as_slice +( +) +& +[ +1 +2 +3 +] +) +; +assert_eq +! +( +iter +. +as_mut_slice +( +) +& +[ +1 +2 +3 +] +) +; +iter +. +next +( +) +; +assert_eq +! +( +iter +. +as_slice +( +) +& +[ +2 +3 +] +) +; +assert_eq +! +( +iter +. +as_mut_slice +( +) +& +[ +2 +3 +] +) +; +iter +. +next_back +( +) +; +assert_eq +! +( +iter +. +as_slice +( +) +& +[ +2 +] +) +; +assert_eq +! +( +iter +. +as_mut_slice +( +) +& +[ +2 +] +) +; +} +# +[ +test +] +fn +test_into_iter_clone +( +) +{ +/ +/ +Test +that +the +cloned +iterator +yields +identical +elements +and +that +it +owns +its +own +copy +/ +/ +( +i +. +e +. +no +use +after +move +errors +) +. +let +mut +iter += +SmallVec +: +: +< +[ +u8 +; +2 +] +> +: +: +from_iter +( +0 +. +. +3 +) +. +into_iter +( +) +; +let +mut +clone_iter += +iter +. +clone +( +) +; +while +let +Some +( +x +) += +iter +. +next +( +) +{ +assert_eq +! +( +x +clone_iter +. +next +( +) +. +unwrap +( +) +) +; +} +assert_eq +! +( +clone_iter +. +next +( +) +None +) +; +} +# +[ +test +] +fn +test_into_iter_clone_partially_consumed_iterator +( +) +{ +/ +/ +Test +that +the +cloned +iterator +only +contains +the +remaining +elements +of +the +original +iterator +. +let +mut +iter += +SmallVec +: +: +< +[ +u8 +; +2 +] +> +: +: +from_iter +( +0 +. +. +3 +) +. +into_iter +( +) +. +skip +( +1 +) +; +let +mut +clone_iter += +iter +. +clone +( +) +; +while +let +Some +( +x +) += +iter +. +next +( +) +{ +assert_eq +! +( +x +clone_iter +. +next +( +) +. +unwrap +( +) +) +; +} +assert_eq +! +( +clone_iter +. +next +( +) +None +) +; +} +# +[ +test +] +fn +test_into_iter_clone_empty_smallvec +( +) +{ +let +mut +iter += +SmallVec +: +: +< +[ +u8 +; +2 +] +> +: +: +new +( +) +. +into_iter +( +) +; +let +mut +clone_iter += +iter +. +clone +( +) +; +assert_eq +! +( +iter +. +next +( +) +None +) +; +assert_eq +! +( +clone_iter +. +next +( +) +None +) +; +} +# +[ +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 += +" +write +" +) +] +# +[ +test +] +fn +test_write +( +) +{ +use +std +: +: +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 +( ) -- -> -Self -{ -SetLenOnDrop -{ -local_len -: -* -len -len -} -} -# -[ -inline -] -fn -get +0 +) +; +v +. +push ( -& -self +4 ) -- -> -usize -{ -self +; +assert_eq +! +( +v +[ . -local_len +. +] +[ +4 +] +) +; } # [ -inline +test ] fn -increment_len +resumable_extend ( -& -mut -self -increment -: -usize ) { -self -. -local_len -+ +let +s = -increment +" +a +b +c +" ; -} -} -impl -< +/ +/ +This +iterator +yields +: +( +Some +( ' a -> -Drop -for -SetLenOnDrop -< ' -a -> -{ -# -[ -inline -] -fn -drop +) +None +Some ( -& -mut -self +' +b +' ) -{ -* -self -. -len +None +Some +( +' +c +' +) +) +None +let +it = -self +s . -local_len -; -} +chars +( +) +. +scan +( +0 +| +_ +ch +| +if +ch +. +is_whitespace +( +) +{ +None } -# -[ -cfg +else +{ +Some ( -feature -= -" -const_generics -" +ch ) -] -unsafe -impl -< -T -const -N +} +) +; +let +mut +v : -usize -> -Array -for +SmallVec +< [ -T +char ; -N +4 ] -{ -type -Item +> = -T +SmallVec +: +: +new +( +) ; -fn -size +v +. +extend ( +it ) -- -> -usize -{ -N -} +; +assert_eq +! +( +v +[ +. +. +] +[ +' +a +' +] +) +; } +/ +/ +# +139 # [ -cfg -( -not +test +] +fn +uninhabited ( -feature -= -" -const_generics -" -) ) +{ +enum +Void +{ +} +let +_sv += +SmallVec +: +: +< +[ +Void +; +8 ] -macro_rules -! -impl_array -( -( -( -size +> : -expr +: +new +( ) -+ +; +} +# +[ +test +] +fn +grow_spilled_same_size +( ) -= -> { -( -unsafe -impl +let +mut +v +: +SmallVec < -T -> -Array -for [ -T +u8 ; -size +2 ] -{ -type -Item +> = -T +SmallVec +: +: +new +( +) ; -fn -size +v +. +push ( +0 ) -- -> -usize -{ -size -} -} +; +v +. +push +( +1 ) -+ -} +; +v +. +push +( +2 ) ; -# -[ -cfg +assert +! ( -not +v +. +spilled ( -feature -= -" -const_generics -" ) ) -] -impl_array +; +assert_eq ! ( -0 -1 -2 -3 +v +. +capacity +( +) 4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -20 -24 -32 -36 -0x40 -0x60 -0x80 -0x100 -0x200 -0x400 -0x600 -0x800 -0x1000 -0x2000 -0x4000 -0x6000 -0x8000 -0x10000 -0x20000 -0x40000 -0x60000 -0x80000 -0x10_0000 ) ; / / -/ -Convenience -trait -for -constructing -a -SmallVec -pub -trait -ToSmallVec -< -A -: -Array -> -{ -/ -/ -/ -Construct -a -new -SmallVec -from -a -slice +grow +with +the +same +capacity +v . -fn -to_smallvec +grow ( -& -self +4 +) +; +assert_eq +! +( +v +. +capacity +( +) +4 +) +; +assert_eq +! +( +v +[ +. +. +] +[ +0 +1 +2 +] ) -- -> -SmallVec -< -A -> ; } -impl -< -A -: -Array -> -ToSmallVec -< -A -> -for +# [ -A -: -: -Item +cfg +( +feature += +" +const_generics +" +) ] -where -A -: -: -Item -: -Copy -{ # [ -inline +test ] fn -to_smallvec +const_generics ( -& -self ) -- -> +{ +let +_v += SmallVec +: +: < -A +[ +i32 +; +987 +] > -{ -SmallVec : : -from_slice +default ( -self ) +; } } diff --git a/third_party/rust/smallvec/scripts/run_miri.sh b/third_party/rust/smallvec/scripts/run_miri.sh index 1c3edc9f36944..d3be64f89a351 100644 --- a/third_party/rust/smallvec/scripts/run_miri.sh +++ b/third_party/rust/smallvec/scripts/run_miri.sh @@ -142,6 +142,14 @@ test - - verbose +- +- +- +Zmiri +- +ignore +- +leaks cargo miri test @@ -152,6 +160,14 @@ verbose - features union +- +- +- +Zmiri +- +ignore +- +leaks cargo miri test @@ -163,3 +179,11 @@ verbose all - features +- +- +- +Zmiri +- +ignore +- +leaks diff --git a/third_party/rust/smallvec/src/specialization.rs b/third_party/rust/smallvec/specialization.rs similarity index 100% rename from third_party/rust/smallvec/src/specialization.rs rename to third_party/rust/smallvec/specialization.rs diff --git a/third_party/rust/smallvec/src/tests.rs b/third_party/rust/smallvec/src/tests.rs deleted file mode 100644 index 97b747ced140e..0000000000000 --- a/third_party/rust/smallvec/src/tests.rs +++ /dev/null @@ -1,7700 +0,0 @@ -use -crate -: -: -{ -smallvec -SmallVec -} -; -use -std -: -: -iter -: -: -FromIterator -; -use -alloc -: -: -borrow -: -: -ToOwned -; -use -alloc -: -: -boxed -: -: -Box -; -use -alloc -: -: -rc -: -: -Rc -; -use -alloc -: -: -{ -vec -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 -) -; -let -old_capacity -= -v -. -capacity -( -) -; -assert_eq -! -( -v -. -drain -( -1 -. -. -) -. -collect -: -: -< -Vec -< -_ -> -> -( -) -& -[ -4 -5 -] -) -; -/ -/ -drain -should -not -change -the -capacity -assert_eq -! -( -v -. -capacity -( -) -old_capacity -) -; -} -# -[ -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 -drain_forget -( -) -{ -let -mut -v -: -SmallVec -< -[ -u8 -; -1 -] -> -= -smallvec -! -[ -0 -1 -2 -3 -4 -5 -6 -7 -] -; -std -: -: -mem -: -: -forget -( -v -. -drain -( -2 -. -. -5 -) -) -; -assert_eq -! -( -v -. -len -( -) -2 -) -; -} -# -[ -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 -] -) -; -} -/ -/ -https -: -/ -/ -github -. -com -/ -servo -/ -rust -- -smallvec -/ -issues -/ -96 -mod -insert_many_panic -{ -use -crate -: -: -{ -smallvec -SmallVec -} -; -use -alloc -: -: -boxed -: -: -Box -; -struct -PanicOnDoubleDrop -{ -dropped -: -Box -< -bool -> -} -impl -PanicOnDoubleDrop -{ -fn -new -( -) -- -> -Self -{ -Self -{ -dropped -: -Box -: -: -new -( -false -) -} -} -} -impl -Drop -for -PanicOnDoubleDrop -{ -fn -drop -( -& -mut -self -) -{ -assert -! -( -! -* -self -. -dropped -" -already -dropped -" -) -; -* -self -. -dropped -= -true -; -} -} -/ -/ -/ -Claims -to -yield -hint -items -but -actually -yields -count -then -panics -. -struct -BadIter -{ -hint -: -usize -count -: -usize -} -impl -Iterator -for -BadIter -{ -type -Item -= -PanicOnDoubleDrop -; -fn -size_hint -( -& -self -) -- -> -( -usize -Option -< -usize -> -) -{ -( -self -. -hint -None -) -} -fn -next -( -& -mut -self -) -- -> -Option -< -Self -: -: -Item -> -{ -if -self -. -count -= -= -0 -{ -panic -! -( -) -} -self -. -count -- -= -1 -; -Some -( -PanicOnDoubleDrop -: -: -new -( -) -) -} -} -# -[ -test -] -fn -panic_early_at_start -( -) -{ -let -mut -vec -: -SmallVec -< -[ -PanicOnDoubleDrop -; -0 -] -> -= -smallvec -! -[ -PanicOnDoubleDrop -: -: -new -( -) -PanicOnDoubleDrop -: -: -new -( -) -] -; -let -result -= -: -: -std -: -: -panic -: -: -catch_unwind -( -move -| -| -{ -vec -. -insert_many -( -0 -BadIter -{ -hint -: -1 -count -: -0 -} -) -; -} -) -; -assert -! -( -result -. -is_err -( -) -) -; -} -# -[ -test -] -fn -panic_early_in_middle -( -) -{ -let -mut -vec -: -SmallVec -< -[ -PanicOnDoubleDrop -; -0 -] -> -= -smallvec -! -[ -PanicOnDoubleDrop -: -: -new -( -) -PanicOnDoubleDrop -: -: -new -( -) -] -; -let -result -= -: -: -std -: -: -panic -: -: -catch_unwind -( -move -| -| -{ -vec -. -insert_many -( -1 -BadIter -{ -hint -: -4 -count -: -2 -} -) -; -} -) -; -assert -! -( -result -. -is_err -( -) -) -; -} -# -[ -test -] -fn -panic_early_at_end -( -) -{ -let -mut -vec -: -SmallVec -< -[ -PanicOnDoubleDrop -; -0 -] -> -= -smallvec -! -[ -PanicOnDoubleDrop -: -: -new -( -) -PanicOnDoubleDrop -: -: -new -( -) -] -; -let -result -= -: -: -std -: -: -panic -: -: -catch_unwind -( -move -| -| -{ -vec -. -insert_many -( -2 -BadIter -{ -hint -: -3 -count -: -1 -} -) -; -} -) -; -assert -! -( -result -. -is_err -( -) -) -; -} -# -[ -test -] -fn -panic_late_at_start -( -) -{ -let -mut -vec -: -SmallVec -< -[ -PanicOnDoubleDrop -; -0 -] -> -= -smallvec -! -[ -PanicOnDoubleDrop -: -: -new -( -) -PanicOnDoubleDrop -: -: -new -( -) -] -; -let -result -= -: -: -std -: -: -panic -: -: -catch_unwind -( -move -| -| -{ -vec -. -insert_many -( -0 -BadIter -{ -hint -: -3 -count -: -5 -} -) -; -} -) -; -assert -! -( -result -. -is_err -( -) -) -; -} -# -[ -test -] -fn -panic_late_at_end -( -) -{ -let -mut -vec -: -SmallVec -< -[ -PanicOnDoubleDrop -; -0 -] -> -= -smallvec -! -[ -PanicOnDoubleDrop -: -: -new -( -) -PanicOnDoubleDrop -: -: -new -( -) -] -; -let -result -= -: -: -std -: -: -panic -: -: -catch_unwind -( -move -| -| -{ -vec -. -insert_many -( -2 -BadIter -{ -hint -: -3 -count -: -5 -} -) -; -} -) -; -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 -) -; -} -# -[ -test -] -fn -test_hash -( -) -{ -use -std -: -: -collections -: -: -hash_map -: -: -DefaultHasher -; -use -std -: -: -hash -: -: -Hash -; -{ -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 -( -. -. -2 -) -. -len -( -) -2 -) -; -assert_eq -! -( -vec -. -into_iter -( -) -. -len -( -) -1 -) -; -} -# -[ -test -] -fn -test_into_iter_as_slice -( -) -{ -let -vec -= -SmallVec -: -: -< -[ -u32 -; -2 -] -> -: -: -from -( -& -[ -1 -2 -3 -] -[ -. -. -] -) -; -let -mut -iter -= -vec -. -clone -( -) -. -into_iter -( -) -; -assert_eq -! -( -iter -. -as_slice -( -) -& -[ -1 -2 -3 -] -) -; -assert_eq -! -( -iter -. -as_mut_slice -( -) -& -[ -1 -2 -3 -] -) -; -iter -. -next -( -) -; -assert_eq -! -( -iter -. -as_slice -( -) -& -[ -2 -3 -] -) -; -assert_eq -! -( -iter -. -as_mut_slice -( -) -& -[ -2 -3 -] -) -; -iter -. -next_back -( -) -; -assert_eq -! -( -iter -. -as_slice -( -) -& -[ -2 -] -) -; -assert_eq -! -( -iter -. -as_mut_slice -( -) -& -[ -2 -] -) -; -} -# -[ -test -] -fn -test_into_iter_clone -( -) -{ -/ -/ -Test -that -the -cloned -iterator -yields -identical -elements -and -that -it -owns -its -own -copy -/ -/ -( -i -. -e -. -no -use -after -move -errors -) -. -let -mut -iter -= -SmallVec -: -: -< -[ -u8 -; -2 -] -> -: -: -from_iter -( -0 -. -. -3 -) -. -into_iter -( -) -; -let -mut -clone_iter -= -iter -. -clone -( -) -; -while -let -Some -( -x -) -= -iter -. -next -( -) -{ -assert_eq -! -( -x -clone_iter -. -next -( -) -. -unwrap -( -) -) -; -} -assert_eq -! -( -clone_iter -. -next -( -) -None -) -; -} -# -[ -test -] -fn -test_into_iter_clone_partially_consumed_iterator -( -) -{ -/ -/ -Test -that -the -cloned -iterator -only -contains -the -remaining -elements -of -the -original -iterator -. -let -mut -iter -= -SmallVec -: -: -< -[ -u8 -; -2 -] -> -: -: -from_iter -( -0 -. -. -3 -) -. -into_iter -( -) -. -skip -( -1 -) -; -let -mut -clone_iter -= -iter -. -clone -( -) -; -while -let -Some -( -x -) -= -iter -. -next -( -) -{ -assert_eq -! -( -x -clone_iter -. -next -( -) -. -unwrap -( -) -) -; -} -assert_eq -! -( -clone_iter -. -next -( -) -None -) -; -} -# -[ -test -] -fn -test_into_iter_clone_empty_smallvec -( -) -{ -let -mut -iter -= -SmallVec -: -: -< -[ -u8 -; -2 -] -> -: -: -new -( -) -. -into_iter -( -) -; -let -mut -clone_iter -= -iter -. -clone -( -) -; -assert_eq -! -( -iter -. -next -( -) -None -) -; -assert_eq -! -( -clone_iter -. -next -( -) -None -) -; -} -# -[ -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 -= -" -write -" -) -] -# -[ -test -] -fn -test_write -( -) -{ -use -std -: -: -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 -] -) -; -} -# -[ -cfg -( -feature -= -" -const_generics -" -) -] -# -[ -test -] -fn -const_generics -( -) -{ -let -_v -= -SmallVec -: -: -< -[ -i32 -; -987 -] -> -: -: -default -( -) -; -} -# -[ -test -] -fn -empty_macro -( -) -{ -let -_v -: -SmallVec -< -[ -u8 -; -1 -] -> -= -smallvec -! -[ -] -; -} -# -[ -test -] -fn -zero_size_items -( -) -{ -SmallVec -: -: -< -[ -( -) -; -0 -] -> -: -: -new -( -) -. -push -( -( -) -) -; -} diff --git a/third_party/rust/smallvec/tests/macro.rs b/third_party/rust/smallvec/tests/macro.rs deleted file mode 100644 index 3e8154d3b34ce..0000000000000 --- a/third_party/rust/smallvec/tests/macro.rs +++ /dev/null @@ -1,167 +0,0 @@ -/ -/ -/ -This -file -tests -smallvec -! -without -actually -having -the -macro -in -scope -. -/ -/ -/ -This -forces -any -recursion -to -use -a -crate -prefix -to -reliably -find -itself -. -# -[ -test -] -fn -smallvec -( -) -{ -let -mut -vec -: -smallvec -: -: -SmallVec -< -[ -i32 -; -2 -] -> -; -macro_rules -! -check -{ -( -init -: -tt -) -= -> -{ -vec -= -smallvec -: -: -smallvec -! -init -; -assert_eq -! -( -* -vec -* -vec -! -init -) -; -} -} -check -! -( -[ -0 -; -0 -] -) -; -check -! -( -[ -1 -; -1 -] -) -; -check -! -( -[ -2 -; -2 -] -) -; -check -! -( -[ -3 -; -3 -] -) -; -check -! -( -[ -] -) -; -check -! -( -[ -1 -] -) -; -check -! -( -[ -1 -2 -] -) -; -check -! -( -[ -1 -2 -3 -] -) -; -}