From 40e77dad836abf130bf49af1838d108f0fc2e94e Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 25 Sep 2019 15:15:52 -0400 Subject: [PATCH 1/2] musl [PATCH] arm: fix setjmp and longjmp asm for armv8-a From: Szabolcs Nagy armv8 removed the coprocessor instructions other than cp14, so on an armv8 system the related hwcaps should never be set. new llvm complains about the use of coprocessor instructions in armv8-a mode (even though they are never executed at runtime), so ifdef them out when musl is built for armv8. i think the patch looks ok --- lib/libc/musl/src/setjmp/arm/{longjmp.s => longjmp.S} | 7 +++++++ lib/libc/musl/src/setjmp/arm/{setjmp.s => setjmp.S} | 7 +++++++ src/install_files.h | 4 ++-- 3 files changed, 16 insertions(+), 2 deletions(-) rename lib/libc/musl/src/setjmp/arm/{longjmp.s => longjmp.S} (87%) rename lib/libc/musl/src/setjmp/arm/{setjmp.s => setjmp.S} (88%) diff --git a/lib/libc/musl/src/setjmp/arm/longjmp.s b/lib/libc/musl/src/setjmp/arm/longjmp.S similarity index 87% rename from lib/libc/musl/src/setjmp/arm/longjmp.s rename to lib/libc/musl/src/setjmp/arm/longjmp.S index 76cc2920a3c9f0654fde5a9c6006afb9169f3666..8df0b8190dd7c8f8be90f6c089b7469c43d7a373 100644 --- a/lib/libc/musl/src/setjmp/arm/longjmp.s +++ b/lib/libc/musl/src/setjmp/arm/longjmp.S @@ -16,11 +16,14 @@ longjmp: ldr r2,1f ldr r1,[r1,r2] +#if __ARM_ARCH < 8 tst r1,#0x260 beq 3f + // HWCAP_ARM_FPA tst r1,#0x20 beq 2f ldc p2, cr4, [ip], #48 +#endif 2: tst r1,#0x40 beq 2f .fpu vfp @@ -28,6 +31,8 @@ longjmp: .fpu softvfp .eabi_attribute 10, 0 .eabi_attribute 27, 0 +#if __ARM_ARCH < 8 + // HWCAP_ARM_IWMMXT 2: tst r1,#0x200 beq 3f ldcl p1, cr10, [ip], #8 @@ -36,6 +41,8 @@ longjmp: ldcl p1, cr13, [ip], #8 ldcl p1, cr14, [ip], #8 ldcl p1, cr15, [ip], #8 +#endif +2: 3: bx lr .hidden __hwcap diff --git a/lib/libc/musl/src/setjmp/arm/setjmp.s b/lib/libc/musl/src/setjmp/arm/setjmp.S similarity index 88% rename from lib/libc/musl/src/setjmp/arm/setjmp.s rename to lib/libc/musl/src/setjmp/arm/setjmp.S index 011315b70f94b2e3d5cdc5d86d2333a34a1fb442..45731d228e80fb236b98d2f614a1c29854beea3a 100644 --- a/lib/libc/musl/src/setjmp/arm/setjmp.s +++ b/lib/libc/musl/src/setjmp/arm/setjmp.S @@ -18,11 +18,14 @@ setjmp: ldr r2,1f ldr r1,[r1,r2] +#if __ARM_ARCH < 8 tst r1,#0x260 beq 3f + // HWCAP_ARM_FPA tst r1,#0x20 beq 2f stc p2, cr4, [ip], #48 +#endif 2: tst r1,#0x40 beq 2f .fpu vfp @@ -30,6 +33,8 @@ setjmp: .fpu softvfp .eabi_attribute 10, 0 .eabi_attribute 27, 0 +#if __ARM_ARCH < 8 + // HWCAP_ARM_IWMMXT 2: tst r1,#0x200 beq 3f stcl p1, cr10, [ip], #8 @@ -38,6 +43,8 @@ setjmp: stcl p1, cr13, [ip], #8 stcl p1, cr14, [ip], #8 stcl p1, cr15, [ip], #8 +#endif +2: 3: bx lr .hidden __hwcap diff --git a/src/install_files.h b/src/install_files.h index 138d0f5278a75557f023b830b466468ac24bbcde..5e89c07b54f6fdbf85dcad7c60670b78e93633e7 100644 --- a/src/install_files.h +++ b/src/install_files.h @@ -1155,8 +1155,8 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/select/select.c", "musl/src/setjmp/aarch64/longjmp.s", "musl/src/setjmp/aarch64/setjmp.s", -"musl/src/setjmp/arm/longjmp.s", -"musl/src/setjmp/arm/setjmp.s", +"musl/src/setjmp/arm/longjmp.S", +"musl/src/setjmp/arm/setjmp.S", "musl/src/setjmp/i386/longjmp.s", "musl/src/setjmp/i386/setjmp.s", "musl/src/setjmp/longjmp.c", -- 2.54.0 From d1705baa749a696132e272974858fef8273614ff Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 25 Sep 2019 15:57:13 -0400 Subject: [PATCH 2/2] enable test coverage for armv8-linux-musleabihf * fix libc prototypes of offsets to have correct integer sizes and signedness. This gets all behavior tests to pass for armv8-linux-musleabihf * fix linux mmap syscall to have correct integer size and signedness for offset * disable failing armv8-linux-musleabihf std lib tests. See 3289. I suspect compiler-rt issue. Note these tests fail with this target triple regardless of whether musl is actually linked (-lc). --- std/c.zig | 6 +++--- std/fmt.zig | 24 ++++++++++++++++++++++++ std/heap.zig | 2 +- std/math/big/rational.zig | 8 ++++++++ std/math/complex/atan.zig | 5 +++++ std/math/complex/cosh.zig | 5 +++++ std/math/complex/exp.zig | 5 +++++ std/math/complex/sinh.zig | 5 +++++ std/math/complex/tanh.zig | 5 +++++ std/math/cos.zig | 4 ++++ std/math/pow.zig | 12 ++++++++++++ std/math/sin.zig | 20 ++++++++++++++++++++ std/math/tan.zig | 4 ++++ std/os.zig | 2 +- std/os/linux.zig | 6 +++--- test/tests.zig | 21 ++++++++++----------- 16 files changed, 115 insertions(+), 19 deletions(-) diff --git a/std/c.zig b/std/c.zig index bd7e9b64a3c7e9bc2db2753a1feab6f5383d8e95..9c7ec2f0e5e50336f4466a30ef30daac95f69213 100644 --- a/std/c.zig +++ b/std/c.zig @@ -70,13 +70,13 @@ pub extern "c" fn raise(sig: c_int) c_int; pub extern "c" fn read(fd: fd_t, buf: [*]u8, nbyte: usize) isize; pub extern "c" fn readv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint) isize; pub extern "c" fn pread(fd: fd_t, buf: [*]u8, nbyte: usize, offset: u64) isize; -pub extern "c" fn preadv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: usize) isize; +pub extern "c" fn preadv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: u64) isize; pub extern "c" fn writev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint) isize; -pub extern "c" fn pwritev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint, offset: usize) isize; +pub extern "c" fn pwritev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint, offset: u64) isize; pub extern "c" fn stat(noalias path: [*]const u8, noalias buf: *Stat) c_int; pub extern "c" fn write(fd: fd_t, buf: [*]const u8, nbyte: usize) isize; pub extern "c" fn pwrite(fd: fd_t, buf: [*]const u8, nbyte: usize, offset: u64) isize; -pub extern "c" fn mmap(addr: ?*align(page_size) c_void, len: usize, prot: c_uint, flags: c_uint, fd: fd_t, offset: isize) *c_void; +pub extern "c" fn mmap(addr: ?*align(page_size) c_void, len: usize, prot: c_uint, flags: c_uint, fd: fd_t, offset: u64) *c_void; pub extern "c" fn munmap(addr: *align(page_size) c_void, len: usize) c_int; pub extern "c" fn mprotect(addr: *align(page_size) c_void, len: usize, prot: c_uint) c_int; pub extern "c" fn unlink(path: [*]const u8) c_int; diff --git a/std/fmt.zig b/std/fmt.zig index 984d46272cc9f4623b41abd585dc09b828e8da0c..3f3e3fca73d2b17cf39c0dac5fc3cdb9ba487ec6 100644 --- a/std/fmt.zig +++ b/std/fmt.zig @@ -1233,6 +1233,10 @@ test "cstr" { } test "filesize" { + if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) { + // TODO https://github.com/ziglang/zig/issues/3289 + return error.SkipZigTest; + } try testFmt("file size: 63MiB\n", "file size: {Bi}\n", usize(63 * 1024 * 1024)); try testFmt("file size: 66.06MB\n", "file size: {B:.2}\n", usize(63 * 1024 * 1024)); } @@ -1267,6 +1271,10 @@ test "enum" { } test "float.scientific" { + if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) { + // TODO https://github.com/ziglang/zig/issues/3289 + return error.SkipZigTest; + } try testFmt("f32: 1.34000003e+00", "f32: {e}", f32(1.34)); try testFmt("f32: 1.23400001e+01", "f32: {e}", f32(12.34)); try testFmt("f64: -1.234e+11", "f64: {e}", f64(-12.34e10)); @@ -1274,6 +1282,10 @@ test "float.scientific" { } test "float.scientific.precision" { + if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) { + // TODO https://github.com/ziglang/zig/issues/3289 + return error.SkipZigTest; + } try testFmt("f64: 1.40971e-42", "f64: {e:.5}", f64(1.409706e-42)); try testFmt("f64: 1.00000e-09", "f64: {e:.5}", f64(@bitCast(f32, u32(814313563)))); try testFmt("f64: 7.81250e-03", "f64: {e:.5}", f64(@bitCast(f32, u32(1006632960)))); @@ -1283,6 +1295,10 @@ test "float.scientific.precision" { } test "float.special" { + if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) { + // TODO https://github.com/ziglang/zig/issues/3289 + return error.SkipZigTest; + } try testFmt("f64: nan", "f64: {}", math.nan_f64); // negative nan is not defined by IEE 754, // and ARM thus normalizes it to positive nan @@ -1294,6 +1310,10 @@ test "float.special" { } test "float.decimal" { + if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) { + // TODO https://github.com/ziglang/zig/issues/3289 + return error.SkipZigTest; + } try testFmt("f64: 152314000000000000000000000000", "f64: {d}", f64(1.52314e+29)); try testFmt("f32: 1.1", "f32: {d:.1}", f32(1.1234)); try testFmt("f32: 1234.57", "f32: {d:.2}", f32(1234.567)); @@ -1312,6 +1332,10 @@ test "float.decimal" { } test "float.libc.sanity" { + if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) { + // TODO https://github.com/ziglang/zig/issues/3289 + return error.SkipZigTest; + } try testFmt("f64: 0.00001", "f64: {d:.5}", f64(@bitCast(f32, u32(916964781)))); try testFmt("f64: 0.00001", "f64: {d:.5}", f64(@bitCast(f32, u32(925353389)))); try testFmt("f64: 0.10000", "f64: {d:.5}", f64(@bitCast(f32, u32(1036831278)))); diff --git a/std/heap.zig b/std/heap.zig index a07f7505676988aba9a6514c2ce49f161221e33e..b968b6242f6a634e9f33d83a35dec88aa43da1b6 100644 --- a/std/heap.zig +++ b/std/heap.zig @@ -780,7 +780,7 @@ test "FixedBufferAllocator" { } test "FixedBufferAllocator.reset" { - var buf: [8]u8 align(@alignOf(usize)) = undefined; + var buf: [8]u8 align(@alignOf(u64)) = undefined; var fba = FixedBufferAllocator.init(buf[0..]); const X = 0xeeeeeeeeeeeeeeee; diff --git a/std/math/big/rational.zig b/std/math/big/rational.zig index 27a3b7300fa055e5ca3f6fe0e22491db67c60478..6a51931e3c98fbefa97e34d6ffa55c3cc7a8fd1b 100644 --- a/std/math/big/rational.zig +++ b/std/math/big/rational.zig @@ -742,6 +742,10 @@ test "big.rational setFloatString" { } test "big.rational toFloat" { + if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) { + // TODO https://github.com/ziglang/zig/issues/3289 + return error.SkipZigTest; + } var a = try Rational.init(al); // = 3.14159297943115234375 @@ -754,6 +758,10 @@ test "big.rational toFloat" { } test "big.rational set/to Float round-trip" { + if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) { + // TODO https://github.com/ziglang/zig/issues/3289 + return error.SkipZigTest; + } var a = try Rational.init(al); var prng = std.rand.DefaultPrng.init(0x5EED); var i: usize = 0; diff --git a/std/math/complex/atan.zig b/std/math/complex/atan.zig index 89bc8dfaf0956688796dfc8c5783ae95ce42b511..3cd19961c8b1916262ad23ec23e29712651813bc 100644 --- a/std/math/complex/atan.zig +++ b/std/math/complex/atan.zig @@ -5,6 +5,7 @@ // https://git.musl-libc.org/cgit/musl/tree/src/complex/catan.c const std = @import("../../std.zig"); +const builtin = @import("builtin"); const testing = std.testing; const math = std.math; const cmath = math.complex; @@ -129,6 +130,10 @@ test "complex.catan32" { } test "complex.catan64" { + if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) { + // TODO https://github.com/ziglang/zig/issues/3289 + return error.SkipZigTest; + } const a = Complex(f64).new(5, 3); const c = atan(a); diff --git a/std/math/complex/cosh.zig b/std/math/complex/cosh.zig index be7bfde963c2a15a869610235d23029d642a1fae..89afcac42eb920c180767bbe5161b001da94d4c2 100644 --- a/std/math/complex/cosh.zig +++ b/std/math/complex/cosh.zig @@ -4,6 +4,7 @@ // https://git.musl-libc.org/cgit/musl/tree/src/complex/ccoshf.c // https://git.musl-libc.org/cgit/musl/tree/src/complex/ccosh.c +const builtin = @import("builtin"); const std = @import("../../std.zig"); const testing = std.testing; const math = std.math; @@ -164,6 +165,10 @@ test "complex.ccosh32" { } test "complex.ccosh64" { + if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) { + // TODO https://github.com/ziglang/zig/issues/3289 + return error.SkipZigTest; + } const a = Complex(f64).new(5, 3); const c = cosh(a); diff --git a/std/math/complex/exp.zig b/std/math/complex/exp.zig index 9b686bebc3288da2440c90fa8683a3bc406dd6fb..5cd1cb4ed6c0d551ec829e06dcb4f3d5e3a4690f 100644 --- a/std/math/complex/exp.zig +++ b/std/math/complex/exp.zig @@ -4,6 +4,7 @@ // https://git.musl-libc.org/cgit/musl/tree/src/complex/cexpf.c // https://git.musl-libc.org/cgit/musl/tree/src/complex/cexp.c +const builtin = @import("builtin"); const std = @import("../../std.zig"); const testing = std.testing; const math = std.math; @@ -130,6 +131,10 @@ test "complex.cexp32" { } test "complex.cexp64" { + if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) { + // TODO https://github.com/ziglang/zig/issues/3289 + return error.SkipZigTest; + } const a = Complex(f64).new(5, 3); const c = exp(a); diff --git a/std/math/complex/sinh.zig b/std/math/complex/sinh.zig index 6286d8447ff5f85940642d7f4a23a8228e190e8c..0b1294bb6a63a19310193f4e9451c0d1388c517c 100644 --- a/std/math/complex/sinh.zig +++ b/std/math/complex/sinh.zig @@ -4,6 +4,7 @@ // https://git.musl-libc.org/cgit/musl/tree/src/complex/csinhf.c // https://git.musl-libc.org/cgit/musl/tree/src/complex/csinh.c +const builtin = @import("builtin"); const std = @import("../../std.zig"); const testing = std.testing; const math = std.math; @@ -163,6 +164,10 @@ test "complex.csinh32" { } test "complex.csinh64" { + if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) { + // TODO https://github.com/ziglang/zig/issues/3289 + return error.SkipZigTest; + } const a = Complex(f64).new(5, 3); const c = sinh(a); diff --git a/std/math/complex/tanh.zig b/std/math/complex/tanh.zig index 5c14ec66f2dbf44e2038b4aa110e00a4fb15f4ea..6895e8a76976307a6adfedd23dfebc87612d6285 100644 --- a/std/math/complex/tanh.zig +++ b/std/math/complex/tanh.zig @@ -4,6 +4,7 @@ // https://git.musl-libc.org/cgit/musl/tree/src/complex/ctanhf.c // https://git.musl-libc.org/cgit/musl/tree/src/complex/ctanh.c +const builtin = @import("builtin"); const std = @import("../../std.zig"); const testing = std.testing; const math = std.math; @@ -112,6 +113,10 @@ test "complex.ctanh32" { } test "complex.ctanh64" { + if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) { + // TODO https://github.com/ziglang/zig/issues/3289 + return error.SkipZigTest; + } const a = Complex(f64).new(5, 3); const c = tanh(a); diff --git a/std/math/cos.zig b/std/math/cos.zig index dc4aff59d6ffde27216977f92f88dfdbc7c473d0..5261a25f80c1f6cc0ef76d7fc7febed8864312cd 100644 --- a/std/math/cos.zig +++ b/std/math/cos.zig @@ -100,6 +100,10 @@ test "math.cos32" { } test "math.cos64" { + if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) { + // TODO https://github.com/ziglang/zig/issues/3289 + return error.SkipZigTest; + } const epsilon = 0.000001; expect(math.approxEq(f64, cos_(f64, 0.0), 1.0, epsilon)); diff --git a/std/math/pow.zig b/std/math/pow.zig index 18c9f80634eff38e7c7ae284c3e17e5c36314614..c3a77921376789f3f5fec24546c54f550cdd9714 100644 --- a/std/math/pow.zig +++ b/std/math/pow.zig @@ -184,6 +184,10 @@ fn isOddInteger(x: f64) bool { } test "math.pow" { + if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) { + // TODO https://github.com/ziglang/zig/issues/3289 + return error.SkipZigTest; + } const epsilon = 0.000001; expect(math.approxEq(f32, pow(f32, 0.0, 3.3), 0.0, epsilon)); @@ -202,6 +206,10 @@ test "math.pow" { } test "math.pow.special" { + if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) { + // TODO https://github.com/ziglang/zig/issues/3289 + return error.SkipZigTest; + } const epsilon = 0.000001; expect(pow(f32, 4, 0.0) == 1.0); @@ -244,6 +252,10 @@ test "math.pow.special" { } test "math.pow.overflow" { + if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) { + // TODO https://github.com/ziglang/zig/issues/3289 + return error.SkipZigTest; + } expect(math.isPositiveInf(pow(f64, 2, 1 << 32))); expect(pow(f64, 2, -(1 << 32)) == 0); expect(math.isNegativeInf(pow(f64, -2, (1 << 32) + 1))); diff --git a/std/math/sin.zig b/std/math/sin.zig index f21db4054ef3ba34d82100cab14a4205a5514ab5..ee07b4f85e118829737334581dcd0b70a97f5c75 100644 --- a/std/math/sin.zig +++ b/std/math/sin.zig @@ -84,12 +84,20 @@ fn sin_(comptime T: type, x_: T) T { } test "math.sin" { + if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) { + // TODO https://github.com/ziglang/zig/issues/3289 + return error.SkipZigTest; + } expect(sin(f32(0.0)) == sin_(f32, 0.0)); expect(sin(f64(0.0)) == sin_(f64, 0.0)); expect(comptime (math.sin(f64(2))) == math.sin(f64(2))); } test "math.sin32" { + if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) { + // TODO https://github.com/ziglang/zig/issues/3289 + return error.SkipZigTest; + } const epsilon = 0.000001; expect(math.approxEq(f32, sin_(f32, 0.0), 0.0, epsilon)); @@ -102,6 +110,10 @@ test "math.sin32" { } test "math.sin64" { + if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) { + // TODO https://github.com/ziglang/zig/issues/3289 + return error.SkipZigTest; + } const epsilon = 0.000001; expect(math.approxEq(f64, sin_(f64, 0.0), 0.0, epsilon)); @@ -114,6 +126,10 @@ test "math.sin64" { } test "math.sin32.special" { + if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) { + // TODO https://github.com/ziglang/zig/issues/3289 + return error.SkipZigTest; + } expect(sin_(f32, 0.0) == 0.0); expect(sin_(f32, -0.0) == -0.0); expect(math.isNan(sin_(f32, math.inf(f32)))); @@ -122,6 +138,10 @@ test "math.sin32.special" { } test "math.sin64.special" { + if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) { + // TODO https://github.com/ziglang/zig/issues/3289 + return error.SkipZigTest; + } expect(sin_(f64, 0.0) == 0.0); expect(sin_(f64, -0.0) == -0.0); expect(math.isNan(sin_(f64, math.inf(f64)))); diff --git a/std/math/tan.zig b/std/math/tan.zig index e8259ee7ad2946fa70c96f29287e69ae013a941e..049c85df12d50413b91b8d965d3e80bdc0571fd1 100644 --- a/std/math/tan.zig +++ b/std/math/tan.zig @@ -91,6 +91,10 @@ test "math.tan32" { } test "math.tan64" { + if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) { + // TODO https://github.com/ziglang/zig/issues/3289 + return error.SkipZigTest; + } const epsilon = 0.000001; expect(math.approxEq(f64, tan_(f64, 0.0), 0.0, epsilon)); diff --git a/std/os.zig b/std/os.zig index d29c7d3c0e132800e89b8251eff419ade3926f27..ed626e0dcc19489758ce3b68023f21e6dc175573 100644 --- a/std/os.zig +++ b/std/os.zig @@ -2048,7 +2048,7 @@ pub fn mmap( prot: u32, flags: u32, fd: fd_t, - offset: isize, + offset: u64, ) MMapError![]align(mem.page_size) u8 { const err = if (builtin.link_libc) blk: { const rc = std.c.mmap(ptr, length, prot, flags, fd, offset); diff --git a/std/os/linux.zig b/std/os/linux.zig index 375c7eba8461a71302aea85b00c944ce2de37656..7dcd01572ee9cf3e8160e927334835d494acd602 100644 --- a/std/os/linux.zig +++ b/std/os/linux.zig @@ -190,11 +190,11 @@ pub fn umount2(special: [*]const u8, flags: u32) usize { return syscall2(SYS_umount2, @ptrToInt(special), flags); } -pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: u32, fd: i32, offset: isize) usize { +pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: u32, fd: i32, offset: u64) usize { if (@hasDecl(@This(), "SYS_mmap2")) { - return syscall6(SYS_mmap2, @ptrToInt(address), length, prot, flags, @bitCast(usize, isize(fd)), @bitCast(usize, @divTrunc(offset, MMAP2_UNIT))); + return syscall6(SYS_mmap2, @ptrToInt(address), length, prot, flags, @bitCast(usize, isize(fd)), @truncate(usize, offset / MMAP2_UNIT)); } else { - return syscall6(SYS_mmap, @ptrToInt(address), length, prot, flags, @bitCast(usize, isize(fd)), @bitCast(usize, offset)); + return syscall6(SYS_mmap, @ptrToInt(address), length, prot, flags, @bitCast(usize, isize(fd)), offset); } } diff --git a/test/tests.zig b/test/tests.zig index 7dc1d1f620eaa026c8e8f1cfcdb1c8388eb4c0c6..20c8276e42edfb73eef056d0b5800b7ea16648f2 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -109,17 +109,16 @@ const test_targets = [_]TestTarget{ }, }, }, - // TODO https://github.com/ziglang/zig/issues/3286 - //TestTarget{ - // .target = Target{ - // .Cross = CrossTarget{ - // .os = .linux, - // .arch = builtin.Arch{ .arm = builtin.Arch.Arm32.v8_5a }, - // .abi = .musleabihf, - // }, - // }, - // .link_libc = true, - //}, + TestTarget{ + .target = Target{ + .Cross = CrossTarget{ + .os = .linux, + .arch = builtin.Arch{ .arm = builtin.Arch.Arm32.v8_5a }, + .abi = .musleabihf, + }, + }, + .link_libc = true, + }, // TODO https://github.com/ziglang/zig/issues/3287 //TestTarget{ // .target = Target{ -- 2.54.0