1
+ const std = @import ("../std.zig" );
2
+ const builtin = @import ("builtin" );
3
+ const maxInt = std .math .maxInt ;
4
+ const emscripten = std .os .emscripten ;
5
+ const wasi = std .os .wasi ;
6
+ const iovec = std .os .iovec ;
7
+ const iovec_const = std .os .iovec_const ;
8
+ const FILE = std .c .FILE ;
9
+
10
+ pub const AF = emscripten .AF ;
11
+ pub const AT = emscripten .AT ;
12
+ pub const CLOCK = emscripten .CLOCK ;
13
+ pub const CPU_COUNT = emscripten .CPU_COUNT ;
14
+ pub const E = emscripten .E ;
15
+ pub const F = emscripten .F ;
16
+ pub const FD_CLOEXEC = emscripten .FD_CLOEXEC ;
17
+ pub const F_OK = emscripten .F_OK ;
18
+ pub const Flock = emscripten .Flock ;
19
+ pub const IFNAMESIZE = emscripten .IFNAMESIZE ;
20
+ pub const IOV_MAX = emscripten .IOV_MAX ;
21
+ pub const IPPROTO = emscripten .IPPROTO ;
22
+ pub const LOCK = emscripten .LOCK ;
23
+ pub const MADV = emscripten .MADV ;
24
+ pub const MAP = struct {
25
+ pub usingnamespace emscripten .MAP ;
26
+ /// Only used by libc to communicate failure.
27
+ pub const FAILED = @as (* anyopaque , @ptrFromInt (maxInt (usize )));
28
+ };
29
+ pub const MSF = emscripten .MSF ;
30
+ pub const MSG = emscripten .MSG ;
31
+ pub const NAME_MAX = emscripten .NAME_MAX ;
32
+ pub const O = emscripten .O ;
33
+ pub const PATH_MAX = emscripten .PATH_MAX ;
34
+ pub const POLL = emscripten .POLL ;
35
+ pub const PROT = emscripten .PROT ;
36
+ pub const REG = emscripten .REG ;
37
+ pub const RLIM = emscripten .RLIM ;
38
+ pub const R_OK = emscripten .R_OK ;
39
+ pub const S = emscripten .S ;
40
+ pub const SA = emscripten .SA ;
41
+ pub const SEEK = emscripten .SEEK ;
42
+ pub const SHUT = emscripten .SHUT ;
43
+ pub const SIG = emscripten .SIG ;
44
+ pub const SIOCGIFINDEX = emscripten .SIOCGIFINDEX ;
45
+ pub const SO = emscripten .SO ;
46
+ pub const SOCK = emscripten .SOCK ;
47
+ pub const SOL = emscripten .SOL ;
48
+ pub const STDERR_FILENO = emscripten .STDERR_FILENO ;
49
+ pub const STDIN_FILENO = emscripten .STDIN_FILENO ;
50
+ pub const STDOUT_FILENO = emscripten .STDOUT_FILENO ;
51
+ pub const Sigaction = emscripten .Sigaction ;
52
+ pub const TCP = emscripten .TCP ;
53
+ pub const TCSA = emscripten .TCSA ;
54
+ pub const W = emscripten .W ;
55
+ pub const W_OK = emscripten .W_OK ;
56
+ pub const X_OK = emscripten .X_OK ;
57
+ pub const addrinfo = emscripten .addrinfo ;
58
+ pub const blkcnt_t = emscripten .blkcnt_t ;
59
+ pub const blksize_t = emscripten .blksize_t ;
60
+ pub const clock_t = emscripten .clock_t ;
61
+ pub const cpu_set_t = emscripten .cpu_set_t ;
62
+ pub const dev_t = emscripten .dev_t ;
63
+ pub const dl_phdr_info = emscripten .dl_phdr_info ;
64
+ pub const empty_sigset = emscripten .empty_sigset ;
65
+ pub const fd_t = emscripten .fd_t ;
66
+ pub const gid_t = emscripten .gid_t ;
67
+ pub const ifreq = emscripten .ifreq ;
68
+ pub const ino_t = emscripten .ino_t ;
69
+ pub const mcontext_t = emscripten .mcontext_t ;
70
+ pub const mode_t = emscripten .mode_t ;
71
+ pub const msghdr = emscripten .msghdr ;
72
+ pub const msghdr_const = emscripten .msghdr_const ;
73
+ pub const nfds_t = emscripten .nfds_t ;
74
+ pub const nlink_t = emscripten .nlink_t ;
75
+ pub const off_t = emscripten .off_t ;
76
+ pub const pid_t = emscripten .pid_t ;
77
+ pub const pollfd = emscripten .pollfd ;
78
+ pub const rlim_t = emscripten .rlim_t ;
79
+ pub const rlimit = emscripten .rlimit ;
80
+ pub const rlimit_resource = emscripten .rlimit_resource ;
81
+ pub const rusage = emscripten .rusage ;
82
+ pub const siginfo_t = emscripten .siginfo_t ;
83
+ pub const sigset_t = emscripten .sigset_t ;
84
+ pub const sockaddr = emscripten .sockaddr ;
85
+ pub const socklen_t = emscripten .socklen_t ;
86
+ pub const stack_t = emscripten .stack_t ;
87
+ pub const tcflag_t = emscripten .tcflag_t ;
88
+ pub const termios = emscripten .termios ;
89
+ pub const time_t = emscripten .time_t ;
90
+ pub const timespec = emscripten .timespec ;
91
+ pub const timeval = emscripten .timeval ;
92
+ pub const timezone = emscripten .timezone ;
93
+ pub const ucontext_t = emscripten .ucontext_t ;
94
+ pub const uid_t = emscripten .uid_t ;
95
+ pub const utsname = emscripten .utsname ;
96
+
97
+ pub const _errno = struct {
98
+ extern "c" fn __errno_location () * c_int ;
99
+ }.__errno_location ;
100
+
101
+ pub const Stat = emscripten .Stat ;
102
+
103
+ pub const AI = struct {
104
+ pub const PASSIVE = 0x01 ;
105
+ pub const CANONNAME = 0x02 ;
106
+ pub const NUMERICHOST = 0x04 ;
107
+ pub const V4MAPPED = 0x08 ;
108
+ pub const ALL = 0x10 ;
109
+ pub const ADDRCONFIG = 0x20 ;
110
+ pub const NUMERICSERV = 0x400 ;
111
+ };
112
+
113
+ pub const NI = struct {
114
+ pub const NUMERICHOST = 0x01 ;
115
+ pub const NUMERICSERV = 0x02 ;
116
+ pub const NOFQDN = 0x04 ;
117
+ pub const NAMEREQD = 0x08 ;
118
+ pub const DGRAM = 0x10 ;
119
+ pub const NUMERICSCOPE = 0x100 ;
120
+ pub const MAXHOST = 255 ;
121
+ pub const MAXSERV = 32 ;
122
+ };
123
+
124
+ pub const EAI = enum (c_int ) {
125
+ BADFLAGS = -1 ,
126
+ NONAME = -2 ,
127
+ AGAIN = -3 ,
128
+ FAIL = -4 ,
129
+ FAMILY = -6 ,
130
+ SOCKTYPE = -7 ,
131
+ SERVICE = -8 ,
132
+ MEMORY = -10 ,
133
+ SYSTEM = -11 ,
134
+ OVERFLOW = -12 ,
135
+
136
+ NODATA = -5 ,
137
+ ADDRFAMILY = -9 ,
138
+ INPROGRESS = -100 ,
139
+ CANCELED = -101 ,
140
+ NOTCANCELED = -102 ,
141
+ ALLDONE = -103 ,
142
+ INTR = -104 ,
143
+ IDN_ENCODE = -105 ,
144
+
145
+ _ ,
146
+ };
147
+
148
+ pub const fallocate64 = fallocate ;
149
+
150
+ pub const fopen64 = std .c .fopen ;
151
+ pub const fstat64 = std .c .fstat ;
152
+ pub const fstatat64 = std .c .fstatat ;
153
+ pub const ftruncate64 = std .c .ftruncate ;
154
+ pub const getrlimit64 = std .c .getrlimit ;
155
+ pub const lseek64 = std .c .lseek ;
156
+ pub const mmap64 = std .c .mmap ;
157
+ pub const open64 = std .c .open ;
158
+ pub const openat64 = std .c .openat ;
159
+ pub const pread64 = std .c .pread ;
160
+ pub const preadv64 = std .c .preadv ;
161
+ pub const pwrite64 = std .c .pwrite ;
162
+ pub const pwritev64 = std .c .pwritev ;
163
+ pub const setrlimit64 = std .c .setrlimit ;
164
+
165
+ /// See std.elf for constants for this
166
+ pub const dl_iterate_phdr_callback = * const fn (info : * dl_phdr_info , size : usize , data : ? * anyopaque ) callconv (.C ) c_int ;
167
+
168
+ pub extern "c" fn dl_iterate_phdr (callback : dl_iterate_phdr_callback , data : ? * anyopaque ) c_int ;
169
+
170
+ pub extern "c" fn sigaltstack (ss : ? * stack_t , old_ss : ? * stack_t ) c_int ;
171
+
172
+ pub extern "c" fn memfd_create (name : [* :0 ]const u8 , flags : c_uint ) c_int ;
173
+ pub extern "c" fn pipe2 (fds : * [2 ]fd_t , flags : u32 ) c_int ;
174
+
175
+ pub extern "c" fn fallocate (fd : fd_t , mode : c_int , offset : off_t , len : off_t ) c_int ;
176
+
177
+ pub extern "c" fn copy_file_range (fd_in : fd_t , off_in : ? * i64 , fd_out : fd_t , off_out : ? * i64 , len : usize , flags : c_uint ) isize ;
178
+
179
+ pub extern "c" fn prlimit (pid : pid_t , resource : rlimit_resource , new_limit : * const rlimit , old_limit : * rlimit ) c_int ;
180
+ pub extern "c" fn posix_memalign (memptr : * ? * anyopaque , alignment : usize , size : usize ) c_int ;
181
+ pub extern "c" fn malloc_usable_size (? * const anyopaque ) usize ;
182
+
183
+ pub extern "c" fn mincore (
184
+ addr : * align (std.mem.page_size ) anyopaque ,
185
+ length : usize ,
186
+ vec : [* ]u8 ,
187
+ ) c_int ;
188
+
189
+ pub extern "c" fn madvise (
190
+ addr : * align (std.mem.page_size ) anyopaque ,
191
+ length : usize ,
192
+ advice : c_uint ,
193
+ ) c_int ;
194
+
195
+ pub const pthread_attr_t = extern struct {
196
+ __size : [56 ]u8 ,
197
+ __align : c_long ,
198
+ };
199
+
1
200
pub const pthread_mutex_t = extern struct {
2
201
size : [__SIZEOF_PTHREAD_MUTEX_T ]u8 align (4 ) = [_ ]u8 {0 } ** __SIZEOF_PTHREAD_MUTEX_T ,
3
202
};
@@ -7,5 +206,33 @@ pub const pthread_cond_t = extern struct {
7
206
pub const pthread_rwlock_t = extern struct {
8
207
size : [32 ]u8 align (4 ) = [_ ]u8 {0 } ** 32 ,
9
208
};
209
+
10
210
const __SIZEOF_PTHREAD_COND_T = 48 ;
11
- const __SIZEOF_PTHREAD_MUTEX_T = 28 ;
211
+ const __SIZEOF_PTHREAD_MUTEX_T = 24 ;
212
+
213
+ pub const pthread_key_t = c_uint ;
214
+ pub const sem_t = extern struct {
215
+ __size : [__SIZEOF_SEM_T ]u8 align (@alignOf (usize )),
216
+ };
217
+
218
+ const __SIZEOF_SEM_T = 4 * @sizeOf (usize );
219
+
220
+ pub extern "c" fn pthread_setname_np (thread : std.c.pthread_t , name : [* :0 ]const u8 ) E ;
221
+ pub extern "c" fn pthread_getname_np (thread : std.c.pthread_t , name : [* :0 ]u8 , len : usize ) E ;
222
+
223
+ pub const RTLD = struct {
224
+ pub const LAZY = 1 ;
225
+ pub const NOW = 2 ;
226
+ pub const NOLOAD = 4 ;
227
+ pub const NODELETE = 4096 ;
228
+ pub const GLOBAL = 256 ;
229
+ pub const LOCAL = 0 ;
230
+ };
231
+
232
+ pub const dirent = struct {
233
+ d_ino : c_uint ,
234
+ d_off : c_uint ,
235
+ d_reclen : c_ushort ,
236
+ d_type : u8 ,
237
+ d_name : [256 ]u8 ,
238
+ };
0 commit comments