1#![cfg_attr(not(feature = "rustc-dep-of-std"), no_std)]
2#![cfg_attr(feature = "rustc-dep-of-std", feature(no_core))]
3#![cfg_attr(feature = "rustc-dep-of-std", feature(lang_items))]
4#![cfg_attr(feature = "rustc-dep-of-std", no_core)]
5
6#![allow(non_camel_case_types)]
8
9#[cfg(feature = "rustc-dep-of-std")]
10extern crate rustc_std_workspace_core as core;
11#[cfg(feature = "rustc-dep-of-std")]
12use core::ops;
13
14use core::prelude::v1::*;
15
16pub use core::ffi::c_void;
17
18
19pub type c_char = u8;
20pub type time_t = i32;
21pub type wchar_t = u16;
22pub type c_long = i64;
23pub type c_ulong = u64;
24
25pub type c_schar = i8;
26pub type c_uchar = u8;
27pub type c_short = i16;
28pub type c_ushort = u16;
29pub type c_int = i32;
30pub type c_uint = u32;
31pub type c_float = f32;
32pub type c_double = f64;
33pub type c_longlong = i64;
34pub type c_ulonglong = u64;
35pub type intmax_t = i64;
36pub type uintmax_t = u64;
37
38pub type size_t = usize;
39pub type ptrdiff_t = isize;
40pub type intptr_t = isize;
41pub type uintptr_t = usize;
42pub type ssize_t = isize;
43
44pub type pid_t = i32;
45pub type uid_t = u32;
46pub type gid_t = u32;
47pub type in_addr_t = u32;
48pub type in6_addr_t = [u8; 0x10];
49pub type in_port_t = u16;
50
51pub type mode_t = c_uint;
52pub type off_t = i64;
53
54pub type pthread_t = u64;
55pub type pthread_cond_t = *mut c_void;
56pub type pthread_condattr_t = *mut c_void;
57pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0 as *mut _;
58
59#[repr(C)]
60pub struct sem_t { __size: [c_char; 16],
62}
63
64#[repr(C)]
65pub struct tm {
66 pub tm_sec: c_int,
67 pub tm_min: c_int,
68 pub tm_hour: c_int,
69 pub tm_mday: c_int,
70 pub tm_mon: c_int,
71 pub tm_year: c_int,
72 pub tm_wday: c_int,
73 pub tm_yday: c_int,
74 pub tm_isdst: c_int,
75}
76
77#[cfg(not(feature = "rustc-dep-of-std"))]
78#[allow(non_snake_case, non_upper_case_globals, dead_code)]
79pub mod FileOpenMode {
80 pub const Write: *const u8 = "w\0".as_bytes().as_ptr();
81 pub const Read: *const u8 = "r\0".as_bytes().as_ptr();
82 pub const Append: *const u8 = "a\0".as_bytes().as_ptr();
83 pub const ReadUpdate: *const u8 = "r+\0".as_bytes().as_ptr();
84 pub const WriteUpdate: *const u8 = "w+\0".as_bytes().as_ptr();
85 pub const AppendUpdate: *const u8 = "a+\0".as_bytes().as_ptr();
86}
87
88#[cfg_attr(not(feature = "rustc-dep-of-std"), derive(Debug, Clone, Copy))]
89pub enum FILE {}
90
91#[cfg_attr(not(feature = "rustc-dep-of-std"), derive(Debug, Clone, Copy))]
92pub enum DIR {}
93
94extern "C" {
95 pub fn malloc(size: size_t) -> *mut c_void;
96 pub fn memalign(align: size_t, size: size_t) -> *mut c_void;
97 pub fn free(ptr: *mut c_void);
98 pub fn calloc(num: size_t, size: size_t) -> *mut c_void;
99 pub fn realloc(ptr: *mut c_void, size: size_t) -> *mut c_void;
100 }
102
103pub type pthread_key_t = c_uint;
104pub type clockid_t = i32;
105
106#[repr(C)]
107#[derive(Copy, Clone)]
108pub union pthread_mutex_t {
109 pub __data: __pthread_mutex_s,
110 pub __size: [c_char; 40usize],
111 pub __align: c_long,
112 _bindgen_union_align: [u64; 5usize],
113}
114
115#[repr(C)]
116#[derive(Copy, Clone)]
117pub struct __pthread_mutex_s {
118 pub __lock: c_int,
119 pub __count: c_uint,
120 pub __owner: c_int,
121 pub __nusers: c_uint,
122 pub __kind: c_int,
123 pub __spins: c_short,
124 pub __elision: c_short,
125 pub __list: __pthread_list_t,
126}
127
128#[repr(C)]
129#[derive(Copy, Clone)]
130pub struct __pthread_list_t {
131 pub __prev: *mut __pthread_list_t,
132 pub __next: *mut __pthread_list_t,
133}
134
135#[repr(C)]
136#[derive(Copy, Clone)]
137pub union pthread_mutexattr_t {
138 pub __size: [c_char; 4usize],
139 pub __align: c_int,
140 _bindgen_union_align: u32,
141}
142
143#[repr(C)]
144#[derive(Copy, Clone)]
145pub struct pthread_attr_t {
146 __size: [c_char; 0x38] }
148
149#[repr(C)]
150#[derive(Copy, Clone)]
151pub struct timespec {
152 pub tv_sec: time_t,
153 pub tv_nsec: c_long,
154}
155
156pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
157 __size: [0; 40]
158};
159
160pub const PTHREAD_MUTEX_NORMAL: c_int = 0;
161pub const PTHREAD_MUTEX_RECURSIVE: c_int = 1;
162
163pub const EINTR: c_int = 4;
166pub const EINVAL: c_int = 22;
167pub const EISCONN: c_int = 106;
168
169pub const CLOCK_MONOTONIC: clockid_t = 0;
170pub const CLOCK_REALTIME: clockid_t = 0;
171pub const ETIMEDOUT: c_int = 60;
172
173extern "C" {
174 #[link_name = "__pthread_key_create"]
175 pub fn pthread_key_create(key: *mut pthread_key_t, func: extern fn(*mut c_void)) -> c_int;
176
177 #[link_name = "__pthread_key_delete"]
178 pub fn pthread_key_delete(key: pthread_key_t) -> c_int;
179
180 #[link_name = "__pthread_mutex_lock"]
181 pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> c_int;
182
183 pub fn pthread_setspecific(
184 key: pthread_key_t,
185 value: *const c_void,
186 ) -> c_int;
187 pub fn pthread_getspecific(key: pthread_key_t) -> *mut c_void;
188
189 pub fn pthread_mutexattr_init(
190 attr: *mut pthread_mutexattr_t
191 ) -> c_int;
192
193 pub fn pthread_mutexattr_settype(
194 attr: *mut pthread_mutexattr_t,
195 _type: c_int
196 ) -> c_int;
197
198 pub fn pthread_mutexattr_destroy(
199 attr: *mut pthread_mutexattr_t
200 ) -> c_int;
201
202 pub fn pthread_mutex_trylock(
203 lock: *mut pthread_mutex_t
204 ) -> c_int;
205
206 pub fn pthread_mutex_unlock(
207 lock: *mut pthread_mutex_t
208 ) -> c_int;
209
210 pub fn pthread_mutex_destroy(
211 lock: *mut pthread_mutex_t
212 ) -> c_int;
213
214 pub fn pthread_mutex_init(
215 lock: *mut pthread_mutex_t,
216 attr: *const pthread_mutexattr_t
217 ) -> c_int;
218
219 pub fn pthread_self() -> pthread_t;
220
221 #[link_name = "__pthread_join"]
222 pub fn pthread_join(
223 native: pthread_t,
224 value: *mut *mut c_void,
225 ) -> c_int;
226
227 pub fn pthread_detach(thread: pthread_t) -> c_int;
228
229 pub fn pthread_attr_setstacksize(
230 attr: *mut pthread_attr_t,
231 stack_size: size_t,
232 ) -> c_int;
233
234 pub fn pthread_attr_init(attr: *mut pthread_attr_t) -> c_int;
235
236 pub fn pthread_create(
237 native: *mut pthread_t,
238 attr: *const pthread_attr_t,
239 f: extern "C" fn(*mut c_void) -> *mut c_void,
240 value: *mut c_void,
241 ) -> c_int;
242
243 pub fn pthread_attr_destroy(attr: *mut pthread_attr_t) -> c_int;
244
245 pub fn pthread_setname_np(
246 t: pthread_t,
247 name: *const c_char,
248 arg: *const c_void,
249 ) -> c_int;
250
251 pub fn pthread_condattr_init(attr: *mut pthread_condattr_t) -> c_int;
252
253 pub fn pthread_condattr_setclock(
254 attr: *mut pthread_condattr_t,
255 clock_id: clockid_t,
256 ) -> c_int;
257
258 pub fn pthread_condattr_destroy(attr: *mut pthread_condattr_t) -> c_int;
259 pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> c_int;
260 pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> c_int;
261 pub fn pthread_cond_wait(
262 cond: *mut pthread_cond_t,
263 lock: *mut pthread_mutex_t,
264 ) -> c_int;
265 pub fn clock_gettime(clk_id: clockid_t, tp: *mut timespec) -> c_int;
266 pub fn pthread_cond_timedwait(
267 cond: *mut pthread_cond_t,
268 lock: *mut pthread_mutex_t,
269 abstime: *const timespec,
270 ) -> c_int;
271 pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> c_int;
272 pub fn pthread_cond_init(
273 cond: *mut pthread_cond_t,
274 attr: *const pthread_condattr_t,
275 ) -> c_int;
276}
277
278pub type socklen_t = c_uint;
279pub type sa_family_t = c_char;
280pub type __time_t = time_t;
281pub type __suseconds_t = c_long;
282pub type suseconds_t = c_long;
283pub type nfds_t = c_uint;
284
285#[repr(C)]
286#[derive(Debug, Copy, Clone)]
287pub struct in_addr {
288 pub s_addr: in_addr_t,
289}
290
291#[repr(C)]
292#[derive(Debug, Copy, Clone)]
293pub struct in6_addr {
294 pub s6_addr: in6_addr_t,
295}
296
297#[repr(C)]
298#[derive(Debug, Copy, Clone)]
299pub struct sockaddr_in {
300 pub sin_len: u8,
301 pub sin_family: sa_family_t,
302 pub sin_port: in_port_t,
303 pub sin_addr: in_addr,
304 pub sin_zero: [u8;8]
305}
306
307#[repr(C)]
308#[derive(Debug, Copy, Clone)]
309pub struct sockaddr_in6 {
310 pub sin6_family: sa_family_t,
311 pub sin6_port: in_port_t,
312 pub sin6_flowinfo: u32,
313 pub sin6_addr: in6_addr,
314 pub sin6_scope_id: u32,
315}
316
317#[repr(C)]
318#[derive(Debug, Copy, Clone)]
319pub struct sockaddr {
320 pub sa_len: u8,
321 pub sa_family: sa_family_t,
322 pub sa_data: [c_char; 14usize],
323}
324
325#[repr(C)]
326#[derive(Debug, Copy, Clone)]
327pub struct iovec {
328 pub iov_base: *mut c_void,
329 pub iov_len: size_t,
330}
331
332#[repr(C)]
333#[derive(Debug, Copy, Clone)]
334pub struct msghdr {
335 pub msg_name: *mut c_void,
336 pub msg_namelen: socklen_t,
337 pub msg_iov: *mut iovec,
338 pub msg_iovlen: size_t,
339 pub msg_control: *mut c_void,
340 pub msg_controllen: size_t,
341 pub msg_flags: c_int,
342}
343
344#[repr(C)]
345#[derive(Debug, Copy, Clone)]
346pub struct mmsghdr {
347 pub msg_hdr: msghdr,
348 pub msg_len: c_uint,
349}
350
351#[repr(C)]
352#[derive(Debug, Copy, Clone)]
353pub struct timeval {
354 pub tv_sec: __time_t,
355 pub tv_usec: __suseconds_t,
356}
357
358#[repr(C)]
359#[derive(Copy, Clone)]
360pub struct sockaddr_storage {
361 pub sin_len: u8,
362 pub ss_family: sa_family_t,
363 pub __ss_padding: [c_char; 118usize],
364 pub __ss_align: c_ulong,
365}
366
367#[repr(C)]
368#[derive(Copy, Clone)]
369pub struct pollfd {
370 pub fd: c_int,
371 pub events: c_short,
372 pub revents: c_short,
373}
374
375#[repr(C)]
376#[derive(Copy, Clone, Debug)]
377pub struct addrinfo {
378 pub ai_flags: c_int, pub ai_family: c_int,pub ai_socktype: c_int, pub ai_protocol: c_int, pub ai_addrlen: socklen_t, pub ai_canonname: *const c_char, pub ai_addr: *const sockaddr, pub ai_next: *mut addrinfo, }
387
388#[repr(C)]
389#[derive(Copy, Clone, Debug)]
390pub struct ip_mreq {
391 pub imr_multiaddr: in_addr,
392 pub imr_interface: in_addr,
393}
394
395#[repr(C)]
396#[derive(Copy, Clone, Debug)]
397pub struct ipv6_mreq {
398 pub ipv6mr_multiaddr: in6_addr,
399 pub ipv6mr_interface: c_uint,
400}
401
402#[repr(C)]
403#[derive(Copy, Clone, Debug)]
404pub struct linger
405{
406 pub l_onoff: i32,
407 pub l_linger: i32,
408}
409
410pub const SHUT_RD: c_int = 0;
411pub const SHUT_WR: c_int = 1;
412pub const SHUT_RDWR: c_int = 2;
413
414pub const TCP_NODELAY: c_int = 1;
415pub const TCP_MAXSEG: c_int = 2;
416pub const TCP_KEEPINTVL: c_int = 512;
417pub const TCP_KEEPCNT: c_int = 1024;
418
419
420pub const IPPROTO_ICMP: c_int = 1;
421pub const IPPROTO_ICMPV6: c_int = 58;
422pub const IPPROTO_TCP: c_int = 6;
423pub const IPPROTO_UDP: c_int = 17;
424pub const IPPROTO_IP: c_int = 0;
425pub const IPPROTO_IPV6: c_int = 41;
426
427pub const SO_ERROR: c_int = 0x1007;
428pub const SOL_SOCKET: c_int = 0xffff;
429pub const FIONBIO: c_uint = 0x8004667e;
430pub const EINPROGRESS: c_int = 115;
431
432pub const AF_INET: c_int = 2;
433pub const AF_INET6: c_int = 24;
434
435pub const POLLIN: c_short = 0x1;
436pub const POLLPRI: c_short = 0x2;
437pub const POLLOUT: c_short = 0x4;
438pub const POLLERR: c_short = 0x8;
439pub const POLLHUP: c_short = 0x10;
440pub const POLLNVAL: c_short = 0x20;
441pub const POLLRDNORM: c_short = 0x040;
442pub const POLLWRNORM: c_short = 0x004;
443pub const POLLRDBAND: c_short = 0x080;
444pub const POLLWRBAND: c_short = 0x100;
445
446pub const MSG_OOB: c_int = 0x1;
447pub const MSG_PEEK: c_int = 0x2;
448pub const MSG_TRUNC: c_int = 0x10;
449
450pub const EAI_NODATA: c_int = 7;
451pub const EAI_SYSTEM: c_int = 11;
452
453pub const IPV6_UNICAST_HOPS: c_int = 4;
454pub const IP_MULTICAST_IF: c_int = 9;
455pub const IPV6_MULTICAST_IF: c_int = 9;
456pub const IPV6_MULTICAST_HOPS: c_int = 10;
457pub const IPV6_MULTICAST_LOOP: c_int = 11;
458pub const IP_ADD_MEMBERSHIP: c_int = 12;
459pub const IPV6_ADD_MEMBERSHIP: c_int = 12; pub const IP_DROP_MEMBERSHIP: c_int = 13;
461pub const IPV6_DROP_MEMBERSHIP: c_int = 13;
462
463pub const SOCK_STREAM: c_int = 1;
464pub const SOCK_DGRAM: c_int = 2;
465pub const SOCK_RAW: c_int = 3;
466pub const SOCK_RDM: c_int = 4;
467pub const SOCK_SEQPACKET: c_int = 5;
468
469pub const SO_SNDBUF: c_int = 0x1001;
470pub const SO_RCVBUF: c_int = 0x1002;
471pub const SO_SNDTIMEO: c_int = 0x1005;
472pub const SO_RCVTIMEO: c_int = 0x1006;
473pub const SO_TYPE: c_int = 0x1008;
474
475pub const IP_TOS: c_int = 3;
476pub const IP_TTL: c_int = 4;
477pub const IP_RECVOPTS: c_int = 5;
478pub const SO_REUSEADDR: c_int = 4;
479pub const IPV6_V6ONLY: c_int = 27;
480pub const IP_MULTICAST_TTL: c_int = 10;
481pub const IP_MULTICAST_LOOP: c_int = 11;
482pub const IP_RECVTOS: c_int = 168;
483
484pub const FIOCLEX: c_uint = 0x20006601;
485pub const O_NONBLOCK: c_int = 0x800;
487pub const F_DUPFD: c_int = 0;
488pub const F_GETFD: c_int = 1;
489pub const F_SETFD: c_int = 2;
490pub const F_GETFL: c_int = 3;
491pub const F_SETFL: c_int = 4;
492pub const F_DUPFD_CLOEXEC: c_int = 17;
493
494pub const SO_KEEPALIVE: c_int = 0x0008;
495pub const SO_BROADCAST: c_int = 0x20;
496pub const SO_LINGER: c_int = 0x80;
497pub const SO_OOBINLINE: c_int = 0x100;
498
499pub const INADDR_ANY: c_int = 0;
500
501extern "C" {
502 #[link_name = "nnsocketIoctl"]
503 pub fn ioctl(fd: c_int, request: c_uint, ...) -> c_int;
504
505 #[link_name = "nnsocketFreeAddrInfo"]
506 pub fn freeaddrinfo(res: *mut addrinfo);
507
508 #[link_name = "nnsocketGetAddrInfo"]
509 pub fn getaddrinfo(
510 node: *const c_char,
511 service: *const c_char,
512 hints: *const addrinfo,
513 res: *mut *mut addrinfo
514 ) -> c_int;
515
516 #[link_name = "nnsocketFcntl"]
517 pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int;
518
519 pub fn pread(
520 fd: c_int,
521 buf: *mut c_void,
522 count: size_t,
523 offset: off_t
524 ) -> ssize_t;
525}
526
527pub unsafe fn writev(
528 _fd: c_int,
529 _buf: *const iovec,
530 _count: c_int,
531) -> ssize_t {
532 -1
539}
540
541pub unsafe fn readv(_fd: c_int, _buf: *const iovec, _count: c_int) -> ssize_t {
542 -1
549}
550
551pub fn socketpair(
552 __domain: c_int,
553 __type: c_int,
554 __protocol: c_int,
555 __fds: *mut c_int,
556) -> c_int {
557 -1
558}
559
560extern "C" {
562 #[link_name = "nnsocketSocket"]
563 pub fn socket(
564 __domain: c_int,
565 __type: c_int,
566 __protocol: c_int,
567 ) -> c_int;
568 #[link_name = "nnsocketBind"]
569 pub fn bind(
570 __fd: c_int,
571 __addr: *const sockaddr,
572 __len: socklen_t,
573 ) -> c_int;
574 #[link_name = "nnsocketGetSockName"]
575 pub fn getsockname(
576 __fd: c_int,
577 __addr: *mut sockaddr,
578 __len: *mut socklen_t,
579 ) -> c_int;
580 #[link_name = "nnsocketConnect"]
581 pub fn connect(
582 __fd: c_int,
583 __addr: *const sockaddr,
584 __len: socklen_t,
585 ) -> c_int;
586 #[link_name = "nnsocketGetPeerName"]
587 pub fn getpeername(
588 __fd: c_int,
589 __addr: *mut sockaddr,
590 __len: *mut socklen_t,
591 ) -> c_int;
592 #[link_name = "nnsocketSend"]
593 pub fn send(
594 __fd: c_int,
595 __buf: *const c_void,
596 __n: size_t,
597 __flags: c_int,
598 ) -> ssize_t;
599 #[link_name = "nnsocketRecv"]
600 pub fn recv(
601 __fd: c_int,
602 __buf: *mut c_void,
603 __n: size_t,
604 __flags: c_int,
605 ) -> ssize_t;
606 #[link_name = "nnsocketSendTo"]
607 pub fn sendto(
608 __fd: c_int,
609 __buf: *const c_void,
610 __n: size_t,
611 __flags: c_int,
612 __addr: *const sockaddr,
613 __addr_len: socklen_t,
614 ) -> ssize_t;
615 #[link_name = "nnsocketRecvFrom"]
616 pub fn recvfrom(
617 __fd: c_int,
618 __buf: *mut c_void,
619 __n: size_t,
620 __flags: c_int,
621 __addr: *mut sockaddr,
622 __addr_len: *mut socklen_t,
623 ) -> ssize_t;
624 #[link_name = "nnsocketSendMsg"]
625 pub fn sendmsg(
626 __fd: c_int,
627 __message: *const msghdr,
628 __flags: c_int,
629 ) -> ssize_t;
630 #[link_name = "nnsocketRecvMsg"]
637 pub fn recvmsg(
638 __fd: c_int,
639 __message: *mut msghdr,
640 __flags: c_int,
641 ) -> ssize_t;
642 #[link_name = "nnsocketGetSockOpt"]
650 pub fn getsockopt(
651 __fd: c_int,
652 __level: c_int,
653 __optname: c_int,
654 __optval: *mut c_void,
655 __optlen: *mut socklen_t,
656 ) -> c_int;
657 #[link_name = "nnsocketSetSockOpt"]
658 pub fn setsockopt(
659 __fd: c_int,
660 __level: c_int,
661 __optname: c_int,
662 __optval: *const c_void,
663 __optlen: socklen_t,
664 ) -> c_int;
665
666 #[link_name = "nnsocketListen"]
667 pub fn listen(__fd: c_int, __n: c_int) -> c_int;
668 #[link_name = "nnsocketAccept"]
669 pub fn accept(
670 __fd: c_int,
671 __addr: *mut sockaddr,
672 __addr_len: *mut socklen_t,
673 ) -> c_int;
674 #[link_name = "nnsocketShutdown"]
682 pub fn shutdown(
683 __fd: c_int,
684 __how: c_int,
685 ) -> c_int;
686 #[link_name = "nnsocketSockAtMark"]
687 pub fn sockatmark(__fd: c_int) -> c_int;
688 #[link_name = "nnsocketPoll"]
689 pub fn poll(
690 fds: *mut pollfd,
691 nfds: nfds_t,
692 timeout: c_int
693 ) -> c_int;
694}
695
696extern "C" {
697 #[link_name = "__nnmusl_ErrnoLocation"]
698 pub fn errno_loc() -> *mut i64;
699}
700
701pub fn gai_strerror(_: c_int) -> *const c_char {
702 "invalid error, no gai_strerror present\0".as_ptr() as _
703}
704
705extern "C" {
706 pub fn isalnum(c: c_int) -> c_int;
707 pub fn isalpha(c: c_int) -> c_int;
708 pub fn iscntrl(c: c_int) -> c_int;
709 pub fn isdigit(c: c_int) -> c_int;
710 pub fn isgraph(c: c_int) -> c_int;
711 pub fn islower(c: c_int) -> c_int;
712 pub fn isprint(c: c_int) -> c_int;
713 pub fn ispunct(c: c_int) -> c_int;
714 pub fn isspace(c: c_int) -> c_int;
715 pub fn isupper(c: c_int) -> c_int;
716 pub fn isxdigit(c: c_int) -> c_int;
717 pub fn isblank(c: c_int) -> c_int;
718 pub fn tolower(c: c_int) -> c_int;
719 pub fn toupper(c: c_int) -> c_int;
720
721 pub fn qsort(
722 base: *mut c_void,
723 num: size_t,
724 size: size_t,
725 compar: unsafe extern "C" fn(*const c_void, *const c_void) -> c_int,
726 );
727 pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE;
728 pub fn fflush(file: *mut FILE) -> c_int;
729 pub fn fclose(file: *mut FILE) -> c_int;
730 pub fn remove(filename: *const c_char) -> c_int;
731 pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int;
732 pub fn setvbuf(
733 stream: *mut FILE,
734 buffer: *mut c_char,
735 mode: c_int,
736 size: size_t,
737 ) -> c_int;
738 pub fn setbuf(stream: *mut FILE, buf: *mut c_char);
739 pub fn getchar() -> c_int;
740 pub fn putchar(c: c_int) -> c_int;
741 pub fn fgetc(stream: *mut FILE) -> c_int;
742 pub fn fputc(c: c_int, stream: *mut FILE) -> c_int;
743 pub fn puts(s: *const c_char) -> c_int;
744 pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int;
745 pub fn fwrite(
746 ptr: *const c_void,
747 size: size_t,
748 nobj: size_t,
749 stream: *mut FILE,
750 ) -> size_t;
751 pub fn fread_unlocked(
752 ptr: *mut c_void,
753 size: size_t,
754 nobj: size_t,
755 stream: *mut FILE,
756 ) -> size_t;
757 pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int;
758 pub fn ftell(stream: *mut FILE) -> c_long;
759 pub fn rewind(stream: *mut FILE);
760
761 pub fn perror(s: *const c_char);
762 pub fn atoi(s: *const c_char) -> c_int;
763
764 pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
765 pub fn strtol(
766 s: *const c_char,
767 endp: *mut *mut c_char,
768 base: c_int,
769 ) -> c_long;
770
771 pub fn abort() -> !;
772 pub fn exit(status: c_int) -> !;
773
774 pub fn atexit(cb: extern "C" fn()) -> c_int;
775
776 pub fn getenv(s: *const c_char) -> *mut c_char;
777
778 pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char;
779 pub fn strncpy(
780 dst: *mut c_char,
781 src: *const c_char,
782 n: size_t,
783 ) -> *mut c_char;
784 pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char;
785 pub fn strncat(
786 s: *mut c_char,
787 ct: *const c_char,
788 n: size_t,
789 ) -> *mut c_char;
790 pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int;
791 pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int;
792 pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int;
793 pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char;
794 pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char;
795 pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t;
796 pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t;
797 pub fn strdup(cs: *const c_char) -> *mut c_char;
798 pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char;
799 pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char;
800 pub fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int;
801 pub fn strncasecmp(
802 s1: *const c_char,
803 s2: *const c_char,
804 n: size_t,
805 ) -> c_int;
806 pub fn strlen(cs: *const c_char) -> size_t;
807 pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t;
808
809 pub fn strerror(n: c_int) -> *mut c_char;
810 pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char;
811 pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t;
812
813 pub fn wcslen(buf: *const wchar_t) -> size_t;
814 pub fn wcstombs(
815 dest: *mut c_char,
816 src: *const wchar_t,
817 n: size_t,
818 ) -> size_t;
819
820 pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void;
821 pub fn wmemchr(cx: *const wchar_t, c: wchar_t, n: size_t) -> *mut wchar_t;
822 pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int;
823 pub fn memcpy(
824 dest: *mut c_void,
825 src: *const c_void,
826 n: size_t,
827 ) -> *mut c_void;
828
829 pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void;
830
831 pub fn fprintf(
832 stream: *mut FILE,
833 format: *const c_char,
834 ...
835 ) -> c_int;
836 pub fn printf(format: *const c_char, ...) -> c_int;
837 pub fn snprintf(
838 s: *mut c_char,
839 n: size_t,
840 format: *const c_char,
841 ...
842 ) -> c_int;
843 pub fn sprintf(s: *mut c_char, format: *const c_char, ...) -> c_int;
844 pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int;
845
846 pub fn access(path: *const c_char, amode: c_int) -> c_int;
847
848 pub fn chdir(dir: *const c_char) -> c_int;
849
850 pub fn close(fd: c_int) -> c_int;
851
852 pub fn getpid() -> pid_t;
853
854 pub fn lseek(fd: c_int, offset: off_t, whence: c_int) -> off_t;
855
856 pub fn posix_memalign(
857 memptr: *mut *mut c_void,
858 align: size_t,
859 size: size_t,
860 ) -> c_int;
861
862 pub fn rmdir(path: *const c_char) -> c_int;
863 pub fn sleep(secs: c_uint) -> c_uint;
864 pub fn read(fd: c_int, buf: *const c_void, count: size_t)
865 -> ssize_t;
866
867 pub fn open(path: *const c_char, oflag: c_int, ...) -> c_int;
868
869 pub fn unlink(c: *const c_char) -> c_int;
870
871 pub fn write(
872 fd: c_int,
873 buf: *const c_void,
874 count: size_t,
875 ) -> ssize_t;
876
877 pub fn pwrite(
878 fd: c_int,
879 buf: *const c_void,
880 count: size_t,
881 offset: off_t,
882 ) -> ssize_t;
883
884 pub fn setenv(
885 name: *const c_char,
886 val: *const c_char,
887 overwrite: c_int,
888 ) -> c_int;
889
890 pub fn unsetenv(name: *const c_char) -> c_int;
891
892 pub fn ftruncate(fd: c_int, length: off_t) -> c_int;
893
894 pub fn sched_yield() -> c_int;
895
896 pub fn mktime(tm: *mut tm) -> time_t;
897 pub fn time(time: *mut time_t) -> time_t;
898 pub fn gmtime(time_p: *const time_t) -> *mut tm;
899 pub fn localtime(time_p: *const time_t) -> *mut tm;
900 pub fn difftime(time1: time_t, time0: time_t) -> c_double;
901
902 pub fn putenv(string: *mut c_char) -> c_int;
903
904 pub fn setlocale(
905 category: c_int,
906 locale: *const c_char,
907 ) -> *mut c_char;
908
909 pub fn sem_wait(sem: *mut sem_t) -> c_int;
910 pub fn sem_trywait(sem: *mut sem_t) -> c_int;
911 pub fn sem_post(sem: *mut sem_t) -> c_int;
912
913 pub fn strcasestr(cs: *const c_char, ct: *const c_char) -> *mut c_char;
914 pub fn getline(
915 lineptr: *mut *mut c_char,
916 n: *mut size_t,
917 stream: *mut FILE,
918 ) -> ssize_t;
919
920 pub fn fdopendir(fd: c_int) -> *mut DIR;
921
922 pub fn nanosleep(a: *const timespec, b: *mut timespec) -> c_int;
923}
924
925#[cfg(not(feature = "rustc-dep-of-std"))]
926pub fn fwrite_slice<T: Sized>(slice: &[T], stream: *mut FILE) -> size_t {
927 unsafe {
928 fwrite(
929 slice.as_ptr() as _,
930 core::mem::size_of::<T>(),
931 slice.len(),
932 stream
933 )
934 }
935}