1 //! ARMv6K Nintendo 3DS C Newlib definitions
2 
3 pub type c_char = u8;
4 pub type c_long = i32;
5 pub type c_ulong = u32;
6 
7 pub type wchar_t = ::c_uint;
8 
9 pub type u_register_t = ::c_uint;
10 pub type u_char = ::c_uchar;
11 pub type u_short = ::c_ushort;
12 pub type u_int = ::c_uint;
13 pub type u_long = c_ulong;
14 pub type ushort = ::c_ushort;
15 pub type uint = ::c_uint;
16 pub type ulong = c_ulong;
17 pub type clock_t = c_ulong;
18 pub type daddr_t = c_long;
19 pub type caddr_t = *mut c_char;
20 pub type sbintime_t = ::c_longlong;
21 pub type sigset_t = ::c_ulong;
22 
23 s! {
24     pub struct hostent {
25         pub h_name: *mut ::c_char,
26         pub h_aliases: *mut *mut ::c_char,
27         pub h_addrtype: u16,
28         pub h_length: u16,
29         pub h_addr_list: *mut *mut ::c_char,
30     }
31 
32     pub struct sockaddr {
33         pub sa_family: ::sa_family_t,
34         pub sa_data: [::c_char; 26usize],
35     }
36 
37     pub struct sockaddr_storage {
38         pub ss_family: ::sa_family_t,
39         pub __ss_padding: [::c_char; 26usize],
40     }
41 
42     pub struct sockaddr_in {
43         pub sin_family: ::sa_family_t,
44         pub sin_port: ::in_port_t,
45         pub sin_addr: ::in_addr,
46         pub sin_zero: [::c_char; 8],
47     }
48 
49     pub struct sockaddr_in6 {
50         pub sin6_family: ::sa_family_t,
51         pub sin6_port: ::in_port_t,
52         pub sin6_flowinfo: u32,
53         pub sin6_addr: ::in6_addr,
54         pub sin6_scope_id: u32,
55     }
56 
57     pub struct sockaddr_un {
58         pub sun_len: ::c_uchar,
59         pub sun_family: ::sa_family_t,
60         pub sun_path: [::c_char; 104usize],
61     }
62 
63     pub struct sched_param {
64         pub sched_priority: ::c_int,
65     }
66 
67     pub struct stat {
68         pub st_dev: ::dev_t,
69         pub st_ino: ::ino_t,
70         pub st_mode: ::mode_t,
71         pub st_nlink: ::nlink_t,
72         pub st_uid: ::uid_t,
73         pub st_gid: ::gid_t,
74         pub st_rdev: ::dev_t,
75         pub st_size: ::off_t,
76         pub st_atim: ::timespec,
77         pub st_mtim: ::timespec,
78         pub st_ctim: ::timespec,
79         pub st_blksize: ::blksize_t,
80         pub st_blocks: ::blkcnt_t,
81         pub st_spare4: [::c_long; 2usize],
82     }
83 }
84 
85 pub const SIGEV_NONE: ::c_int = 1;
86 pub const SIGEV_SIGNAL: ::c_int = 2;
87 pub const SIGEV_THREAD: ::c_int = 3;
88 pub const SA_NOCLDSTOP: ::c_int = 1;
89 pub const MINSIGSTKSZ: ::c_int = 2048;
90 pub const SIGSTKSZ: ::c_int = 8192;
91 pub const SS_ONSTACK: ::c_int = 1;
92 pub const SS_DISABLE: ::c_int = 2;
93 pub const SIG_SETMASK: ::c_int = 0;
94 pub const SIG_BLOCK: ::c_int = 1;
95 pub const SIG_UNBLOCK: ::c_int = 2;
96 pub const SIGHUP: ::c_int = 1;
97 pub const SIGINT: ::c_int = 2;
98 pub const SIGQUIT: ::c_int = 3;
99 pub const SIGILL: ::c_int = 4;
100 pub const SIGTRAP: ::c_int = 5;
101 pub const SIGABRT: ::c_int = 6;
102 pub const SIGEMT: ::c_int = 7;
103 pub const SIGFPE: ::c_int = 8;
104 pub const SIGKILL: ::c_int = 9;
105 pub const SIGBUS: ::c_int = 10;
106 pub const SIGSEGV: ::c_int = 11;
107 pub const SIGSYS: ::c_int = 12;
108 pub const SIGPIPE: ::c_int = 13;
109 pub const SIGALRM: ::c_int = 14;
110 pub const SIGTERM: ::c_int = 15;
111 pub const SIGURG: ::c_int = 16;
112 pub const SIGSTOP: ::c_int = 17;
113 pub const SIGTSTP: ::c_int = 18;
114 pub const SIGCONT: ::c_int = 19;
115 pub const SIGCHLD: ::c_int = 20;
116 pub const SIGCLD: ::c_int = 20;
117 pub const SIGTTIN: ::c_int = 21;
118 pub const SIGTTOU: ::c_int = 22;
119 pub const SIGIO: ::c_int = 23;
120 pub const SIGPOLL: ::c_int = 23;
121 pub const SIGXCPU: ::c_int = 24;
122 pub const SIGXFSZ: ::c_int = 25;
123 pub const SIGVTALRM: ::c_int = 26;
124 pub const SIGPROF: ::c_int = 27;
125 pub const SIGWINCH: ::c_int = 28;
126 pub const SIGLOST: ::c_int = 29;
127 pub const SIGUSR1: ::c_int = 30;
128 pub const SIGUSR2: ::c_int = 31;
129 pub const NSIG: ::c_int = 32;
130 pub const CLOCK_ENABLED: ::c_uint = 1;
131 pub const CLOCK_DISABLED: ::c_uint = 0;
132 pub const CLOCK_ALLOWED: ::c_uint = 1;
133 pub const CLOCK_DISALLOWED: ::c_uint = 0;
134 pub const TIMER_ABSTIME: ::c_uint = 4;
135 pub const SOL_SOCKET: ::c_int = 65535;
136 pub const MSG_OOB: ::c_int = 1;
137 pub const MSG_PEEK: ::c_int = 2;
138 pub const MSG_DONTWAIT: ::c_int = 4;
139 pub const MSG_DONTROUTE: ::c_int = 0;
140 pub const MSG_WAITALL: ::c_int = 0;
141 pub const MSG_MORE: ::c_int = 0;
142 pub const MSG_NOSIGNAL: ::c_int = 0;
143 pub const SOL_CONFIG: ::c_uint = 65534;
144 
145 pub const _SC_PAGESIZE: ::c_int = 8;
146 pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 51;
147 
148 pub const PTHREAD_STACK_MIN: ::size_t = 4096;
149 pub const WNOHANG: ::c_int = 1;
150 
151 pub const POLLIN: ::c_short = 0x0001;
152 pub const POLLPRI: ::c_short = 0x0002;
153 pub const POLLOUT: ::c_short = 0x0004;
154 pub const POLLRDNORM: ::c_short = 0x0040;
155 pub const POLLWRNORM: ::c_short = POLLOUT;
156 pub const POLLRDBAND: ::c_short = 0x0080;
157 pub const POLLWRBAND: ::c_short = 0x0100;
158 pub const POLLERR: ::c_short = 0x0008;
159 pub const POLLHUP: ::c_short = 0x0010;
160 pub const POLLNVAL: ::c_short = 0x0020;
161 
162 pub const EAI_AGAIN: ::c_int = 2;
163 pub const EAI_BADFLAGS: ::c_int = 3;
164 pub const EAI_FAIL: ::c_int = 4;
165 pub const EAI_SERVICE: ::c_int = 9;
166 pub const EAI_SYSTEM: ::c_int = 11;
167 pub const EAI_BADHINTS: ::c_int = 12;
168 pub const EAI_PROTOCOL: ::c_int = 13;
169 pub const EAI_OVERFLOW: ::c_int = 14;
170 pub const EAI_MAX: ::c_int = 15;
171 
172 pub const AF_UNIX: ::c_int = 1;
173 pub const AF_INET6: ::c_int = 23;
174 
175 pub const FIONBIO: ::c_ulong = 1;
176 
177 pub const RTLD_DEFAULT: *mut ::c_void = 0 as *mut ::c_void;
178 
179 // For pthread get/setschedparam
180 pub const SCHED_FIFO: ::c_int = 1;
181 pub const SCHED_RR: ::c_int = 2;
182 
183 // For getrandom()
184 pub const GRND_NONBLOCK: ::c_uint = 0x1;
185 pub const GRND_RANDOM: ::c_uint = 0x2;
186 
187 // Horizon OS works doesn't or can't hold any of this information
188 safe_f! {
189     pub {const} fn WIFSTOPPED(_status: ::c_int) -> bool {
190         false
191     }
192 
193     pub {const} fn WSTOPSIG(_status: ::c_int) -> ::c_int {
194         0
195     }
196 
197     pub {const} fn WIFCONTINUED(_status: ::c_int) -> bool {
198         true
199     }
200 
201     pub {const} fn WIFSIGNALED(_status: ::c_int) -> bool {
202         false
203     }
204 
205     pub {const} fn WTERMSIG(_status: ::c_int) -> ::c_int {
206         0
207     }
208 
209     pub {const} fn WIFEXITED(_status: ::c_int) -> bool {
210         true
211     }
212 
213     pub {const} fn WEXITSTATUS(_status: ::c_int) -> ::c_int {
214         0
215     }
216 
217     pub {const} fn WCOREDUMP(_status: ::c_int) -> bool {
218         false
219     }
220 }
221 
222 extern "C" {
pthread_create( native: *mut ::pthread_t, attr: *const ::pthread_attr_t, f: extern "C" fn(_: *mut ::c_void) -> *mut ::c_void, value: *mut ::c_void, ) -> ::c_int223     pub fn pthread_create(
224         native: *mut ::pthread_t,
225         attr: *const ::pthread_attr_t,
226         f: extern "C" fn(_: *mut ::c_void) -> *mut ::c_void,
227         value: *mut ::c_void,
228     ) -> ::c_int;
229 
pthread_attr_getschedparam( attr: *const ::pthread_attr_t, param: *mut sched_param, ) -> ::c_int230     pub fn pthread_attr_getschedparam(
231         attr: *const ::pthread_attr_t,
232         param: *mut sched_param,
233     ) -> ::c_int;
234 
pthread_attr_setschedparam( attr: *mut ::pthread_attr_t, param: *const sched_param, ) -> ::c_int235     pub fn pthread_attr_setschedparam(
236         attr: *mut ::pthread_attr_t,
237         param: *const sched_param,
238     ) -> ::c_int;
239 
pthread_attr_getprocessorid_np( attr: *const ::pthread_attr_t, processor_id: *mut ::c_int, ) -> ::c_int240     pub fn pthread_attr_getprocessorid_np(
241         attr: *const ::pthread_attr_t,
242         processor_id: *mut ::c_int,
243     ) -> ::c_int;
244 
pthread_attr_setprocessorid_np( attr: *mut ::pthread_attr_t, processor_id: ::c_int, ) -> ::c_int245     pub fn pthread_attr_setprocessorid_np(
246         attr: *mut ::pthread_attr_t,
247         processor_id: ::c_int,
248     ) -> ::c_int;
249 
pthread_getschedparam( native: ::pthread_t, policy: *mut ::c_int, param: *mut ::sched_param, ) -> ::c_int250     pub fn pthread_getschedparam(
251         native: ::pthread_t,
252         policy: *mut ::c_int,
253         param: *mut ::sched_param,
254     ) -> ::c_int;
255 
pthread_setschedparam( native: ::pthread_t, policy: ::c_int, param: *const ::sched_param, ) -> ::c_int256     pub fn pthread_setschedparam(
257         native: ::pthread_t,
258         policy: ::c_int,
259         param: *const ::sched_param,
260     ) -> ::c_int;
261 
pthread_condattr_getclock( attr: *const ::pthread_condattr_t, clock_id: *mut ::clockid_t, ) -> ::c_int262     pub fn pthread_condattr_getclock(
263         attr: *const ::pthread_condattr_t,
264         clock_id: *mut ::clockid_t,
265     ) -> ::c_int;
266 
pthread_condattr_setclock( attr: *mut ::pthread_condattr_t, clock_id: ::clockid_t, ) -> ::c_int267     pub fn pthread_condattr_setclock(
268         attr: *mut ::pthread_condattr_t,
269         clock_id: ::clockid_t,
270     ) -> ::c_int;
271 
pthread_getprocessorid_np() -> ::c_int272     pub fn pthread_getprocessorid_np() -> ::c_int;
273 
getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t274     pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
275 
gethostid() -> ::c_long276     pub fn gethostid() -> ::c_long;
277 }
278 
279 pub use crate::unix::newlib::generic::dirent;
280