| author | |
| committer | |
| log | 4f9c928e5623b291af83cefe0a63ce2226e51dbe |
| tree | bed37fbcea2fbdccd5d033f6fe0e6f140157e528 |
| parent | e9e91b4ed058f4c4e3f3380ec06cb914becd04a8 |
| parent | d788181a3b96ec653f5bef42916a8129837cdac4 |
| signature |
Miscellaneous patches9 files changed, 306 insertions(+), 49 deletions(-)
lib/std/Thread.zig+21-4| ... | ... | @@ -68,11 +68,28 @@ else switch (std.Target.current.os.tag) { |
| 68 | 68 | }; |
| 69 | 69 | |
| 70 | 70 | /// Signals the processor that it is inside a busy-wait spin-loop ("spin lock"). |
| 71 | pub fn spinLoopHint() void { | |
| 71 | pub fn spinLoopHint() callconv(.Inline) void { | |
| 72 | 72 | switch (std.Target.current.cpu.arch) { |
| 73 | .i386, .x86_64 => asm volatile ("pause" ::: "memory"), | |
| 74 | .arm, .aarch64 => asm volatile ("yield" ::: "memory"), | |
| 75 | else => {}, | |
| 73 | .i386, .x86_64 => { | |
| 74 | asm volatile ("pause" ::: "memory"); | |
| 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 | } |
| 78 | 95 |
lib/std/math/copysign.zig+18| ... | ... | @@ -20,6 +20,7 @@ pub fn copysign(comptime T: type, x: T, y: T) T { |
| 20 | 20 | f16 => copysign16(x, y), |
| 21 | 21 | f32 => copysign32(x, y), |
| 22 | 22 | f64 => copysign64(x, y), |
| 23 | f128 => copysign128(x, y), | |
| 23 | 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 | 52 | return @bitCast(f64, h1 | h2); |
| 52 | 53 | } |
| 53 | 54 | |
| 55 | fn 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 | ||
| 54 | 64 | test "math.copysign" { |
| 55 | 65 | expect(copysign(f16, 1.0, 1.0) == copysign16(1.0, 1.0)); |
| 56 | 66 | expect(copysign(f32, 1.0, 1.0) == copysign32(1.0, 1.0)); |
| 57 | 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 | } |
| 59 | 70 | |
| 60 | 71 | test "math.copysign16" { |
| ... | ... | @@ -77,3 +88,10 @@ test "math.copysign64" { |
| 77 | 88 | expect(copysign64(-5.0, -1.0) == -5.0); |
| 78 | 89 | expect(copysign64(-5.0, 1.0) == 5.0); |
| 79 | 90 | } |
| 91 | ||
| 92 | test "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 | 24 | const bits = @bitCast(u64, x); |
| 25 | 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 | 31 | else => { |
| 28 | 32 | @compileError("isFinite not implemented for " ++ @typeName(T)); |
| 29 | 33 | }, |
| ... | ... | @@ -37,10 +41,24 @@ test "math.isFinite" { |
| 37 | 41 | expect(isFinite(@as(f32, -0.0))); |
| 38 | 42 | expect(isFinite(@as(f64, 0.0))); |
| 39 | 43 | expect(isFinite(@as(f64, -0.0))); |
| 44 | expect(isFinite(@as(f128, 0.0))); | |
| 45 | expect(isFinite(@as(f128, -0.0))); | |
| 46 | ||
| 40 | 47 | expect(!isFinite(math.inf(f16))); |
| 41 | 48 | expect(!isFinite(-math.inf(f16))); |
| 42 | 49 | expect(!isFinite(math.inf(f32))); |
| 43 | 50 | expect(!isFinite(-math.inf(f32))); |
| 44 | 51 | expect(!isFinite(math.inf(f64))); |
| 45 | 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 | 14 | f16 => signbit16(x), |
| 15 | 15 | f32 => signbit32(x), |
| 16 | 16 | f64 => signbit64(x), |
| 17 | f128 => signbit128(x), | |
| 17 | 18 | else => @compileError("signbit not implemented for " ++ @typeName(T)), |
| 18 | 19 | }; |
| 19 | 20 | } |
| ... | ... | @@ -33,10 +34,16 @@ fn signbit64(x: f64) bool { |
| 33 | 34 | return bits >> 63 != 0; |
| 34 | 35 | } |
| 35 | 36 | |
| 37 | fn signbit128(x: f128) bool { | |
| 38 | const bits = @bitCast(u128, x); | |
| 39 | return bits >> 127 != 0; | |
| 40 | } | |
| 41 | ||
| 36 | 42 | test "math.signbit" { |
| 37 | 43 | expect(signbit(@as(f16, 4.0)) == signbit16(4.0)); |
| 38 | 44 | expect(signbit(@as(f32, 4.0)) == signbit32(4.0)); |
| 39 | 45 | expect(signbit(@as(f64, 4.0)) == signbit64(4.0)); |
| 46 | expect(signbit(@as(f128, 4.0)) == signbit128(4.0)); | |
| 40 | 47 | } |
| 41 | 48 | |
| 42 | 49 | test "math.signbit16" { |
| ... | ... | @@ -53,3 +60,8 @@ test "math.signbit64" { |
| 53 | 60 | expect(!signbit64(4.0)); |
| 54 | 61 | expect(signbit64(-3.0)); |
| 55 | 62 | } |
| 63 | ||
| 64 | test "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 | 10 | |
| 11 | 11 | pub usingnamespace switch (builtin.arch) { |
| 12 | 12 | .mips, .mipsel => @import("linux/errno-mips.zig"), |
| 13 | .sparc, .sparcel, .sparcv9 => @import("linux/errno-sparc.zig"), | |
| 13 | 14 | else => @import("linux/errno-generic.zig"), |
| 14 | 15 | }; |
| 15 | 16 | |
| ... | ... | @@ -247,40 +248,78 @@ else |
| 247 | 248 | pub const SIG_SETMASK = 2; |
| 248 | 249 | }; |
| 249 | 250 | |
| 250 | pub const SIGHUP = 1; | |
| 251 | pub const SIGINT = 2; | |
| 252 | pub const SIGQUIT = 3; | |
| 253 | pub const SIGILL = 4; | |
| 254 | pub const SIGTRAP = 5; | |
| 255 | pub const SIGABRT = 6; | |
| 256 | pub const SIGIOT = SIGABRT; | |
| 257 | pub const SIGBUS = 7; | |
| 258 | pub const SIGFPE = 8; | |
| 259 | pub const SIGKILL = 9; | |
| 260 | pub const SIGUSR1 = 10; | |
| 261 | pub const SIGSEGV = 11; | |
| 262 | pub const SIGUSR2 = 12; | |
| 263 | pub const SIGPIPE = 13; | |
| 264 | pub const SIGALRM = 14; | |
| 265 | pub const SIGTERM = 15; | |
| 266 | pub const SIGSTKFLT = 16; | |
| 267 | pub const SIGCHLD = 17; | |
| 268 | pub const SIGCONT = 18; | |
| 269 | pub const SIGSTOP = 19; | |
| 270 | pub const SIGTSTP = 20; | |
| 271 | pub const SIGTTIN = 21; | |
| 272 | pub const SIGTTOU = 22; | |
| 273 | pub const SIGURG = 23; | |
| 274 | pub const SIGXCPU = 24; | |
| 275 | pub const SIGXFSZ = 25; | |
| 276 | pub const SIGVTALRM = 26; | |
| 277 | pub const SIGPROF = 27; | |
| 278 | pub const SIGWINCH = 28; | |
| 279 | pub const SIGIO = 29; | |
| 280 | pub const SIGPOLL = 29; | |
| 281 | pub const SIGPWR = 30; | |
| 282 | pub const SIGSYS = 31; | |
| 283 | pub const SIGUNUSED = SIGSYS; | |
| 251 | pub usingnamespace if (is_sparc) struct { | |
| 252 | pub const SIGHUP = 1; | |
| 253 | pub const SIGINT = 2; | |
| 254 | pub const SIGQUIT = 3; | |
| 255 | pub const SIGILL = 4; | |
| 256 | pub const SIGTRAP = 5; | |
| 257 | pub const SIGABRT = 6; | |
| 258 | pub const SIGEMT = 7; | |
| 259 | pub const SIGFPE = 8; | |
| 260 | pub const SIGKILL = 9; | |
| 261 | pub const SIGBUS = 10; | |
| 262 | pub const SIGSEGV = 11; | |
| 263 | pub const SIGSYS = 12; | |
| 264 | pub const SIGPIPE = 13; | |
| 265 | pub const SIGALRM = 14; | |
| 266 | pub const SIGTERM = 15; | |
| 267 | pub const SIGURG = 16; | |
| 268 | pub const SIGSTOP = 17; | |
| 269 | pub const SIGTSTP = 18; | |
| 270 | pub const SIGCONT = 19; | |
| 271 | pub const SIGCHLD = 20; | |
| 272 | pub const SIGTTIN = 21; | |
| 273 | pub const SIGTTOU = 22; | |
| 274 | pub const SIGPOLL = 23; | |
| 275 | pub const SIGXCPU = 24; | |
| 276 | pub const SIGXFSZ = 25; | |
| 277 | pub const SIGVTALRM = 26; | |
| 278 | pub const SIGPROF = 27; | |
| 279 | pub const SIGWINCH = 28; | |
| 280 | pub const SIGLOST = 29; | |
| 281 | pub const SIGUSR1 = 30; | |
| 282 | pub const SIGUSR2 = 31; | |
| 283 | pub const SIGIOT = SIGABRT; | |
| 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 | }; | |
| 284 | 323 | |
| 285 | 324 | pub const O_RDONLY = 0o0; |
| 286 | 325 | pub const O_WRONLY = 0o1; |
lib/std/os/bits/linux/errno-mips.zig+4| ... | ... | @@ -3,6 +3,9 @@ |
| 3 | 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. |
| 4 | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | 5 | // and substantial portions of the software. |
| 6 | ||
| 7 | // These are MIPS ABI compatible. | |
| 8 | ||
| 6 | 9 | pub const EPERM = 1; |
| 7 | 10 | pub const ENOENT = 2; |
| 8 | 11 | pub const ESRCH = 3; |
| ... | ... | @@ -37,6 +40,7 @@ pub const EMLINK = 31; |
| 37 | 40 | pub const EPIPE = 32; |
| 38 | 41 | pub const EDOM = 33; |
| 39 | 42 | pub const ERANGE = 34; |
| 43 | ||
| 40 | 44 | pub const ENOMSG = 35; |
| 41 | 45 | pub const EIDRM = 36; |
| 42 | 46 | pub 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 | ||
| 9 | pub const EPERM = 1; | |
| 10 | pub const ENOENT = 2; | |
| 11 | pub const ESRCH = 3; | |
| 12 | pub const EINTR = 4; | |
| 13 | pub const EIO = 5; | |
| 14 | pub const ENXIO = 6; | |
| 15 | pub const E2BIG = 7; | |
| 16 | pub const ENOEXEC = 8; | |
| 17 | pub const EBADF = 9; | |
| 18 | pub const ECHILD = 10; | |
| 19 | pub const EAGAIN = 11; | |
| 20 | pub const ENOMEM = 12; | |
| 21 | pub const EACCES = 13; | |
| 22 | pub const EFAULT = 14; | |
| 23 | pub const ENOTBLK = 15; | |
| 24 | pub const EBUSY = 16; | |
| 25 | pub const EEXIST = 17; | |
| 26 | pub const EXDEV = 18; | |
| 27 | pub const ENODEV = 19; | |
| 28 | pub const ENOTDIR = 20; | |
| 29 | pub const EISDIR = 21; | |
| 30 | pub const EINVAL = 22; | |
| 31 | pub const ENFILE = 23; | |
| 32 | pub const EMFILE = 24; | |
| 33 | pub const ENOTTY = 25; | |
| 34 | pub const ETXTBSY = 26; | |
| 35 | pub const EFBIG = 27; | |
| 36 | pub const ENOSPC = 28; | |
| 37 | pub const ESPIPE = 29; | |
| 38 | pub const EROFS = 30; | |
| 39 | pub const EMLINK = 31; | |
| 40 | pub const EPIPE = 32; | |
| 41 | pub const EDOM = 33; | |
| 42 | pub const ERANGE = 34; | |
| 43 | ||
| 44 | pub const EWOULDBLOCK = EAGAIN; | |
| 45 | pub const EINPROGRESS = 36; | |
| 46 | pub const EALREADY = 37; | |
| 47 | pub const ENOTSOCK = 38; | |
| 48 | pub const EDESTADDRREQ = 39; | |
| 49 | pub const EMSGSIZE = 40; | |
| 50 | pub const EPROTOTYPE = 41; | |
| 51 | pub const ENOPROTOOPT = 42; | |
| 52 | pub const EPROTONOSUPPORT = 43; | |
| 53 | pub const ESOCKTNOSUPPORT = 44; | |
| 54 | pub const EOPNOTSUPP = 45; | |
| 55 | pub const EPFNOSUPPORT = 46; | |
| 56 | pub const EAFNOSUPPORT = 47; | |
| 57 | pub const EADDRINUSE = 48; | |
| 58 | pub const EADDRNOTAVAIL = 49; | |
| 59 | pub const ENETDOWN = 50; | |
| 60 | pub const ENETUNREACH = 51; | |
| 61 | pub const ENETRESET = 52; | |
| 62 | pub const ECONNABORTED = 53; | |
| 63 | pub const ECONNRESET = 54; | |
| 64 | pub const ENOBUFS = 55; | |
| 65 | pub const EISCONN = 56; | |
| 66 | pub const ENOTCONN = 57; | |
| 67 | pub const ESHUTDOWN = 58; | |
| 68 | pub const ETOOMANYREFS = 59; | |
| 69 | pub const ETIMEDOUT = 60; | |
| 70 | pub const ECONNREFUSED = 61; | |
| 71 | pub const ELOOP = 62; | |
| 72 | pub const ENAMETOOLONG = 63; | |
| 73 | pub const EHOSTDOWN = 64; | |
| 74 | pub const EHOSTUNREACH = 65; | |
| 75 | pub const ENOTEMPTY = 66; | |
| 76 | pub const EPROCLIM = 67; | |
| 77 | pub const EUSERS = 68; | |
| 78 | pub const EDQUOT = 69; | |
| 79 | pub const ESTALE = 70; | |
| 80 | pub const EREMOTE = 71; | |
| 81 | pub const ENOSTR = 72; | |
| 82 | pub const ETIME = 73; | |
| 83 | pub const ENOSR = 74; | |
| 84 | pub const ENOMSG = 75; | |
| 85 | pub const EBADMSG = 76; | |
| 86 | pub const EIDRM = 77; | |
| 87 | pub const EDEADLK = 78; | |
| 88 | pub const ENOLCK = 79; | |
| 89 | pub const ENONET = 80; | |
| 90 | pub const ERREMOTE = 81; | |
| 91 | pub const ENOLINK = 82; | |
| 92 | pub const EADV = 83; | |
| 93 | pub const ESRMNT = 84; | |
| 94 | pub const ECOMM = 85; | |
| 95 | pub const EPROTO = 86; | |
| 96 | pub const EMULTIHOP = 87; | |
| 97 | pub const EDOTDOT = 88; | |
| 98 | pub const EREMCHG = 89; | |
| 99 | pub const ENOSYS = 90; | |
| 100 | pub const ESTRPIPE = 91; | |
| 101 | pub const EOVERFLOW = 92; | |
| 102 | pub const EBADFD = 93; | |
| 103 | pub const ECHRNG = 94; | |
| 104 | pub const EL2NSYNC = 95; | |
| 105 | pub const EL3HLT = 96; | |
| 106 | pub const EL3RST = 97; | |
| 107 | pub const ELNRNG = 98; | |
| 108 | pub const EUNATCH = 99; | |
| 109 | pub const ENOCSI = 100; | |
| 110 | pub const EL2HLT = 101; | |
| 111 | pub const EBADE = 102; | |
| 112 | pub const EBADR = 103; | |
| 113 | pub const EXFULL = 104; | |
| 114 | pub const ENOANO = 105; | |
| 115 | pub const EBADRQC = 106; | |
| 116 | pub const EBADSLT = 107; | |
| 117 | pub const EDEADLOCK = 108; | |
| 118 | pub const EBFONT = 109; | |
| 119 | pub const ELIBEXEC = 110; | |
| 120 | pub const ENODATA = 111; | |
| 121 | pub const ELIBBAD = 112; | |
| 122 | pub const ENOPKG = 113; | |
| 123 | pub const ELIBACC = 114; | |
| 124 | pub const ENOTUNIQ = 115; | |
| 125 | pub const ERESTART = 116; | |
| 126 | pub const EUCLEAN = 117; | |
| 127 | pub const ENOTNAM = 118; | |
| 128 | pub const ENAVAIL = 119; | |
| 129 | pub const EISNAM = 120; | |
| 130 | pub const EREMOTEIO = 121; | |
| 131 | pub const EILSEQ = 122; | |
| 132 | pub const ELIBMAX = 123; | |
| 133 | pub const ELIBSCN = 124; | |
| 134 | pub const ENOMEDIUM = 125; | |
| 135 | pub const EMEDIUMTYPE = 126; | |
| 136 | pub const ECANCELED = 127; | |
| 137 | pub const ENOKEY = 128; | |
| 138 | pub const EKEYEXPIRED = 129; | |
| 139 | pub const EKEYREVOKED = 130; | |
| 140 | pub const EKEYREJECTED = 131; | |
| 141 | pub const EOWNERDEAD = 132; | |
| 142 | pub const ENOTRECOVERABLE = 133; | |
| 143 | pub const ERFKILL = 134; | |
| 144 | pub 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 | 386 | } |
| 387 | 387 | |
| 388 | 388 | pub 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 | 390 | const offset_halves = splitValue64(offset); |
| 391 | 391 | if (require_aligned_register_pair) { |
| 392 | 392 | return syscall6( |
| ... | ... | @@ -409,8 +409,10 @@ pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: u64) usize { |
| 409 | 409 | ); |
| 410 | 410 | } |
| 411 | 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 | 414 | return syscall4( |
| 413 | .pread, | |
| 415 | S, | |
| 414 | 416 | @bitCast(usize, @as(isize, fd)), |
| 415 | 417 | @ptrToInt(buf), |
| 416 | 418 | count, |
| ... | ... | @@ -450,7 +452,7 @@ pub fn write(fd: i32, buf: [*]const u8, count: usize) usize { |
| 450 | 452 | } |
| 451 | 453 | |
| 452 | 454 | pub fn ftruncate(fd: i32, length: u64) usize { |
| 453 | if (@hasField(SYS, "ftruncate64")) { | |
| 455 | if (@hasField(SYS, "ftruncate64") and usize_bits < 64) { | |
| 454 | 456 | const length_halves = splitValue64(length); |
| 455 | 457 | if (require_aligned_register_pair) { |
| 456 | 458 | return syscall4( |
| ... | ... | @@ -478,7 +480,7 @@ pub fn ftruncate(fd: i32, length: u64) usize { |
| 478 | 480 | } |
| 479 | 481 | |
| 480 | 482 | pub 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 | 484 | const offset_halves = splitValue64(offset); |
| 483 | 485 | |
| 484 | 486 | if (require_aligned_register_pair) { |
| ... | ... | @@ -502,8 +504,10 @@ pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: u64) usize { |
| 502 | 504 | ); |
| 503 | 505 | } |
| 504 | 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 | 509 | return syscall4( |
| 506 | .pwrite, | |
| 510 | S, | |
| 507 | 511 | @bitCast(usize, @as(isize, fd)), |
| 508 | 512 | @ptrToInt(buf), |
| 509 | 513 | count, |
lib/std/special/c.zig+7-6| ... | ... | @@ -614,23 +614,24 @@ fn clone() callconv(.Naked) void { |
| 614 | 614 | \\ # Shuffle the arguments |
| 615 | 615 | \\ mov 217, %%g1 |
| 616 | 616 | \\ mov %%i2, %%o0 |
| 617 | \\ sub %%i1, 2047, %%o1 | |
| 617 | \\ # Add some extra space for the initial frame | |
| 618 | \\ sub %%i1, 176 + 2047, %%o1 | |
| 618 | 619 | \\ mov %%i4, %%o2 |
| 619 | 620 | \\ mov %%i5, %%o3 |
| 620 | \\ ldx [%%fp + 192 - 2*8 + 2047], %%o4 | |
| 621 | \\ ldx [%%fp + 0x8af], %%o4 | |
| 621 | 622 | \\ t 0x6d |
| 622 | 623 | \\ bcs,pn %%xcc, 2f |
| 623 | 624 | \\ nop |
| 624 | \\ # sparc64 returns the child pid in o0 and a flag telling | |
| 625 | \\ # whether the process is the child in o1 | |
| 625 | \\ # The child pid is returned in o0 while o1 tells if this | |
| 626 | \\ # process is # the child (=1) or the parent (=0). | |
| 626 | 627 | \\ brnz %%o1, 1f |
| 627 | 628 | \\ nop |
| 628 | \\ # This is the parent process, return the child pid | |
| 629 | \\ # Parent process, return the child pid | |
| 629 | 630 | \\ mov %%o0, %%i0 |
| 630 | 631 | \\ ret |
| 631 | 632 | \\ restore |
| 632 | 633 | \\1: |
| 633 | \\ # This is the child process | |
| 634 | \\ # Child process, call func(arg) | |
| 634 | 635 | \\ mov %%g0, %%fp |
| 635 | 636 | \\ call %%g2 |
| 636 | 637 | \\ mov %%g3, %%o0 |