authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-01 18:07:58-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2021-05-01 18:07:58-04:00
log4f9c928e5623b291af83cefe0a63ce2226e51dbe
treebed37fbcea2fbdccd5d033f6fe0e6f140157e528
parente9e91b4ed058f4c4e3f3380ec06cb914becd04a8
parentd788181a3b96ec653f5bef42916a8129837cdac4
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #8665 from LemonBoy/misc

Miscellaneous patches

9 files changed, 306 insertions(+), 49 deletions(-)

lib/std/Thread.zig+21-4
...@@ -68,11 +68,28 @@ else switch (std.Target.current.os.tag) {...@@ -68,11 +68,28 @@ else switch (std.Target.current.os.tag) {
68};68};
6969
70/// Signals the processor that it is inside a busy-wait spin-loop ("spin lock").70/// Signals the processor that it is inside a busy-wait spin-loop ("spin lock").
71pub fn spinLoopHint() void {71pub fn spinLoopHint() callconv(.Inline) void {
72 switch (std.Target.current.cpu.arch) {72 switch (std.Target.current.cpu.arch) {
73 .i386, .x86_64 => asm volatile ("pause" ::: "memory"),73 .i386, .x86_64 => {
74 .arm, .aarch64 => asm volatile ("yield" ::: "memory"),74 asm volatile ("pause" ::: "memory");
75 else => {},75 },
76 .arm, .armeb, .thumb, .thumbeb => {
77 // `yield` was introduced in v6k but are also available on v6m.
78 const can_yield = comptime std.Target.arm.featureSetHas(std.Target.current.cpu.features, .has_v6m);
79 if (can_yield) asm volatile ("yield" ::: "memory");
80 },
81 .aarch64, .aarch64_be, .aarch64_32 => {
82 asm volatile ("isb" ::: "memory");
83 },
84 .powerpc64, .powerpc64le => {
85 // No-op that serves as `yield` hint.
86 asm volatile ("or 27, 27, 27" ::: "memory");
87 },
88 else => {
89 // Do nothing but prevent the compiler from optimizing away the
90 // spinning loop.
91 asm volatile ("" ::: "memory");
92 },
76 }93 }
77}94}
7895
lib/std/math/copysign.zig+18
...@@ -20,6 +20,7 @@ pub fn copysign(comptime T: type, x: T, y: T) T {...@@ -20,6 +20,7 @@ pub fn copysign(comptime T: type, x: T, y: T) T {
20 f16 => copysign16(x, y),20 f16 => copysign16(x, y),
21 f32 => copysign32(x, y),21 f32 => copysign32(x, y),
22 f64 => copysign64(x, y),22 f64 => copysign64(x, y),
23 f128 => copysign128(x, y),
23 else => @compileError("copysign not implemented for " ++ @typeName(T)),24 else => @compileError("copysign not implemented for " ++ @typeName(T)),
24 };25 };
25}26}
...@@ -51,10 +52,20 @@ fn copysign64(x: f64, y: f64) f64 {...@@ -51,10 +52,20 @@ fn copysign64(x: f64, y: f64) f64 {
51 return @bitCast(f64, h1 | h2);52 return @bitCast(f64, h1 | h2);
52}53}
5354
55fn copysign128(x: f128, y: f128) f128 {
56 const ux = @bitCast(u128, x);
57 const uy = @bitCast(u128, y);
58
59 const h1 = ux & (maxInt(u128) / 2);
60 const h2 = uy & (@as(u128, 1) << 127);
61 return @bitCast(f128, h1 | h2);
62}
63
54test "math.copysign" {64test "math.copysign" {
55 expect(copysign(f16, 1.0, 1.0) == copysign16(1.0, 1.0));65 expect(copysign(f16, 1.0, 1.0) == copysign16(1.0, 1.0));
56 expect(copysign(f32, 1.0, 1.0) == copysign32(1.0, 1.0));66 expect(copysign(f32, 1.0, 1.0) == copysign32(1.0, 1.0));
57 expect(copysign(f64, 1.0, 1.0) == copysign64(1.0, 1.0));67 expect(copysign(f64, 1.0, 1.0) == copysign64(1.0, 1.0));
68 expect(copysign(f128, 1.0, 1.0) == copysign128(1.0, 1.0));
58}69}
5970
60test "math.copysign16" {71test "math.copysign16" {
...@@ -77,3 +88,10 @@ test "math.copysign64" {...@@ -77,3 +88,10 @@ test "math.copysign64" {
77 expect(copysign64(-5.0, -1.0) == -5.0);88 expect(copysign64(-5.0, -1.0) == -5.0);
78 expect(copysign64(-5.0, 1.0) == 5.0);89 expect(copysign64(-5.0, 1.0) == 5.0);
79}90}
91
92test "math.copysign128" {
93 expect(copysign128(5.0, 1.0) == 5.0);
94 expect(copysign128(5.0, -1.0) == -5.0);
95 expect(copysign128(-5.0, -1.0) == -5.0);
96 expect(copysign128(-5.0, 1.0) == 5.0);
97}
lib/std/math/isfinite.zig+18
...@@ -24,6 +24,10 @@ pub fn isFinite(x: anytype) bool {...@@ -24,6 +24,10 @@ pub fn isFinite(x: anytype) bool {
24 const bits = @bitCast(u64, x);24 const bits = @bitCast(u64, x);
25 return bits & (maxInt(u64) >> 1) < (0x7FF << 52);25 return bits & (maxInt(u64) >> 1) < (0x7FF << 52);
26 },26 },
27 f128 => {
28 const bits = @bitCast(u128, x);
29 return bits & (maxInt(u128) >> 1) < (0x7FFF << 112);
30 },
27 else => {31 else => {
28 @compileError("isFinite not implemented for " ++ @typeName(T));32 @compileError("isFinite not implemented for " ++ @typeName(T));
29 },33 },
...@@ -37,10 +41,24 @@ test "math.isFinite" {...@@ -37,10 +41,24 @@ test "math.isFinite" {
37 expect(isFinite(@as(f32, -0.0)));41 expect(isFinite(@as(f32, -0.0)));
38 expect(isFinite(@as(f64, 0.0)));42 expect(isFinite(@as(f64, 0.0)));
39 expect(isFinite(@as(f64, -0.0)));43 expect(isFinite(@as(f64, -0.0)));
44 expect(isFinite(@as(f128, 0.0)));
45 expect(isFinite(@as(f128, -0.0)));
46
40 expect(!isFinite(math.inf(f16)));47 expect(!isFinite(math.inf(f16)));
41 expect(!isFinite(-math.inf(f16)));48 expect(!isFinite(-math.inf(f16)));
42 expect(!isFinite(math.inf(f32)));49 expect(!isFinite(math.inf(f32)));
43 expect(!isFinite(-math.inf(f32)));50 expect(!isFinite(-math.inf(f32)));
44 expect(!isFinite(math.inf(f64)));51 expect(!isFinite(math.inf(f64)));
45 expect(!isFinite(-math.inf(f64)));52 expect(!isFinite(-math.inf(f64)));
53 expect(!isFinite(math.inf(f128)));
54 expect(!isFinite(-math.inf(f128)));
55
56 expect(!isFinite(math.nan(f16)));
57 expect(!isFinite(-math.nan(f16)));
58 expect(!isFinite(math.nan(f32)));
59 expect(!isFinite(-math.nan(f32)));
60 expect(!isFinite(math.nan(f64)));
61 expect(!isFinite(-math.nan(f64)));
62 expect(!isFinite(math.nan(f128)));
63 expect(!isFinite(-math.nan(f128)));
46}64}
lib/std/math/signbit.zig+12
...@@ -14,6 +14,7 @@ pub fn signbit(x: anytype) bool {...@@ -14,6 +14,7 @@ pub fn signbit(x: anytype) bool {
14 f16 => signbit16(x),14 f16 => signbit16(x),
15 f32 => signbit32(x),15 f32 => signbit32(x),
16 f64 => signbit64(x),16 f64 => signbit64(x),
17 f128 => signbit128(x),
17 else => @compileError("signbit not implemented for " ++ @typeName(T)),18 else => @compileError("signbit not implemented for " ++ @typeName(T)),
18 };19 };
19}20}
...@@ -33,10 +34,16 @@ fn signbit64(x: f64) bool {...@@ -33,10 +34,16 @@ fn signbit64(x: f64) bool {
33 return bits >> 63 != 0;34 return bits >> 63 != 0;
34}35}
3536
37fn signbit128(x: f128) bool {
38 const bits = @bitCast(u128, x);
39 return bits >> 127 != 0;
40}
41
36test "math.signbit" {42test "math.signbit" {
37 expect(signbit(@as(f16, 4.0)) == signbit16(4.0));43 expect(signbit(@as(f16, 4.0)) == signbit16(4.0));
38 expect(signbit(@as(f32, 4.0)) == signbit32(4.0));44 expect(signbit(@as(f32, 4.0)) == signbit32(4.0));
39 expect(signbit(@as(f64, 4.0)) == signbit64(4.0));45 expect(signbit(@as(f64, 4.0)) == signbit64(4.0));
46 expect(signbit(@as(f128, 4.0)) == signbit128(4.0));
40}47}
4148
42test "math.signbit16" {49test "math.signbit16" {
...@@ -53,3 +60,8 @@ test "math.signbit64" {...@@ -53,3 +60,8 @@ test "math.signbit64" {
53 expect(!signbit64(4.0));60 expect(!signbit64(4.0));
54 expect(signbit64(-3.0));61 expect(signbit64(-3.0));
55}62}
63
64test "math.signbit128" {
65 expect(!signbit128(4.0));
66 expect(signbit128(-3.0));
67}
lib/std/os/bits/linux.zig+73-34
...@@ -10,6 +10,7 @@ usingnamespace @import("../bits.zig");...@@ -10,6 +10,7 @@ usingnamespace @import("../bits.zig");
1010
11pub usingnamespace switch (builtin.arch) {11pub usingnamespace switch (builtin.arch) {
12 .mips, .mipsel => @import("linux/errno-mips.zig"),12 .mips, .mipsel => @import("linux/errno-mips.zig"),
13 .sparc, .sparcel, .sparcv9 => @import("linux/errno-sparc.zig"),
13 else => @import("linux/errno-generic.zig"),14 else => @import("linux/errno-generic.zig"),
14};15};
1516
...@@ -247,40 +248,78 @@ else...@@ -247,40 +248,78 @@ else
247 pub const SIG_SETMASK = 2;248 pub const SIG_SETMASK = 2;
248 };249 };
249250
250pub const SIGHUP = 1;251pub usingnamespace if (is_sparc) struct {
251pub const SIGINT = 2;252 pub const SIGHUP = 1;
252pub const SIGQUIT = 3;253 pub const SIGINT = 2;
253pub const SIGILL = 4;254 pub const SIGQUIT = 3;
254pub const SIGTRAP = 5;255 pub const SIGILL = 4;
255pub const SIGABRT = 6;256 pub const SIGTRAP = 5;
256pub const SIGIOT = SIGABRT;257 pub const SIGABRT = 6;
257pub const SIGBUS = 7;258 pub const SIGEMT = 7;
258pub const SIGFPE = 8;259 pub const SIGFPE = 8;
259pub const SIGKILL = 9;260 pub const SIGKILL = 9;
260pub const SIGUSR1 = 10;261 pub const SIGBUS = 10;
261pub const SIGSEGV = 11;262 pub const SIGSEGV = 11;
262pub const SIGUSR2 = 12;263 pub const SIGSYS = 12;
263pub const SIGPIPE = 13;264 pub const SIGPIPE = 13;
264pub const SIGALRM = 14;265 pub const SIGALRM = 14;
265pub const SIGTERM = 15;266 pub const SIGTERM = 15;
266pub const SIGSTKFLT = 16;267 pub const SIGURG = 16;
267pub const SIGCHLD = 17;268 pub const SIGSTOP = 17;
268pub const SIGCONT = 18;269 pub const SIGTSTP = 18;
269pub const SIGSTOP = 19;270 pub const SIGCONT = 19;
270pub const SIGTSTP = 20;271 pub const SIGCHLD = 20;
271pub const SIGTTIN = 21;272 pub const SIGTTIN = 21;
272pub const SIGTTOU = 22;273 pub const SIGTTOU = 22;
273pub const SIGURG = 23;274 pub const SIGPOLL = 23;
274pub const SIGXCPU = 24;275 pub const SIGXCPU = 24;
275pub const SIGXFSZ = 25;276 pub const SIGXFSZ = 25;
276pub const SIGVTALRM = 26;277 pub const SIGVTALRM = 26;
277pub const SIGPROF = 27;278 pub const SIGPROF = 27;
278pub const SIGWINCH = 28;279 pub const SIGWINCH = 28;
279pub const SIGIO = 29;280 pub const SIGLOST = 29;
280pub const SIGPOLL = 29;281 pub const SIGUSR1 = 30;
281pub const SIGPWR = 30;282 pub const SIGUSR2 = 31;
282pub const SIGSYS = 31;283 pub const SIGIOT = SIGABRT;
283pub const SIGUNUSED = SIGSYS;284 pub const SIGCLD = SIGCHLD;
285 pub const SIGPWR = SIGLOST;
286 pub const SIGIO = SIGPOLL;
287} else struct {
288 pub const SIGHUP = 1;
289 pub const SIGINT = 2;
290 pub const SIGQUIT = 3;
291 pub const SIGILL = 4;
292 pub const SIGTRAP = 5;
293 pub const SIGABRT = 6;
294 pub const SIGIOT = SIGABRT;
295 pub const SIGBUS = 7;
296 pub const SIGFPE = 8;
297 pub const SIGKILL = 9;
298 pub const SIGUSR1 = 10;
299 pub const SIGSEGV = 11;
300 pub const SIGUSR2 = 12;
301 pub const SIGPIPE = 13;
302 pub const SIGALRM = 14;
303 pub const SIGTERM = 15;
304 pub const SIGSTKFLT = 16;
305 pub const SIGCHLD = 17;
306 pub const SIGCONT = 18;
307 pub const SIGSTOP = 19;
308 pub const SIGTSTP = 20;
309 pub const SIGTTIN = 21;
310 pub const SIGTTOU = 22;
311 pub const SIGURG = 23;
312 pub const SIGXCPU = 24;
313 pub const SIGXFSZ = 25;
314 pub const SIGVTALRM = 26;
315 pub const SIGPROF = 27;
316 pub const SIGWINCH = 28;
317 pub const SIGIO = 29;
318 pub const SIGPOLL = 29;
319 pub const SIGPWR = 30;
320 pub const SIGSYS = 31;
321 pub const SIGUNUSED = SIGSYS;
322};
284323
285pub const O_RDONLY = 0o0;324pub const O_RDONLY = 0o0;
286pub const O_WRONLY = 0o1;325pub const O_WRONLY = 0o1;
lib/std/os/bits/linux/errno-mips.zig+4
...@@ -3,6 +3,9 @@...@@ -3,6 +3,9 @@
3// This file is part of [zig](https://ziglang.org/), which is MIT licensed.3// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
4// The MIT license requires this copyright notice to be included in all copies4// The MIT license requires this copyright notice to be included in all copies
5// and substantial portions of the software.5// and substantial portions of the software.
6
7// These are MIPS ABI compatible.
8
6pub const EPERM = 1;9pub const EPERM = 1;
7pub const ENOENT = 2;10pub const ENOENT = 2;
8pub const ESRCH = 3;11pub const ESRCH = 3;
...@@ -37,6 +40,7 @@ pub const EMLINK = 31;...@@ -37,6 +40,7 @@ pub const EMLINK = 31;
37pub const EPIPE = 32;40pub const EPIPE = 32;
38pub const EDOM = 33;41pub const EDOM = 33;
39pub const ERANGE = 34;42pub const ERANGE = 34;
43
40pub const ENOMSG = 35;44pub const ENOMSG = 35;
41pub const EIDRM = 36;45pub const EIDRM = 36;
42pub const ECHRNG = 37;46pub const ECHRNG = 37;
lib/std/os/bits/linux/errno-sparc.zig created+144
...@@ -0,0 +1,144 @@
1// SPDX-License-Identifier: MIT
2// Copyright (c) 2015-2021 Zig Contributors
3// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
4// The MIT license requires this copyright notice to be included in all copies
5// and substantial portions of the software.
6
7// These match the SunOS error numbering scheme.
8
9pub const EPERM = 1;
10pub const ENOENT = 2;
11pub const ESRCH = 3;
12pub const EINTR = 4;
13pub const EIO = 5;
14pub const ENXIO = 6;
15pub const E2BIG = 7;
16pub const ENOEXEC = 8;
17pub const EBADF = 9;
18pub const ECHILD = 10;
19pub const EAGAIN = 11;
20pub const ENOMEM = 12;
21pub const EACCES = 13;
22pub const EFAULT = 14;
23pub const ENOTBLK = 15;
24pub const EBUSY = 16;
25pub const EEXIST = 17;
26pub const EXDEV = 18;
27pub const ENODEV = 19;
28pub const ENOTDIR = 20;
29pub const EISDIR = 21;
30pub const EINVAL = 22;
31pub const ENFILE = 23;
32pub const EMFILE = 24;
33pub const ENOTTY = 25;
34pub const ETXTBSY = 26;
35pub const EFBIG = 27;
36pub const ENOSPC = 28;
37pub const ESPIPE = 29;
38pub const EROFS = 30;
39pub const EMLINK = 31;
40pub const EPIPE = 32;
41pub const EDOM = 33;
42pub const ERANGE = 34;
43
44pub const EWOULDBLOCK = EAGAIN;
45pub const EINPROGRESS = 36;
46pub const EALREADY = 37;
47pub const ENOTSOCK = 38;
48pub const EDESTADDRREQ = 39;
49pub const EMSGSIZE = 40;
50pub const EPROTOTYPE = 41;
51pub const ENOPROTOOPT = 42;
52pub const EPROTONOSUPPORT = 43;
53pub const ESOCKTNOSUPPORT = 44;
54pub const EOPNOTSUPP = 45;
55pub const EPFNOSUPPORT = 46;
56pub const EAFNOSUPPORT = 47;
57pub const EADDRINUSE = 48;
58pub const EADDRNOTAVAIL = 49;
59pub const ENETDOWN = 50;
60pub const ENETUNREACH = 51;
61pub const ENETRESET = 52;
62pub const ECONNABORTED = 53;
63pub const ECONNRESET = 54;
64pub const ENOBUFS = 55;
65pub const EISCONN = 56;
66pub const ENOTCONN = 57;
67pub const ESHUTDOWN = 58;
68pub const ETOOMANYREFS = 59;
69pub const ETIMEDOUT = 60;
70pub const ECONNREFUSED = 61;
71pub const ELOOP = 62;
72pub const ENAMETOOLONG = 63;
73pub const EHOSTDOWN = 64;
74pub const EHOSTUNREACH = 65;
75pub const ENOTEMPTY = 66;
76pub const EPROCLIM = 67;
77pub const EUSERS = 68;
78pub const EDQUOT = 69;
79pub const ESTALE = 70;
80pub const EREMOTE = 71;
81pub const ENOSTR = 72;
82pub const ETIME = 73;
83pub const ENOSR = 74;
84pub const ENOMSG = 75;
85pub const EBADMSG = 76;
86pub const EIDRM = 77;
87pub const EDEADLK = 78;
88pub const ENOLCK = 79;
89pub const ENONET = 80;
90pub const ERREMOTE = 81;
91pub const ENOLINK = 82;
92pub const EADV = 83;
93pub const ESRMNT = 84;
94pub const ECOMM = 85;
95pub const EPROTO = 86;
96pub const EMULTIHOP = 87;
97pub const EDOTDOT = 88;
98pub const EREMCHG = 89;
99pub const ENOSYS = 90;
100pub const ESTRPIPE = 91;
101pub const EOVERFLOW = 92;
102pub const EBADFD = 93;
103pub const ECHRNG = 94;
104pub const EL2NSYNC = 95;
105pub const EL3HLT = 96;
106pub const EL3RST = 97;
107pub const ELNRNG = 98;
108pub const EUNATCH = 99;
109pub const ENOCSI = 100;
110pub const EL2HLT = 101;
111pub const EBADE = 102;
112pub const EBADR = 103;
113pub const EXFULL = 104;
114pub const ENOANO = 105;
115pub const EBADRQC = 106;
116pub const EBADSLT = 107;
117pub const EDEADLOCK = 108;
118pub const EBFONT = 109;
119pub const ELIBEXEC = 110;
120pub const ENODATA = 111;
121pub const ELIBBAD = 112;
122pub const ENOPKG = 113;
123pub const ELIBACC = 114;
124pub const ENOTUNIQ = 115;
125pub const ERESTART = 116;
126pub const EUCLEAN = 117;
127pub const ENOTNAM = 118;
128pub const ENAVAIL = 119;
129pub const EISNAM = 120;
130pub const EREMOTEIO = 121;
131pub const EILSEQ = 122;
132pub const ELIBMAX = 123;
133pub const ELIBSCN = 124;
134pub const ENOMEDIUM = 125;
135pub const EMEDIUMTYPE = 126;
136pub const ECANCELED = 127;
137pub const ENOKEY = 128;
138pub const EKEYEXPIRED = 129;
139pub const EKEYREVOKED = 130;
140pub const EKEYREJECTED = 131;
141pub const EOWNERDEAD = 132;
142pub const ENOTRECOVERABLE = 133;
143pub const ERFKILL = 134;
144pub const EHWPOISON = 135;
lib/std/os/linux.zig+9-5
...@@ -386,7 +386,7 @@ pub fn symlinkat(existing: [*:0]const u8, newfd: i32, newpath: [*:0]const u8) us...@@ -386,7 +386,7 @@ pub fn symlinkat(existing: [*:0]const u8, newfd: i32, newpath: [*:0]const u8) us
386}386}
387387
388pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: u64) usize {388pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: u64) usize {
389 if (@hasField(SYS, "pread64")) {389 if (@hasField(SYS, "pread64") and usize_bits < 64) {
390 const offset_halves = splitValue64(offset);390 const offset_halves = splitValue64(offset);
391 if (require_aligned_register_pair) {391 if (require_aligned_register_pair) {
392 return syscall6(392 return syscall6(
...@@ -409,8 +409,10 @@ pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: u64) usize {...@@ -409,8 +409,10 @@ pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: u64) usize {
409 );409 );
410 }410 }
411 } else {411 } else {
412 // Some architectures (eg. 64bit SPARC) pread is called pread64.
413 const S = if (!@hasField(SYS, "pread") and @hasField(SYS, "pread64")) .pread64 else .pread;
412 return syscall4(414 return syscall4(
413 .pread,415 S,
414 @bitCast(usize, @as(isize, fd)),416 @bitCast(usize, @as(isize, fd)),
415 @ptrToInt(buf),417 @ptrToInt(buf),
416 count,418 count,
...@@ -450,7 +452,7 @@ pub fn write(fd: i32, buf: [*]const u8, count: usize) usize {...@@ -450,7 +452,7 @@ pub fn write(fd: i32, buf: [*]const u8, count: usize) usize {
450}452}
451453
452pub fn ftruncate(fd: i32, length: u64) usize {454pub fn ftruncate(fd: i32, length: u64) usize {
453 if (@hasField(SYS, "ftruncate64")) {455 if (@hasField(SYS, "ftruncate64") and usize_bits < 64) {
454 const length_halves = splitValue64(length);456 const length_halves = splitValue64(length);
455 if (require_aligned_register_pair) {457 if (require_aligned_register_pair) {
456 return syscall4(458 return syscall4(
...@@ -478,7 +480,7 @@ pub fn ftruncate(fd: i32, length: u64) usize {...@@ -478,7 +480,7 @@ pub fn ftruncate(fd: i32, length: u64) usize {
478}480}
479481
480pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: u64) usize {482pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: u64) usize {
481 if (@hasField(SYS, "pwrite64")) {483 if (@hasField(SYS, "pwrite64") and usize_bits < 64) {
482 const offset_halves = splitValue64(offset);484 const offset_halves = splitValue64(offset);
483485
484 if (require_aligned_register_pair) {486 if (require_aligned_register_pair) {
...@@ -502,8 +504,10 @@ pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: u64) usize {...@@ -502,8 +504,10 @@ pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: u64) usize {
502 );504 );
503 }505 }
504 } else {506 } else {
507 // Some architectures (eg. 64bit SPARC) pwrite is called pwrite64.
508 const S = if (!@hasField(SYS, "pwrite") and @hasField(SYS, "pwrite64")) .pwrite64 else .pwrite;
505 return syscall4(509 return syscall4(
506 .pwrite,510 S,
507 @bitCast(usize, @as(isize, fd)),511 @bitCast(usize, @as(isize, fd)),
508 @ptrToInt(buf),512 @ptrToInt(buf),
509 count,513 count,
lib/std/special/c.zig+7-6
...@@ -614,23 +614,24 @@ fn clone() callconv(.Naked) void {...@@ -614,23 +614,24 @@ fn clone() callconv(.Naked) void {
614 \\ # Shuffle the arguments614 \\ # Shuffle the arguments
615 \\ mov 217, %%g1615 \\ mov 217, %%g1
616 \\ mov %%i2, %%o0616 \\ mov %%i2, %%o0
617 \\ sub %%i1, 2047, %%o1617 \\ # Add some extra space for the initial frame
618 \\ sub %%i1, 176 + 2047, %%o1
618 \\ mov %%i4, %%o2619 \\ mov %%i4, %%o2
619 \\ mov %%i5, %%o3620 \\ mov %%i5, %%o3
620 \\ ldx [%%fp + 192 - 2*8 + 2047], %%o4621 \\ ldx [%%fp + 0x8af], %%o4
621 \\ t 0x6d622 \\ t 0x6d
622 \\ bcs,pn %%xcc, 2f623 \\ bcs,pn %%xcc, 2f
623 \\ nop624 \\ nop
624 \\ # sparc64 returns the child pid in o0 and a flag telling625 \\ # The child pid is returned in o0 while o1 tells if this
625 \\ # whether the process is the child in o1626 \\ # process is # the child (=1) or the parent (=0).
626 \\ brnz %%o1, 1f627 \\ brnz %%o1, 1f
627 \\ nop628 \\ nop
628 \\ # This is the parent process, return the child pid629 \\ # Parent process, return the child pid
629 \\ mov %%o0, %%i0630 \\ mov %%o0, %%i0
630 \\ ret631 \\ ret
631 \\ restore632 \\ restore
632 \\1:633 \\1:
633 \\ # This is the child process634 \\ # Child process, call func(arg)
634 \\ mov %%g0, %%fp635 \\ mov %%g0, %%fp
635 \\ call %%g2636 \\ call %%g2
636 \\ mov %%g3, %%o0637 \\ mov %%g3, %%o0