@@ -100,176 +100,183 @@ extern crate std as core;
100
100
#[ macro_use] mod macros;
101
101
mod dox;
102
102
103
- // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help enable
104
- // more optimization opportunities around it recognizing things like
105
- // malloc/free.
106
- #[ repr( u8 ) ]
107
- pub enum c_void {
108
- // Two dummy variants so the #[repr] attribute can be used.
109
- #[ doc( hidden) ]
110
- __variant1,
111
- #[ doc( hidden) ]
112
- __variant2,
113
- }
103
+ cfg_if ! {
104
+ if #[ cfg( all( target_arch = "wasm32" , not( target_os = "emscripten" ) ) ) ] {
105
+ // empty ...
106
+ } else {
114
107
115
- pub type int8_t = i8 ;
116
- pub type int16_t = i16 ;
117
- pub type int32_t = i32 ;
118
- pub type int64_t = i64 ;
119
- pub type uint8_t = u8 ;
120
- pub type uint16_t = u16 ;
121
- pub type uint32_t = u32 ;
122
- pub type uint64_t = u64 ;
108
+ // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help enable
109
+ // more optimization opportunities around it recognizing things like
110
+ // malloc/free.
111
+ #[ repr( u8 ) ]
112
+ pub enum c_void {
113
+ // Two dummy variants so the #[repr] attribute can be used.
114
+ #[ doc( hidden) ]
115
+ __variant1,
116
+ #[ doc( hidden) ]
117
+ __variant2,
118
+ }
123
119
124
- pub type c_schar = i8 ;
125
- pub type c_uchar = u8 ;
126
- pub type c_short = i16 ;
127
- pub type c_ushort = u16 ;
128
- pub type c_int = i32 ;
129
- pub type c_uint = u32 ;
130
- pub type c_float = f32 ;
131
- pub type c_double = f64 ;
132
- pub type c_longlong = i64 ;
133
- pub type c_ulonglong = u64 ;
134
- pub type intmax_t = i64 ;
135
- pub type uintmax_t = u64 ;
120
+ pub type int8_t = i8 ;
121
+ pub type int16_t = i16 ;
122
+ pub type int32_t = i32 ;
123
+ pub type int64_t = i64 ;
124
+ pub type uint8_t = u8 ;
125
+ pub type uint16_t = u16 ;
126
+ pub type uint32_t = u32 ;
127
+ pub type uint64_t = u64 ;
136
128
137
- pub type size_t = usize ;
138
- pub type ptrdiff_t = isize ;
139
- pub type intptr_t = isize ;
140
- pub type uintptr_t = usize ;
141
- pub type ssize_t = isize ;
129
+ pub type c_schar = i8 ;
130
+ pub type c_uchar = u8 ;
131
+ pub type c_short = i16 ;
132
+ pub type c_ushort = u16 ;
133
+ pub type c_int = i32 ;
134
+ pub type c_uint = u32 ;
135
+ pub type c_float = f32 ;
136
+ pub type c_double = f64 ;
137
+ pub type c_longlong = i64 ;
138
+ pub type c_ulonglong = u64 ;
139
+ pub type intmax_t = i64 ;
140
+ pub type uintmax_t = u64 ;
142
141
143
- pub enum FILE { }
144
- pub enum fpos_t { } // TODO: fill this out with a struct
142
+ pub type size_t = usize ;
143
+ pub type ptrdiff_t = isize ;
144
+ pub type intptr_t = isize ;
145
+ pub type uintptr_t = usize ;
146
+ pub type ssize_t = isize ;
145
147
146
- extern {
147
- pub fn isalnum ( c : c_int ) -> c_int ;
148
- pub fn isalpha ( c : c_int ) -> c_int ;
149
- pub fn iscntrl ( c : c_int ) -> c_int ;
150
- pub fn isdigit ( c : c_int ) -> c_int ;
151
- pub fn isgraph ( c : c_int ) -> c_int ;
152
- pub fn islower ( c : c_int ) -> c_int ;
153
- pub fn isprint ( c : c_int ) -> c_int ;
154
- pub fn ispunct ( c : c_int ) -> c_int ;
155
- pub fn isspace ( c : c_int ) -> c_int ;
156
- pub fn isupper ( c : c_int ) -> c_int ;
157
- pub fn isxdigit ( c : c_int ) -> c_int ;
158
- pub fn tolower ( c : c_int ) -> c_int ;
159
- pub fn toupper ( c : c_int ) -> c_int ;
148
+ pub enum FILE { }
149
+ pub enum fpos_t { } // TODO: fill this out with a struct
160
150
161
- #[ cfg_attr( all( target_os = "macos" , target_arch = "x86" ) ,
162
- link_name = "fopen$UNIX2003" ) ]
163
- pub fn fopen ( filename : * const c_char ,
164
- mode : * const c_char ) -> * mut FILE ;
165
- #[ cfg_attr( all( target_os = "macos" , target_arch = "x86" ) ,
166
- link_name = "freopen$UNIX2003" ) ]
167
- pub fn freopen ( filename : * const c_char , mode : * const c_char ,
168
- file : * mut FILE ) -> * mut FILE ;
169
- pub fn fflush ( file : * mut FILE ) -> c_int ;
170
- pub fn fclose ( file : * mut FILE ) -> c_int ;
171
- pub fn remove ( filename : * const c_char ) -> c_int ;
172
- pub fn rename ( oldname : * const c_char , newname : * const c_char ) -> c_int ;
173
- pub fn tmpfile ( ) -> * mut FILE ;
174
- pub fn setvbuf ( stream : * mut FILE ,
175
- buffer : * mut c_char ,
176
- mode : c_int ,
177
- size : size_t ) -> c_int ;
178
- pub fn setbuf ( stream : * mut FILE , buf : * mut c_char ) ;
179
- pub fn getchar ( ) -> c_int ;
180
- pub fn putchar ( c : c_int ) -> c_int ;
181
- pub fn fgetc ( stream : * mut FILE ) -> c_int ;
182
- pub fn fgets ( buf : * mut c_char , n : c_int , stream : * mut FILE ) -> * mut c_char ;
183
- pub fn fputc ( c : c_int , stream : * mut FILE ) -> c_int ;
184
- #[ cfg_attr( all( target_os = "macos" , target_arch = "x86" ) ,
185
- link_name = "fputs$UNIX2003" ) ]
186
- pub fn fputs ( s : * const c_char , stream : * mut FILE ) -> c_int ;
187
- pub fn puts ( s : * const c_char ) -> c_int ;
188
- pub fn ungetc ( c : c_int , stream : * mut FILE ) -> c_int ;
189
- pub fn fread ( ptr : * mut c_void ,
190
- size : size_t ,
191
- nobj : size_t ,
192
- stream : * mut FILE )
193
- -> size_t ;
194
- #[ cfg_attr( all( target_os = "macos" , target_arch = "x86" ) ,
195
- link_name = "fwrite$UNIX2003" ) ]
196
- pub fn fwrite ( ptr : * const c_void ,
197
- size : size_t ,
198
- nobj : size_t ,
199
- stream : * mut FILE )
200
- -> size_t ;
201
- pub fn fseek ( stream : * mut FILE , offset : c_long , whence : c_int ) -> c_int ;
202
- pub fn ftell ( stream : * mut FILE ) -> c_long ;
203
- pub fn rewind ( stream : * mut FILE ) ;
204
- #[ cfg_attr( target_os = "netbsd" , link_name = "__fgetpos50" ) ]
205
- pub fn fgetpos ( stream : * mut FILE , ptr : * mut fpos_t ) -> c_int ;
206
- #[ cfg_attr( target_os = "netbsd" , link_name = "__fsetpos50" ) ]
207
- pub fn fsetpos ( stream : * mut FILE , ptr : * const fpos_t ) -> c_int ;
208
- pub fn feof ( stream : * mut FILE ) -> c_int ;
209
- pub fn ferror ( stream : * mut FILE ) -> c_int ;
210
- pub fn perror ( s : * const c_char ) ;
211
- pub fn atoi ( s : * const c_char ) -> c_int ;
212
- #[ cfg_attr( all( target_os = "macos" , target_arch = "x86" ) ,
213
- link_name = "strtod$UNIX2003" ) ]
214
- pub fn strtod ( s : * const c_char , endp : * mut * mut c_char ) -> c_double ;
215
- pub fn strtol ( s : * const c_char ,
216
- endp : * mut * mut c_char , base : c_int ) -> c_long ;
217
- pub fn strtoul ( s : * const c_char , endp : * mut * mut c_char ,
218
- base : c_int ) -> c_ulong ;
219
- pub fn calloc ( nobj : size_t , size : size_t ) -> * mut c_void ;
220
- pub fn malloc ( size : size_t ) -> * mut c_void ;
221
- pub fn realloc ( p : * mut c_void , size : size_t ) -> * mut c_void ;
222
- pub fn free ( p : * mut c_void ) ;
223
- pub fn abort ( ) -> !;
224
- pub fn exit ( status : c_int ) -> !;
225
- pub fn _exit ( status : c_int ) -> !;
226
- pub fn atexit ( cb : extern fn ( ) ) -> c_int ;
227
- #[ cfg_attr( all( target_os = "macos" , target_arch = "x86" ) ,
228
- link_name = "system$UNIX2003" ) ]
229
- pub fn system ( s : * const c_char ) -> c_int ;
230
- pub fn getenv ( s : * const c_char ) -> * mut c_char ;
151
+ extern {
152
+ pub fn isalnum( c: c_int) -> c_int;
153
+ pub fn isalpha( c: c_int) -> c_int;
154
+ pub fn iscntrl( c: c_int) -> c_int;
155
+ pub fn isdigit( c: c_int) -> c_int;
156
+ pub fn isgraph( c: c_int) -> c_int;
157
+ pub fn islower( c: c_int) -> c_int;
158
+ pub fn isprint( c: c_int) -> c_int;
159
+ pub fn ispunct( c: c_int) -> c_int;
160
+ pub fn isspace( c: c_int) -> c_int;
161
+ pub fn isupper( c: c_int) -> c_int;
162
+ pub fn isxdigit( c: c_int) -> c_int;
163
+ pub fn tolower( c: c_int) -> c_int;
164
+ pub fn toupper( c: c_int) -> c_int;
231
165
232
- pub fn strcpy ( dst : * mut c_char , src : * const c_char ) -> * mut c_char ;
233
- pub fn strncpy ( dst : * mut c_char , src : * const c_char , n : size_t )
234
- -> * mut c_char ;
235
- pub fn strcat ( s : * mut c_char , ct : * const c_char ) -> * mut c_char ;
236
- pub fn strncat ( s : * mut c_char , ct : * const c_char , n : size_t ) -> * mut c_char ;
237
- pub fn strcmp ( cs : * const c_char , ct : * const c_char ) -> c_int ;
238
- pub fn strncmp ( cs : * const c_char , ct : * const c_char , n : size_t ) -> c_int ;
239
- pub fn strcoll ( cs : * const c_char , ct : * const c_char ) -> c_int ;
240
- pub fn strchr ( cs : * const c_char , c : c_int ) -> * mut c_char ;
241
- pub fn strrchr ( cs : * const c_char , c : c_int ) -> * mut c_char ;
242
- pub fn strspn ( cs : * const c_char , ct : * const c_char ) -> size_t ;
243
- pub fn strcspn ( cs : * const c_char , ct : * const c_char ) -> size_t ;
244
- pub fn strdup ( cs : * const c_char ) -> * mut c_char ;
245
- pub fn strpbrk ( cs : * const c_char , ct : * const c_char ) -> * mut c_char ;
246
- pub fn strstr ( cs : * const c_char , ct : * const c_char ) -> * mut c_char ;
247
- pub fn strlen ( cs : * const c_char ) -> size_t ;
248
- pub fn strnlen ( cs : * const c_char , maxlen : size_t ) -> size_t ;
249
- #[ cfg_attr( all( target_os = "macos" , target_arch = "x86" ) ,
250
- link_name = "strerror$UNIX2003" ) ]
251
- pub fn strerror ( n : c_int ) -> * mut c_char ;
252
- pub fn strtok ( s : * mut c_char , t : * const c_char ) -> * mut c_char ;
253
- pub fn strxfrm ( s : * mut c_char , ct : * const c_char , n : size_t ) -> size_t ;
254
- pub fn wcslen ( buf : * const wchar_t ) -> size_t ;
255
- pub fn wcstombs ( dest : * mut c_char , src : * const wchar_t , n : size_t ) -> :: size_t ;
166
+ #[ cfg_attr( all( target_os = "macos" , target_arch = "x86" ) ,
167
+ link_name = "fopen$UNIX2003" ) ]
168
+ pub fn fopen( filename: * const c_char,
169
+ mode: * const c_char) -> * mut FILE ;
170
+ #[ cfg_attr( all( target_os = "macos" , target_arch = "x86" ) ,
171
+ link_name = "freopen$UNIX2003" ) ]
172
+ pub fn freopen( filename: * const c_char, mode: * const c_char,
173
+ file: * mut FILE ) -> * mut FILE ;
174
+ pub fn fflush( file: * mut FILE ) -> c_int;
175
+ pub fn fclose( file: * mut FILE ) -> c_int;
176
+ pub fn remove( filename: * const c_char) -> c_int;
177
+ pub fn rename( oldname: * const c_char, newname: * const c_char) -> c_int;
178
+ pub fn tmpfile( ) -> * mut FILE ;
179
+ pub fn setvbuf( stream: * mut FILE ,
180
+ buffer: * mut c_char,
181
+ mode: c_int,
182
+ size: size_t) -> c_int;
183
+ pub fn setbuf( stream: * mut FILE , buf: * mut c_char) ;
184
+ pub fn getchar( ) -> c_int;
185
+ pub fn putchar( c: c_int) -> c_int;
186
+ pub fn fgetc( stream: * mut FILE ) -> c_int;
187
+ pub fn fgets( buf: * mut c_char, n: c_int, stream: * mut FILE ) -> * mut c_char;
188
+ pub fn fputc( c: c_int, stream: * mut FILE ) -> c_int;
189
+ #[ cfg_attr( all( target_os = "macos" , target_arch = "x86" ) ,
190
+ link_name = "fputs$UNIX2003" ) ]
191
+ pub fn fputs( s: * const c_char, stream: * mut FILE ) -> c_int;
192
+ pub fn puts( s: * const c_char) -> c_int;
193
+ pub fn ungetc( c: c_int, stream: * mut FILE ) -> c_int;
194
+ pub fn fread( ptr: * mut c_void,
195
+ size: size_t,
196
+ nobj: size_t,
197
+ stream: * mut FILE )
198
+ -> size_t;
199
+ #[ cfg_attr( all( target_os = "macos" , target_arch = "x86" ) ,
200
+ link_name = "fwrite$UNIX2003" ) ]
201
+ pub fn fwrite( ptr: * const c_void,
202
+ size: size_t,
203
+ nobj: size_t,
204
+ stream: * mut FILE )
205
+ -> size_t;
206
+ pub fn fseek( stream: * mut FILE , offset: c_long, whence: c_int) -> c_int;
207
+ pub fn ftell( stream: * mut FILE ) -> c_long;
208
+ pub fn rewind( stream: * mut FILE ) ;
209
+ #[ cfg_attr( target_os = "netbsd" , link_name = "__fgetpos50" ) ]
210
+ pub fn fgetpos( stream: * mut FILE , ptr: * mut fpos_t) -> c_int;
211
+ #[ cfg_attr( target_os = "netbsd" , link_name = "__fsetpos50" ) ]
212
+ pub fn fsetpos( stream: * mut FILE , ptr: * const fpos_t) -> c_int;
213
+ pub fn feof( stream: * mut FILE ) -> c_int;
214
+ pub fn ferror( stream: * mut FILE ) -> c_int;
215
+ pub fn perror( s: * const c_char) ;
216
+ pub fn atoi( s: * const c_char) -> c_int;
217
+ #[ cfg_attr( all( target_os = "macos" , target_arch = "x86" ) ,
218
+ link_name = "strtod$UNIX2003" ) ]
219
+ pub fn strtod( s: * const c_char, endp: * mut * mut c_char) -> c_double;
220
+ pub fn strtol( s: * const c_char,
221
+ endp: * mut * mut c_char, base: c_int) -> c_long;
222
+ pub fn strtoul( s: * const c_char, endp: * mut * mut c_char,
223
+ base: c_int) -> c_ulong;
224
+ pub fn calloc( nobj: size_t, size: size_t) -> * mut c_void;
225
+ pub fn malloc( size: size_t) -> * mut c_void;
226
+ pub fn realloc( p: * mut c_void, size: size_t) -> * mut c_void;
227
+ pub fn free( p: * mut c_void) ;
228
+ pub fn abort( ) -> !;
229
+ pub fn exit( status: c_int) -> !;
230
+ pub fn _exit( status: c_int) -> !;
231
+ pub fn atexit( cb: extern fn ( ) ) -> c_int;
232
+ #[ cfg_attr( all( target_os = "macos" , target_arch = "x86" ) ,
233
+ link_name = "system$UNIX2003" ) ]
234
+ pub fn system( s: * const c_char) -> c_int;
235
+ pub fn getenv( s: * const c_char) -> * mut c_char;
256
236
257
- pub fn memchr ( cx : * const c_void , c : c_int , n : size_t ) -> * mut c_void ;
258
- pub fn memcmp ( cx : * const c_void , ct : * const c_void , n : size_t ) -> c_int ;
259
- pub fn memcpy ( dest : * mut c_void , src : * const c_void , n : size_t ) -> * mut c_void ;
260
- pub fn memmove ( dest : * mut c_void , src : * const c_void , n : size_t ) -> * mut c_void ;
261
- pub fn memset ( dest : * mut c_void , c : c_int , n : size_t ) -> * mut c_void ;
262
- }
237
+ pub fn strcpy( dst: * mut c_char, src: * const c_char) -> * mut c_char;
238
+ pub fn strncpy( dst: * mut c_char, src: * const c_char, n: size_t)
239
+ -> * mut c_char;
240
+ pub fn strcat( s: * mut c_char, ct: * const c_char) -> * mut c_char;
241
+ pub fn strncat( s: * mut c_char, ct: * const c_char, n: size_t) -> * mut c_char;
242
+ pub fn strcmp( cs: * const c_char, ct: * const c_char) -> c_int;
243
+ pub fn strncmp( cs: * const c_char, ct: * const c_char, n: size_t) -> c_int;
244
+ pub fn strcoll( cs: * const c_char, ct: * const c_char) -> c_int;
245
+ pub fn strchr( cs: * const c_char, c: c_int) -> * mut c_char;
246
+ pub fn strrchr( cs: * const c_char, c: c_int) -> * mut c_char;
247
+ pub fn strspn( cs: * const c_char, ct: * const c_char) -> size_t;
248
+ pub fn strcspn( cs: * const c_char, ct: * const c_char) -> size_t;
249
+ pub fn strdup( cs: * const c_char) -> * mut c_char;
250
+ pub fn strpbrk( cs: * const c_char, ct: * const c_char) -> * mut c_char;
251
+ pub fn strstr( cs: * const c_char, ct: * const c_char) -> * mut c_char;
252
+ pub fn strlen( cs: * const c_char) -> size_t;
253
+ pub fn strnlen( cs: * const c_char, maxlen: size_t) -> size_t;
254
+ #[ cfg_attr( all( target_os = "macos" , target_arch = "x86" ) ,
255
+ link_name = "strerror$UNIX2003" ) ]
256
+ pub fn strerror( n: c_int) -> * mut c_char;
257
+ pub fn strtok( s: * mut c_char, t: * const c_char) -> * mut c_char;
258
+ pub fn strxfrm( s: * mut c_char, ct: * const c_char, n: size_t) -> size_t;
259
+ pub fn wcslen( buf: * const wchar_t) -> size_t;
260
+ pub fn wcstombs( dest: * mut c_char, src: * const wchar_t, n: size_t) -> :: size_t;
261
+
262
+ pub fn memchr( cx: * const c_void, c: c_int, n: size_t) -> * mut c_void;
263
+ pub fn memcmp( cx: * const c_void, ct: * const c_void, n: size_t) -> c_int;
264
+ pub fn memcpy( dest: * mut c_void, src: * const c_void, n: size_t) -> * mut c_void;
265
+ pub fn memmove( dest: * mut c_void, src: * const c_void, n: size_t) -> * mut c_void;
266
+ pub fn memset( dest: * mut c_void, c: c_int, n: size_t) -> * mut c_void;
267
+ }
263
268
264
- // These are all inline functions on android, so they end up just being entirely
265
- // missing on that platform.
266
- #[ cfg( not( target_os = "android" ) ) ]
267
- extern {
268
- pub fn abs ( i : c_int ) -> c_int ;
269
- pub fn atof ( s : * const c_char ) -> c_double ;
270
- pub fn labs ( i : c_long ) -> c_long ;
271
- pub fn rand ( ) -> c_int ;
272
- pub fn srand ( seed : c_uint ) ;
269
+ // These are all inline functions on android, so they end up just being entirely
270
+ // missing on that platform.
271
+ #[ cfg( not( target_os = "android" ) ) ]
272
+ extern {
273
+ pub fn abs( i: c_int) -> c_int;
274
+ pub fn atof( s: * const c_char) -> c_double;
275
+ pub fn labs( i: c_long) -> c_long;
276
+ pub fn rand( ) -> c_int;
277
+ pub fn srand( seed: c_uint) ;
278
+ }
279
+ }
273
280
}
274
281
275
282
cfg_if ! {
0 commit comments