18428 Commits

Author SHA1 Message Date
Stephen Gregoratto
a4369918b1 Generate linux syscalls via. the linux source tree
Previously, updating the `SYS` enum for each architecture required
manually looking at the syscall tables and inserting any new additions.

This commit adds a tool, `generate_linux_syscalls.zig`, that automates
this process using the syscall tables in the Linux source tree. On
architectures without a table, it runs `zig cc` as a pre-processor to
extract the system-call numbers from the Linux headers.
2022-05-16 23:55:11 -04:00
Felix "xq" Queißner
6d27341b96 Fixes comptime 'error: cannot assign to constant' error in siphash. 2022-05-16 22:31:09 -04:00
Andrew Kelley
5888446c03
Merge pull request #11316 from wsengir/stage2-overflow-safety
stage2: vectorized overflow arithmetic, integer overflow safety, left-shift overflow safety
2022-05-16 20:40:57 -04:00
Thiago Teodoro Pereira Silva
7a4758ed78
std.os: add timerfd_create, timerfd_settime and timerfd_gettime 2022-05-17 00:56:33 +02:00
leesongun
1de7b8d26c
std.math.powi: use standard definition of underflow/overflow, implement u0, i0, i1 edge case (#11499) 2022-05-16 18:28:20 -04:00
Isaac Freund
1392c24166 std.os: Add memfd_create for FreeBSD
This is minorly breaking as e.g. std.os.linux.MFD_CLOEXEC is now
std.os.linux.MFD.CLOEXEC.
2022-05-16 17:43:44 -04:00
Andrew Kelley
f33b3fc3ea zig.h: add casts for overflow arithmetic operations
This avoids the following error:

```
error: incompatible pointer types passing 'int64_t *' (aka 'long long *') to parameter of type 'long *'
    overflow = __builtin_saddl_overflow(lhs, rhs, res);
                                                  ^~~
```

My previous understanding was that this error would not occur because
prior to this line we check that int64_t is equivalent to long, like
this:

```c
```

However, it appears that this is still a warning in C if int64_t is
primarily aliased to `long long`, even though `long` and `long long` are
the same thing.
2022-05-16 14:30:28 -07:00
Jakub Konka
a0de0adb8e arm: disable recursive fibonacci 2022-05-16 13:55:26 -07:00
Jakub Konka
7f96ca101a arm: sub_with_overflow should always track V flag 2022-05-16 13:55:26 -07:00
Jakub Konka
852c820841 aarch64: sub_with_overflow should always track V flag 2022-05-16 13:55:26 -07:00
Andrew Kelley
a84be7e988 zig.h: improve overflow shl
* zig_addo_u128: fix type-o
 * redo the shift-left overflow inline functions. no need to depend on
   compiler-rt.
2022-05-16 13:55:26 -07:00
Luuk de Gram
160aa4c11d wasm: Improve shl_with_overflow
This re-implements the shl_with_overflow operation from scratch,
making it a lot more robust and outputs the equal code to the LLVM backend.
2022-05-16 13:55:26 -07:00
Luuk de Gram
0a2d3d4155 wasm: Improve overflow add/sub for ints <= 64bits
The implementation for add_with_overflow and sub_with_overflow is now a lot
more robust and takes account for signed integers and arbitrary integer bitsizes.
The final output is equal to that of the LLVM backend.
2022-05-16 13:55:26 -07:00
Jakub Konka
b94d165b69 x64: fix capacity prealloc limit in lowerToMrEnc helper 2022-05-16 13:55:26 -07:00
Andrew Kelley
316bf4fce5 disable 5 failing stage2_wasm tests 2022-05-16 13:55:26 -07:00
Andrew Kelley
03ed0f0d28 C backend: implement overflow arithmetic
Most of the work here was additions to zig.h. The lowering code is
mainly responsible for calling the correct function name depending on
the operand type.

Some of the compiler-rt calls here are not implemented yet and are
non-standard symbols due to the C programming language not needing them.

After this commit, the behavior tests with -ofmt=c are passing again.
2022-05-16 13:55:26 -07:00
William Sengir
a5ea22d069 LLVM: correctly pad result tuple of airOverflow 2022-05-16 13:55:26 -07:00
William Sengir
bb3532e775 stage2: add more vector overflow tests 2022-05-16 13:55:26 -07:00
William Sengir
21be3d9166 stage2: add vectorized overflow arithmetic behavior tests 2022-05-16 13:55:26 -07:00
William Sengir
afc714d5e5 stage2: implement runtime safety checks for shl_exact 2022-05-16 13:55:26 -07:00
William Sengir
c2980f332e Sema: implement integer overflow safety for add, sub, mul 2022-05-16 13:55:26 -07:00
William Sengir
eb06c78a8a Sema: vectorize overflow arithmetic 2022-05-16 13:55:26 -07:00
William Sengir
86a928ce61 stage2: perform comptime vectorization of *_with_overflow in Value 2022-05-16 13:55:26 -07:00
William Sengir
e8117bab6f stage2: clean up creation of boolean Values 2022-05-16 13:55:26 -07:00
William Sengir
6b5c87957b stage2: handle vectors in Value.intFitsInType 2022-05-16 13:55:26 -07:00
William Sengir
ca1ab38d3a stage2: add global Type constant for u1 2022-05-16 13:55:26 -07:00
William Sengir
c2cb9b7cad stage2: vectorize shl_with_overflow in LLVM backend 2022-05-16 13:55:26 -07:00
William Sengir
c641fb8f05 stage2: fix {add,sub,mul}_with_overflow vectorization in LLVM backend 2022-05-16 13:55:26 -07:00
Jakub Konka
5b03d55c5e x64: rename brk to int3, and MIR to interrupt 2022-05-15 19:52:43 +02:00
Jakub Konka
5f97652da8 x64: remove verbose_mir functionality
Originally I thought interleaving AIR with MIR will be useful, however
as it stands, I have used it very sporadically, and recently, not at
all, and I do not think anyone else is actually using it. If there is
a simple error such as a wrong instruction emitted,
`objdump` is perfectly capable of narrowing it down, while if there's
something more subtle happening, regardless of having `--verbose-mir`
functionality or not, you still gotta go via the debugger which
offers a better view at interleaved source program with the emitted
machine code. Finally, I believe `-femit-asm` when we add it will offer a
more generic substitute.
2022-05-15 18:21:50 +02:00
Luuk de Gram
5138856a72 test harness: Set filename on error return
While calling `next` an error can occur while parsing the file.
However, we don't set the filename that is currently being processed, until `next` completed successfully.
This means that for invalid test names, the wrong filename was being displayed in the panic message.
The fix is to retrieve the correct filename when an error occurs and then setting the filename appropriately.
2022-05-15 09:30:59 +02:00
Robin
1bdcbd18ae
init-exe: add note about log_level in ReleaseSmall and ReleaseFast build mode (#11626)
As suggested in https://github.com/ziglang/zig/issues/9945#issuecomment-950114977 by @wizzard0.

Fixes #9945.
2022-05-14 12:56:58 +02:00
Andrew Kelley
802f220739
Merge pull request #11647 from ziglang/migrate-runtime-safety-tests
migrate runtime safety tests to the new test harness
2022-05-13 23:57:15 -04:00
Andrew Kelley
0cd43b0f86 runtime safety tests only on the native target
This matches master branch. We can look into adding more target coverage
as we switch to stage2. As it stands, this works around having to
duplicate the "Executor" logic to figure out when to not run the tests
due to them being non-native.
2022-05-13 17:59:06 -07:00
Andrew Kelley
7d8b90b905 test harness: actually run the stage1 "run" tests 2022-05-13 17:32:23 -07:00
Andrew Kelley
c30edd78f9 std.Progress: activate() calls maybeRefresh()
This makes the progress bar display the ongoing operation in the case
that the API user calls activate().
2022-05-13 14:31:30 -07:00
Andrew Kelley
b986fcfc99 test-cases: honor -Dtest-filter argument from zig build 2022-05-13 14:31:02 -07:00
Andrew Kelley
f6e9b6620d build.zig: rename a local variable 2022-05-13 14:30:43 -07:00
Andrew Kelley
915032715f test harness: dump stderr when compiler crashes 2022-05-13 14:03:20 -07:00
Andrew Kelley
7755f7863a disable a runtime safety test that is failing on WASI 2022-05-13 14:03:20 -07:00
Andrew Kelley
66f3efb63b migrate runtime safety tests to the new test harness
* migrate runtime safety tests to the new test harness
   - this required adding compare output / execution support for stage1
     to the test harness.
 * rename `zig build test-stage2` to `zig build test-cases` since it now
   does quite a bit of stage1 testing actually. I named it this way
   since the main directory in the source tree associated with these
   tests is "test/cases/".
 * add some documentation for the test manifest format.
2022-05-13 14:03:20 -07:00
Andrew Kelley
f32928c50d
Merge pull request #11641 from erikarvstedt/fixup_rand_float_improvement
Minor fixes for random float generation
2022-05-13 16:50:18 -04:00
Kirk Scheibelhut
24633b5613 zig fmt: make --exclude ignore missing dirs 2022-05-13 16:45:00 -04:00
Koakuma
fb0692334e target: Rename sparcv9 -> sparc64
Rename all references of sparcv9 to sparc64, to make Zig align more with
other projects. Also, added new function to convert glibc arch name to Zig
arch name, since it refers to the architecture as sparcv9.

This is based on the suggestion by @kubkon in PR 11847.
(https://github.com/ziglang/zig/pull/11487#pullrequestreview-963761757)
2022-05-13 16:43:59 -04:00
Jonathan Marler
aceb7e18bd std.os.linux: fix signature of setgroups
the list parameter should be a multi-item pointer rather than a single-item
pointer. see: https://linux.die.net/man/2/setgroups

> setgroups() sets the supplementary group IDs for the calling process...
> the size argument specifies the number of supplementary group IDs in the buffer pointed to by list.
2022-05-13 17:46:56 +02:00
Andrew Kelley
537f905216 fix bad runtime safety test cases
The "slicing operator with sentinel" runtime safety test cases should
all have been compile errors in their current forms. In this commit I
adjust them to use runtime-known slices before triggering the runtime
safety.

Furthermore the test cases did not actually have unique names.
2022-05-12 21:15:41 -07:00
Travis Staloch
974af5f291 add std.math.sign 2022-05-12 16:09:09 -04:00
Erik Arvstedt
23ef7a8060 std.rand.float: simplify leading zero calculations
This saves a `bitwise or` operation in the common case and
removes the (slightly magic) mask constants.
2022-05-12 16:23:39 +02:00
Erik Arvstedt
1d5ea10bee std.rand: fixup 'improve random float generation'
- Test: Fix bucket counting. Previously, the first hit was not counted.
  This off-by-one error slightly increased the mean of `*_total_variance`,
  which decreased the acceptance rate for a particular random seed
  from 95% to 92.6%. (Irrelevant for test failure because the seed is fixed.)
- Improve comments
2022-05-12 15:39:19 +02:00
Andrew Kelley
5c20c7036b
Merge pull request #10796 from marler8997/envmap
Envmap
2022-05-12 02:49:11 -04:00