├── Makefile ├── README.md ├── rebar ├── rebar.config ├── rust_src ├── Cargo.lock ├── Cargo.toml └── src │ ├── c.rs │ └── lib.rs ├── src ├── er.app.src └── er.erl └── test.sh /Makefile: -------------------------------------------------------------------------------- 1 | # Please override these to match your environment! 2 | ERLANG_SRC_DIR ?= ${HOME}/.kerl/builds/17.1/otp_src_17.1 3 | ERLANG_EI_LIB_DIR ?= ${HOME}/apps/erlang/17.1/lib/erl_interface-3.7.17/lib 4 | RUST_DIR ?= ${HOME}/apps/rust/1.0.0 5 | 6 | # Past this line the stuff should not require any fiddling with. 7 | RUST_LIBS := ${RUST_DIR}/ 8 | LDFLAGS = -L${ERLANG_EI_LIB_DIR} -lerl_interface -lei 9 | 10 | ifeq ($(shell uname), Darwin) 11 | ## e.g. x86_64-apple-darwin 12 | RUST_PLATFORM ?= $(shell uname -m)-apple-darwin 13 | ## e.g. x86_64-apple-darwin13.4.0 14 | ERLANG_PLATFORM ?= ${RUST_PLATFORM}$(shell uname -r) 15 | #PLATFORM_SO := dylib 16 | # For whaterver reason Erlang looks for .so files even on MacOSX 17 | PLATFORM_SO := so 18 | else 19 | ## e.g. x86_64-unknown-linux-gnu 20 | RUST_PLATFORM ?= $(shell uname -m)-unknown-linux-gnu 21 | ERLANG_PLATFORM ?= ${RUST_PLATFORM} 22 | PLATFORM_SO := so 23 | endif 24 | 25 | MACOSX_LDFLAGS = \ 26 | ${RUST_DIR}/lib/rustlib/${RUST_PLATFORM}/lib/liballoc-4e7c5e5c.rlib \ 27 | ${RUST_DIR}/lib/rustlib/${RUST_PLATFORM}/lib/libcollections-4e7c5e5c.rlib \ 28 | ${RUST_DIR}/lib/rustlib/${RUST_PLATFORM}/lib/libcore-4e7c5e5c.rlib \ 29 | ${RUST_DIR}/lib/rustlib/${RUST_PLATFORM}/lib/libcore-4e7c5e5c.rlib \ 30 | ${RUST_DIR}/lib/rustlib/${RUST_PLATFORM}/lib/liblibc-4e7c5e5c.rlib \ 31 | ${RUST_DIR}/lib/rustlib/${RUST_PLATFORM}/lib/librand-4e7c5e5c.rlib \ 32 | ${RUST_DIR}/lib/rustlib/${RUST_PLATFORM}/lib/libstd-4e7c5e5c.rlib \ 33 | ${RUST_DIR}/lib/rustlib/${RUST_PLATFORM}/lib/libstd-4e7c5e5c.rlib \ 34 | ${RUST_DIR}/lib/rustlib/${RUST_PLATFORM}/lib/libunicode-4e7c5e5c.rlib \ 35 | -flat_namespace -undefined suppress \ 36 | -L"${RUST_DIR}/lib/rustlib/${RUST_PLATFORM}/lib" \ 37 | "-Wl,-force_load,${RUST_DIR}/lib/rustlib/${RUST_PLATFORM}/lib/libmorestack.a" \ 38 | "-Wl,-dead_strip" -dynamiclib -lSystem -lcompiler-rt 39 | 40 | ERLNIF_INCLUDES := \ 41 | -I ${ERLANG_SRC_DIR}/erts/emulator/beam \ 42 | -I ${ERLANG_SRC_DIR}/erts/include/${ERLANG_PLATFORM} 43 | 44 | native: priv/er.${PLATFORM_SO} 45 | 46 | priv/er.${PLATFORM_SO}: rust_src/target/debug/liber.${PLATFORM_SO} 47 | @-mkdir priv >/dev/null 2>&1 48 | cp $< $@ 49 | 50 | rust_src/target/debug/liber.${PLATFORM_SO}: rust_src/src/c.rs 51 | ## This is hacky... basically, building fails due to missing linker flags on MacOSX and doesn't on Linux, 52 | ## that's why we behave differently on each platform. 53 | ifeq ($(shell uname), Linux) 54 | cd rust_src && cargo build > cargo.log 2>&1 55 | cd rust_src/target/debug 56 | else 57 | -cd rust_src && cargo build > cargo.log 2>&1 58 | cd rust_src/target/debug && cc -m64 -o liber.${PLATFORM_SO} er.o deps/liblibc-*.rlib ${LDFLAGS} ${MACOSX_LDFLAGS} 59 | endif 60 | 61 | ERL_NIF_H := ${ERLANG_SRC_DIR}/erts/emulator/beam/erl_nif.h 62 | 63 | BINDGEN ?= ${HOME}/work/rust-bindgen/target/debug/bindgen -builtins 64 | 65 | rust_src/src/c.rs: ${ERL_NIF_H} 66 | ${BINDGEN} ${ERLNIF_INCLUDES} $< -o $@ 67 | 68 | clean: 69 | -rm priv/er.so 70 | -rm rust_src/target/debug/liberrust.so 71 | cd rust_src && cargo clean 72 | 73 | compile: native 74 | ./rebar compile 75 | 76 | test: compile 77 | ./test.sh 78 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Erlang NIF in Rust 2 | 3 | This is an example of how to implement a NIF in Rust. 4 | It works for me, might work for you, but don't be mad if it eats your homework. 5 | 6 | While it would be feasible to write real-world code following this example, 7 | as the entire `erl_nif.h` interface is available thanks to [`bindgen`][bindgen], 8 | it would still require a lot of yak shaving. 9 | You'll be much better off using Daniel Goertzen's [`ruster_unsafe`][ruster_unsafe]. 10 | It's a Rust crate that takes the idea of this example a lot further 11 | and delivers ready to use bindings. 12 | Don't miss [`ruster_unsafe demo`][ruster_demo]. 13 | 14 | ## Running the code 15 | 16 | Adjust the following options in `Makefile` to match your environment: 17 | 18 | ``` 19 | ERLANG_SRC_DIR ?= ${HOME}/.kerl/builds/17.1/otp_src_17.1 20 | ERLANG_EI_LIB_DIR ?= ${HOME}/apps/erlang/17.1/lib/erl_interface-3.7.17/lib 21 | RUST_DIR ?= ${HOME}/apps/rust/1.0.0 22 | ``` 23 | 24 | Then run: 25 | 26 | ``` 27 | make test 28 | ``` 29 | 30 | If you got 31 | 32 | ``` 33 | Test OK - the Rust NIF works 34 | ``` 35 | 36 | as the last output line then everything worked fine - you have the example 37 | dynamically loaded library in `priv/`. 38 | Otherwise, you might've received 39 | 40 | ``` 41 | Test failed - try building the dynamically loaded library manually 42 | ``` 43 | 44 | in which case the real fun begins - please inspect the `Makefile` and file 45 | an issue on what went wrong (did I mention that PRs are also welcome?). 46 | 47 | ## ?! 48 | 49 | This is an example project for 50 | [a short presentation about using Rust NIFs from within Erlang][rust-teaser]. 51 | 52 | [bindgen]: https://github.com/crabtw/rust-bindgen 53 | [rust-teaser]: https://github.com/lavrin/erlang-and-rust-teaser 54 | [ruster_unsafe]: https://github.com/goertzenator/ruster_unsafe 55 | [ruster_demo]: https://github.com/goertzenator/ruster_unsafe_demo 56 | -------------------------------------------------------------------------------- /rebar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erszcz/erlang-rust-nif/6c4c18435c0b6cb6eb08e77a50ee3bee5e6e097a/rebar -------------------------------------------------------------------------------- /rebar.config: -------------------------------------------------------------------------------- 1 | {port_specs, 2 | [{".*", "priv/er.so", ["c_src/*.c"], 3 | [{env, [{".*", "CFLAGS", "$CFLAGS -g -Wall"}, 4 | {".*", "LDFLAGS", "$LDFLAGS -fPIC"}]}]}]}. 5 | 6 | {pre_hooks, [{compile, "make native"}]}. 7 | -------------------------------------------------------------------------------- /rust_src/Cargo.lock: -------------------------------------------------------------------------------- 1 | [root] 2 | name = "er" 3 | version = "0.0.1" 4 | dependencies = [ 5 | "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", 6 | ] 7 | 8 | [[package]] 9 | name = "libc" 10 | version = "0.1.8" 11 | source = "registry+https://github.com/rust-lang/crates.io-index" 12 | 13 | -------------------------------------------------------------------------------- /rust_src/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "er" 3 | version = "0.0.1" 4 | authors = ["Radek Szymczyszyn "] 5 | 6 | [lib] 7 | name = "er" 8 | path = "src/lib.rs" 9 | crate-type = ["dylib"] 10 | 11 | [dependencies.libc] 12 | name = "libc" 13 | -------------------------------------------------------------------------------- /rust_src/src/c.rs: -------------------------------------------------------------------------------- 1 | #![allow(dead_code)] 2 | #![allow(non_camel_case_types)] 3 | #![allow(non_snake_case)] 4 | 5 | /* the rest is automatically generated by rust-bindgen */ 6 | 7 | #[repr(C)] 8 | #[derive(Copy)] 9 | pub struct Struct_Unnamed1 { 10 | pub driver_major_version: ::libc::c_int, 11 | pub driver_minor_version: ::libc::c_int, 12 | pub erts_version: *mut ::libc::c_char, 13 | pub otp_release: *mut ::libc::c_char, 14 | pub thread_support: ::libc::c_int, 15 | pub smp_support: ::libc::c_int, 16 | pub async_threads: ::libc::c_int, 17 | pub scheduler_threads: ::libc::c_int, 18 | pub nif_major_version: ::libc::c_int, 19 | pub nif_minor_version: ::libc::c_int, 20 | } 21 | impl ::std::clone::Clone for Struct_Unnamed1 { 22 | fn clone(&self) -> Self { *self } 23 | } 24 | impl ::std::default::Default for Struct_Unnamed1 { 25 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 26 | } 27 | pub type ErlDrvSysInfo = Struct_Unnamed1; 28 | #[repr(C)] 29 | #[derive(Copy)] 30 | pub struct Struct_Unnamed2 { 31 | pub suggested_stack_size: ::libc::c_int, 32 | } 33 | impl ::std::clone::Clone for Struct_Unnamed2 { 34 | fn clone(&self) -> Self { *self } 35 | } 36 | impl ::std::default::Default for Struct_Unnamed2 { 37 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 38 | } 39 | pub type ErlDrvThreadOpts = Struct_Unnamed2; 40 | pub type __int8_t = ::libc::c_char; 41 | pub type __uint8_t = ::libc::c_uchar; 42 | pub type __int16_t = ::libc::c_short; 43 | pub type __uint16_t = ::libc::c_ushort; 44 | pub type __int32_t = ::libc::c_int; 45 | pub type __uint32_t = ::libc::c_uint; 46 | pub type __int64_t = ::libc::c_longlong; 47 | pub type __uint64_t = ::libc::c_ulonglong; 48 | pub type __darwin_intptr_t = ::libc::c_long; 49 | pub type __darwin_natural_t = ::libc::c_uint; 50 | pub type __darwin_ct_rune_t = ::libc::c_int; 51 | #[repr(C)] 52 | #[derive(Copy)] 53 | pub struct Union_Unnamed3 { 54 | pub _bindgen_data_: [u64; 16usize], 55 | } 56 | impl Union_Unnamed3 { 57 | pub unsafe fn __mbstate8(&mut self) -> *mut [::libc::c_char; 128usize] { 58 | let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); 59 | ::std::mem::transmute(raw.offset(0)) 60 | } 61 | pub unsafe fn _mbstateL(&mut self) -> *mut ::libc::c_longlong { 62 | let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); 63 | ::std::mem::transmute(raw.offset(0)) 64 | } 65 | } 66 | impl ::std::clone::Clone for Union_Unnamed3 { 67 | fn clone(&self) -> Self { *self } 68 | } 69 | impl ::std::default::Default for Union_Unnamed3 { 70 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 71 | } 72 | pub type __mbstate_t = Union_Unnamed3; 73 | pub type __darwin_mbstate_t = __mbstate_t; 74 | pub type __darwin_ptrdiff_t = ::libc::c_long; 75 | pub type __darwin_size_t = ::libc::c_ulong; 76 | pub type __darwin_va_list = __builtin_va_list; 77 | pub type __darwin_wchar_t = ::libc::c_int; 78 | pub type __darwin_rune_t = __darwin_wchar_t; 79 | pub type __darwin_wint_t = ::libc::c_int; 80 | pub type __darwin_clock_t = ::libc::c_ulong; 81 | pub type __darwin_socklen_t = __uint32_t; 82 | pub type __darwin_ssize_t = ::libc::c_long; 83 | pub type __darwin_time_t = ::libc::c_long; 84 | #[repr(C)] 85 | #[derive(Copy)] 86 | pub struct Struct___darwin_pthread_handler_rec { 87 | pub __routine: ::std::option::Option ()>, 90 | pub __arg: *mut ::libc::c_void, 91 | pub __next: *mut Struct___darwin_pthread_handler_rec, 92 | } 93 | impl ::std::clone::Clone for Struct___darwin_pthread_handler_rec { 94 | fn clone(&self) -> Self { *self } 95 | } 96 | impl ::std::default::Default for Struct___darwin_pthread_handler_rec { 97 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 98 | } 99 | #[repr(C)] 100 | #[derive(Copy)] 101 | pub struct Struct__opaque_pthread_attr_t { 102 | pub __sig: ::libc::c_long, 103 | pub __opaque: [::libc::c_char; 56usize], 104 | } 105 | impl ::std::clone::Clone for Struct__opaque_pthread_attr_t { 106 | fn clone(&self) -> Self { *self } 107 | } 108 | impl ::std::default::Default for Struct__opaque_pthread_attr_t { 109 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 110 | } 111 | #[repr(C)] 112 | #[derive(Copy)] 113 | pub struct Struct__opaque_pthread_cond_t { 114 | pub __sig: ::libc::c_long, 115 | pub __opaque: [::libc::c_char; 40usize], 116 | } 117 | impl ::std::clone::Clone for Struct__opaque_pthread_cond_t { 118 | fn clone(&self) -> Self { *self } 119 | } 120 | impl ::std::default::Default for Struct__opaque_pthread_cond_t { 121 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 122 | } 123 | #[repr(C)] 124 | #[derive(Copy)] 125 | pub struct Struct__opaque_pthread_condattr_t { 126 | pub __sig: ::libc::c_long, 127 | pub __opaque: [::libc::c_char; 8usize], 128 | } 129 | impl ::std::clone::Clone for Struct__opaque_pthread_condattr_t { 130 | fn clone(&self) -> Self { *self } 131 | } 132 | impl ::std::default::Default for Struct__opaque_pthread_condattr_t { 133 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 134 | } 135 | #[repr(C)] 136 | #[derive(Copy)] 137 | pub struct Struct__opaque_pthread_mutex_t { 138 | pub __sig: ::libc::c_long, 139 | pub __opaque: [::libc::c_char; 56usize], 140 | } 141 | impl ::std::clone::Clone for Struct__opaque_pthread_mutex_t { 142 | fn clone(&self) -> Self { *self } 143 | } 144 | impl ::std::default::Default for Struct__opaque_pthread_mutex_t { 145 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 146 | } 147 | #[repr(C)] 148 | #[derive(Copy)] 149 | pub struct Struct__opaque_pthread_mutexattr_t { 150 | pub __sig: ::libc::c_long, 151 | pub __opaque: [::libc::c_char; 8usize], 152 | } 153 | impl ::std::clone::Clone for Struct__opaque_pthread_mutexattr_t { 154 | fn clone(&self) -> Self { *self } 155 | } 156 | impl ::std::default::Default for Struct__opaque_pthread_mutexattr_t { 157 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 158 | } 159 | #[repr(C)] 160 | #[derive(Copy)] 161 | pub struct Struct__opaque_pthread_once_t { 162 | pub __sig: ::libc::c_long, 163 | pub __opaque: [::libc::c_char; 8usize], 164 | } 165 | impl ::std::clone::Clone for Struct__opaque_pthread_once_t { 166 | fn clone(&self) -> Self { *self } 167 | } 168 | impl ::std::default::Default for Struct__opaque_pthread_once_t { 169 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 170 | } 171 | #[repr(C)] 172 | #[derive(Copy)] 173 | pub struct Struct__opaque_pthread_rwlock_t { 174 | pub __sig: ::libc::c_long, 175 | pub __opaque: [::libc::c_char; 192usize], 176 | } 177 | impl ::std::clone::Clone for Struct__opaque_pthread_rwlock_t { 178 | fn clone(&self) -> Self { *self } 179 | } 180 | impl ::std::default::Default for Struct__opaque_pthread_rwlock_t { 181 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 182 | } 183 | #[repr(C)] 184 | #[derive(Copy)] 185 | pub struct Struct__opaque_pthread_rwlockattr_t { 186 | pub __sig: ::libc::c_long, 187 | pub __opaque: [::libc::c_char; 16usize], 188 | } 189 | impl ::std::clone::Clone for Struct__opaque_pthread_rwlockattr_t { 190 | fn clone(&self) -> Self { *self } 191 | } 192 | impl ::std::default::Default for Struct__opaque_pthread_rwlockattr_t { 193 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 194 | } 195 | #[repr(C)] 196 | #[derive(Copy)] 197 | pub struct Struct__opaque_pthread_t { 198 | pub __sig: ::libc::c_long, 199 | pub __cleanup_stack: *mut Struct___darwin_pthread_handler_rec, 200 | pub __opaque: [::libc::c_char; 1168usize], 201 | } 202 | impl ::std::clone::Clone for Struct__opaque_pthread_t { 203 | fn clone(&self) -> Self { *self } 204 | } 205 | impl ::std::default::Default for Struct__opaque_pthread_t { 206 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 207 | } 208 | pub type __darwin_blkcnt_t = __int64_t; 209 | pub type __darwin_blksize_t = __int32_t; 210 | pub type __darwin_dev_t = __int32_t; 211 | pub type __darwin_fsblkcnt_t = ::libc::c_uint; 212 | pub type __darwin_fsfilcnt_t = ::libc::c_uint; 213 | pub type __darwin_gid_t = __uint32_t; 214 | pub type __darwin_id_t = __uint32_t; 215 | pub type __darwin_ino64_t = __uint64_t; 216 | pub type __darwin_ino_t = __darwin_ino64_t; 217 | pub type __darwin_mach_port_name_t = __darwin_natural_t; 218 | pub type __darwin_mach_port_t = __darwin_mach_port_name_t; 219 | pub type __darwin_mode_t = __uint16_t; 220 | pub type __darwin_off_t = __int64_t; 221 | pub type __darwin_pid_t = __int32_t; 222 | pub type __darwin_pthread_attr_t = Struct__opaque_pthread_attr_t; 223 | pub type __darwin_pthread_cond_t = Struct__opaque_pthread_cond_t; 224 | pub type __darwin_pthread_condattr_t = Struct__opaque_pthread_condattr_t; 225 | pub type __darwin_pthread_key_t = ::libc::c_ulong; 226 | pub type __darwin_pthread_mutex_t = Struct__opaque_pthread_mutex_t; 227 | pub type __darwin_pthread_mutexattr_t = Struct__opaque_pthread_mutexattr_t; 228 | pub type __darwin_pthread_once_t = Struct__opaque_pthread_once_t; 229 | pub type __darwin_pthread_rwlock_t = Struct__opaque_pthread_rwlock_t; 230 | pub type __darwin_pthread_rwlockattr_t = Struct__opaque_pthread_rwlockattr_t; 231 | pub type __darwin_pthread_t = *mut Struct__opaque_pthread_t; 232 | pub type __darwin_sigset_t = __uint32_t; 233 | pub type __darwin_suseconds_t = __int32_t; 234 | pub type __darwin_uid_t = __uint32_t; 235 | pub type __darwin_useconds_t = __uint32_t; 236 | pub type __darwin_uuid_t = [::libc::c_uchar; 16usize]; 237 | pub type __darwin_uuid_string_t = [::libc::c_char; 37usize]; 238 | pub type __darwin_nl_item = ::libc::c_int; 239 | pub type __darwin_wctrans_t = ::libc::c_int; 240 | pub type __darwin_wctype_t = __uint32_t; 241 | pub type Enum_Unnamed4 = ::libc::c_uint; 242 | pub const P_ALL: ::libc::c_uint = 0; 243 | pub const P_PID: ::libc::c_uint = 1; 244 | pub const P_PGID: ::libc::c_uint = 2; 245 | pub type idtype_t = Enum_Unnamed4; 246 | pub type pid_t = __darwin_pid_t; 247 | pub type id_t = __darwin_id_t; 248 | pub type sig_atomic_t = ::libc::c_int; 249 | #[repr(C)] 250 | #[derive(Copy)] 251 | pub struct Struct___darwin_i386_thread_state { 252 | pub __eax: ::libc::c_uint, 253 | pub __ebx: ::libc::c_uint, 254 | pub __ecx: ::libc::c_uint, 255 | pub __edx: ::libc::c_uint, 256 | pub __edi: ::libc::c_uint, 257 | pub __esi: ::libc::c_uint, 258 | pub __ebp: ::libc::c_uint, 259 | pub __esp: ::libc::c_uint, 260 | pub __ss: ::libc::c_uint, 261 | pub __eflags: ::libc::c_uint, 262 | pub __eip: ::libc::c_uint, 263 | pub __cs: ::libc::c_uint, 264 | pub __ds: ::libc::c_uint, 265 | pub __es: ::libc::c_uint, 266 | pub __fs: ::libc::c_uint, 267 | pub __gs: ::libc::c_uint, 268 | } 269 | impl ::std::clone::Clone for Struct___darwin_i386_thread_state { 270 | fn clone(&self) -> Self { *self } 271 | } 272 | impl ::std::default::Default for Struct___darwin_i386_thread_state { 273 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 274 | } 275 | #[repr(C)] 276 | #[derive(Copy)] 277 | pub struct Struct___darwin_fp_control { 278 | pub _bindgen_bitfield_1_: ::libc::c_ushort, 279 | } 280 | impl ::std::clone::Clone for Struct___darwin_fp_control { 281 | fn clone(&self) -> Self { *self } 282 | } 283 | impl ::std::default::Default for Struct___darwin_fp_control { 284 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 285 | } 286 | pub type __darwin_fp_control_t = Struct___darwin_fp_control; 287 | #[repr(C)] 288 | #[derive(Copy)] 289 | pub struct Struct___darwin_fp_status { 290 | pub _bindgen_bitfield_1_: ::libc::c_ushort, 291 | } 292 | impl ::std::clone::Clone for Struct___darwin_fp_status { 293 | fn clone(&self) -> Self { *self } 294 | } 295 | impl ::std::default::Default for Struct___darwin_fp_status { 296 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 297 | } 298 | pub type __darwin_fp_status_t = Struct___darwin_fp_status; 299 | #[repr(C)] 300 | #[derive(Copy)] 301 | pub struct Struct___darwin_mmst_reg { 302 | pub __mmst_reg: [::libc::c_char; 10usize], 303 | pub __mmst_rsrv: [::libc::c_char; 6usize], 304 | } 305 | impl ::std::clone::Clone for Struct___darwin_mmst_reg { 306 | fn clone(&self) -> Self { *self } 307 | } 308 | impl ::std::default::Default for Struct___darwin_mmst_reg { 309 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 310 | } 311 | #[repr(C)] 312 | #[derive(Copy)] 313 | pub struct Struct___darwin_xmm_reg { 314 | pub __xmm_reg: [::libc::c_char; 16usize], 315 | } 316 | impl ::std::clone::Clone for Struct___darwin_xmm_reg { 317 | fn clone(&self) -> Self { *self } 318 | } 319 | impl ::std::default::Default for Struct___darwin_xmm_reg { 320 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 321 | } 322 | #[repr(C)] 323 | #[derive(Copy)] 324 | pub struct Struct___darwin_i386_float_state { 325 | pub __fpu_reserved: [::libc::c_int; 2usize], 326 | pub __fpu_fcw: Struct___darwin_fp_control, 327 | pub __fpu_fsw: Struct___darwin_fp_status, 328 | pub __fpu_ftw: __uint8_t, 329 | pub __fpu_rsrv1: __uint8_t, 330 | pub __fpu_fop: __uint16_t, 331 | pub __fpu_ip: __uint32_t, 332 | pub __fpu_cs: __uint16_t, 333 | pub __fpu_rsrv2: __uint16_t, 334 | pub __fpu_dp: __uint32_t, 335 | pub __fpu_ds: __uint16_t, 336 | pub __fpu_rsrv3: __uint16_t, 337 | pub __fpu_mxcsr: __uint32_t, 338 | pub __fpu_mxcsrmask: __uint32_t, 339 | pub __fpu_stmm0: Struct___darwin_mmst_reg, 340 | pub __fpu_stmm1: Struct___darwin_mmst_reg, 341 | pub __fpu_stmm2: Struct___darwin_mmst_reg, 342 | pub __fpu_stmm3: Struct___darwin_mmst_reg, 343 | pub __fpu_stmm4: Struct___darwin_mmst_reg, 344 | pub __fpu_stmm5: Struct___darwin_mmst_reg, 345 | pub __fpu_stmm6: Struct___darwin_mmst_reg, 346 | pub __fpu_stmm7: Struct___darwin_mmst_reg, 347 | pub __fpu_xmm0: Struct___darwin_xmm_reg, 348 | pub __fpu_xmm1: Struct___darwin_xmm_reg, 349 | pub __fpu_xmm2: Struct___darwin_xmm_reg, 350 | pub __fpu_xmm3: Struct___darwin_xmm_reg, 351 | pub __fpu_xmm4: Struct___darwin_xmm_reg, 352 | pub __fpu_xmm5: Struct___darwin_xmm_reg, 353 | pub __fpu_xmm6: Struct___darwin_xmm_reg, 354 | pub __fpu_xmm7: Struct___darwin_xmm_reg, 355 | pub __fpu_rsrv4: [::libc::c_char; 224usize], 356 | pub __fpu_reserved1: ::libc::c_int, 357 | } 358 | impl ::std::clone::Clone for Struct___darwin_i386_float_state { 359 | fn clone(&self) -> Self { *self } 360 | } 361 | impl ::std::default::Default for Struct___darwin_i386_float_state { 362 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 363 | } 364 | #[repr(C)] 365 | #[derive(Copy)] 366 | pub struct Struct___darwin_i386_avx_state { 367 | pub __fpu_reserved: [::libc::c_int; 2usize], 368 | pub __fpu_fcw: Struct___darwin_fp_control, 369 | pub __fpu_fsw: Struct___darwin_fp_status, 370 | pub __fpu_ftw: __uint8_t, 371 | pub __fpu_rsrv1: __uint8_t, 372 | pub __fpu_fop: __uint16_t, 373 | pub __fpu_ip: __uint32_t, 374 | pub __fpu_cs: __uint16_t, 375 | pub __fpu_rsrv2: __uint16_t, 376 | pub __fpu_dp: __uint32_t, 377 | pub __fpu_ds: __uint16_t, 378 | pub __fpu_rsrv3: __uint16_t, 379 | pub __fpu_mxcsr: __uint32_t, 380 | pub __fpu_mxcsrmask: __uint32_t, 381 | pub __fpu_stmm0: Struct___darwin_mmst_reg, 382 | pub __fpu_stmm1: Struct___darwin_mmst_reg, 383 | pub __fpu_stmm2: Struct___darwin_mmst_reg, 384 | pub __fpu_stmm3: Struct___darwin_mmst_reg, 385 | pub __fpu_stmm4: Struct___darwin_mmst_reg, 386 | pub __fpu_stmm5: Struct___darwin_mmst_reg, 387 | pub __fpu_stmm6: Struct___darwin_mmst_reg, 388 | pub __fpu_stmm7: Struct___darwin_mmst_reg, 389 | pub __fpu_xmm0: Struct___darwin_xmm_reg, 390 | pub __fpu_xmm1: Struct___darwin_xmm_reg, 391 | pub __fpu_xmm2: Struct___darwin_xmm_reg, 392 | pub __fpu_xmm3: Struct___darwin_xmm_reg, 393 | pub __fpu_xmm4: Struct___darwin_xmm_reg, 394 | pub __fpu_xmm5: Struct___darwin_xmm_reg, 395 | pub __fpu_xmm6: Struct___darwin_xmm_reg, 396 | pub __fpu_xmm7: Struct___darwin_xmm_reg, 397 | pub __fpu_rsrv4: [::libc::c_char; 224usize], 398 | pub __fpu_reserved1: ::libc::c_int, 399 | pub __avx_reserved1: [::libc::c_char; 64usize], 400 | pub __fpu_ymmh0: Struct___darwin_xmm_reg, 401 | pub __fpu_ymmh1: Struct___darwin_xmm_reg, 402 | pub __fpu_ymmh2: Struct___darwin_xmm_reg, 403 | pub __fpu_ymmh3: Struct___darwin_xmm_reg, 404 | pub __fpu_ymmh4: Struct___darwin_xmm_reg, 405 | pub __fpu_ymmh5: Struct___darwin_xmm_reg, 406 | pub __fpu_ymmh6: Struct___darwin_xmm_reg, 407 | pub __fpu_ymmh7: Struct___darwin_xmm_reg, 408 | } 409 | impl ::std::clone::Clone for Struct___darwin_i386_avx_state { 410 | fn clone(&self) -> Self { *self } 411 | } 412 | impl ::std::default::Default for Struct___darwin_i386_avx_state { 413 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 414 | } 415 | #[repr(C)] 416 | #[derive(Copy)] 417 | pub struct Struct___darwin_i386_exception_state { 418 | pub __trapno: __uint16_t, 419 | pub __cpu: __uint16_t, 420 | pub __err: __uint32_t, 421 | pub __faultvaddr: __uint32_t, 422 | } 423 | impl ::std::clone::Clone for Struct___darwin_i386_exception_state { 424 | fn clone(&self) -> Self { *self } 425 | } 426 | impl ::std::default::Default for Struct___darwin_i386_exception_state { 427 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 428 | } 429 | #[repr(C)] 430 | #[derive(Copy)] 431 | pub struct Struct___darwin_x86_debug_state32 { 432 | pub __dr0: ::libc::c_uint, 433 | pub __dr1: ::libc::c_uint, 434 | pub __dr2: ::libc::c_uint, 435 | pub __dr3: ::libc::c_uint, 436 | pub __dr4: ::libc::c_uint, 437 | pub __dr5: ::libc::c_uint, 438 | pub __dr6: ::libc::c_uint, 439 | pub __dr7: ::libc::c_uint, 440 | } 441 | impl ::std::clone::Clone for Struct___darwin_x86_debug_state32 { 442 | fn clone(&self) -> Self { *self } 443 | } 444 | impl ::std::default::Default for Struct___darwin_x86_debug_state32 { 445 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 446 | } 447 | #[repr(C)] 448 | #[derive(Copy)] 449 | pub struct Struct___darwin_x86_thread_state64 { 450 | pub __rax: __uint64_t, 451 | pub __rbx: __uint64_t, 452 | pub __rcx: __uint64_t, 453 | pub __rdx: __uint64_t, 454 | pub __rdi: __uint64_t, 455 | pub __rsi: __uint64_t, 456 | pub __rbp: __uint64_t, 457 | pub __rsp: __uint64_t, 458 | pub __r8: __uint64_t, 459 | pub __r9: __uint64_t, 460 | pub __r10: __uint64_t, 461 | pub __r11: __uint64_t, 462 | pub __r12: __uint64_t, 463 | pub __r13: __uint64_t, 464 | pub __r14: __uint64_t, 465 | pub __r15: __uint64_t, 466 | pub __rip: __uint64_t, 467 | pub __rflags: __uint64_t, 468 | pub __cs: __uint64_t, 469 | pub __fs: __uint64_t, 470 | pub __gs: __uint64_t, 471 | } 472 | impl ::std::clone::Clone for Struct___darwin_x86_thread_state64 { 473 | fn clone(&self) -> Self { *self } 474 | } 475 | impl ::std::default::Default for Struct___darwin_x86_thread_state64 { 476 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 477 | } 478 | #[repr(C)] 479 | #[derive(Copy)] 480 | pub struct Struct___darwin_x86_float_state64 { 481 | pub __fpu_reserved: [::libc::c_int; 2usize], 482 | pub __fpu_fcw: Struct___darwin_fp_control, 483 | pub __fpu_fsw: Struct___darwin_fp_status, 484 | pub __fpu_ftw: __uint8_t, 485 | pub __fpu_rsrv1: __uint8_t, 486 | pub __fpu_fop: __uint16_t, 487 | pub __fpu_ip: __uint32_t, 488 | pub __fpu_cs: __uint16_t, 489 | pub __fpu_rsrv2: __uint16_t, 490 | pub __fpu_dp: __uint32_t, 491 | pub __fpu_ds: __uint16_t, 492 | pub __fpu_rsrv3: __uint16_t, 493 | pub __fpu_mxcsr: __uint32_t, 494 | pub __fpu_mxcsrmask: __uint32_t, 495 | pub __fpu_stmm0: Struct___darwin_mmst_reg, 496 | pub __fpu_stmm1: Struct___darwin_mmst_reg, 497 | pub __fpu_stmm2: Struct___darwin_mmst_reg, 498 | pub __fpu_stmm3: Struct___darwin_mmst_reg, 499 | pub __fpu_stmm4: Struct___darwin_mmst_reg, 500 | pub __fpu_stmm5: Struct___darwin_mmst_reg, 501 | pub __fpu_stmm6: Struct___darwin_mmst_reg, 502 | pub __fpu_stmm7: Struct___darwin_mmst_reg, 503 | pub __fpu_xmm0: Struct___darwin_xmm_reg, 504 | pub __fpu_xmm1: Struct___darwin_xmm_reg, 505 | pub __fpu_xmm2: Struct___darwin_xmm_reg, 506 | pub __fpu_xmm3: Struct___darwin_xmm_reg, 507 | pub __fpu_xmm4: Struct___darwin_xmm_reg, 508 | pub __fpu_xmm5: Struct___darwin_xmm_reg, 509 | pub __fpu_xmm6: Struct___darwin_xmm_reg, 510 | pub __fpu_xmm7: Struct___darwin_xmm_reg, 511 | pub __fpu_xmm8: Struct___darwin_xmm_reg, 512 | pub __fpu_xmm9: Struct___darwin_xmm_reg, 513 | pub __fpu_xmm10: Struct___darwin_xmm_reg, 514 | pub __fpu_xmm11: Struct___darwin_xmm_reg, 515 | pub __fpu_xmm12: Struct___darwin_xmm_reg, 516 | pub __fpu_xmm13: Struct___darwin_xmm_reg, 517 | pub __fpu_xmm14: Struct___darwin_xmm_reg, 518 | pub __fpu_xmm15: Struct___darwin_xmm_reg, 519 | pub __fpu_rsrv4: [::libc::c_char; 96usize], 520 | pub __fpu_reserved1: ::libc::c_int, 521 | } 522 | impl ::std::clone::Clone for Struct___darwin_x86_float_state64 { 523 | fn clone(&self) -> Self { *self } 524 | } 525 | impl ::std::default::Default for Struct___darwin_x86_float_state64 { 526 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 527 | } 528 | #[repr(C)] 529 | #[derive(Copy)] 530 | pub struct Struct___darwin_x86_avx_state64 { 531 | pub __fpu_reserved: [::libc::c_int; 2usize], 532 | pub __fpu_fcw: Struct___darwin_fp_control, 533 | pub __fpu_fsw: Struct___darwin_fp_status, 534 | pub __fpu_ftw: __uint8_t, 535 | pub __fpu_rsrv1: __uint8_t, 536 | pub __fpu_fop: __uint16_t, 537 | pub __fpu_ip: __uint32_t, 538 | pub __fpu_cs: __uint16_t, 539 | pub __fpu_rsrv2: __uint16_t, 540 | pub __fpu_dp: __uint32_t, 541 | pub __fpu_ds: __uint16_t, 542 | pub __fpu_rsrv3: __uint16_t, 543 | pub __fpu_mxcsr: __uint32_t, 544 | pub __fpu_mxcsrmask: __uint32_t, 545 | pub __fpu_stmm0: Struct___darwin_mmst_reg, 546 | pub __fpu_stmm1: Struct___darwin_mmst_reg, 547 | pub __fpu_stmm2: Struct___darwin_mmst_reg, 548 | pub __fpu_stmm3: Struct___darwin_mmst_reg, 549 | pub __fpu_stmm4: Struct___darwin_mmst_reg, 550 | pub __fpu_stmm5: Struct___darwin_mmst_reg, 551 | pub __fpu_stmm6: Struct___darwin_mmst_reg, 552 | pub __fpu_stmm7: Struct___darwin_mmst_reg, 553 | pub __fpu_xmm0: Struct___darwin_xmm_reg, 554 | pub __fpu_xmm1: Struct___darwin_xmm_reg, 555 | pub __fpu_xmm2: Struct___darwin_xmm_reg, 556 | pub __fpu_xmm3: Struct___darwin_xmm_reg, 557 | pub __fpu_xmm4: Struct___darwin_xmm_reg, 558 | pub __fpu_xmm5: Struct___darwin_xmm_reg, 559 | pub __fpu_xmm6: Struct___darwin_xmm_reg, 560 | pub __fpu_xmm7: Struct___darwin_xmm_reg, 561 | pub __fpu_xmm8: Struct___darwin_xmm_reg, 562 | pub __fpu_xmm9: Struct___darwin_xmm_reg, 563 | pub __fpu_xmm10: Struct___darwin_xmm_reg, 564 | pub __fpu_xmm11: Struct___darwin_xmm_reg, 565 | pub __fpu_xmm12: Struct___darwin_xmm_reg, 566 | pub __fpu_xmm13: Struct___darwin_xmm_reg, 567 | pub __fpu_xmm14: Struct___darwin_xmm_reg, 568 | pub __fpu_xmm15: Struct___darwin_xmm_reg, 569 | pub __fpu_rsrv4: [::libc::c_char; 96usize], 570 | pub __fpu_reserved1: ::libc::c_int, 571 | pub __avx_reserved1: [::libc::c_char; 64usize], 572 | pub __fpu_ymmh0: Struct___darwin_xmm_reg, 573 | pub __fpu_ymmh1: Struct___darwin_xmm_reg, 574 | pub __fpu_ymmh2: Struct___darwin_xmm_reg, 575 | pub __fpu_ymmh3: Struct___darwin_xmm_reg, 576 | pub __fpu_ymmh4: Struct___darwin_xmm_reg, 577 | pub __fpu_ymmh5: Struct___darwin_xmm_reg, 578 | pub __fpu_ymmh6: Struct___darwin_xmm_reg, 579 | pub __fpu_ymmh7: Struct___darwin_xmm_reg, 580 | pub __fpu_ymmh8: Struct___darwin_xmm_reg, 581 | pub __fpu_ymmh9: Struct___darwin_xmm_reg, 582 | pub __fpu_ymmh10: Struct___darwin_xmm_reg, 583 | pub __fpu_ymmh11: Struct___darwin_xmm_reg, 584 | pub __fpu_ymmh12: Struct___darwin_xmm_reg, 585 | pub __fpu_ymmh13: Struct___darwin_xmm_reg, 586 | pub __fpu_ymmh14: Struct___darwin_xmm_reg, 587 | pub __fpu_ymmh15: Struct___darwin_xmm_reg, 588 | } 589 | impl ::std::clone::Clone for Struct___darwin_x86_avx_state64 { 590 | fn clone(&self) -> Self { *self } 591 | } 592 | impl ::std::default::Default for Struct___darwin_x86_avx_state64 { 593 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 594 | } 595 | #[repr(C)] 596 | #[derive(Copy)] 597 | pub struct Struct___darwin_x86_exception_state64 { 598 | pub __trapno: __uint16_t, 599 | pub __cpu: __uint16_t, 600 | pub __err: __uint32_t, 601 | pub __faultvaddr: __uint64_t, 602 | } 603 | impl ::std::clone::Clone for Struct___darwin_x86_exception_state64 { 604 | fn clone(&self) -> Self { *self } 605 | } 606 | impl ::std::default::Default for Struct___darwin_x86_exception_state64 { 607 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 608 | } 609 | #[repr(C)] 610 | #[derive(Copy)] 611 | pub struct Struct___darwin_x86_debug_state64 { 612 | pub __dr0: __uint64_t, 613 | pub __dr1: __uint64_t, 614 | pub __dr2: __uint64_t, 615 | pub __dr3: __uint64_t, 616 | pub __dr4: __uint64_t, 617 | pub __dr5: __uint64_t, 618 | pub __dr6: __uint64_t, 619 | pub __dr7: __uint64_t, 620 | } 621 | impl ::std::clone::Clone for Struct___darwin_x86_debug_state64 { 622 | fn clone(&self) -> Self { *self } 623 | } 624 | impl ::std::default::Default for Struct___darwin_x86_debug_state64 { 625 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 626 | } 627 | #[repr(C)] 628 | #[derive(Copy)] 629 | pub struct Struct___darwin_mcontext32 { 630 | pub __es: Struct___darwin_i386_exception_state, 631 | pub __ss: Struct___darwin_i386_thread_state, 632 | pub __fs: Struct___darwin_i386_float_state, 633 | } 634 | impl ::std::clone::Clone for Struct___darwin_mcontext32 { 635 | fn clone(&self) -> Self { *self } 636 | } 637 | impl ::std::default::Default for Struct___darwin_mcontext32 { 638 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 639 | } 640 | #[repr(C)] 641 | #[derive(Copy)] 642 | pub struct Struct___darwin_mcontext_avx32 { 643 | pub __es: Struct___darwin_i386_exception_state, 644 | pub __ss: Struct___darwin_i386_thread_state, 645 | pub __fs: Struct___darwin_i386_avx_state, 646 | } 647 | impl ::std::clone::Clone for Struct___darwin_mcontext_avx32 { 648 | fn clone(&self) -> Self { *self } 649 | } 650 | impl ::std::default::Default for Struct___darwin_mcontext_avx32 { 651 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 652 | } 653 | #[repr(C)] 654 | #[derive(Copy)] 655 | pub struct Struct___darwin_mcontext64 { 656 | pub __es: Struct___darwin_x86_exception_state64, 657 | pub __ss: Struct___darwin_x86_thread_state64, 658 | pub __fs: Struct___darwin_x86_float_state64, 659 | } 660 | impl ::std::clone::Clone for Struct___darwin_mcontext64 { 661 | fn clone(&self) -> Self { *self } 662 | } 663 | impl ::std::default::Default for Struct___darwin_mcontext64 { 664 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 665 | } 666 | #[repr(C)] 667 | #[derive(Copy)] 668 | pub struct Struct___darwin_mcontext_avx64 { 669 | pub __es: Struct___darwin_x86_exception_state64, 670 | pub __ss: Struct___darwin_x86_thread_state64, 671 | pub __fs: Struct___darwin_x86_avx_state64, 672 | } 673 | impl ::std::clone::Clone for Struct___darwin_mcontext_avx64 { 674 | fn clone(&self) -> Self { *self } 675 | } 676 | impl ::std::default::Default for Struct___darwin_mcontext_avx64 { 677 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 678 | } 679 | pub type mcontext_t = *mut Struct___darwin_mcontext64; 680 | #[repr(C)] 681 | #[derive(Copy)] 682 | pub struct Struct___darwin_sigaltstack { 683 | pub ss_sp: *mut ::libc::c_void, 684 | pub ss_size: __darwin_size_t, 685 | pub ss_flags: ::libc::c_int, 686 | } 687 | impl ::std::clone::Clone for Struct___darwin_sigaltstack { 688 | fn clone(&self) -> Self { *self } 689 | } 690 | impl ::std::default::Default for Struct___darwin_sigaltstack { 691 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 692 | } 693 | pub type stack_t = Struct___darwin_sigaltstack; 694 | #[repr(C)] 695 | #[derive(Copy)] 696 | pub struct Struct___darwin_ucontext { 697 | pub uc_onstack: ::libc::c_int, 698 | pub uc_sigmask: __darwin_sigset_t, 699 | pub uc_stack: Struct___darwin_sigaltstack, 700 | pub uc_link: *mut Struct___darwin_ucontext, 701 | pub uc_mcsize: __darwin_size_t, 702 | pub uc_mcontext: *mut Struct___darwin_mcontext64, 703 | } 704 | impl ::std::clone::Clone for Struct___darwin_ucontext { 705 | fn clone(&self) -> Self { *self } 706 | } 707 | impl ::std::default::Default for Struct___darwin_ucontext { 708 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 709 | } 710 | pub type ucontext_t = Struct___darwin_ucontext; 711 | pub type pthread_attr_t = __darwin_pthread_attr_t; 712 | pub type sigset_t = __darwin_sigset_t; 713 | pub type size_t = __darwin_size_t; 714 | pub type uid_t = __darwin_uid_t; 715 | #[repr(C)] 716 | #[derive(Copy)] 717 | pub struct Union_sigval { 718 | pub _bindgen_data_: [u64; 1usize], 719 | } 720 | impl Union_sigval { 721 | pub unsafe fn sival_int(&mut self) -> *mut ::libc::c_int { 722 | let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); 723 | ::std::mem::transmute(raw.offset(0)) 724 | } 725 | pub unsafe fn sival_ptr(&mut self) -> *mut *mut ::libc::c_void { 726 | let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); 727 | ::std::mem::transmute(raw.offset(0)) 728 | } 729 | } 730 | impl ::std::clone::Clone for Union_sigval { 731 | fn clone(&self) -> Self { *self } 732 | } 733 | impl ::std::default::Default for Union_sigval { 734 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 735 | } 736 | #[repr(C)] 737 | #[derive(Copy)] 738 | pub struct Struct_sigevent { 739 | pub sigev_notify: ::libc::c_int, 740 | pub sigev_signo: ::libc::c_int, 741 | pub sigev_value: Union_sigval, 742 | pub sigev_notify_function: ::std::option::Option ()>, 745 | pub sigev_notify_attributes: *mut pthread_attr_t, 746 | } 747 | impl ::std::clone::Clone for Struct_sigevent { 748 | fn clone(&self) -> Self { *self } 749 | } 750 | impl ::std::default::Default for Struct_sigevent { 751 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 752 | } 753 | #[repr(C)] 754 | #[derive(Copy)] 755 | pub struct Struct___siginfo { 756 | pub si_signo: ::libc::c_int, 757 | pub si_errno: ::libc::c_int, 758 | pub si_code: ::libc::c_int, 759 | pub si_pid: pid_t, 760 | pub si_uid: uid_t, 761 | pub si_status: ::libc::c_int, 762 | pub si_addr: *mut ::libc::c_void, 763 | pub si_value: Union_sigval, 764 | pub si_band: ::libc::c_long, 765 | pub __pad: [::libc::c_ulong; 7usize], 766 | } 767 | impl ::std::clone::Clone for Struct___siginfo { 768 | fn clone(&self) -> Self { *self } 769 | } 770 | impl ::std::default::Default for Struct___siginfo { 771 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 772 | } 773 | pub type siginfo_t = Struct___siginfo; 774 | #[repr(C)] 775 | #[derive(Copy)] 776 | pub struct Union___sigaction_u { 777 | pub _bindgen_data_: [u64; 1usize], 778 | } 779 | impl Union___sigaction_u { 780 | pub unsafe fn __sa_handler(&mut self) 781 | -> *mut ::std::option::Option ()> { 782 | let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); 783 | ::std::mem::transmute(raw.offset(0)) 784 | } 785 | pub unsafe fn __sa_sigaction(&mut self) 786 | -> 787 | *mut ::std::option::Option ()> { 791 | let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); 792 | ::std::mem::transmute(raw.offset(0)) 793 | } 794 | } 795 | impl ::std::clone::Clone for Union___sigaction_u { 796 | fn clone(&self) -> Self { *self } 797 | } 798 | impl ::std::default::Default for Union___sigaction_u { 799 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 800 | } 801 | #[repr(C)] 802 | #[derive(Copy)] 803 | pub struct Struct___sigaction { 804 | pub __sigaction_u: Union___sigaction_u, 805 | pub sa_tramp: ::std::option::Option ()>, 813 | pub sa_mask: sigset_t, 814 | pub sa_flags: ::libc::c_int, 815 | } 816 | impl ::std::clone::Clone for Struct___sigaction { 817 | fn clone(&self) -> Self { *self } 818 | } 819 | impl ::std::default::Default for Struct___sigaction { 820 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 821 | } 822 | #[repr(C)] 823 | #[derive(Copy)] 824 | pub struct Struct_sigaction { 825 | pub __sigaction_u: Union___sigaction_u, 826 | pub sa_mask: sigset_t, 827 | pub sa_flags: ::libc::c_int, 828 | } 829 | impl ::std::clone::Clone for Struct_sigaction { 830 | fn clone(&self) -> Self { *self } 831 | } 832 | impl ::std::default::Default for Struct_sigaction { 833 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 834 | } 835 | pub type sig_t = 836 | ::std::option::Option ()>; 837 | #[repr(C)] 838 | #[derive(Copy)] 839 | pub struct Struct_sigvec { 840 | pub sv_handler: ::std::option::Option ()>, 842 | pub sv_mask: ::libc::c_int, 843 | pub sv_flags: ::libc::c_int, 844 | } 845 | impl ::std::clone::Clone for Struct_sigvec { 846 | fn clone(&self) -> Self { *self } 847 | } 848 | impl ::std::default::Default for Struct_sigvec { 849 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 850 | } 851 | #[repr(C)] 852 | #[derive(Copy)] 853 | pub struct Struct_sigstack { 854 | pub ss_sp: *mut ::libc::c_char, 855 | pub ss_onstack: ::libc::c_int, 856 | } 857 | impl ::std::clone::Clone for Struct_sigstack { 858 | fn clone(&self) -> Self { *self } 859 | } 860 | impl ::std::default::Default for Struct_sigstack { 861 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 862 | } 863 | pub type int8_t = ::libc::c_char; 864 | pub type int16_t = ::libc::c_short; 865 | pub type int32_t = ::libc::c_int; 866 | pub type int64_t = ::libc::c_longlong; 867 | pub type uint8_t = ::libc::c_uchar; 868 | pub type uint16_t = ::libc::c_ushort; 869 | pub type uint32_t = ::libc::c_uint; 870 | pub type uint64_t = ::libc::c_ulonglong; 871 | pub type int_least8_t = int8_t; 872 | pub type int_least16_t = int16_t; 873 | pub type int_least32_t = int32_t; 874 | pub type int_least64_t = int64_t; 875 | pub type uint_least8_t = uint8_t; 876 | pub type uint_least16_t = uint16_t; 877 | pub type uint_least32_t = uint32_t; 878 | pub type uint_least64_t = uint64_t; 879 | pub type int_fast8_t = int8_t; 880 | pub type int_fast16_t = int16_t; 881 | pub type int_fast32_t = int32_t; 882 | pub type int_fast64_t = int64_t; 883 | pub type uint_fast8_t = uint8_t; 884 | pub type uint_fast16_t = uint16_t; 885 | pub type uint_fast32_t = uint32_t; 886 | pub type uint_fast64_t = uint64_t; 887 | pub type intptr_t = __darwin_intptr_t; 888 | pub type uintptr_t = ::libc::c_ulong; 889 | pub type intmax_t = ::libc::c_long; 890 | pub type uintmax_t = ::libc::c_ulong; 891 | #[repr(C)] 892 | #[derive(Copy)] 893 | pub struct Struct_timeval { 894 | pub tv_sec: __darwin_time_t, 895 | pub tv_usec: __darwin_suseconds_t, 896 | } 897 | impl ::std::clone::Clone for Struct_timeval { 898 | fn clone(&self) -> Self { *self } 899 | } 900 | impl ::std::default::Default for Struct_timeval { 901 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 902 | } 903 | pub type rlim_t = __uint64_t; 904 | #[repr(C)] 905 | #[derive(Copy)] 906 | pub struct Struct_rusage { 907 | pub ru_utime: Struct_timeval, 908 | pub ru_stime: Struct_timeval, 909 | pub ru_maxrss: ::libc::c_long, 910 | pub ru_ixrss: ::libc::c_long, 911 | pub ru_idrss: ::libc::c_long, 912 | pub ru_isrss: ::libc::c_long, 913 | pub ru_minflt: ::libc::c_long, 914 | pub ru_majflt: ::libc::c_long, 915 | pub ru_nswap: ::libc::c_long, 916 | pub ru_inblock: ::libc::c_long, 917 | pub ru_oublock: ::libc::c_long, 918 | pub ru_msgsnd: ::libc::c_long, 919 | pub ru_msgrcv: ::libc::c_long, 920 | pub ru_nsignals: ::libc::c_long, 921 | pub ru_nvcsw: ::libc::c_long, 922 | pub ru_nivcsw: ::libc::c_long, 923 | } 924 | impl ::std::clone::Clone for Struct_rusage { 925 | fn clone(&self) -> Self { *self } 926 | } 927 | impl ::std::default::Default for Struct_rusage { 928 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 929 | } 930 | pub type rusage_info_t = *mut ::libc::c_void; 931 | #[repr(C)] 932 | #[derive(Copy)] 933 | pub struct Struct_rusage_info_v0 { 934 | pub ri_uuid: [uint8_t; 16usize], 935 | pub ri_user_time: uint64_t, 936 | pub ri_system_time: uint64_t, 937 | pub ri_pkg_idle_wkups: uint64_t, 938 | pub ri_interrupt_wkups: uint64_t, 939 | pub ri_pageins: uint64_t, 940 | pub ri_wired_size: uint64_t, 941 | pub ri_resident_size: uint64_t, 942 | pub ri_phys_footprint: uint64_t, 943 | pub ri_proc_start_abstime: uint64_t, 944 | pub ri_proc_exit_abstime: uint64_t, 945 | } 946 | impl ::std::clone::Clone for Struct_rusage_info_v0 { 947 | fn clone(&self) -> Self { *self } 948 | } 949 | impl ::std::default::Default for Struct_rusage_info_v0 { 950 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 951 | } 952 | #[repr(C)] 953 | #[derive(Copy)] 954 | pub struct Struct_rusage_info_v1 { 955 | pub ri_uuid: [uint8_t; 16usize], 956 | pub ri_user_time: uint64_t, 957 | pub ri_system_time: uint64_t, 958 | pub ri_pkg_idle_wkups: uint64_t, 959 | pub ri_interrupt_wkups: uint64_t, 960 | pub ri_pageins: uint64_t, 961 | pub ri_wired_size: uint64_t, 962 | pub ri_resident_size: uint64_t, 963 | pub ri_phys_footprint: uint64_t, 964 | pub ri_proc_start_abstime: uint64_t, 965 | pub ri_proc_exit_abstime: uint64_t, 966 | pub ri_child_user_time: uint64_t, 967 | pub ri_child_system_time: uint64_t, 968 | pub ri_child_pkg_idle_wkups: uint64_t, 969 | pub ri_child_interrupt_wkups: uint64_t, 970 | pub ri_child_pageins: uint64_t, 971 | pub ri_child_elapsed_abstime: uint64_t, 972 | } 973 | impl ::std::clone::Clone for Struct_rusage_info_v1 { 974 | fn clone(&self) -> Self { *self } 975 | } 976 | impl ::std::default::Default for Struct_rusage_info_v1 { 977 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 978 | } 979 | #[repr(C)] 980 | #[derive(Copy)] 981 | pub struct Struct_rusage_info_v2 { 982 | pub ri_uuid: [uint8_t; 16usize], 983 | pub ri_user_time: uint64_t, 984 | pub ri_system_time: uint64_t, 985 | pub ri_pkg_idle_wkups: uint64_t, 986 | pub ri_interrupt_wkups: uint64_t, 987 | pub ri_pageins: uint64_t, 988 | pub ri_wired_size: uint64_t, 989 | pub ri_resident_size: uint64_t, 990 | pub ri_phys_footprint: uint64_t, 991 | pub ri_proc_start_abstime: uint64_t, 992 | pub ri_proc_exit_abstime: uint64_t, 993 | pub ri_child_user_time: uint64_t, 994 | pub ri_child_system_time: uint64_t, 995 | pub ri_child_pkg_idle_wkups: uint64_t, 996 | pub ri_child_interrupt_wkups: uint64_t, 997 | pub ri_child_pageins: uint64_t, 998 | pub ri_child_elapsed_abstime: uint64_t, 999 | pub ri_diskio_bytesread: uint64_t, 1000 | pub ri_diskio_byteswritten: uint64_t, 1001 | } 1002 | impl ::std::clone::Clone for Struct_rusage_info_v2 { 1003 | fn clone(&self) -> Self { *self } 1004 | } 1005 | impl ::std::default::Default for Struct_rusage_info_v2 { 1006 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 1007 | } 1008 | #[repr(C)] 1009 | #[derive(Copy)] 1010 | pub struct Struct_rlimit { 1011 | pub rlim_cur: rlim_t, 1012 | pub rlim_max: rlim_t, 1013 | } 1014 | impl ::std::clone::Clone for Struct_rlimit { 1015 | fn clone(&self) -> Self { *self } 1016 | } 1017 | impl ::std::default::Default for Struct_rlimit { 1018 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 1019 | } 1020 | #[repr(C)] 1021 | #[derive(Copy)] 1022 | pub struct Struct_proc_rlimit_control_wakeupmon { 1023 | pub wm_flags: uint32_t, 1024 | pub wm_rate: int32_t, 1025 | } 1026 | impl ::std::clone::Clone for Struct_proc_rlimit_control_wakeupmon { 1027 | fn clone(&self) -> Self { *self } 1028 | } 1029 | impl ::std::default::Default for Struct_proc_rlimit_control_wakeupmon { 1030 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 1031 | } 1032 | #[repr(C)] 1033 | #[derive(Copy)] 1034 | pub struct Union_wait { 1035 | pub _bindgen_data_: [u32; 1usize], 1036 | } 1037 | impl Union_wait { 1038 | pub unsafe fn w_status(&mut self) -> *mut ::libc::c_int { 1039 | let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); 1040 | ::std::mem::transmute(raw.offset(0)) 1041 | } 1042 | pub unsafe fn w_T(&mut self) -> *mut Struct_Unnamed5 { 1043 | let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); 1044 | ::std::mem::transmute(raw.offset(0)) 1045 | } 1046 | pub unsafe fn w_S(&mut self) -> *mut Struct_Unnamed6 { 1047 | let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); 1048 | ::std::mem::transmute(raw.offset(0)) 1049 | } 1050 | } 1051 | impl ::std::clone::Clone for Union_wait { 1052 | fn clone(&self) -> Self { *self } 1053 | } 1054 | impl ::std::default::Default for Union_wait { 1055 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 1056 | } 1057 | #[repr(C)] 1058 | #[derive(Copy)] 1059 | pub struct Struct_Unnamed5 { 1060 | pub _bindgen_bitfield_1_: ::libc::c_uint, 1061 | } 1062 | impl ::std::clone::Clone for Struct_Unnamed5 { 1063 | fn clone(&self) -> Self { *self } 1064 | } 1065 | impl ::std::default::Default for Struct_Unnamed5 { 1066 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 1067 | } 1068 | #[repr(C)] 1069 | #[derive(Copy)] 1070 | pub struct Struct_Unnamed6 { 1071 | pub _bindgen_bitfield_1_: ::libc::c_uint, 1072 | } 1073 | impl ::std::clone::Clone for Struct_Unnamed6 { 1074 | fn clone(&self) -> Self { *self } 1075 | } 1076 | impl ::std::default::Default for Struct_Unnamed6 { 1077 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 1078 | } 1079 | pub type ct_rune_t = __darwin_ct_rune_t; 1080 | pub type rune_t = __darwin_rune_t; 1081 | pub type wchar_t = __darwin_wchar_t; 1082 | #[repr(C)] 1083 | #[derive(Copy)] 1084 | pub struct Struct_Unnamed7 { 1085 | pub quot: ::libc::c_int, 1086 | pub rem: ::libc::c_int, 1087 | } 1088 | impl ::std::clone::Clone for Struct_Unnamed7 { 1089 | fn clone(&self) -> Self { *self } 1090 | } 1091 | impl ::std::default::Default for Struct_Unnamed7 { 1092 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 1093 | } 1094 | pub type div_t = Struct_Unnamed7; 1095 | #[repr(C)] 1096 | #[derive(Copy)] 1097 | pub struct Struct_Unnamed8 { 1098 | pub quot: ::libc::c_long, 1099 | pub rem: ::libc::c_long, 1100 | } 1101 | impl ::std::clone::Clone for Struct_Unnamed8 { 1102 | fn clone(&self) -> Self { *self } 1103 | } 1104 | impl ::std::default::Default for Struct_Unnamed8 { 1105 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 1106 | } 1107 | pub type ldiv_t = Struct_Unnamed8; 1108 | #[repr(C)] 1109 | #[derive(Copy)] 1110 | pub struct Struct_Unnamed9 { 1111 | pub quot: ::libc::c_longlong, 1112 | pub rem: ::libc::c_longlong, 1113 | } 1114 | impl ::std::clone::Clone for Struct_Unnamed9 { 1115 | fn clone(&self) -> Self { *self } 1116 | } 1117 | impl ::std::default::Default for Struct_Unnamed9 { 1118 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 1119 | } 1120 | pub type lldiv_t = Struct_Unnamed9; 1121 | pub type u_int8_t = ::libc::c_uchar; 1122 | pub type u_int16_t = ::libc::c_ushort; 1123 | pub type u_int32_t = ::libc::c_uint; 1124 | pub type u_int64_t = ::libc::c_ulonglong; 1125 | pub type register_t = int64_t; 1126 | pub type user_addr_t = u_int64_t; 1127 | pub type user_size_t = u_int64_t; 1128 | pub type user_ssize_t = int64_t; 1129 | pub type user_long_t = int64_t; 1130 | pub type user_ulong_t = u_int64_t; 1131 | pub type user_time_t = int64_t; 1132 | pub type user_off_t = int64_t; 1133 | pub type syscall_arg_t = u_int64_t; 1134 | pub type dev_t = __darwin_dev_t; 1135 | pub type mode_t = __darwin_mode_t; 1136 | pub type ErlNifUInt64 = ::libc::c_ulong; 1137 | pub type ErlNifSInt64 = ::libc::c_long; 1138 | pub type ERL_NIF_TERM = ::libc::c_ulong; 1139 | pub type ERL_NIF_UINT = ERL_NIF_TERM; 1140 | pub enum Struct_enif_environment_t { } 1141 | pub type ErlNifEnv = Struct_enif_environment_t; 1142 | #[repr(C)] 1143 | #[derive(Copy)] 1144 | pub struct Struct_Unnamed10 { 1145 | pub name: *const ::libc::c_char, 1146 | pub arity: ::libc::c_uint, 1147 | pub fptr: ::std::option::Option ERL_NIF_TERM>, 1151 | } 1152 | impl ::std::clone::Clone for Struct_Unnamed10 { 1153 | fn clone(&self) -> Self { *self } 1154 | } 1155 | impl ::std::default::Default for Struct_Unnamed10 { 1156 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 1157 | } 1158 | pub type ErlNifFunc = Struct_Unnamed10; 1159 | #[repr(C)] 1160 | #[derive(Copy)] 1161 | pub struct Struct_enif_entry_t { 1162 | pub major: ::libc::c_int, 1163 | pub minor: ::libc::c_int, 1164 | pub name: *const ::libc::c_char, 1165 | pub num_of_funcs: ::libc::c_int, 1166 | pub funcs: *mut ErlNifFunc, 1167 | pub load: ::std::option::Option ::libc::c_int>, 1172 | pub reload: ::std::option::Option ::libc::c_int>, 1177 | pub upgrade: ::std::option::Option ::libc::c_int>, 1184 | pub unload: ::std::option::Option ()>, 1188 | pub vm_variant: *const ::libc::c_char, 1189 | } 1190 | impl ::std::clone::Clone for Struct_enif_entry_t { 1191 | fn clone(&self) -> Self { *self } 1192 | } 1193 | impl ::std::default::Default for Struct_enif_entry_t { 1194 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 1195 | } 1196 | pub type ErlNifEntry = Struct_enif_entry_t; 1197 | #[repr(C)] 1198 | #[derive(Copy)] 1199 | pub struct Struct_Unnamed11 { 1200 | pub size: size_t, 1201 | pub data: *mut ::libc::c_uchar, 1202 | pub bin_term: ERL_NIF_TERM, 1203 | pub ref_bin: *mut ::libc::c_void, 1204 | } 1205 | impl ::std::clone::Clone for Struct_Unnamed11 { 1206 | fn clone(&self) -> Self { *self } 1207 | } 1208 | impl ::std::default::Default for Struct_Unnamed11 { 1209 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 1210 | } 1211 | pub type ErlNifBinary = Struct_Unnamed11; 1212 | pub enum Struct_enif_resource_type_t { } 1213 | pub type ErlNifResourceType = Struct_enif_resource_type_t; 1214 | pub type ErlNifResourceDtor = 1215 | extern "C" fn(arg1: *mut ErlNifEnv, arg2: *mut ::libc::c_void) -> (); 1216 | pub type Enum_Unnamed12 = ::libc::c_uint; 1217 | pub const ERL_NIF_RT_CREATE: ::libc::c_uint = 1; 1218 | pub const ERL_NIF_RT_TAKEOVER: ::libc::c_uint = 2; 1219 | pub type ErlNifResourceFlags = Enum_Unnamed12; 1220 | pub type Enum_Unnamed13 = ::libc::c_uint; 1221 | pub const ERL_NIF_LATIN1: ::libc::c_uint = 1; 1222 | pub type ErlNifCharEncoding = Enum_Unnamed13; 1223 | #[repr(C)] 1224 | #[derive(Copy)] 1225 | pub struct Struct_Unnamed14 { 1226 | pub pid: ERL_NIF_TERM, 1227 | } 1228 | impl ::std::clone::Clone for Struct_Unnamed14 { 1229 | fn clone(&self) -> Self { *self } 1230 | } 1231 | impl ::std::default::Default for Struct_Unnamed14 { 1232 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 1233 | } 1234 | pub type ErlNifPid = Struct_Unnamed14; 1235 | pub type ErlNifSysInfo = ErlDrvSysInfo; 1236 | pub enum Struct_ErlDrvTid_ { } 1237 | pub type ErlNifTid = *mut Struct_ErlDrvTid_; 1238 | pub enum Struct_ErlDrvMutex_ { } 1239 | pub type ErlNifMutex = Struct_ErlDrvMutex_; 1240 | pub enum Struct_ErlDrvCond_ { } 1241 | pub type ErlNifCond = Struct_ErlDrvCond_; 1242 | pub enum Struct_ErlDrvRWLock_ { } 1243 | pub type ErlNifRWLock = Struct_ErlDrvRWLock_; 1244 | pub type ErlNifTSDKey = ::libc::c_int; 1245 | pub type ErlNifThreadOpts = ErlDrvThreadOpts; 1246 | #[repr(C)] 1247 | #[derive(Copy)] 1248 | pub struct Struct_Unnamed15 { 1249 | pub map: ERL_NIF_TERM, 1250 | pub t_limit: ERL_NIF_UINT, 1251 | pub idx: ERL_NIF_UINT, 1252 | pub ks: *mut ERL_NIF_TERM, 1253 | pub vs: *mut ERL_NIF_TERM, 1254 | pub __spare__: [*mut ::libc::c_void; 2usize], 1255 | } 1256 | impl ::std::clone::Clone for Struct_Unnamed15 { 1257 | fn clone(&self) -> Self { *self } 1258 | } 1259 | impl ::std::default::Default for Struct_Unnamed15 { 1260 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 1261 | } 1262 | pub type ErlNifMapIterator = Struct_Unnamed15; 1263 | pub type Enum_Unnamed16 = ::libc::c_uint; 1264 | pub const ERL_NIF_MAP_ITERATOR_HEAD: ::libc::c_uint = 1; 1265 | pub const ERL_NIF_MAP_ITERATOR_TAIL: ::libc::c_uint = 2; 1266 | pub type ErlNifMapIteratorEntry = Enum_Unnamed16; 1267 | pub type __builtin_va_list = [__va_list_tag; 1usize]; 1268 | pub type __va_list_tag = Struct___va_list_tag; 1269 | #[repr(C)] 1270 | #[derive(Copy)] 1271 | pub struct Struct___va_list_tag { 1272 | pub gp_offset: ::libc::c_uint, 1273 | pub fp_offset: ::libc::c_uint, 1274 | pub overflow_arg_area: *mut ::libc::c_void, 1275 | pub reg_save_area: *mut ::libc::c_void, 1276 | } 1277 | impl ::std::clone::Clone for Struct___va_list_tag { 1278 | fn clone(&self) -> Self { *self } 1279 | } 1280 | impl ::std::default::Default for Struct___va_list_tag { 1281 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 1282 | } 1283 | extern "C" { 1284 | pub static mut __mb_cur_max: ::libc::c_int; 1285 | pub static mut suboptarg: *mut ::libc::c_char; 1286 | } 1287 | extern "C" { 1288 | pub fn signal(arg1: ::libc::c_int, 1289 | arg2: 1290 | ::std::option::Option ()>) 1292 | -> 1293 | ::std::option::Option 1298 | ()>) 1299 | -> ()>; 1300 | pub fn getpriority(arg1: ::libc::c_int, arg2: id_t) -> ::libc::c_int; 1301 | pub fn getiopolicy_np(arg1: ::libc::c_int, arg2: ::libc::c_int) 1302 | -> ::libc::c_int; 1303 | pub fn getrlimit(arg1: ::libc::c_int, arg2: *mut Struct_rlimit) 1304 | -> ::libc::c_int; 1305 | pub fn getrusage(arg1: ::libc::c_int, arg2: *mut Struct_rusage) 1306 | -> ::libc::c_int; 1307 | pub fn setpriority(arg1: ::libc::c_int, arg2: id_t, arg3: ::libc::c_int) 1308 | -> ::libc::c_int; 1309 | pub fn setiopolicy_np(arg1: ::libc::c_int, arg2: ::libc::c_int, 1310 | arg3: ::libc::c_int) -> ::libc::c_int; 1311 | pub fn setrlimit(arg1: ::libc::c_int, arg2: *const Struct_rlimit) 1312 | -> ::libc::c_int; 1313 | pub fn wait(arg1: *mut ::libc::c_int) -> pid_t; 1314 | pub fn waitpid(arg1: pid_t, arg2: *mut ::libc::c_int, arg3: ::libc::c_int) 1315 | -> pid_t; 1316 | pub fn waitid(arg1: idtype_t, arg2: id_t, arg3: *mut siginfo_t, 1317 | arg4: ::libc::c_int) -> ::libc::c_int; 1318 | pub fn wait3(arg1: *mut ::libc::c_int, arg2: ::libc::c_int, 1319 | arg3: *mut Struct_rusage) -> pid_t; 1320 | pub fn wait4(arg1: pid_t, arg2: *mut ::libc::c_int, arg3: ::libc::c_int, 1321 | arg4: *mut Struct_rusage) -> pid_t; 1322 | pub fn alloca(arg1: size_t) -> *mut ::libc::c_void; 1323 | pub fn abort() -> (); 1324 | pub fn abs(arg1: ::libc::c_int) -> ::libc::c_int; 1325 | pub fn atexit(arg1: ::std::option::Option ()>) 1326 | -> ::libc::c_int; 1327 | pub fn atof(arg1: *const ::libc::c_char) -> ::libc::c_double; 1328 | pub fn atoi(arg1: *const ::libc::c_char) -> ::libc::c_int; 1329 | pub fn atol(arg1: *const ::libc::c_char) -> ::libc::c_long; 1330 | pub fn atoll(arg1: *const ::libc::c_char) -> ::libc::c_longlong; 1331 | pub fn bsearch(arg1: *const ::libc::c_void, arg2: *const ::libc::c_void, 1332 | arg3: size_t, arg4: size_t, 1333 | arg5: 1334 | ::std::option::Option ::libc::c_int>) 1339 | -> *mut ::libc::c_void; 1340 | pub fn calloc(arg1: size_t, arg2: size_t) -> *mut ::libc::c_void; 1341 | pub fn div(arg1: ::libc::c_int, arg2: ::libc::c_int) -> div_t; 1342 | pub fn exit(arg1: ::libc::c_int) -> (); 1343 | pub fn free(arg1: *mut ::libc::c_void) -> (); 1344 | pub fn getenv(arg1: *const ::libc::c_char) -> *mut ::libc::c_char; 1345 | pub fn labs(arg1: ::libc::c_long) -> ::libc::c_long; 1346 | pub fn ldiv(arg1: ::libc::c_long, arg2: ::libc::c_long) -> ldiv_t; 1347 | pub fn llabs(arg1: ::libc::c_longlong) -> ::libc::c_longlong; 1348 | pub fn lldiv(arg1: ::libc::c_longlong, arg2: ::libc::c_longlong) 1349 | -> lldiv_t; 1350 | pub fn malloc(arg1: size_t) -> *mut ::libc::c_void; 1351 | pub fn mblen(arg1: *const ::libc::c_char, arg2: size_t) -> ::libc::c_int; 1352 | pub fn mbstowcs(arg1: *mut wchar_t, arg2: *const ::libc::c_char, 1353 | arg3: size_t) -> size_t; 1354 | pub fn mbtowc(arg1: *mut wchar_t, arg2: *const ::libc::c_char, 1355 | arg3: size_t) -> ::libc::c_int; 1356 | pub fn posix_memalign(arg1: *mut *mut ::libc::c_void, arg2: size_t, 1357 | arg3: size_t) -> ::libc::c_int; 1358 | pub fn qsort(arg1: *mut ::libc::c_void, arg2: size_t, arg3: size_t, 1359 | arg4: 1360 | ::std::option::Option ::libc::c_int>) -> (); 1365 | pub fn rand() -> ::libc::c_int; 1366 | pub fn realloc(arg1: *mut ::libc::c_void, arg2: size_t) 1367 | -> *mut ::libc::c_void; 1368 | pub fn srand(arg1: ::libc::c_uint) -> (); 1369 | pub fn strtod(arg1: *const ::libc::c_char, arg2: *mut *mut ::libc::c_char) 1370 | -> ::libc::c_double; 1371 | pub fn strtof(arg1: *const ::libc::c_char, arg2: *mut *mut ::libc::c_char) 1372 | -> ::libc::c_float; 1373 | pub fn strtol(arg1: *const ::libc::c_char, arg2: *mut *mut ::libc::c_char, 1374 | arg3: ::libc::c_int) -> ::libc::c_long; 1375 | pub fn strtold(arg1: *const ::libc::c_char, 1376 | arg2: *mut *mut ::libc::c_char) -> ::libc::c_double; 1377 | pub fn strtoll(arg1: *const ::libc::c_char, 1378 | arg2: *mut *mut ::libc::c_char, arg3: ::libc::c_int) 1379 | -> ::libc::c_longlong; 1380 | pub fn strtoul(arg1: *const ::libc::c_char, 1381 | arg2: *mut *mut ::libc::c_char, arg3: ::libc::c_int) 1382 | -> ::libc::c_ulong; 1383 | pub fn strtoull(arg1: *const ::libc::c_char, 1384 | arg2: *mut *mut ::libc::c_char, arg3: ::libc::c_int) 1385 | -> ::libc::c_ulonglong; 1386 | pub fn system(arg1: *const ::libc::c_char) -> ::libc::c_int; 1387 | pub fn wcstombs(arg1: *mut ::libc::c_char, arg2: *const wchar_t, 1388 | arg3: size_t) -> size_t; 1389 | pub fn wctomb(arg1: *mut ::libc::c_char, arg2: wchar_t) -> ::libc::c_int; 1390 | pub fn _Exit(arg1: ::libc::c_int) -> (); 1391 | pub fn a64l(arg1: *const ::libc::c_char) -> ::libc::c_long; 1392 | pub fn drand48() -> ::libc::c_double; 1393 | pub fn ecvt(arg1: ::libc::c_double, arg2: ::libc::c_int, 1394 | arg3: *mut ::libc::c_int, arg4: *mut ::libc::c_int) 1395 | -> *mut ::libc::c_char; 1396 | pub fn erand48(arg1: *mut ::libc::c_ushort) -> ::libc::c_double; 1397 | pub fn fcvt(arg1: ::libc::c_double, arg2: ::libc::c_int, 1398 | arg3: *mut ::libc::c_int, arg4: *mut ::libc::c_int) 1399 | -> *mut ::libc::c_char; 1400 | pub fn gcvt(arg1: ::libc::c_double, arg2: ::libc::c_int, 1401 | arg3: *mut ::libc::c_char) -> *mut ::libc::c_char; 1402 | pub fn getsubopt(arg1: *mut *mut ::libc::c_char, 1403 | arg2: *const *mut ::libc::c_char, 1404 | arg3: *mut *mut ::libc::c_char) -> ::libc::c_int; 1405 | pub fn grantpt(arg1: ::libc::c_int) -> ::libc::c_int; 1406 | pub fn initstate(arg1: ::libc::c_uint, arg2: *mut ::libc::c_char, 1407 | arg3: size_t) -> *mut ::libc::c_char; 1408 | pub fn jrand48(arg1: *mut ::libc::c_ushort) -> ::libc::c_long; 1409 | pub fn l64a(arg1: ::libc::c_long) -> *mut ::libc::c_char; 1410 | pub fn lcong48(arg1: *mut ::libc::c_ushort) -> (); 1411 | pub fn lrand48() -> ::libc::c_long; 1412 | pub fn mktemp(arg1: *mut ::libc::c_char) -> *mut ::libc::c_char; 1413 | pub fn mkstemp(arg1: *mut ::libc::c_char) -> ::libc::c_int; 1414 | pub fn mrand48() -> ::libc::c_long; 1415 | pub fn nrand48(arg1: *mut ::libc::c_ushort) -> ::libc::c_long; 1416 | pub fn posix_openpt(arg1: ::libc::c_int) -> ::libc::c_int; 1417 | pub fn ptsname(arg1: ::libc::c_int) -> *mut ::libc::c_char; 1418 | pub fn putenv(arg1: *mut ::libc::c_char) -> ::libc::c_int; 1419 | pub fn random() -> ::libc::c_long; 1420 | pub fn rand_r(arg1: *mut ::libc::c_uint) -> ::libc::c_int; 1421 | pub fn realpath(arg1: *const ::libc::c_char, arg2: *mut ::libc::c_char) 1422 | -> *mut ::libc::c_char; 1423 | pub fn seed48(arg1: *mut ::libc::c_ushort) -> *mut ::libc::c_ushort; 1424 | pub fn setenv(arg1: *const ::libc::c_char, arg2: *const ::libc::c_char, 1425 | arg3: ::libc::c_int) -> ::libc::c_int; 1426 | pub fn setkey(arg1: *const ::libc::c_char) -> (); 1427 | pub fn setstate(arg1: *const ::libc::c_char) -> *mut ::libc::c_char; 1428 | pub fn srand48(arg1: ::libc::c_long) -> (); 1429 | pub fn srandom(arg1: ::libc::c_uint) -> (); 1430 | pub fn unlockpt(arg1: ::libc::c_int) -> ::libc::c_int; 1431 | pub fn unsetenv(arg1: *const ::libc::c_char) -> ::libc::c_int; 1432 | pub fn arc4random() -> u_int32_t; 1433 | pub fn arc4random_addrandom(arg1: *mut ::libc::c_uchar, 1434 | arg2: ::libc::c_int) -> (); 1435 | pub fn arc4random_buf(arg1: *mut ::libc::c_void, arg2: size_t) -> (); 1436 | pub fn arc4random_stir() -> (); 1437 | pub fn arc4random_uniform(arg1: u_int32_t) -> u_int32_t; 1438 | pub fn atexit_b(arg1: ::libc::c_void) -> ::libc::c_int; 1439 | pub fn bsearch_b(arg1: *const ::libc::c_void, arg2: *const ::libc::c_void, 1440 | arg3: size_t, arg4: size_t, arg5: ::libc::c_void) 1441 | -> *mut ::libc::c_void; 1442 | pub fn cgetcap(arg1: *mut ::libc::c_char, arg2: *const ::libc::c_char, 1443 | arg3: ::libc::c_int) -> *mut ::libc::c_char; 1444 | pub fn cgetclose() -> ::libc::c_int; 1445 | pub fn cgetent(arg1: *mut *mut ::libc::c_char, 1446 | arg2: *mut *mut ::libc::c_char, 1447 | arg3: *const ::libc::c_char) -> ::libc::c_int; 1448 | pub fn cgetfirst(arg1: *mut *mut ::libc::c_char, 1449 | arg2: *mut *mut ::libc::c_char) -> ::libc::c_int; 1450 | pub fn cgetmatch(arg1: *const ::libc::c_char, arg2: *const ::libc::c_char) 1451 | -> ::libc::c_int; 1452 | pub fn cgetnext(arg1: *mut *mut ::libc::c_char, 1453 | arg2: *mut *mut ::libc::c_char) -> ::libc::c_int; 1454 | pub fn cgetnum(arg1: *mut ::libc::c_char, arg2: *const ::libc::c_char, 1455 | arg3: *mut ::libc::c_long) -> ::libc::c_int; 1456 | pub fn cgetset(arg1: *const ::libc::c_char) -> ::libc::c_int; 1457 | pub fn cgetstr(arg1: *mut ::libc::c_char, arg2: *const ::libc::c_char, 1458 | arg3: *mut *mut ::libc::c_char) -> ::libc::c_int; 1459 | pub fn cgetustr(arg1: *mut ::libc::c_char, arg2: *const ::libc::c_char, 1460 | arg3: *mut *mut ::libc::c_char) -> ::libc::c_int; 1461 | pub fn daemon(arg1: ::libc::c_int, arg2: ::libc::c_int) -> ::libc::c_int; 1462 | pub fn devname(arg1: dev_t, arg2: mode_t) -> *mut ::libc::c_char; 1463 | pub fn devname_r(arg1: dev_t, arg2: mode_t, buf: *mut ::libc::c_char, 1464 | len: ::libc::c_int) -> *mut ::libc::c_char; 1465 | pub fn getbsize(arg1: *mut ::libc::c_int, arg2: *mut ::libc::c_long) 1466 | -> *mut ::libc::c_char; 1467 | pub fn getloadavg(arg1: *mut ::libc::c_double, arg2: ::libc::c_int) 1468 | -> ::libc::c_int; 1469 | pub fn getprogname() -> *const ::libc::c_char; 1470 | pub fn heapsort(arg1: *mut ::libc::c_void, arg2: size_t, arg3: size_t, 1471 | arg4: 1472 | ::std::option::Option ::libc::c_int>) 1477 | -> ::libc::c_int; 1478 | pub fn heapsort_b(arg1: *mut ::libc::c_void, arg2: size_t, arg3: size_t, 1479 | arg4: ::libc::c_void) -> ::libc::c_int; 1480 | pub fn mergesort(arg1: *mut ::libc::c_void, arg2: size_t, arg3: size_t, 1481 | arg4: 1482 | ::std::option::Option ::libc::c_int>) 1487 | -> ::libc::c_int; 1488 | pub fn mergesort_b(arg1: *mut ::libc::c_void, arg2: size_t, arg3: size_t, 1489 | arg4: ::libc::c_void) -> ::libc::c_int; 1490 | pub fn psort(arg1: *mut ::libc::c_void, arg2: size_t, arg3: size_t, 1491 | arg4: 1492 | ::std::option::Option ::libc::c_int>) -> (); 1497 | pub fn psort_b(arg1: *mut ::libc::c_void, arg2: size_t, arg3: size_t, 1498 | arg4: ::libc::c_void) -> (); 1499 | pub fn psort_r(arg1: *mut ::libc::c_void, arg2: size_t, arg3: size_t, 1500 | arg4: *mut ::libc::c_void, 1501 | arg5: 1502 | ::std::option::Option ::libc::c_int>) -> (); 1509 | pub fn qsort_b(arg1: *mut ::libc::c_void, arg2: size_t, arg3: size_t, 1510 | arg4: ::libc::c_void) -> (); 1511 | pub fn qsort_r(arg1: *mut ::libc::c_void, arg2: size_t, arg3: size_t, 1512 | arg4: *mut ::libc::c_void, 1513 | arg5: 1514 | ::std::option::Option ::libc::c_int>) -> (); 1521 | pub fn radixsort(arg1: *mut *const ::libc::c_uchar, arg2: ::libc::c_int, 1522 | arg3: *const ::libc::c_uchar, arg4: ::libc::c_uint) 1523 | -> ::libc::c_int; 1524 | pub fn setprogname(arg1: *const ::libc::c_char) -> (); 1525 | pub fn sradixsort(arg1: *mut *const ::libc::c_uchar, arg2: ::libc::c_int, 1526 | arg3: *const ::libc::c_uchar, arg4: ::libc::c_uint) 1527 | -> ::libc::c_int; 1528 | pub fn sranddev() -> (); 1529 | pub fn srandomdev() -> (); 1530 | pub fn reallocf(arg1: *mut ::libc::c_void, arg2: size_t) 1531 | -> *mut ::libc::c_void; 1532 | pub fn strtoq(arg1: *const ::libc::c_char, arg2: *mut *mut ::libc::c_char, 1533 | arg3: ::libc::c_int) -> ::libc::c_longlong; 1534 | pub fn strtouq(arg1: *const ::libc::c_char, 1535 | arg2: *mut *mut ::libc::c_char, arg3: ::libc::c_int) 1536 | -> ::libc::c_ulonglong; 1537 | pub fn valloc(arg1: size_t) -> *mut ::libc::c_void; 1538 | pub fn enif_priv_data(arg1: *mut ErlNifEnv) -> *mut ::libc::c_void; 1539 | pub fn enif_alloc(size: size_t) -> *mut ::libc::c_void; 1540 | pub fn enif_free(ptr: *mut ::libc::c_void) -> (); 1541 | pub fn enif_is_atom(arg1: *mut ErlNifEnv, term: ERL_NIF_TERM) 1542 | -> ::libc::c_int; 1543 | pub fn enif_is_binary(arg1: *mut ErlNifEnv, term: ERL_NIF_TERM) 1544 | -> ::libc::c_int; 1545 | pub fn enif_is_ref(arg1: *mut ErlNifEnv, term: ERL_NIF_TERM) 1546 | -> ::libc::c_int; 1547 | pub fn enif_inspect_binary(arg1: *mut ErlNifEnv, bin_term: ERL_NIF_TERM, 1548 | bin: *mut ErlNifBinary) -> ::libc::c_int; 1549 | pub fn enif_alloc_binary(size: size_t, bin: *mut ErlNifBinary) 1550 | -> ::libc::c_int; 1551 | pub fn enif_realloc_binary(bin: *mut ErlNifBinary, size: size_t) 1552 | -> ::libc::c_int; 1553 | pub fn enif_release_binary(bin: *mut ErlNifBinary) -> (); 1554 | pub fn enif_get_int(arg1: *mut ErlNifEnv, term: ERL_NIF_TERM, 1555 | ip: *mut ::libc::c_int) -> ::libc::c_int; 1556 | pub fn enif_get_ulong(arg1: *mut ErlNifEnv, term: ERL_NIF_TERM, 1557 | ip: *mut ::libc::c_ulong) -> ::libc::c_int; 1558 | pub fn enif_get_double(arg1: *mut ErlNifEnv, term: ERL_NIF_TERM, 1559 | dp: *mut ::libc::c_double) -> ::libc::c_int; 1560 | pub fn enif_get_list_cell(env: *mut ErlNifEnv, term: ERL_NIF_TERM, 1561 | head: *mut ERL_NIF_TERM, 1562 | tail: *mut ERL_NIF_TERM) -> ::libc::c_int; 1563 | pub fn enif_get_tuple(env: *mut ErlNifEnv, tpl: ERL_NIF_TERM, 1564 | arity: *mut ::libc::c_int, 1565 | array: *mut *const ERL_NIF_TERM) -> ::libc::c_int; 1566 | pub fn enif_is_identical(lhs: ERL_NIF_TERM, rhs: ERL_NIF_TERM) 1567 | -> ::libc::c_int; 1568 | pub fn enif_compare(lhs: ERL_NIF_TERM, rhs: ERL_NIF_TERM) 1569 | -> ::libc::c_int; 1570 | pub fn enif_make_binary(env: *mut ErlNifEnv, bin: *mut ErlNifBinary) 1571 | -> ERL_NIF_TERM; 1572 | pub fn enif_make_badarg(env: *mut ErlNifEnv) -> ERL_NIF_TERM; 1573 | pub fn enif_make_int(env: *mut ErlNifEnv, i: ::libc::c_int) 1574 | -> ERL_NIF_TERM; 1575 | pub fn enif_make_ulong(env: *mut ErlNifEnv, i: ::libc::c_ulong) 1576 | -> ERL_NIF_TERM; 1577 | pub fn enif_make_double(env: *mut ErlNifEnv, d: ::libc::c_double) 1578 | -> ERL_NIF_TERM; 1579 | pub fn enif_make_atom(env: *mut ErlNifEnv, name: *const ::libc::c_char) 1580 | -> ERL_NIF_TERM; 1581 | pub fn enif_make_existing_atom(env: *mut ErlNifEnv, 1582 | name: *const ::libc::c_char, 1583 | atom: *mut ERL_NIF_TERM, 1584 | arg1: ErlNifCharEncoding) -> ::libc::c_int; 1585 | pub fn enif_make_tuple(env: *mut ErlNifEnv, cnt: ::libc::c_uint, ...) 1586 | -> ERL_NIF_TERM; 1587 | pub fn enif_make_list(env: *mut ErlNifEnv, cnt: ::libc::c_uint, ...) 1588 | -> ERL_NIF_TERM; 1589 | pub fn enif_make_list_cell(env: *mut ErlNifEnv, car: ERL_NIF_TERM, 1590 | cdr: ERL_NIF_TERM) -> ERL_NIF_TERM; 1591 | pub fn enif_make_string(env: *mut ErlNifEnv, 1592 | string: *const ::libc::c_char, 1593 | arg1: ErlNifCharEncoding) -> ERL_NIF_TERM; 1594 | pub fn enif_make_ref(env: *mut ErlNifEnv) -> ERL_NIF_TERM; 1595 | pub fn enif_mutex_create(name: *mut ::libc::c_char) -> *mut ErlNifMutex; 1596 | pub fn enif_mutex_destroy(mtx: *mut ErlNifMutex) -> (); 1597 | pub fn enif_mutex_trylock(mtx: *mut ErlNifMutex) -> ::libc::c_int; 1598 | pub fn enif_mutex_lock(mtx: *mut ErlNifMutex) -> (); 1599 | pub fn enif_mutex_unlock(mtx: *mut ErlNifMutex) -> (); 1600 | pub fn enif_cond_create(name: *mut ::libc::c_char) -> *mut ErlNifCond; 1601 | pub fn enif_cond_destroy(cnd: *mut ErlNifCond) -> (); 1602 | pub fn enif_cond_signal(cnd: *mut ErlNifCond) -> (); 1603 | pub fn enif_cond_broadcast(cnd: *mut ErlNifCond) -> (); 1604 | pub fn enif_cond_wait(cnd: *mut ErlNifCond, mtx: *mut ErlNifMutex) -> (); 1605 | pub fn enif_rwlock_create(name: *mut ::libc::c_char) -> *mut ErlNifRWLock; 1606 | pub fn enif_rwlock_destroy(rwlck: *mut ErlNifRWLock) -> (); 1607 | pub fn enif_rwlock_tryrlock(rwlck: *mut ErlNifRWLock) -> ::libc::c_int; 1608 | pub fn enif_rwlock_rlock(rwlck: *mut ErlNifRWLock) -> (); 1609 | pub fn enif_rwlock_runlock(rwlck: *mut ErlNifRWLock) -> (); 1610 | pub fn enif_rwlock_tryrwlock(rwlck: *mut ErlNifRWLock) -> ::libc::c_int; 1611 | pub fn enif_rwlock_rwlock(rwlck: *mut ErlNifRWLock) -> (); 1612 | pub fn enif_rwlock_rwunlock(rwlck: *mut ErlNifRWLock) -> (); 1613 | pub fn enif_tsd_key_create(name: *mut ::libc::c_char, 1614 | key: *mut ErlNifTSDKey) -> ::libc::c_int; 1615 | pub fn enif_tsd_key_destroy(key: ErlNifTSDKey) -> (); 1616 | pub fn enif_tsd_set(key: ErlNifTSDKey, data: *mut ::libc::c_void) -> (); 1617 | pub fn enif_tsd_get(key: ErlNifTSDKey) -> *mut ::libc::c_void; 1618 | pub fn enif_thread_opts_create(name: *mut ::libc::c_char) 1619 | -> *mut ErlNifThreadOpts; 1620 | pub fn enif_thread_opts_destroy(opts: *mut ErlNifThreadOpts) -> (); 1621 | pub fn enif_thread_create(name: *mut ::libc::c_char, tid: *mut ErlNifTid, 1622 | func: 1623 | ::std::option::Option 1626 | *mut ::libc::c_void>, 1627 | args: *mut ::libc::c_void, 1628 | opts: *mut ErlNifThreadOpts) -> ::libc::c_int; 1629 | pub fn enif_thread_self() -> ErlNifTid; 1630 | pub fn enif_equal_tids(tid1: ErlNifTid, tid2: ErlNifTid) -> ::libc::c_int; 1631 | pub fn enif_thread_exit(resp: *mut ::libc::c_void) -> (); 1632 | pub fn enif_thread_join(arg1: ErlNifTid, respp: *mut *mut ::libc::c_void) 1633 | -> ::libc::c_int; 1634 | pub fn enif_realloc(ptr: *mut ::libc::c_void, size: size_t) 1635 | -> *mut ::libc::c_void; 1636 | pub fn enif_system_info(sip: *mut ErlNifSysInfo, si_size: size_t) -> (); 1637 | pub fn enif_fprintf(filep: *mut ::libc::c_void, 1638 | format: *const ::libc::c_char, ...) -> ::libc::c_int; 1639 | pub fn enif_inspect_iolist_as_binary(arg1: *mut ErlNifEnv, 1640 | term: ERL_NIF_TERM, 1641 | bin: *mut ErlNifBinary) 1642 | -> ::libc::c_int; 1643 | pub fn enif_make_sub_binary(arg1: *mut ErlNifEnv, bin_term: ERL_NIF_TERM, 1644 | pos: size_t, size: size_t) -> ERL_NIF_TERM; 1645 | pub fn enif_get_string(arg1: *mut ErlNifEnv, list: ERL_NIF_TERM, 1646 | buf: *mut ::libc::c_char, len: ::libc::c_uint, 1647 | arg2: ErlNifCharEncoding) -> ::libc::c_int; 1648 | pub fn enif_get_atom(arg1: *mut ErlNifEnv, atom: ERL_NIF_TERM, 1649 | buf: *mut ::libc::c_char, len: ::libc::c_uint, 1650 | arg2: ErlNifCharEncoding) -> ::libc::c_int; 1651 | pub fn enif_is_fun(arg1: *mut ErlNifEnv, term: ERL_NIF_TERM) 1652 | -> ::libc::c_int; 1653 | pub fn enif_is_pid(arg1: *mut ErlNifEnv, term: ERL_NIF_TERM) 1654 | -> ::libc::c_int; 1655 | pub fn enif_is_port(arg1: *mut ErlNifEnv, term: ERL_NIF_TERM) 1656 | -> ::libc::c_int; 1657 | pub fn enif_get_uint(arg1: *mut ErlNifEnv, term: ERL_NIF_TERM, 1658 | ip: *mut ::libc::c_uint) -> ::libc::c_int; 1659 | pub fn enif_get_long(arg1: *mut ErlNifEnv, term: ERL_NIF_TERM, 1660 | ip: *mut ::libc::c_long) -> ::libc::c_int; 1661 | pub fn enif_make_uint(arg1: *mut ErlNifEnv, i: ::libc::c_uint) 1662 | -> ERL_NIF_TERM; 1663 | pub fn enif_make_long(arg1: *mut ErlNifEnv, i: ::libc::c_long) 1664 | -> ERL_NIF_TERM; 1665 | pub fn enif_make_tuple_from_array(arg1: *mut ErlNifEnv, 1666 | arr: *const ERL_NIF_TERM, 1667 | cnt: ::libc::c_uint) -> ERL_NIF_TERM; 1668 | pub fn enif_make_list_from_array(arg1: *mut ErlNifEnv, 1669 | arr: *const ERL_NIF_TERM, 1670 | cnt: ::libc::c_uint) -> ERL_NIF_TERM; 1671 | pub fn enif_is_empty_list(arg1: *mut ErlNifEnv, term: ERL_NIF_TERM) 1672 | -> ::libc::c_int; 1673 | pub fn enif_open_resource_type(arg1: *mut ErlNifEnv, 1674 | module_str: *const ::libc::c_char, 1675 | name_str: *const ::libc::c_char, 1676 | dtor: 1677 | ::std::option::Option ()>, 1682 | flags: ErlNifResourceFlags, 1683 | tried: *mut ErlNifResourceFlags) 1684 | -> *mut ErlNifResourceType; 1685 | pub fn enif_alloc_resource(_type: *mut ErlNifResourceType, size: size_t) 1686 | -> *mut ::libc::c_void; 1687 | pub fn enif_release_resource(obj: *mut ::libc::c_void) -> (); 1688 | pub fn enif_make_resource(arg1: *mut ErlNifEnv, obj: *mut ::libc::c_void) 1689 | -> ERL_NIF_TERM; 1690 | pub fn enif_get_resource(arg1: *mut ErlNifEnv, term: ERL_NIF_TERM, 1691 | _type: *mut ErlNifResourceType, 1692 | objp: *mut *mut ::libc::c_void) -> ::libc::c_int; 1693 | pub fn enif_sizeof_resource(obj: *mut ::libc::c_void) -> size_t; 1694 | pub fn enif_make_new_binary(arg1: *mut ErlNifEnv, size: size_t, 1695 | termp: *mut ERL_NIF_TERM) 1696 | -> *mut ::libc::c_uchar; 1697 | pub fn enif_is_list(arg1: *mut ErlNifEnv, term: ERL_NIF_TERM) 1698 | -> ::libc::c_int; 1699 | pub fn enif_is_tuple(arg1: *mut ErlNifEnv, term: ERL_NIF_TERM) 1700 | -> ::libc::c_int; 1701 | pub fn enif_get_atom_length(arg1: *mut ErlNifEnv, atom: ERL_NIF_TERM, 1702 | len: *mut ::libc::c_uint, 1703 | arg2: ErlNifCharEncoding) -> ::libc::c_int; 1704 | pub fn enif_get_list_length(env: *mut ErlNifEnv, term: ERL_NIF_TERM, 1705 | len: *mut ::libc::c_uint) -> ::libc::c_int; 1706 | pub fn enif_make_atom_len(env: *mut ErlNifEnv, 1707 | name: *const ::libc::c_char, len: size_t) 1708 | -> ERL_NIF_TERM; 1709 | pub fn enif_make_existing_atom_len(env: *mut ErlNifEnv, 1710 | name: *const ::libc::c_char, 1711 | len: size_t, atom: *mut ERL_NIF_TERM, 1712 | arg1: ErlNifCharEncoding) 1713 | -> ::libc::c_int; 1714 | pub fn enif_make_string_len(env: *mut ErlNifEnv, 1715 | string: *const ::libc::c_char, len: size_t, 1716 | arg1: ErlNifCharEncoding) -> ERL_NIF_TERM; 1717 | pub fn enif_alloc_env() -> *mut ErlNifEnv; 1718 | pub fn enif_free_env(env: *mut ErlNifEnv) -> (); 1719 | pub fn enif_clear_env(env: *mut ErlNifEnv) -> (); 1720 | pub fn enif_send(env: *mut ErlNifEnv, to_pid: *const ErlNifPid, 1721 | msg_env: *mut ErlNifEnv, msg: ERL_NIF_TERM) 1722 | -> ::libc::c_int; 1723 | pub fn enif_make_copy(dst_env: *mut ErlNifEnv, src_term: ERL_NIF_TERM) 1724 | -> ERL_NIF_TERM; 1725 | pub fn enif_self(caller_env: *mut ErlNifEnv, pid: *mut ErlNifPid) 1726 | -> *mut ErlNifPid; 1727 | pub fn enif_get_local_pid(env: *mut ErlNifEnv, arg1: ERL_NIF_TERM, 1728 | pid: *mut ErlNifPid) -> ::libc::c_int; 1729 | pub fn enif_keep_resource(obj: *mut ::libc::c_void) -> (); 1730 | pub fn enif_make_resource_binary(arg1: *mut ErlNifEnv, 1731 | obj: *mut ::libc::c_void, 1732 | data: *const ::libc::c_void, 1733 | size: size_t) -> ERL_NIF_TERM; 1734 | pub fn enif_is_exception(arg1: *mut ErlNifEnv, term: ERL_NIF_TERM) 1735 | -> ::libc::c_int; 1736 | pub fn enif_make_reverse_list(arg1: *mut ErlNifEnv, term: ERL_NIF_TERM, 1737 | list: *mut ERL_NIF_TERM) -> ::libc::c_int; 1738 | pub fn enif_is_number(arg1: *mut ErlNifEnv, term: ERL_NIF_TERM) 1739 | -> ::libc::c_int; 1740 | pub fn enif_dlopen(lib: *const ::libc::c_char, 1741 | err_handler: 1742 | ::std::option::Option ()>, 1747 | err_arg: *mut ::libc::c_void) -> *mut ::libc::c_void; 1748 | pub fn enif_dlsym(handle: *mut ::libc::c_void, 1749 | symbol: *const ::libc::c_char, 1750 | err_handler: 1751 | ::std::option::Option ()>, 1756 | err_arg: *mut ::libc::c_void) -> *mut ::libc::c_void; 1757 | pub fn enif_consume_timeslice(arg1: *mut ErlNifEnv, 1758 | percent: ::libc::c_int) -> ::libc::c_int; 1759 | pub fn enif_is_map(env: *mut ErlNifEnv, term: ERL_NIF_TERM) 1760 | -> ::libc::c_int; 1761 | pub fn enif_get_map_size(env: *mut ErlNifEnv, term: ERL_NIF_TERM, 1762 | size: *mut size_t) -> ::libc::c_int; 1763 | pub fn enif_make_new_map(env: *mut ErlNifEnv) -> ERL_NIF_TERM; 1764 | pub fn enif_make_map_put(env: *mut ErlNifEnv, map_in: ERL_NIF_TERM, 1765 | key: ERL_NIF_TERM, value: ERL_NIF_TERM, 1766 | map_out: *mut ERL_NIF_TERM) -> ::libc::c_int; 1767 | pub fn enif_get_map_value(env: *mut ErlNifEnv, map: ERL_NIF_TERM, 1768 | key: ERL_NIF_TERM, value: *mut ERL_NIF_TERM) 1769 | -> ::libc::c_int; 1770 | pub fn enif_make_map_update(env: *mut ErlNifEnv, map_in: ERL_NIF_TERM, 1771 | key: ERL_NIF_TERM, value: ERL_NIF_TERM, 1772 | map_out: *mut ERL_NIF_TERM) -> ::libc::c_int; 1773 | pub fn enif_make_map_remove(env: *mut ErlNifEnv, map_in: ERL_NIF_TERM, 1774 | key: ERL_NIF_TERM, map_out: *mut ERL_NIF_TERM) 1775 | -> ::libc::c_int; 1776 | pub fn enif_map_iterator_create(env: *mut ErlNifEnv, map: ERL_NIF_TERM, 1777 | iter: *mut ErlNifMapIterator, 1778 | entry: ErlNifMapIteratorEntry) 1779 | -> ::libc::c_int; 1780 | pub fn enif_map_iterator_destroy(env: *mut ErlNifEnv, 1781 | iter: *mut ErlNifMapIterator) -> (); 1782 | pub fn enif_map_iterator_is_head(env: *mut ErlNifEnv, 1783 | iter: *mut ErlNifMapIterator) 1784 | -> ::libc::c_int; 1785 | pub fn enif_map_iterator_is_tail(env: *mut ErlNifEnv, 1786 | iter: *mut ErlNifMapIterator) 1787 | -> ::libc::c_int; 1788 | pub fn enif_map_iterator_next(env: *mut ErlNifEnv, 1789 | iter: *mut ErlNifMapIterator) 1790 | -> ::libc::c_int; 1791 | pub fn enif_map_iterator_prev(env: *mut ErlNifEnv, 1792 | iter: *mut ErlNifMapIterator) 1793 | -> ::libc::c_int; 1794 | pub fn enif_map_iterator_get_pair(env: *mut ErlNifEnv, 1795 | iter: *mut ErlNifMapIterator, 1796 | key: *mut ERL_NIF_TERM, 1797 | value: *mut ERL_NIF_TERM) 1798 | -> ::libc::c_int; 1799 | } 1800 | -------------------------------------------------------------------------------- /rust_src/src/lib.rs: -------------------------------------------------------------------------------- 1 | extern crate libc; 2 | use libc::c_char; 3 | use libc::c_int; 4 | mod c; 5 | 6 | #[no_mangle] 7 | pub extern "C" fn native_add(env: *mut c::ErlNifEnv, 8 | argc: c_int, 9 | args: *const c::ERL_NIF_TERM) -> c::ERL_NIF_TERM 10 | { 11 | if argc != 2 12 | { unsafe { return c::enif_make_badarg(env); } } 13 | let mut a: c_int = 0; 14 | let mut b: c_int = 0; 15 | unsafe { 16 | if c::enif_get_int(env, *args.offset(0), &mut a) == 0 17 | { return c::enif_make_badarg(env); } 18 | if c::enif_get_int(env, *args.offset(1), &mut b) == 0 19 | { return c::enif_make_badarg(env); } 20 | c::enif_make_int(env, a + b) 21 | } 22 | } 23 | 24 | static mut funcs: [c::ErlNifFunc; 1] = [ 25 | c::ErlNifFunc{ name: 0 as *const c_char, 26 | arity: 2, 27 | fptr: Some(native_add) } 28 | ]; 29 | 30 | static mut nif_entry: c::ErlNifEntry = c::ErlNifEntry{ 31 | major : 2, 32 | minor : 6, 33 | name : 0 as *const c_char, 34 | num_of_funcs : 0, 35 | funcs : 0 as *mut c::ErlNifFunc, 36 | load : None, 37 | reload : None, 38 | upgrade : None, 39 | unload : None, 40 | vm_variant : 0 as *const c_char 41 | }; 42 | 43 | #[no_mangle] 44 | pub extern "C" fn nif_init() -> *mut c::ErlNifEntry 45 | { 46 | unsafe { 47 | funcs[0].name = b"native_add\0".as_ptr() as *const i8; 48 | nif_entry.name = b"er\0".as_ptr() as *const i8; 49 | nif_entry.num_of_funcs = funcs.len() as i32; 50 | nif_entry.funcs = funcs.as_mut_ptr(); 51 | nif_entry.vm_variant = b"beam.vanilla\0".as_ptr() as *const i8; 52 | &mut nif_entry 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/er.app.src: -------------------------------------------------------------------------------- 1 | {application, er, 2 | [ 3 | {description, "An example Erlang NIF implemented in Rust"}, 4 | {vsn, "1"}, 5 | {modules, [ 6 | er 7 | ]}, 8 | {registered, []}, 9 | {applications, [ 10 | kernel, 11 | stdlib 12 | ]}, 13 | {env, []} 14 | ]}. 15 | -------------------------------------------------------------------------------- /src/er.erl: -------------------------------------------------------------------------------- 1 | -module(er). 2 | 3 | -export([f/2, 4 | test/0]). 5 | 6 | %% Native library support 7 | -export([load/0]). 8 | -on_load(load/0). 9 | 10 | %% 11 | %% API 12 | %% 13 | 14 | test() -> 15 | io:format("~B~n", [f(123, 456)]). 16 | 17 | f(A, B) -> 18 | native_add(A, B). 19 | 20 | native_add(_, _) -> 21 | throw({?MODULE, nif_not_loaded}). 22 | 23 | %% 24 | %% Native library support 25 | %% 26 | 27 | -spec load() -> any(). 28 | load() -> 29 | PrivDir = case code:priv_dir(?MODULE) of 30 | {error, _} -> 31 | EbinDir = filename:dirname(code:which(?MODULE)), 32 | AppPath = filename:dirname(EbinDir), 33 | filename:join(AppPath, "priv"); 34 | Path -> 35 | Path 36 | end, 37 | erlang:load_nif(filename:join(PrivDir, "er"), none). 38 | -------------------------------------------------------------------------------- /test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | EXPECTED=579 4 | ACTUAL=$(erl -noinput -noshell -pa ebin/ priv/ -s er test -s init stop) 5 | 6 | [ x"$EXPECTED" = x"$ACTUAL" ] \ 7 | && echo "Test OK - the Rust NIF works" \ 8 | || echo "Test failed - try building the dynamically loaded library manually" 9 | --------------------------------------------------------------------------------