authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-26 13:44:36-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2019-09-26 13:44:36-04:00
log4d65373a3d0f616cceb4bef67289d014f30d8ea4
tree3a3aa42808895a117240fd32a3bbecfe2a7ed78c
parent2c8864f634cbb42bf45f4f6b7109e9129b357247
parenta94372231ca3c4daab3cf2bc54d2de135ecdd5e8
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #3311 from LemonBoy/mips

Initial support for mipsel architecture

20 files changed, 1343 insertions(+), 476 deletions(-)

lib/std/hash/auto_hash.zig+3
...@@ -355,6 +355,9 @@ test "testHash union" {...@@ -355,6 +355,9 @@ test "testHash union" {
355}355}
356356
357test "testHash vector" {357test "testHash vector" {
358 // Disabled because of #3317
359 if (@import("builtin").arch == .mipsel) return error.SkipZigTest;
360
358 const a: @Vector(4, u32) = [_]u32{ 1, 2, 3, 4 };361 const a: @Vector(4, u32) = [_]u32{ 1, 2, 3, 4 };
359 const b: @Vector(4, u32) = [_]u32{ 1, 2, 3, 5 };362 const b: @Vector(4, u32) = [_]u32{ 1, 2, 3, 5 };
360 testing.expect(testHash(a) == testHash(a));363 testing.expect(testHash(a) == testHash(a));
lib/std/os/bits/linux.zig+57-44
...@@ -3,15 +3,22 @@ const std = @import("../../std.zig");...@@ -3,15 +3,22 @@ const std = @import("../../std.zig");
3const maxInt = std.math.maxInt;3const maxInt = std.math.maxInt;
4usingnamespace @import("../bits.zig");4usingnamespace @import("../bits.zig");
55
6pub usingnamespace @import("linux/errno.zig");6pub usingnamespace switch (builtin.arch) {
7 .mips, .mipsel => @import("linux/errno-mips.zig"),
8 else => @import("linux/errno-generic.zig"),
9};
10
7pub usingnamespace switch (builtin.arch) {11pub usingnamespace switch (builtin.arch) {
8 .x86_64 => @import("linux/x86_64.zig"),12 .x86_64 => @import("linux/x86_64.zig"),
9 .aarch64 => @import("linux/arm64.zig"),13 .aarch64 => @import("linux/arm64.zig"),
10 .arm => @import("linux/arm-eabi.zig"),14 .arm => @import("linux/arm-eabi.zig"),
11 .riscv64 => @import("linux/riscv64.zig"),15 .riscv64 => @import("linux/riscv64.zig"),
16 .mipsel => @import("linux/mipsel.zig"),
12 else => struct {},17 else => struct {},
13};18};
1419
20const is_mips = builtin.arch == .mipsel;
21
15pub const pid_t = i32;22pub const pid_t = i32;
16pub const fd_t = i32;23pub const fd_t = i32;
17pub const uid_t = i32;24pub const uid_t = i32;
...@@ -96,21 +103,21 @@ pub const MAP_TYPE = 0x0f;...@@ -96,21 +103,21 @@ pub const MAP_TYPE = 0x0f;
96pub const MAP_FIXED = 0x10;103pub const MAP_FIXED = 0x10;
97104
98/// don't use a file105/// don't use a file
99pub const MAP_ANONYMOUS = 0x20;106pub const MAP_ANONYMOUS = if (is_mips) 0x800 else 0x20;
100107
101// MAP_ 0x0100 - 0x4000 flags are per architecture108// MAP_ 0x0100 - 0x4000 flags are per architecture
102109
103/// populate (prefault) pagetables110/// populate (prefault) pagetables
104pub const MAP_POPULATE = 0x8000;111pub const MAP_POPULATE = if (is_mips) 0x10000 else 0x8000;
105112
106/// do not block on IO113/// do not block on IO
107pub const MAP_NONBLOCK = 0x10000;114pub const MAP_NONBLOCK = if (is_mips) 0x20000 else 0x10000;
108115
109/// give out an address that is best suited for process/thread stacks116/// give out an address that is best suited for process/thread stacks
110pub const MAP_STACK = 0x20000;117pub const MAP_STACK = if (is_mips) 0x40000 else 0x20000;
111118
112/// create a huge page mapping119/// create a huge page mapping
113pub const MAP_HUGETLB = 0x40000;120pub const MAP_HUGETLB = if (is_mips) 0x80000 else 0x40000;
114121
115/// perform synchronous page faults for the mapping122/// perform synchronous page faults for the mapping
116pub const MAP_SYNC = 0x80000;123pub const MAP_SYNC = 0x80000;
...@@ -247,15 +254,15 @@ pub const SHUT_RD = 0;...@@ -247,15 +254,15 @@ pub const SHUT_RD = 0;
247pub const SHUT_WR = 1;254pub const SHUT_WR = 1;
248pub const SHUT_RDWR = 2;255pub const SHUT_RDWR = 2;
249256
250pub const SOCK_STREAM = 1;257pub const SOCK_STREAM = if (is_mips) 2 else 1;
251pub const SOCK_DGRAM = 2;258pub const SOCK_DGRAM = if (is_mips) 1 else 2;
252pub const SOCK_RAW = 3;259pub const SOCK_RAW = 3;
253pub const SOCK_RDM = 4;260pub const SOCK_RDM = 4;
254pub const SOCK_SEQPACKET = 5;261pub const SOCK_SEQPACKET = 5;
255pub const SOCK_DCCP = 6;262pub const SOCK_DCCP = 6;
256pub const SOCK_PACKET = 10;263pub const SOCK_PACKET = 10;
257pub const SOCK_CLOEXEC = 0o2000000;264pub const SOCK_CLOEXEC = 0o2000000;
258pub const SOCK_NONBLOCK = 0o4000;265pub const SOCK_NONBLOCK = if (is_mips) 0o200 else 0o4000;
259266
260pub const PF_UNSPEC = 0;267pub const PF_UNSPEC = 0;
261pub const PF_LOCAL = 1;268pub const PF_LOCAL = 1;
...@@ -355,32 +362,38 @@ pub const AF_QIPCRTR = PF_QIPCRTR;...@@ -355,32 +362,38 @@ pub const AF_QIPCRTR = PF_QIPCRTR;
355pub const AF_SMC = PF_SMC;362pub const AF_SMC = PF_SMC;
356pub const AF_MAX = PF_MAX;363pub const AF_MAX = PF_MAX;
357364
358pub const SO_DEBUG = 1;365pub usingnamespace if (!@hasDecl(@This(), "SO_DEBUG"))
359pub const SO_REUSEADDR = 2;366 struct {
360pub const SO_TYPE = 3;367 const SO_DEBUG = 1;
361pub const SO_ERROR = 4;368 const SO_REUSEADDR = 2;
362pub const SO_DONTROUTE = 5;369 const SO_TYPE = 3;
363pub const SO_BROADCAST = 6;370 const SO_ERROR = 4;
364pub const SO_SNDBUF = 7;371 const SO_DONTROUTE = 5;
365pub const SO_RCVBUF = 8;372 const SO_BROADCAST = 6;
366pub const SO_KEEPALIVE = 9;373 const SO_SNDBUF = 7;
367pub const SO_OOBINLINE = 10;374 const SO_RCVBUF = 8;
368pub const SO_NO_CHECK = 11;375 const SO_KEEPALIVE = 9;
369pub const SO_PRIORITY = 12;376 const SO_OOBINLINE = 10;
370pub const SO_LINGER = 13;377 const SO_NO_CHECK = 11;
371pub const SO_BSDCOMPAT = 14;378 const SO_PRIORITY = 12;
372pub const SO_REUSEPORT = 15;379 const SO_LINGER = 13;
373pub const SO_PASSCRED = 16;380 const SO_BSDCOMPAT = 14;
374pub const SO_PEERCRED = 17;381 const SO_REUSEPORT = 15;
375pub const SO_RCVLOWAT = 18;382 const SO_PASSCRED = 16;
376pub const SO_SNDLOWAT = 19;383 const SO_PEERCRED = 17;
377pub const SO_RCVTIMEO = 20;384 const SO_RCVLOWAT = 18;
378pub const SO_SNDTIMEO = 21;385 const SO_SNDLOWAT = 19;
379pub const SO_ACCEPTCONN = 30;386 const SO_RCVTIMEO = 20;
380pub const SO_SNDBUFFORCE = 32;387 const SO_SNDTIMEO = 21;
381pub const SO_RCVBUFFORCE = 33;388 const SO_ACCEPTCONN = 30;
382pub const SO_PROTOCOL = 38;389 const SO_PEERSEC = 31;
383pub const SO_DOMAIN = 39;390 const SO_SNDBUFFORCE = 32;
391 const SO_RCVBUFFORCE = 33;
392 const SO_PROTOCOL = 38;
393 const SO_DOMAIN = 39;
394 }
395else
396 struct {};
384397
385pub const SO_SECURITY_AUTHENTICATION = 22;398pub const SO_SECURITY_AUTHENTICATION = 22;
386pub const SO_SECURITY_ENCRYPTION_TRANSPORT = 23;399pub const SO_SECURITY_ENCRYPTION_TRANSPORT = 23;
...@@ -394,11 +407,11 @@ pub const SO_GET_FILTER = SO_ATTACH_FILTER;...@@ -394,11 +407,11 @@ pub const SO_GET_FILTER = SO_ATTACH_FILTER;
394407
395pub const SO_PEERNAME = 28;408pub const SO_PEERNAME = 28;
396pub const SO_TIMESTAMP_OLD = 29;409pub const SO_TIMESTAMP_OLD = 29;
397pub const SO_PEERSEC = 31;
398pub const SO_PASSSEC = 34;410pub const SO_PASSSEC = 34;
399pub const SO_TIMESTAMPNS_OLD = 35;411pub const SO_TIMESTAMPNS_OLD = 35;
400pub const SO_MARK = 36;412pub const SO_MARK = 36;
401pub const SO_TIMESTAMPING_OLD = 37;413pub const SO_TIMESTAMPING_OLD = 37;
414
402pub const SO_RXQ_OVFL = 40;415pub const SO_RXQ_OVFL = 40;
403pub const SO_WIFI_STATUS = 41;416pub const SO_WIFI_STATUS = 41;
404pub const SCM_WIFI_STATUS = SO_WIFI_STATUS;417pub const SCM_WIFI_STATUS = SO_WIFI_STATUS;
...@@ -432,7 +445,7 @@ pub const SO_RCVTIMEO_NEW = 66;...@@ -432,7 +445,7 @@ pub const SO_RCVTIMEO_NEW = 66;
432pub const SO_SNDTIMEO_NEW = 67;445pub const SO_SNDTIMEO_NEW = 67;
433pub const SO_DETACH_REUSEPORT_BPF = 68;446pub const SO_DETACH_REUSEPORT_BPF = 68;
434447
435pub const SOL_SOCKET = 1;448pub const SOL_SOCKET = if (is_mips) 65535 else 1;
436449
437pub const SOL_IP = 0;450pub const SOL_IP = 0;
438pub const SOL_IPV6 = 41;451pub const SOL_IPV6 = 41;
...@@ -496,7 +509,7 @@ pub const DT_LNK = 10;...@@ -496,7 +509,7 @@ pub const DT_LNK = 10;
496pub const DT_SOCK = 12;509pub const DT_SOCK = 12;
497pub const DT_WHT = 14;510pub const DT_WHT = 14;
498511
499pub const TCGETS = 0x5401;512pub const TCGETS = if (is_mips) 0x540D else 0x5401;
500pub const TCSETS = 0x5402;513pub const TCSETS = 0x5402;
501pub const TCSETSW = 0x5403;514pub const TCSETSW = 0x5403;
502pub const TCSETSF = 0x5404;515pub const TCSETSF = 0x5404;
...@@ -512,17 +525,17 @@ pub const TIOCNXCL = 0x540D;...@@ -512,17 +525,17 @@ pub const TIOCNXCL = 0x540D;
512pub const TIOCSCTTY = 0x540E;525pub const TIOCSCTTY = 0x540E;
513pub const TIOCGPGRP = 0x540F;526pub const TIOCGPGRP = 0x540F;
514pub const TIOCSPGRP = 0x5410;527pub const TIOCSPGRP = 0x5410;
515pub const TIOCOUTQ = 0x5411;528pub const TIOCOUTQ = if (is_mips) 0x7472 else 0x5411;
516pub const TIOCSTI = 0x5412;529pub const TIOCSTI = 0x5412;
517pub const TIOCGWINSZ = 0x5413;530pub const TIOCGWINSZ = if (is_mips) 0x40087468 else 0x5413;
518pub const TIOCSWINSZ = 0x5414;531pub const TIOCSWINSZ = if (is_mips) 0x80087467 else 0x5414;
519pub const TIOCMGET = 0x5415;532pub const TIOCMGET = 0x5415;
520pub const TIOCMBIS = 0x5416;533pub const TIOCMBIS = 0x5416;
521pub const TIOCMBIC = 0x5417;534pub const TIOCMBIC = 0x5417;
522pub const TIOCMSET = 0x5418;535pub const TIOCMSET = 0x5418;
523pub const TIOCGSOFTCAR = 0x5419;536pub const TIOCGSOFTCAR = 0x5419;
524pub const TIOCSSOFTCAR = 0x541A;537pub const TIOCSSOFTCAR = 0x541A;
525pub const FIONREAD = 0x541B;538pub const FIONREAD = if (is_mips) 0x467F else 0x541B;
526pub const TIOCINQ = FIONREAD;539pub const TIOCINQ = FIONREAD;
527pub const TIOCLINUX = 0x541C;540pub const TIOCLINUX = 0x541C;
528pub const TIOCCONS = 0x541D;541pub const TIOCCONS = 0x541D;
...@@ -563,8 +576,8 @@ pub const EPOLLPRI = 0x002;...@@ -563,8 +576,8 @@ pub const EPOLLPRI = 0x002;
563pub const EPOLLOUT = 0x004;576pub const EPOLLOUT = 0x004;
564pub const EPOLLRDNORM = 0x040;577pub const EPOLLRDNORM = 0x040;
565pub const EPOLLRDBAND = 0x080;578pub const EPOLLRDBAND = 0x080;
566pub const EPOLLWRNORM = 0x100;579pub const EPOLLWRNORM = if (is_mips) 0x004 else 0x100;
567pub const EPOLLWRBAND = 0x200;580pub const EPOLLWRBAND = if (is_mips) 0x100 else 0x200;
568pub const EPOLLMSG = 0x400;581pub const EPOLLMSG = 0x400;
569pub const EPOLLERR = 0x008;582pub const EPOLLERR = 0x008;
570pub const EPOLLHUP = 0x010;583pub const EPOLLHUP = 0x010;
lib/std/os/bits/linux/errno-generic.zig created+428
...@@ -0,0 +1,428 @@
1/// Operation not permitted
2pub const EPERM = 1;
3
4/// No such file or directory
5pub const ENOENT = 2;
6
7/// No such process
8pub const ESRCH = 3;
9
10/// Interrupted system call
11pub const EINTR = 4;
12
13/// I/O error
14pub const EIO = 5;
15
16/// No such device or address
17pub const ENXIO = 6;
18
19/// Arg list too long
20pub const E2BIG = 7;
21
22/// Exec format error
23pub const ENOEXEC = 8;
24
25/// Bad file number
26pub const EBADF = 9;
27
28/// No child processes
29pub const ECHILD = 10;
30
31/// Try again
32pub const EAGAIN = 11;
33
34/// Out of memory
35pub const ENOMEM = 12;
36
37/// Permission denied
38pub const EACCES = 13;
39
40/// Bad address
41pub const EFAULT = 14;
42
43/// Block device required
44pub const ENOTBLK = 15;
45
46/// Device or resource busy
47pub const EBUSY = 16;
48
49/// File exists
50pub const EEXIST = 17;
51
52/// Cross-device link
53pub const EXDEV = 18;
54
55/// No such device
56pub const ENODEV = 19;
57
58/// Not a directory
59pub const ENOTDIR = 20;
60
61/// Is a directory
62pub const EISDIR = 21;
63
64/// Invalid argument
65pub const EINVAL = 22;
66
67/// File table overflow
68pub const ENFILE = 23;
69
70/// Too many open files
71pub const EMFILE = 24;
72
73/// Not a typewriter
74pub const ENOTTY = 25;
75
76/// Text file busy
77pub const ETXTBSY = 26;
78
79/// File too large
80pub const EFBIG = 27;
81
82/// No space left on device
83pub const ENOSPC = 28;
84
85/// Illegal seek
86pub const ESPIPE = 29;
87
88/// Read-only file system
89pub const EROFS = 30;
90
91/// Too many links
92pub const EMLINK = 31;
93
94/// Broken pipe
95pub const EPIPE = 32;
96
97/// Math argument out of domain of func
98pub const EDOM = 33;
99
100/// Math result not representable
101pub const ERANGE = 34;
102
103/// Resource deadlock would occur
104pub const EDEADLK = 35;
105
106/// File name too long
107pub const ENAMETOOLONG = 36;
108
109/// No record locks available
110pub const ENOLCK = 37;
111
112/// Function not implemented
113pub const ENOSYS = 38;
114
115/// Directory not empty
116pub const ENOTEMPTY = 39;
117
118/// Too many symbolic links encountered
119pub const ELOOP = 40;
120
121/// Operation would block
122pub const EWOULDBLOCK = EAGAIN;
123
124/// No message of desired type
125pub const ENOMSG = 42;
126
127/// Identifier removed
128pub const EIDRM = 43;
129
130/// Channel number out of range
131pub const ECHRNG = 44;
132
133/// Level 2 not synchronized
134pub const EL2NSYNC = 45;
135
136/// Level 3 halted
137pub const EL3HLT = 46;
138
139/// Level 3 reset
140pub const EL3RST = 47;
141
142/// Link number out of range
143pub const ELNRNG = 48;
144
145/// Protocol driver not attached
146pub const EUNATCH = 49;
147
148/// No CSI structure available
149pub const ENOCSI = 50;
150
151/// Level 2 halted
152pub const EL2HLT = 51;
153
154/// Invalid exchange
155pub const EBADE = 52;
156
157/// Invalid request descriptor
158pub const EBADR = 53;
159
160/// Exchange full
161pub const EXFULL = 54;
162
163/// No anode
164pub const ENOANO = 55;
165
166/// Invalid request code
167pub const EBADRQC = 56;
168
169/// Invalid slot
170pub const EBADSLT = 57;
171
172/// Bad font file format
173pub const EBFONT = 59;
174
175/// Device not a stream
176pub const ENOSTR = 60;
177
178/// No data available
179pub const ENODATA = 61;
180
181/// Timer expired
182pub const ETIME = 62;
183
184/// Out of streams resources
185pub const ENOSR = 63;
186
187/// Machine is not on the network
188pub const ENONET = 64;
189
190/// Package not installed
191pub const ENOPKG = 65;
192
193/// Object is remote
194pub const EREMOTE = 66;
195
196/// Link has been severed
197pub const ENOLINK = 67;
198
199/// Advertise error
200pub const EADV = 68;
201
202/// Srmount error
203pub const ESRMNT = 69;
204
205/// Communication error on send
206pub const ECOMM = 70;
207
208/// Protocol error
209pub const EPROTO = 71;
210
211/// Multihop attempted
212pub const EMULTIHOP = 72;
213
214/// RFS specific error
215pub const EDOTDOT = 73;
216
217/// Not a data message
218pub const EBADMSG = 74;
219
220/// Value too large for defined data type
221pub const EOVERFLOW = 75;
222
223/// Name not unique on network
224pub const ENOTUNIQ = 76;
225
226/// File descriptor in bad state
227pub const EBADFD = 77;
228
229/// Remote address changed
230pub const EREMCHG = 78;
231
232/// Can not access a needed shared library
233pub const ELIBACC = 79;
234
235/// Accessing a corrupted shared library
236pub const ELIBBAD = 80;
237
238/// .lib section in a.out corrupted
239pub const ELIBSCN = 81;
240
241/// Attempting to link in too many shared libraries
242pub const ELIBMAX = 82;
243
244/// Cannot exec a shared library directly
245pub const ELIBEXEC = 83;
246
247/// Illegal byte sequence
248pub const EILSEQ = 84;
249
250/// Interrupted system call should be restarted
251pub const ERESTART = 85;
252
253/// Streams pipe error
254pub const ESTRPIPE = 86;
255
256/// Too many users
257pub const EUSERS = 87;
258
259/// Socket operation on non-socket
260pub const ENOTSOCK = 88;
261
262/// Destination address required
263pub const EDESTADDRREQ = 89;
264
265/// Message too long
266pub const EMSGSIZE = 90;
267
268/// Protocol wrong type for socket
269pub const EPROTOTYPE = 91;
270
271/// Protocol not available
272pub const ENOPROTOOPT = 92;
273
274/// Protocol not supported
275pub const EPROTONOSUPPORT = 93;
276
277/// Socket type not supported
278pub const ESOCKTNOSUPPORT = 94;
279
280/// Operation not supported on transport endpoint
281pub const EOPNOTSUPP = 95;
282pub const ENOTSUP = EOPNOTSUPP;
283
284/// Protocol family not supported
285pub const EPFNOSUPPORT = 96;
286
287/// Address family not supported by protocol
288pub const EAFNOSUPPORT = 97;
289
290/// Address already in use
291pub const EADDRINUSE = 98;
292
293/// Cannot assign requested address
294pub const EADDRNOTAVAIL = 99;
295
296/// Network is down
297pub const ENETDOWN = 100;
298
299/// Network is unreachable
300pub const ENETUNREACH = 101;
301
302/// Network dropped connection because of reset
303pub const ENETRESET = 102;
304
305/// Software caused connection abort
306pub const ECONNABORTED = 103;
307
308/// Connection reset by peer
309pub const ECONNRESET = 104;
310
311/// No buffer space available
312pub const ENOBUFS = 105;
313
314/// Transport endpoint is already connected
315pub const EISCONN = 106;
316
317/// Transport endpoint is not connected
318pub const ENOTCONN = 107;
319
320/// Cannot send after transport endpoint shutdown
321pub const ESHUTDOWN = 108;
322
323/// Too many references: cannot splice
324pub const ETOOMANYREFS = 109;
325
326/// Connection timed out
327pub const ETIMEDOUT = 110;
328
329/// Connection refused
330pub const ECONNREFUSED = 111;
331
332/// Host is down
333pub const EHOSTDOWN = 112;
334
335/// No route to host
336pub const EHOSTUNREACH = 113;
337
338/// Operation already in progress
339pub const EALREADY = 114;
340
341/// Operation now in progress
342pub const EINPROGRESS = 115;
343
344/// Stale NFS file handle
345pub const ESTALE = 116;
346
347/// Structure needs cleaning
348pub const EUCLEAN = 117;
349
350/// Not a XENIX named type file
351pub const ENOTNAM = 118;
352
353/// No XENIX semaphores available
354pub const ENAVAIL = 119;
355
356/// Is a named type file
357pub const EISNAM = 120;
358
359/// Remote I/O error
360pub const EREMOTEIO = 121;
361
362/// Quota exceeded
363pub const EDQUOT = 122;
364
365/// No medium found
366pub const ENOMEDIUM = 123;
367
368/// Wrong medium type
369pub const EMEDIUMTYPE = 124;
370
371// nameserver query return codes
372
373/// DNS server returned answer with no data
374pub const ENSROK = 0;
375
376/// DNS server returned answer with no data
377pub const ENSRNODATA = 160;
378
379/// DNS server claims query was misformatted
380pub const ENSRFORMERR = 161;
381
382/// DNS server returned general failure
383pub const ENSRSERVFAIL = 162;
384
385/// Domain name not found
386pub const ENSRNOTFOUND = 163;
387
388/// DNS server does not implement requested operation
389pub const ENSRNOTIMP = 164;
390
391/// DNS server refused query
392pub const ENSRREFUSED = 165;
393
394/// Misformatted DNS query
395pub const ENSRBADQUERY = 166;
396
397/// Misformatted domain name
398pub const ENSRBADNAME = 167;
399
400/// Unsupported address family
401pub const ENSRBADFAMILY = 168;
402
403/// Misformatted DNS reply
404pub const ENSRBADRESP = 169;
405
406/// Could not contact DNS servers
407pub const ENSRCONNREFUSED = 170;
408
409/// Timeout while contacting DNS servers
410pub const ENSRTIMEOUT = 171;
411
412/// End of file
413pub const ENSROF = 172;
414
415/// Error reading file
416pub const ENSRFILE = 173;
417
418/// Out of memory
419pub const ENSRNOMEM = 174;
420
421/// Application terminated lookup
422pub const ENSRDESTRUCTION = 175;
423
424/// Domain name is too long
425pub const ENSRQUERYDOMAINTOOLONG = 176;
426
427/// Domain name is too long
428pub const ENSRCNAMELOOP = 177;
lib/std/os/bits/linux/errno-mips.zig created+134
...@@ -0,0 +1,134 @@
1pub const EPERM = 1;
2pub const ENOENT = 2;
3pub const ESRCH = 3;
4pub const EINTR = 4;
5pub const EIO = 5;
6pub const ENXIO = 6;
7pub const E2BIG = 7;
8pub const ENOEXEC = 8;
9pub const EBADF = 9;
10pub const ECHILD = 10;
11pub const EAGAIN = 11;
12pub const ENOMEM = 12;
13pub const EACCES = 13;
14pub const EFAULT = 14;
15pub const ENOTBLK = 15;
16pub const EBUSY = 16;
17pub const EEXIST = 17;
18pub const EXDEV = 18;
19pub const ENODEV = 19;
20pub const ENOTDIR = 20;
21pub const EISDIR = 21;
22pub const EINVAL = 22;
23pub const ENFILE = 23;
24pub const EMFILE = 24;
25pub const ENOTTY = 25;
26pub const ETXTBSY = 26;
27pub const EFBIG = 27;
28pub const ENOSPC = 28;
29pub const ESPIPE = 29;
30pub const EROFS = 30;
31pub const EMLINK = 31;
32pub const EPIPE = 32;
33pub const EDOM = 33;
34pub const ERANGE = 34;
35pub const ENOMSG = 35;
36pub const EIDRM = 36;
37pub const ECHRNG = 37;
38pub const EL2NSYNC = 38;
39pub const EL3HLT = 39;
40pub const EL3RST = 40;
41pub const ELNRNG = 41;
42pub const EUNATCH = 42;
43pub const ENOCSI = 43;
44pub const EL2HLT = 44;
45pub const EDEADLK = 45;
46pub const ENOLCK = 46;
47pub const EBADE = 50;
48pub const EBADR = 51;
49pub const EXFULL = 52;
50pub const ENOANO = 53;
51pub const EBADRQC = 54;
52pub const EBADSLT = 55;
53pub const EDEADLOCK = 56;
54pub const EBFONT = 59;
55pub const ENOSTR = 60;
56pub const ENODATA = 61;
57pub const ETIME = 62;
58pub const ENOSR = 63;
59pub const ENONET = 64;
60pub const ENOPKG = 65;
61pub const EREMOTE = 66;
62pub const ENOLINK = 67;
63pub const EADV = 68;
64pub const ESRMNT = 69;
65pub const ECOMM = 70;
66pub const EPROTO = 71;
67pub const EDOTDOT = 73;
68pub const EMULTIHOP = 74;
69pub const EBADMSG = 77;
70pub const ENAMETOOLONG = 78;
71pub const EOVERFLOW = 79;
72pub const ENOTUNIQ = 80;
73pub const EBADFD = 81;
74pub const EREMCHG = 82;
75pub const ELIBACC = 83;
76pub const ELIBBAD = 84;
77pub const ELIBSCN = 85;
78pub const ELIBMAX = 86;
79pub const ELIBEXEC = 87;
80pub const EILSEQ = 88;
81pub const ENOSYS = 89;
82pub const ELOOP = 90;
83pub const ERESTART = 91;
84pub const ESTRPIPE = 92;
85pub const ENOTEMPTY = 93;
86pub const EUSERS = 94;
87pub const ENOTSOCK = 95;
88pub const EDESTADDRREQ = 96;
89pub const EMSGSIZE = 97;
90pub const EPROTOTYPE = 98;
91pub const ENOPROTOOPT = 99;
92pub const EPROTONOSUPPORT = 120;
93pub const ESOCKTNOSUPPORT = 121;
94pub const EOPNOTSUPP = 122;
95pub const ENOTSUP = EOPNOTSUPP;
96pub const EPFNOSUPPORT = 123;
97pub const EAFNOSUPPORT = 124;
98pub const EADDRINUSE = 125;
99pub const EADDRNOTAVAIL = 126;
100pub const ENETDOWN = 127;
101pub const ENETUNREACH = 128;
102pub const ENETRESET = 129;
103pub const ECONNABORTED = 130;
104pub const ECONNRESET = 131;
105pub const ENOBUFS = 132;
106pub const EISCONN = 133;
107pub const ENOTCONN = 134;
108pub const EUCLEAN = 135;
109pub const ENOTNAM = 137;
110pub const ENAVAIL = 138;
111pub const EISNAM = 139;
112pub const EREMOTEIO = 140;
113pub const ESHUTDOWN = 143;
114pub const ETOOMANYREFS = 144;
115pub const ETIMEDOUT = 145;
116pub const ECONNREFUSED = 146;
117pub const EHOSTDOWN = 147;
118pub const EHOSTUNREACH = 148;
119pub const EWOULDBLOCK = EAGAIN;
120pub const EALREADY = 149;
121pub const EINPROGRESS = 150;
122pub const ESTALE = 151;
123pub const ECANCELED = 158;
124pub const ENOMEDIUM = 159;
125pub const EMEDIUMTYPE = 160;
126pub const ENOKEY = 161;
127pub const EKEYEXPIRED = 162;
128pub const EKEYREVOKED = 163;
129pub const EKEYREJECTED = 164;
130pub const EOWNERDEAD = 165;
131pub const ENOTRECOVERABLE = 166;
132pub const ERFKILL = 167;
133pub const EHWPOISON = 168;
134pub const EDQUOT = 1133;
lib/std/os/bits/linux/errno.zig deleted-428
...@@ -1,428 +0,0 @@
1/// Operation not permitted
2pub const EPERM = 1;
3
4/// No such file or directory
5pub const ENOENT = 2;
6
7/// No such process
8pub const ESRCH = 3;
9
10/// Interrupted system call
11pub const EINTR = 4;
12
13/// I/O error
14pub const EIO = 5;
15
16/// No such device or address
17pub const ENXIO = 6;
18
19/// Arg list too long
20pub const E2BIG = 7;
21
22/// Exec format error
23pub const ENOEXEC = 8;
24
25/// Bad file number
26pub const EBADF = 9;
27
28/// No child processes
29pub const ECHILD = 10;
30
31/// Try again
32pub const EAGAIN = 11;
33
34/// Out of memory
35pub const ENOMEM = 12;
36
37/// Permission denied
38pub const EACCES = 13;
39
40/// Bad address
41pub const EFAULT = 14;
42
43/// Block device required
44pub const ENOTBLK = 15;
45
46/// Device or resource busy
47pub const EBUSY = 16;
48
49/// File exists
50pub const EEXIST = 17;
51
52/// Cross-device link
53pub const EXDEV = 18;
54
55/// No such device
56pub const ENODEV = 19;
57
58/// Not a directory
59pub const ENOTDIR = 20;
60
61/// Is a directory
62pub const EISDIR = 21;
63
64/// Invalid argument
65pub const EINVAL = 22;
66
67/// File table overflow
68pub const ENFILE = 23;
69
70/// Too many open files
71pub const EMFILE = 24;
72
73/// Not a typewriter
74pub const ENOTTY = 25;
75
76/// Text file busy
77pub const ETXTBSY = 26;
78
79/// File too large
80pub const EFBIG = 27;
81
82/// No space left on device
83pub const ENOSPC = 28;
84
85/// Illegal seek
86pub const ESPIPE = 29;
87
88/// Read-only file system
89pub const EROFS = 30;
90
91/// Too many links
92pub const EMLINK = 31;
93
94/// Broken pipe
95pub const EPIPE = 32;
96
97/// Math argument out of domain of func
98pub const EDOM = 33;
99
100/// Math result not representable
101pub const ERANGE = 34;
102
103/// Resource deadlock would occur
104pub const EDEADLK = 35;
105
106/// File name too long
107pub const ENAMETOOLONG = 36;
108
109/// No record locks available
110pub const ENOLCK = 37;
111
112/// Function not implemented
113pub const ENOSYS = 38;
114
115/// Directory not empty
116pub const ENOTEMPTY = 39;
117
118/// Too many symbolic links encountered
119pub const ELOOP = 40;
120
121/// Operation would block
122pub const EWOULDBLOCK = EAGAIN;
123
124/// No message of desired type
125pub const ENOMSG = 42;
126
127/// Identifier removed
128pub const EIDRM = 43;
129
130/// Channel number out of range
131pub const ECHRNG = 44;
132
133/// Level 2 not synchronized
134pub const EL2NSYNC = 45;
135
136/// Level 3 halted
137pub const EL3HLT = 46;
138
139/// Level 3 reset
140pub const EL3RST = 47;
141
142/// Link number out of range
143pub const ELNRNG = 48;
144
145/// Protocol driver not attached
146pub const EUNATCH = 49;
147
148/// No CSI structure available
149pub const ENOCSI = 50;
150
151/// Level 2 halted
152pub const EL2HLT = 51;
153
154/// Invalid exchange
155pub const EBADE = 52;
156
157/// Invalid request descriptor
158pub const EBADR = 53;
159
160/// Exchange full
161pub const EXFULL = 54;
162
163/// No anode
164pub const ENOANO = 55;
165
166/// Invalid request code
167pub const EBADRQC = 56;
168
169/// Invalid slot
170pub const EBADSLT = 57;
171
172/// Bad font file format
173pub const EBFONT = 59;
174
175/// Device not a stream
176pub const ENOSTR = 60;
177
178/// No data available
179pub const ENODATA = 61;
180
181/// Timer expired
182pub const ETIME = 62;
183
184/// Out of streams resources
185pub const ENOSR = 63;
186
187/// Machine is not on the network
188pub const ENONET = 64;
189
190/// Package not installed
191pub const ENOPKG = 65;
192
193/// Object is remote
194pub const EREMOTE = 66;
195
196/// Link has been severed
197pub const ENOLINK = 67;
198
199/// Advertise error
200pub const EADV = 68;
201
202/// Srmount error
203pub const ESRMNT = 69;
204
205/// Communication error on send
206pub const ECOMM = 70;
207
208/// Protocol error
209pub const EPROTO = 71;
210
211/// Multihop attempted
212pub const EMULTIHOP = 72;
213
214/// RFS specific error
215pub const EDOTDOT = 73;
216
217/// Not a data message
218pub const EBADMSG = 74;
219
220/// Value too large for defined data type
221pub const EOVERFLOW = 75;
222
223/// Name not unique on network
224pub const ENOTUNIQ = 76;
225
226/// File descriptor in bad state
227pub const EBADFD = 77;
228
229/// Remote address changed
230pub const EREMCHG = 78;
231
232/// Can not access a needed shared library
233pub const ELIBACC = 79;
234
235/// Accessing a corrupted shared library
236pub const ELIBBAD = 80;
237
238/// .lib section in a.out corrupted
239pub const ELIBSCN = 81;
240
241/// Attempting to link in too many shared libraries
242pub const ELIBMAX = 82;
243
244/// Cannot exec a shared library directly
245pub const ELIBEXEC = 83;
246
247/// Illegal byte sequence
248pub const EILSEQ = 84;
249
250/// Interrupted system call should be restarted
251pub const ERESTART = 85;
252
253/// Streams pipe error
254pub const ESTRPIPE = 86;
255
256/// Too many users
257pub const EUSERS = 87;
258
259/// Socket operation on non-socket
260pub const ENOTSOCK = 88;
261
262/// Destination address required
263pub const EDESTADDRREQ = 89;
264
265/// Message too long
266pub const EMSGSIZE = 90;
267
268/// Protocol wrong type for socket
269pub const EPROTOTYPE = 91;
270
271/// Protocol not available
272pub const ENOPROTOOPT = 92;
273
274/// Protocol not supported
275pub const EPROTONOSUPPORT = 93;
276
277/// Socket type not supported
278pub const ESOCKTNOSUPPORT = 94;
279
280/// Operation not supported on transport endpoint
281pub const EOPNOTSUPP = 95;
282pub const ENOTSUP = EOPNOTSUPP;
283
284/// Protocol family not supported
285pub const EPFNOSUPPORT = 96;
286
287/// Address family not supported by protocol
288pub const EAFNOSUPPORT = 97;
289
290/// Address already in use
291pub const EADDRINUSE = 98;
292
293/// Cannot assign requested address
294pub const EADDRNOTAVAIL = 99;
295
296/// Network is down
297pub const ENETDOWN = 100;
298
299/// Network is unreachable
300pub const ENETUNREACH = 101;
301
302/// Network dropped connection because of reset
303pub const ENETRESET = 102;
304
305/// Software caused connection abort
306pub const ECONNABORTED = 103;
307
308/// Connection reset by peer
309pub const ECONNRESET = 104;
310
311/// No buffer space available
312pub const ENOBUFS = 105;
313
314/// Transport endpoint is already connected
315pub const EISCONN = 106;
316
317/// Transport endpoint is not connected
318pub const ENOTCONN = 107;
319
320/// Cannot send after transport endpoint shutdown
321pub const ESHUTDOWN = 108;
322
323/// Too many references: cannot splice
324pub const ETOOMANYREFS = 109;
325
326/// Connection timed out
327pub const ETIMEDOUT = 110;
328
329/// Connection refused
330pub const ECONNREFUSED = 111;
331
332/// Host is down
333pub const EHOSTDOWN = 112;
334
335/// No route to host
336pub const EHOSTUNREACH = 113;
337
338/// Operation already in progress
339pub const EALREADY = 114;
340
341/// Operation now in progress
342pub const EINPROGRESS = 115;
343
344/// Stale NFS file handle
345pub const ESTALE = 116;
346
347/// Structure needs cleaning
348pub const EUCLEAN = 117;
349
350/// Not a XENIX named type file
351pub const ENOTNAM = 118;
352
353/// No XENIX semaphores available
354pub const ENAVAIL = 119;
355
356/// Is a named type file
357pub const EISNAM = 120;
358
359/// Remote I/O error
360pub const EREMOTEIO = 121;
361
362/// Quota exceeded
363pub const EDQUOT = 122;
364
365/// No medium found
366pub const ENOMEDIUM = 123;
367
368/// Wrong medium type
369pub const EMEDIUMTYPE = 124;
370
371// nameserver query return codes
372
373/// DNS server returned answer with no data
374pub const ENSROK = 0;
375
376/// DNS server returned answer with no data
377pub const ENSRNODATA = 160;
378
379/// DNS server claims query was misformatted
380pub const ENSRFORMERR = 161;
381
382/// DNS server returned general failure
383pub const ENSRSERVFAIL = 162;
384
385/// Domain name not found
386pub const ENSRNOTFOUND = 163;
387
388/// DNS server does not implement requested operation
389pub const ENSRNOTIMP = 164;
390
391/// DNS server refused query
392pub const ENSRREFUSED = 165;
393
394/// Misformatted DNS query
395pub const ENSRBADQUERY = 166;
396
397/// Misformatted domain name
398pub const ENSRBADNAME = 167;
399
400/// Unsupported address family
401pub const ENSRBADFAMILY = 168;
402
403/// Misformatted DNS reply
404pub const ENSRBADRESP = 169;
405
406/// Could not contact DNS servers
407pub const ENSRCONNREFUSED = 170;
408
409/// Timeout while contacting DNS servers
410pub const ENSRTIMEOUT = 171;
411
412/// End of file
413pub const ENSROF = 172;
414
415/// Error reading file
416pub const ENSRFILE = 173;
417
418/// Out of memory
419pub const ENSRNOMEM = 174;
420
421/// Application terminated lookup
422pub const ENSRDESTRUCTION = 175;
423
424/// Domain name is too long
425pub const ENSRQUERYDOMAINTOOLONG = 176;
426
427/// Domain name is too long
428pub const ENSRCNAMELOOP = 177;
lib/std/os/bits/linux/mipsel.zig created+516
...@@ -0,0 +1,516 @@
1const std = @import("../../../std.zig");
2const linux = std.os.linux;
3const socklen_t = linux.socklen_t;
4const iovec = linux.iovec;
5const iovec_const = linux.iovec_const;
6const uid_t = linux.uid_t;
7const gid_t = linux.gid_t;
8
9pub const SYS_Linux = 4000;
10pub const SYS_syscall = (SYS_Linux + 0);
11pub const SYS_exit = (SYS_Linux + 1);
12pub const SYS_fork = (SYS_Linux + 2);
13pub const SYS_read = (SYS_Linux + 3);
14pub const SYS_write = (SYS_Linux + 4);
15pub const SYS_open = (SYS_Linux + 5);
16pub const SYS_close = (SYS_Linux + 6);
17pub const SYS_waitpid = (SYS_Linux + 7);
18pub const SYS_creat = (SYS_Linux + 8);
19pub const SYS_link = (SYS_Linux + 9);
20pub const SYS_unlink = (SYS_Linux + 10);
21pub const SYS_execve = (SYS_Linux + 11);
22pub const SYS_chdir = (SYS_Linux + 12);
23pub const SYS_time = (SYS_Linux + 13);
24pub const SYS_mknod = (SYS_Linux + 14);
25pub const SYS_chmod = (SYS_Linux + 15);
26pub const SYS_lchown = (SYS_Linux + 16);
27pub const SYS_break = (SYS_Linux + 17);
28pub const SYS_unused18 = (SYS_Linux + 18);
29pub const SYS_lseek = (SYS_Linux + 19);
30pub const SYS_getpid = (SYS_Linux + 20);
31pub const SYS_mount = (SYS_Linux + 21);
32pub const SYS_umount = (SYS_Linux + 22);
33pub const SYS_setuid = (SYS_Linux + 23);
34pub const SYS_getuid = (SYS_Linux + 24);
35pub const SYS_stime = (SYS_Linux + 25);
36pub const SYS_ptrace = (SYS_Linux + 26);
37pub const SYS_alarm = (SYS_Linux + 27);
38pub const SYS_unused28 = (SYS_Linux + 28);
39pub const SYS_pause = (SYS_Linux + 29);
40pub const SYS_utime = (SYS_Linux + 30);
41pub const SYS_stty = (SYS_Linux + 31);
42pub const SYS_gtty = (SYS_Linux + 32);
43pub const SYS_access = (SYS_Linux + 33);
44pub const SYS_nice = (SYS_Linux + 34);
45pub const SYS_ftime = (SYS_Linux + 35);
46pub const SYS_sync = (SYS_Linux + 36);
47pub const SYS_kill = (SYS_Linux + 37);
48pub const SYS_rename = (SYS_Linux + 38);
49pub const SYS_mkdir = (SYS_Linux + 39);
50pub const SYS_rmdir = (SYS_Linux + 40);
51pub const SYS_dup = (SYS_Linux + 41);
52pub const SYS_pipe = (SYS_Linux + 42);
53pub const SYS_times = (SYS_Linux + 43);
54pub const SYS_prof = (SYS_Linux + 44);
55pub const SYS_brk = (SYS_Linux + 45);
56pub const SYS_setgid = (SYS_Linux + 46);
57pub const SYS_getgid = (SYS_Linux + 47);
58pub const SYS_signal = (SYS_Linux + 48);
59pub const SYS_geteuid = (SYS_Linux + 49);
60pub const SYS_getegid = (SYS_Linux + 50);
61pub const SYS_acct = (SYS_Linux + 51);
62pub const SYS_umount2 = (SYS_Linux + 52);
63pub const SYS_lock = (SYS_Linux + 53);
64pub const SYS_ioctl = (SYS_Linux + 54);
65pub const SYS_fcntl = (SYS_Linux + 55);
66pub const SYS_mpx = (SYS_Linux + 56);
67pub const SYS_setpgid = (SYS_Linux + 57);
68pub const SYS_ulimit = (SYS_Linux + 58);
69pub const SYS_unused59 = (SYS_Linux + 59);
70pub const SYS_umask = (SYS_Linux + 60);
71pub const SYS_chroot = (SYS_Linux + 61);
72pub const SYS_ustat = (SYS_Linux + 62);
73pub const SYS_dup2 = (SYS_Linux + 63);
74pub const SYS_getppid = (SYS_Linux + 64);
75pub const SYS_getpgrp = (SYS_Linux + 65);
76pub const SYS_setsid = (SYS_Linux + 66);
77pub const SYS_sigaction = (SYS_Linux + 67);
78pub const SYS_sgetmask = (SYS_Linux + 68);
79pub const SYS_ssetmask = (SYS_Linux + 69);
80pub const SYS_setreuid = (SYS_Linux + 70);
81pub const SYS_setregid = (SYS_Linux + 71);
82pub const SYS_sigsuspend = (SYS_Linux + 72);
83pub const SYS_sigpending = (SYS_Linux + 73);
84pub const SYS_sethostname = (SYS_Linux + 74);
85pub const SYS_setrlimit = (SYS_Linux + 75);
86pub const SYS_getrlimit = (SYS_Linux + 76);
87pub const SYS_getrusage = (SYS_Linux + 77);
88pub const SYS_gettimeofday = (SYS_Linux + 78);
89pub const SYS_settimeofday = (SYS_Linux + 79);
90pub const SYS_getgroups = (SYS_Linux + 80);
91pub const SYS_setgroups = (SYS_Linux + 81);
92pub const SYS_reserved82 = (SYS_Linux + 82);
93pub const SYS_symlink = (SYS_Linux + 83);
94pub const SYS_unused84 = (SYS_Linux + 84);
95pub const SYS_readlink = (SYS_Linux + 85);
96pub const SYS_uselib = (SYS_Linux + 86);
97pub const SYS_swapon = (SYS_Linux + 87);
98pub const SYS_reboot = (SYS_Linux + 88);
99pub const SYS_readdir = (SYS_Linux + 89);
100pub const SYS_mmap = (SYS_Linux + 90);
101pub const SYS_munmap = (SYS_Linux + 91);
102pub const SYS_truncate = (SYS_Linux + 92);
103pub const SYS_ftruncate = (SYS_Linux + 93);
104pub const SYS_fchmod = (SYS_Linux + 94);
105pub const SYS_fchown = (SYS_Linux + 95);
106pub const SYS_getpriority = (SYS_Linux + 96);
107pub const SYS_setpriority = (SYS_Linux + 97);
108pub const SYS_profil = (SYS_Linux + 98);
109pub const SYS_statfs = (SYS_Linux + 99);
110pub const SYS_fstatfs = (SYS_Linux + 100);
111pub const SYS_ioperm = (SYS_Linux + 101);
112pub const SYS_socketcall = (SYS_Linux + 102);
113pub const SYS_syslog = (SYS_Linux + 103);
114pub const SYS_setitimer = (SYS_Linux + 104);
115pub const SYS_getitimer = (SYS_Linux + 105);
116pub const SYS_stat = (SYS_Linux + 106);
117pub const SYS_lstat = (SYS_Linux + 107);
118pub const SYS_fstat = (SYS_Linux + 108);
119pub const SYS_unused109 = (SYS_Linux + 109);
120pub const SYS_iopl = (SYS_Linux + 110);
121pub const SYS_vhangup = (SYS_Linux + 111);
122pub const SYS_idle = (SYS_Linux + 112);
123pub const SYS_vm86 = (SYS_Linux + 113);
124pub const SYS_wait4 = (SYS_Linux + 114);
125pub const SYS_swapoff = (SYS_Linux + 115);
126pub const SYS_sysinfo = (SYS_Linux + 116);
127pub const SYS_ipc = (SYS_Linux + 117);
128pub const SYS_fsync = (SYS_Linux + 118);
129pub const SYS_sigreturn = (SYS_Linux + 119);
130pub const SYS_clone = (SYS_Linux + 120);
131pub const SYS_setdomainname = (SYS_Linux + 121);
132pub const SYS_uname = (SYS_Linux + 122);
133pub const SYS_modify_ldt = (SYS_Linux + 123);
134pub const SYS_adjtimex = (SYS_Linux + 124);
135pub const SYS_mprotect = (SYS_Linux + 125);
136pub const SYS_sigprocmask = (SYS_Linux + 126);
137pub const SYS_create_module = (SYS_Linux + 127);
138pub const SYS_init_module = (SYS_Linux + 128);
139pub const SYS_delete_module = (SYS_Linux + 129);
140pub const SYS_get_kernel_syms = (SYS_Linux + 130);
141pub const SYS_quotactl = (SYS_Linux + 131);
142pub const SYS_getpgid = (SYS_Linux + 132);
143pub const SYS_fchdir = (SYS_Linux + 133);
144pub const SYS_bdflush = (SYS_Linux + 134);
145pub const SYS_sysfs = (SYS_Linux + 135);
146pub const SYS_personality = (SYS_Linux + 136);
147pub const SYS_afs_syscall = (SYS_Linux + 137);
148pub const SYS_setfsuid = (SYS_Linux + 138);
149pub const SYS_setfsgid = (SYS_Linux + 139);
150pub const SYS__llseek = (SYS_Linux + 140);
151pub const SYS_getdents = (SYS_Linux + 141);
152pub const SYS__newselect = (SYS_Linux + 142);
153pub const SYS_flock = (SYS_Linux + 143);
154pub const SYS_msync = (SYS_Linux + 144);
155pub const SYS_readv = (SYS_Linux + 145);
156pub const SYS_writev = (SYS_Linux + 146);
157pub const SYS_cacheflush = (SYS_Linux + 147);
158pub const SYS_cachectl = (SYS_Linux + 148);
159pub const SYS_sysmips = (SYS_Linux + 149);
160pub const SYS_unused150 = (SYS_Linux + 150);
161pub const SYS_getsid = (SYS_Linux + 151);
162pub const SYS_fdatasync = (SYS_Linux + 152);
163pub const SYS__sysctl = (SYS_Linux + 153);
164pub const SYS_mlock = (SYS_Linux + 154);
165pub const SYS_munlock = (SYS_Linux + 155);
166pub const SYS_mlockall = (SYS_Linux + 156);
167pub const SYS_munlockall = (SYS_Linux + 157);
168pub const SYS_sched_setparam = (SYS_Linux + 158);
169pub const SYS_sched_getparam = (SYS_Linux + 159);
170pub const SYS_sched_setscheduler = (SYS_Linux + 160);
171pub const SYS_sched_getscheduler = (SYS_Linux + 161);
172pub const SYS_sched_yield = (SYS_Linux + 162);
173pub const SYS_sched_get_priority_max = (SYS_Linux + 163);
174pub const SYS_sched_get_priority_min = (SYS_Linux + 164);
175pub const SYS_sched_rr_get_interval = (SYS_Linux + 165);
176pub const SYS_nanosleep = (SYS_Linux + 166);
177pub const SYS_mremap = (SYS_Linux + 167);
178pub const SYS_accept = (SYS_Linux + 168);
179pub const SYS_bind = (SYS_Linux + 169);
180pub const SYS_connect = (SYS_Linux + 170);
181pub const SYS_getpeername = (SYS_Linux + 171);
182pub const SYS_getsockname = (SYS_Linux + 172);
183pub const SYS_getsockopt = (SYS_Linux + 173);
184pub const SYS_listen = (SYS_Linux + 174);
185pub const SYS_recv = (SYS_Linux + 175);
186pub const SYS_recvfrom = (SYS_Linux + 176);
187pub const SYS_recvmsg = (SYS_Linux + 177);
188pub const SYS_send = (SYS_Linux + 178);
189pub const SYS_sendmsg = (SYS_Linux + 179);
190pub const SYS_sendto = (SYS_Linux + 180);
191pub const SYS_setsockopt = (SYS_Linux + 181);
192pub const SYS_shutdown = (SYS_Linux + 182);
193pub const SYS_socket = (SYS_Linux + 183);
194pub const SYS_socketpair = (SYS_Linux + 184);
195pub const SYS_setresuid = (SYS_Linux + 185);
196pub const SYS_getresuid = (SYS_Linux + 186);
197pub const SYS_query_module = (SYS_Linux + 187);
198pub const SYS_poll = (SYS_Linux + 188);
199pub const SYS_nfsservctl = (SYS_Linux + 189);
200pub const SYS_setresgid = (SYS_Linux + 190);
201pub const SYS_getresgid = (SYS_Linux + 191);
202pub const SYS_prctl = (SYS_Linux + 192);
203pub const SYS_rt_sigreturn = (SYS_Linux + 193);
204pub const SYS_rt_sigaction = (SYS_Linux + 194);
205pub const SYS_rt_sigprocmask = (SYS_Linux + 195);
206pub const SYS_rt_sigpending = (SYS_Linux + 196);
207pub const SYS_rt_sigtimedwait = (SYS_Linux + 197);
208pub const SYS_rt_sigqueueinfo = (SYS_Linux + 198);
209pub const SYS_rt_sigsuspend = (SYS_Linux + 199);
210pub const SYS_pread64 = (SYS_Linux + 200);
211pub const SYS_pwrite64 = (SYS_Linux + 201);
212pub const SYS_chown = (SYS_Linux + 202);
213pub const SYS_getcwd = (SYS_Linux + 203);
214pub const SYS_capget = (SYS_Linux + 204);
215pub const SYS_capset = (SYS_Linux + 205);
216pub const SYS_sigaltstack = (SYS_Linux + 206);
217pub const SYS_sendfile = (SYS_Linux + 207);
218pub const SYS_getpmsg = (SYS_Linux + 208);
219pub const SYS_putpmsg = (SYS_Linux + 209);
220pub const SYS_mmap2 = (SYS_Linux + 210);
221pub const SYS_truncate64 = (SYS_Linux + 211);
222pub const SYS_ftruncate64 = (SYS_Linux + 212);
223pub const SYS_stat64 = (SYS_Linux + 213);
224pub const SYS_lstat64 = (SYS_Linux + 214);
225pub const SYS_fstat64 = (SYS_Linux + 215);
226pub const SYS_pivot_root = (SYS_Linux + 216);
227pub const SYS_mincore = (SYS_Linux + 217);
228pub const SYS_madvise = (SYS_Linux + 218);
229pub const SYS_getdents64 = (SYS_Linux + 219);
230pub const SYS_fcntl64 = (SYS_Linux + 220);
231pub const SYS_reserved221 = (SYS_Linux + 221);
232pub const SYS_gettid = (SYS_Linux + 222);
233pub const SYS_readahead = (SYS_Linux + 223);
234pub const SYS_setxattr = (SYS_Linux + 224);
235pub const SYS_lsetxattr = (SYS_Linux + 225);
236pub const SYS_fsetxattr = (SYS_Linux + 226);
237pub const SYS_getxattr = (SYS_Linux + 227);
238pub const SYS_lgetxattr = (SYS_Linux + 228);
239pub const SYS_fgetxattr = (SYS_Linux + 229);
240pub const SYS_listxattr = (SYS_Linux + 230);
241pub const SYS_llistxattr = (SYS_Linux + 231);
242pub const SYS_flistxattr = (SYS_Linux + 232);
243pub const SYS_removexattr = (SYS_Linux + 233);
244pub const SYS_lremovexattr = (SYS_Linux + 234);
245pub const SYS_fremovexattr = (SYS_Linux + 235);
246pub const SYS_tkill = (SYS_Linux + 236);
247pub const SYS_sendfile64 = (SYS_Linux + 237);
248pub const SYS_futex = (SYS_Linux + 238);
249pub const SYS_sched_setaffinity = (SYS_Linux + 239);
250pub const SYS_sched_getaffinity = (SYS_Linux + 240);
251pub const SYS_io_setup = (SYS_Linux + 241);
252pub const SYS_io_destroy = (SYS_Linux + 242);
253pub const SYS_io_getevents = (SYS_Linux + 243);
254pub const SYS_io_submit = (SYS_Linux + 244);
255pub const SYS_io_cancel = (SYS_Linux + 245);
256pub const SYS_exit_group = (SYS_Linux + 246);
257pub const SYS_lookup_dcookie = (SYS_Linux + 247);
258pub const SYS_epoll_create = (SYS_Linux + 248);
259pub const SYS_epoll_ctl = (SYS_Linux + 249);
260pub const SYS_epoll_wait = (SYS_Linux + 250);
261pub const SYS_remap_file_pages = (SYS_Linux + 251);
262pub const SYS_set_tid_address = (SYS_Linux + 252);
263pub const SYS_restart_syscall = (SYS_Linux + 253);
264pub const SYS_fadvise64 = (SYS_Linux + 254);
265pub const SYS_statfs64 = (SYS_Linux + 255);
266pub const SYS_fstatfs64 = (SYS_Linux + 256);
267pub const SYS_timer_create = (SYS_Linux + 257);
268pub const SYS_timer_settime = (SYS_Linux + 258);
269pub const SYS_timer_gettime = (SYS_Linux + 259);
270pub const SYS_timer_getoverrun = (SYS_Linux + 260);
271pub const SYS_timer_delete = (SYS_Linux + 261);
272pub const SYS_clock_settime = (SYS_Linux + 262);
273pub const SYS_clock_gettime = (SYS_Linux + 263);
274pub const SYS_clock_getres = (SYS_Linux + 264);
275pub const SYS_clock_nanosleep = (SYS_Linux + 265);
276pub const SYS_tgkill = (SYS_Linux + 266);
277pub const SYS_utimes = (SYS_Linux + 267);
278pub const SYS_mbind = (SYS_Linux + 268);
279pub const SYS_get_mempolicy = (SYS_Linux + 269);
280pub const SYS_set_mempolicy = (SYS_Linux + 270);
281pub const SYS_mq_open = (SYS_Linux + 271);
282pub const SYS_mq_unlink = (SYS_Linux + 272);
283pub const SYS_mq_timedsend = (SYS_Linux + 273);
284pub const SYS_mq_timedreceive = (SYS_Linux + 274);
285pub const SYS_mq_notify = (SYS_Linux + 275);
286pub const SYS_mq_getsetattr = (SYS_Linux + 276);
287pub const SYS_vserver = (SYS_Linux + 277);
288pub const SYS_waitid = (SYS_Linux + 278);
289pub const SYS_add_key = (SYS_Linux + 280);
290pub const SYS_request_key = (SYS_Linux + 281);
291pub const SYS_keyctl = (SYS_Linux + 282);
292pub const SYS_set_thread_area = (SYS_Linux + 283);
293pub const SYS_inotify_init = (SYS_Linux + 284);
294pub const SYS_inotify_add_watch = (SYS_Linux + 285);
295pub const SYS_inotify_rm_watch = (SYS_Linux + 286);
296pub const SYS_migrate_pages = (SYS_Linux + 287);
297pub const SYS_openat = (SYS_Linux + 288);
298pub const SYS_mkdirat = (SYS_Linux + 289);
299pub const SYS_mknodat = (SYS_Linux + 290);
300pub const SYS_fchownat = (SYS_Linux + 291);
301pub const SYS_futimesat = (SYS_Linux + 292);
302pub const SYS_fstatat64 = (SYS_Linux + 293);
303pub const SYS_unlinkat = (SYS_Linux + 294);
304pub const SYS_renameat = (SYS_Linux + 295);
305pub const SYS_linkat = (SYS_Linux + 296);
306pub const SYS_symlinkat = (SYS_Linux + 297);
307pub const SYS_readlinkat = (SYS_Linux + 298);
308pub const SYS_fchmodat = (SYS_Linux + 299);
309pub const SYS_faccessat = (SYS_Linux + 300);
310pub const SYS_pselect6 = (SYS_Linux + 301);
311pub const SYS_ppoll = (SYS_Linux + 302);
312pub const SYS_unshare = (SYS_Linux + 303);
313pub const SYS_splice = (SYS_Linux + 304);
314pub const SYS_sync_file_range = (SYS_Linux + 305);
315pub const SYS_tee = (SYS_Linux + 306);
316pub const SYS_vmsplice = (SYS_Linux + 307);
317pub const SYS_move_pages = (SYS_Linux + 308);
318pub const SYS_set_robust_list = (SYS_Linux + 309);
319pub const SYS_get_robust_list = (SYS_Linux + 310);
320pub const SYS_kexec_load = (SYS_Linux + 311);
321pub const SYS_getcpu = (SYS_Linux + 312);
322pub const SYS_epoll_pwait = (SYS_Linux + 313);
323pub const SYS_ioprio_set = (SYS_Linux + 314);
324pub const SYS_ioprio_get = (SYS_Linux + 315);
325pub const SYS_utimensat = (SYS_Linux + 316);
326pub const SYS_signalfd = (SYS_Linux + 317);
327pub const SYS_timerfd = (SYS_Linux + 318);
328pub const SYS_eventfd = (SYS_Linux + 319);
329pub const SYS_fallocate = (SYS_Linux + 320);
330pub const SYS_timerfd_create = (SYS_Linux + 321);
331pub const SYS_timerfd_gettime = (SYS_Linux + 322);
332pub const SYS_timerfd_settime = (SYS_Linux + 323);
333pub const SYS_signalfd4 = (SYS_Linux + 324);
334pub const SYS_eventfd2 = (SYS_Linux + 325);
335pub const SYS_epoll_create1 = (SYS_Linux + 326);
336pub const SYS_dup3 = (SYS_Linux + 327);
337pub const SYS_pipe2 = (SYS_Linux + 328);
338pub const SYS_inotify_init1 = (SYS_Linux + 329);
339pub const SYS_preadv = (SYS_Linux + 330);
340pub const SYS_pwritev = (SYS_Linux + 331);
341pub const SYS_rt_tgsigqueueinfo = (SYS_Linux + 332);
342pub const SYS_perf_event_open = (SYS_Linux + 333);
343pub const SYS_accept4 = (SYS_Linux + 334);
344pub const SYS_recvmmsg = (SYS_Linux + 335);
345pub const SYS_fanotify_init = (SYS_Linux + 336);
346pub const SYS_fanotify_mark = (SYS_Linux + 337);
347pub const SYS_prlimit64 = (SYS_Linux + 338);
348pub const SYS_name_to_handle_at = (SYS_Linux + 339);
349pub const SYS_open_by_handle_at = (SYS_Linux + 340);
350pub const SYS_clock_adjtime = (SYS_Linux + 341);
351pub const SYS_syncfs = (SYS_Linux + 342);
352pub const SYS_sendmmsg = (SYS_Linux + 343);
353pub const SYS_setns = (SYS_Linux + 344);
354pub const SYS_process_vm_readv = (SYS_Linux + 345);
355pub const SYS_process_vm_writev = (SYS_Linux + 346);
356pub const SYS_kcmp = (SYS_Linux + 347);
357pub const SYS_finit_module = (SYS_Linux + 348);
358pub const SYS_sched_setattr = (SYS_Linux + 349);
359pub const SYS_sched_getattr = (SYS_Linux + 350);
360pub const SYS_renameat2 = (SYS_Linux + 351);
361pub const SYS_seccomp = (SYS_Linux + 352);
362pub const SYS_getrandom = (SYS_Linux + 353);
363pub const SYS_memfd_create = (SYS_Linux + 354);
364pub const SYS_bpf = (SYS_Linux + 355);
365pub const SYS_execveat = (SYS_Linux + 356);
366pub const SYS_userfaultfd = (SYS_Linux + 357);
367pub const SYS_membarrier = (SYS_Linux + 358);
368pub const SYS_mlock2 = (SYS_Linux + 359);
369pub const SYS_copy_file_range = (SYS_Linux + 360);
370pub const SYS_preadv2 = (SYS_Linux + 361);
371pub const SYS_pwritev2 = (SYS_Linux + 362);
372pub const SYS_pkey_mprotect = (SYS_Linux + 363);
373pub const SYS_pkey_alloc = (SYS_Linux + 364);
374pub const SYS_pkey_free = (SYS_Linux + 365);
375pub const SYS_statx = (SYS_Linux + 366);
376pub const SYS_rseq = (SYS_Linux + 367);
377pub const SYS_io_pgetevents = (SYS_Linux + 368);
378
379pub const O_CREAT = 0o0400;
380pub const O_EXCL = 0o02000;
381pub const O_NOCTTY = 0o04000;
382pub const O_TRUNC = 0o01000;
383pub const O_APPEND = 0o0010;
384pub const O_NONBLOCK = 0o0200;
385pub const O_DSYNC = 0o0020;
386pub const O_SYNC = 0o040020;
387pub const O_RSYNC = 0o040020;
388pub const O_DIRECTORY = 0o0200000;
389pub const O_NOFOLLOW = 0o0400000;
390pub const O_CLOEXEC = 0o02000000;
391
392pub const O_ASYNC = 0o010000;
393pub const O_DIRECT = 0o0100000;
394pub const O_LARGEFILE = 0o020000;
395pub const O_NOATIME = 0o01000000;
396pub const O_PATH = 0o010000000;
397pub const O_TMPFILE = 0o020200000;
398pub const O_NDELAY = O_NONBLOCK;
399
400pub const F_DUPFD = 0;
401pub const F_GETFD = 1;
402pub const F_SETFD = 2;
403pub const F_GETFL = 3;
404pub const F_SETFL = 4;
405
406pub const F_SETOWN = 24;
407pub const F_GETOWN = 23;
408pub const F_SETSIG = 10;
409pub const F_GETSIG = 11;
410
411pub const F_GETLK = 33;
412pub const F_SETLK = 34;
413pub const F_SETLKW = 35;
414
415pub const F_SETOWN_EX = 15;
416pub const F_GETOWN_EX = 16;
417
418pub const F_GETOWNER_UIDS = 17;
419
420pub const MMAP2_UNIT = 4096;
421
422pub const MAP_NORESERVE = 0x0400;
423pub const MAP_GROWSDOWN = 0x1000;
424pub const MAP_DENYWRITE = 0x2000;
425pub const MAP_EXECUTABLE = 0x4000;
426pub const MAP_LOCKED = 0x8000;
427pub const MAP_32BIT = 0x40;
428
429pub const SO_DEBUG = 1;
430pub const SO_REUSEADDR = 0x0004;
431pub const SO_KEEPALIVE = 0x0008;
432pub const SO_DONTROUTE = 0x0010;
433pub const SO_BROADCAST = 0x0020;
434pub const SO_LINGER = 0x0080;
435pub const SO_OOBINLINE = 0x0100;
436pub const SO_REUSEPORT = 0x0200;
437pub const SO_SNDBUF = 0x1001;
438pub const SO_RCVBUF = 0x1002;
439pub const SO_SNDLOWAT = 0x1003;
440pub const SO_RCVLOWAT = 0x1004;
441pub const SO_RCVTIMEO = 0x1006;
442pub const SO_SNDTIMEO = 0x1005;
443pub const SO_ERROR = 0x1007;
444pub const SO_TYPE = 0x1008;
445pub const SO_ACCEPTCONN = 0x1009;
446pub const SO_PROTOCOL = 0x1028;
447pub const SO_DOMAIN = 0x1029;
448pub const SO_NO_CHECK = 11;
449pub const SO_PRIORITY = 12;
450pub const SO_BSDCOMPAT = 14;
451pub const SO_PASSCRED = 17;
452pub const SO_PEERCRED = 18;
453pub const SO_PEERSEC = 30;
454pub const SO_SNDBUFFORCE = 31;
455pub const SO_RCVBUFFORCE = 33;
456
457pub const VDSO_USEFUL = true;
458pub const VDSO_CGT_SYM = "__kernel_clock_gettime";
459pub const VDSO_CGT_VER = "LINUX_2.6.39";
460
461pub const blksize_t = i32;
462pub const nlink_t = u32;
463pub const time_t = isize;
464pub const mode_t = u32;
465pub const off_t = i64;
466pub const ino_t = u64;
467pub const dev_t = usize;
468pub const blkcnt_t = i64;
469
470pub const Stat = extern struct {
471 dev: u32,
472 __pad0: [3]u32,
473 ino: ino_t,
474 mode: mode_t,
475 nlink: nlink_t,
476 uid: uid_t,
477 gid: gid_t,
478 rdev: dev_t,
479 __pad1: [3]u32,
480 size: off_t,
481 atim: timespec,
482 mtim: timespec,
483 ctim: timespec,
484 blksize: blksize_t,
485 __pad3: [1]u32,
486 blocks: blkcnt_t,
487
488 pub fn atime(self: Stat) timespec {
489 return self.atim;
490 }
491
492 pub fn mtime(self: Stat) timespec {
493 return self.mtim;
494 }
495
496 pub fn ctime(self: Stat) timespec {
497 return self.ctim;
498 }
499};
500
501pub const timespec = extern struct {
502 tv_sec: isize,
503 tv_nsec: isize,
504};
505
506pub const timeval = extern struct {
507 tv_sec: isize,
508 tv_usec: isize,
509};
510
511pub const timezone = extern struct {
512 tz_minuteswest: i32,
513 tz_dsttime: i32,
514};
515
516pub const Elf_Symndx = u32;
lib/std/os/linux.zig+1
...@@ -19,6 +19,7 @@ pub usingnamespace switch (builtin.arch) {...@@ -19,6 +19,7 @@ pub usingnamespace switch (builtin.arch) {
19 .aarch64 => @import("linux/arm64.zig"),19 .aarch64 => @import("linux/arm64.zig"),
20 .arm => @import("linux/arm-eabi.zig"),20 .arm => @import("linux/arm-eabi.zig"),
21 .riscv64 => @import("linux/riscv64.zig"),21 .riscv64 => @import("linux/riscv64.zig"),
22 .mipsel => @import("linux/mipsel.zig"),
22 else => struct {},23 else => struct {},
23};24};
24pub usingnamespace @import("bits.zig");25pub usingnamespace @import("bits.zig");
lib/std/os/linux/mipsel.zig created+124
...@@ -0,0 +1,124 @@
1pub fn syscall0(number: usize) usize {
2 return asm volatile (
3 \\ syscall
4 \\ blez $7, 1f
5 \\ subu $2, $0, $2
6 \\ 1:
7 : [ret] "={$2}" (-> usize)
8 : [number] "{$2}" (number)
9 : "memory", "cc", "$7"
10 );
11}
12
13pub fn syscall1(number: usize, arg1: usize) usize {
14 return asm volatile (
15 \\ syscall
16 \\ blez $7, 1f
17 \\ subu $2, $0, $2
18 \\ 1:
19 : [ret] "={$2}" (-> usize)
20 : [number] "{$2}" (number),
21 [arg1] "{$4}" (arg1)
22 : "memory", "cc", "$7"
23 );
24}
25
26pub fn syscall2(number: usize, arg1: usize, arg2: usize) usize {
27 return asm volatile (
28 \\ syscall
29 \\ blez $7, 1f
30 \\ subu $2, $0, $2
31 \\ 1:
32 : [ret] "={$2}" (-> usize)
33 : [number] "{$2}" (number),
34 [arg1] "{$4}" (arg1),
35 [arg2] "{$5}" (arg2)
36 : "memory", "cc", "$7"
37 );
38}
39
40pub fn syscall3(number: usize, arg1: usize, arg2: usize, arg3: usize) usize {
41 return asm volatile (
42 \\ syscall
43 \\ blez $7, 1f
44 \\ subu $2, $0, $2
45 \\ 1:
46 : [ret] "={$2}" (-> usize)
47 : [number] "{$2}" (number),
48 [arg1] "{$4}" (arg1),
49 [arg2] "{$5}" (arg2),
50 [arg3] "{$6}" (arg3)
51 : "memory", "cc", "$7"
52 );
53}
54
55pub fn syscall4(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
56 return asm volatile (
57 \\ syscall
58 \\ blez $7, 1f
59 \\ subu $2, $0, $2
60 \\ 1:
61 : [ret] "={$2}" (-> usize)
62 : [number] "{$2}" (number),
63 [arg1] "{$4}" (arg1),
64 [arg2] "{$5}" (arg2),
65 [arg3] "{$6}" (arg3),
66 [arg4] "{$7}" (arg4)
67 : "memory", "cc", "$7"
68 );
69}
70
71pub fn syscall5(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
72 return asm volatile (
73 \\ .set noat
74 \\ subu $sp, $sp, 24
75 \\ sw %[arg5], 16($sp)
76 \\ syscall
77 \\ addu $sp, $sp, 24
78 \\ blez $7, 1f
79 \\ subu $2, $0, $2
80 \\ 1:
81 : [ret] "={$2}" (-> usize)
82 : [number] "{$2}" (number),
83 [arg1] "{$4}" (arg1),
84 [arg2] "{$5}" (arg2),
85 [arg3] "{$6}" (arg3),
86 [arg4] "{$7}" (arg4),
87 [arg5] "r" (arg5)
88 : "memory", "cc", "$7"
89 );
90}
91
92pub fn syscall6(
93 number: usize,
94 arg1: usize,
95 arg2: usize,
96 arg3: usize,
97 arg4: usize,
98 arg5: usize,
99 arg6: usize,
100) usize {
101 return asm volatile (
102 \\ .set noat
103 \\ subu $sp, $sp, 24
104 \\ sw %[arg5], 16($sp)
105 \\ sw %[arg6], 20($sp)
106 \\ syscall
107 \\ addu $sp, $sp, 24
108 \\ blez $7, 1f
109 \\ subu $2, $0, $2
110 \\ 1:
111 : [ret] "={$2}" (-> usize)
112 : [number] "{$2}" (number),
113 [arg1] "{$4}" (arg1),
114 [arg2] "{$5}" (arg2),
115 [arg3] "{$6}" (arg3),
116 [arg4] "{$7}" (arg4),
117 [arg5] "r" (arg5),
118 [arg6] "r" (arg6)
119 : "memory", "cc", "$7"
120 );
121}
122
123/// This matches the libc clone function.
124pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
lib/std/os/linux/tls.zig+4
...@@ -137,6 +137,10 @@ pub fn setThreadPointer(addr: usize) void {...@@ -137,6 +137,10 @@ pub fn setThreadPointer(addr: usize) void {
137 : [addr] "r" (addr)137 : [addr] "r" (addr)
138 );138 );
139 },139 },
140 .mipsel => {
141 const rc = std.os.linux.syscall1(std.os.linux.SYS_set_thread_area, addr);
142 assert(rc == 0);
143 },
140 else => @compileError("Unsupported architecture"),144 else => @compileError("Unsupported architecture"),
141 }145 }
142}146}
lib/std/os/zen.zig+1-1
...@@ -80,7 +80,7 @@ pub const STDOUT_FILENO = 1;...@@ -80,7 +80,7 @@ pub const STDOUT_FILENO = 1;
80pub const STDERR_FILENO = 2;80pub const STDERR_FILENO = 2;
8181
82// FIXME: let's borrow Linux's error numbers for now.82// FIXME: let's borrow Linux's error numbers for now.
83usingnamespace @import("bits/linux/errno.zig");83usingnamespace @import("bits/linux/errno-generic.zig");
84// Get the errno from a syscall return value, or 0 for no error.84// Get the errno from a syscall return value, or 0 for no error.
85pub fn getErrno(r: usize) usize {85pub fn getErrno(r: usize) usize {
86 const signed_r = @bitCast(isize, r);86 const signed_r = @bitCast(isize, r);
lib/std/special/c.zig+35
...@@ -310,6 +310,41 @@ nakedcc fn clone() void {...@@ -310,6 +310,41 @@ nakedcc fn clone() void {
310 \\ ecall310 \\ ecall
311 );311 );
312 },312 },
313 .mipsel => {
314 asm volatile (
315 \\ # Save function pointer and argument pointer on new thread stack
316 \\ and $5, $5, -8
317 \\ subu $5, $5, 16
318 \\ sw $4, 0($5)
319 \\ sw $7, 4($5)
320 \\ # Shuffle (fn,sp,fl,arg,ptid,tls,ctid) to (fl,sp,ptid,tls,ctid)
321 \\ move $4, $6
322 \\ lw $6, 16($sp)
323 \\ lw $7, 20($sp)
324 \\ lw $9, 24($sp)
325 \\ subu $sp, $sp, 16
326 \\ sw $9, 16($sp)
327 \\ li $2, 4120
328 \\ syscall
329 \\ beq $7, $0, 1f
330 \\ nop
331 \\ addu $sp, $sp, 16
332 \\ jr $ra
333 \\ subu $2, $0, $2
334 \\1: beq $2, $0, 1f
335 \\ nop
336 \\ addu $sp, $sp, 16
337 \\ jr $ra
338 \\ nop
339 \\1: lw $25, 0($sp)
340 \\ lw $4, 4($sp)
341 \\ jalr $25
342 \\ nop
343 \\ move $4, $2
344 \\ li $2, 4001
345 \\ syscall
346 );
347 },
313 else => @compileError("Implement clone() for this arch."),348 else => @compileError("Implement clone() for this arch."),
314 }349 }
315}350}
lib/std/special/start.zig+15
...@@ -13,6 +13,11 @@ const is_wasm = switch (builtin.arch) {...@@ -13,6 +13,11 @@ const is_wasm = switch (builtin.arch) {
13 else => false,13 else => false,
14};14};
1515
16const is_mips = switch (builtin.arch) {
17 .mips, .mipsel, .mips64, .mips64el => true,
18 else => false,
19};
20
16comptime {21comptime {
17 if (builtin.link_libc) {22 if (builtin.link_libc) {
18 @export("main", main, .Strong);23 @export("main", main, .Strong);
...@@ -22,6 +27,8 @@ comptime {...@@ -22,6 +27,8 @@ comptime {
22 @export("_start", wasm_freestanding_start, .Strong);27 @export("_start", wasm_freestanding_start, .Strong);
23 } else if (builtin.os == .uefi) {28 } else if (builtin.os == .uefi) {
24 @export("EfiMain", EfiMain, .Strong);29 @export("EfiMain", EfiMain, .Strong);
30 } else if (is_mips) {
31 if (!@hasDecl(root, "__start")) @export("__start", _start, .Strong);
25 } else {32 } else {
26 if (!@hasDecl(root, "_start")) @export("_start", _start, .Strong);33 if (!@hasDecl(root, "_start")) @export("_start", _start, .Strong);
27 }34 }
...@@ -80,6 +87,14 @@ nakedcc fn _start() noreturn {...@@ -80,6 +87,14 @@ nakedcc fn _start() noreturn {
80 : [argc] "=r" (-> [*]usize)87 : [argc] "=r" (-> [*]usize)
81 );88 );
82 },89 },
90 .mipsel => {
91 // Need noat here because LLVM is free to pick any register
92 starting_stack_ptr = asm (
93 \\ .set noat
94 \\ move %[argc], $sp
95 : [argc] "=r" (-> [*]usize)
96 );
97 },
83 else => @compileError("unsupported arch"),98 else => @compileError("unsupported arch"),
84 }99 }
85 // If LLVM inlines stack variables into _start, they will overwrite100 // If LLVM inlines stack variables into _start, they will overwrite
src/analyze.cpp+2
...@@ -918,6 +918,8 @@ bool want_first_arg_sret(CodeGen *g, FnTypeId *fn_type_id) {...@@ -918,6 +918,8 @@ bool want_first_arg_sret(CodeGen *g, FnTypeId *fn_type_id) {
918 return abi_class == X64CABIClass_MEMORY;918 return abi_class == X64CABIClass_MEMORY;
919 } else if (target_is_arm(g->zig_target)) {919 } else if (target_is_arm(g->zig_target)) {
920 return type_size(g, fn_type_id->return_type) > 16;920 return type_size(g, fn_type_id->return_type) > 16;
921 } else if (g->zig_target->arch == ZigLLVM_mipsel) {
922 return false;
921 }923 }
922 zig_panic("TODO implement C ABI for this architecture. See https://github.com/ziglang/zig/issues/1481");924 zig_panic("TODO implement C ABI for this architecture. See https://github.com/ziglang/zig/issues/1481");
923}925}
src/link.cpp-1
...@@ -1816,7 +1816,6 @@ static void construct_linker_job_elf(LinkJob *lj) {...@@ -1816,7 +1816,6 @@ static void construct_linker_job_elf(LinkJob *lj) {
1816 if (g->zig_target->os == OsZen) {1816 if (g->zig_target->os == OsZen) {
1817 lj->args.append("-e");1817 lj->args.append("-e");
1818 lj->args.append("_start");1818 lj->args.append("_start");
1819
1820 lj->args.append("--image-base=0x10000000");1819 lj->args.append("--image-base=0x10000000");
1821 }1820 }
1822}1821}
src/target.cpp+6-1
...@@ -1450,6 +1450,7 @@ const char *arch_stack_pointer_register_name(ZigLLVM_ArchType arch) {...@@ -1450,6 +1450,7 @@ const char *arch_stack_pointer_register_name(ZigLLVM_ArchType arch) {
1450 case ZigLLVM_aarch64_32:1450 case ZigLLVM_aarch64_32:
1451 case ZigLLVM_riscv32:1451 case ZigLLVM_riscv32:
1452 case ZigLLVM_riscv64:1452 case ZigLLVM_riscv64:
1453 case ZigLLVM_mipsel:
1453 return "sp";1454 return "sp";
14541455
1455 case ZigLLVM_amdgcn:1456 case ZigLLVM_amdgcn:
...@@ -1469,7 +1470,6 @@ const char *arch_stack_pointer_register_name(ZigLLVM_ArchType arch) {...@@ -1469,7 +1470,6 @@ const char *arch_stack_pointer_register_name(ZigLLVM_ArchType arch) {
1469 case ZigLLVM_mips:1470 case ZigLLVM_mips:
1470 case ZigLLVM_mips64:1471 case ZigLLVM_mips64:
1471 case ZigLLVM_mips64el:1472 case ZigLLVM_mips64el:
1472 case ZigLLVM_mipsel:
1473 case ZigLLVM_msp430:1473 case ZigLLVM_msp430:
1474 case ZigLLVM_nvptx:1474 case ZigLLVM_nvptx:
1475 case ZigLLVM_nvptx64:1475 case ZigLLVM_nvptx64:
...@@ -1886,6 +1886,11 @@ bool target_is_riscv(const ZigTarget *target) {...@@ -1886,6 +1886,11 @@ bool target_is_riscv(const ZigTarget *target) {
1886 return target->arch == ZigLLVM_riscv32 || target->arch == ZigLLVM_riscv64;1886 return target->arch == ZigLLVM_riscv32 || target->arch == ZigLLVM_riscv64;
1887}1887}
18881888
1889bool target_is_mips(const ZigTarget *target) {
1890 return target->arch == ZigLLVM_mips || target->arch == ZigLLVM_mipsel ||
1891 target->arch == ZigLLVM_mips64 || target->arch == ZigLLVM_mips64el;
1892}
1893
1889unsigned target_fn_align(const ZigTarget *target) {1894unsigned target_fn_align(const ZigTarget *target) {
1890 return 16;1895 return 16;
1891}1896}
src/target.hpp+1
...@@ -172,6 +172,7 @@ bool target_can_exec(const ZigTarget *host_target, const ZigTarget *guest_target...@@ -172,6 +172,7 @@ bool target_can_exec(const ZigTarget *host_target, const ZigTarget *guest_target
172ZigLLVM_OSType get_llvm_os_type(Os os_type);172ZigLLVM_OSType get_llvm_os_type(Os os_type);
173173
174bool target_is_arm(const ZigTarget *target);174bool target_is_arm(const ZigTarget *target);
175bool target_is_mips(const ZigTarget *target);
175bool target_allows_addr_zero(const ZigTarget *target);176bool target_allows_addr_zero(const ZigTarget *target);
176bool target_has_valgrind_support(const ZigTarget *target);177bool target_has_valgrind_support(const ZigTarget *target);
177bool target_os_is_darwin(Os os);178bool target_os_is_darwin(Os os);
test/stage1/behavior/byteswap.zig+3
...@@ -39,6 +39,9 @@ test "@byteSwap integers" {...@@ -39,6 +39,9 @@ test "@byteSwap integers" {
39}39}
4040
41test "@byteSwap vectors" {41test "@byteSwap vectors" {
42 // Disabled because of #3317
43 if (@import("builtin").arch == .mipsel) return error.SkipZigTest;
44
42 const ByteSwapVectorTest = struct {45 const ByteSwapVectorTest = struct {
43 fn run() void {46 fn run() void {
44 t(u8, 2, [_]u8{ 0x12, 0x13 }, [_]u8{ 0x12, 0x13 });47 t(u8, 2, [_]u8{ 0x12, 0x13 }, [_]u8{ 0x12, 0x13 });
test/stage1/behavior/new_stack_call.zig+1
...@@ -6,6 +6,7 @@ var new_stack_bytes: [1024]u8 align(16) = undefined;...@@ -6,6 +6,7 @@ var new_stack_bytes: [1024]u8 align(16) = undefined;
6test "calling a function with a new stack" {6test "calling a function with a new stack" {
7 // TODO: https://github.com/ziglang/zig/issues/32687 // TODO: https://github.com/ziglang/zig/issues/3268
8 if (@import("builtin").arch == .aarch64) return error.SkipZigTest;8 if (@import("builtin").arch == .aarch64) return error.SkipZigTest;
9 if (@import("builtin").arch == .mipsel) return error.SkipZigTest;
910
10 const arg = 1234;11 const arg = 1234;
1112
test/stage1/behavior/shuffle.zig+2-1
...@@ -33,7 +33,8 @@ test "@shuffle" {...@@ -33,7 +33,8 @@ test "@shuffle" {
33 expect(mem.eql(i32, ([4]i32)(res), [4]i32{ 2147483647, 3, -2, 4 }));33 expect(mem.eql(i32, ([4]i32)(res), [4]i32{ 2147483647, 3, -2, 4 }));
3434
35 // bool35 // bool
36 {36 // Disabled because of #3317
37 if (@import("builtin").arch != .mipsel) {
37 var x2: @Vector(4, bool) = [4]bool{ false, true, false, true };38 var x2: @Vector(4, bool) = [4]bool{ false, true, false, true };
38 var v4: @Vector(2, bool) = [2]bool{ true, false };39 var v4: @Vector(2, bool) = [2]bool{ true, false };
39 const mask5: @Vector(4, i32) = [4]i32{ 0, ~i32(1), 1, 2 };40 const mask5: @Vector(4, i32) = [4]i32{ 0, ~i32(1), 1, 2 };
test/tests.zig+10
...@@ -131,6 +131,16 @@ const test_targets = [_]TestTarget{...@@ -131,6 +131,16 @@ const test_targets = [_]TestTarget{
131 // .link_libc = true,131 // .link_libc = true,
132 //},132 //},
133133
134 TestTarget{
135 .target = Target{
136 .Cross = CrossTarget{
137 .os = .linux,
138 .arch = .mipsel,
139 .abi = .none,
140 },
141 },
142 },
143
134 TestTarget{144 TestTarget{
135 .target = Target{145 .target = Target{
136 .Cross = CrossTarget{146 .Cross = CrossTarget{