11615 Commits

Author SHA1 Message Date
Alex Rønne Petersen
481b7bf3f0
std.Target: Remove functions that just wrap component functions.
Functions like isMinGW() and isGnuLibC() have a good reason to exist: They look
at multiple components of the target. But functions like isWasm(), isDarwin(),
isGnu(), etc only exist to save 4-8 characters. I don't think this is a good
enough reason to keep them, especially given that:

* It's not immediately obvious to a reader whether target.isDarwin() means the
  same thing as target.os.tag.isDarwin() precisely because isMinGW() and similar
  functions *do* look at multiple components.
* It's not clear where we would draw the line. The logical conclusion before
  this commit would be to also wrap Arch.isX86(), Os.Tag.isSolarish(),
  Abi.isOpenHarmony(), etc... this obviously quickly gets out of hand.
* It's nice to just have a single correct way of doing something.
2025-02-17 19:18:19 +01:00
Alex Rønne Petersen
e62352611f
std.Target: Move osArchName() and Cpu.Arch.archName() to std.zig.target.
These deal with how Zig stores OS headers in `lib/libc/include` and so don't
really belong in std.Target.
2025-02-17 19:17:56 +01:00
Alex Rønne Petersen
ce8c61b0fc
std.Target: Move Cpu.Arch.supportsAddressSpace() up to Cpu.
This allows it to inspect CPU features which is needed for Propeller, and AVR in
the future.
2025-02-17 19:17:56 +01:00
Alex Rønne Petersen
0048166867
std.Target: Make Cpu.Arch.supportsAddressSpace() take an optional context.
Allows deduplicating the code in Sema.
2025-02-17 19:17:56 +01:00
Alex Rønne Petersen
aa4ac2f85f
std.builtin: Rename CallingConvention.propeller1_sysv to propeller_sysv. 2025-02-17 19:17:56 +01:00
Alex Rønne Petersen
e0f8d4e68e
std.builtin: Rename CallingConvention.wasm_watc to wasm_mvp. 2025-02-17 19:17:56 +01:00
Alex Rønne Petersen
9c015e6c2b
std.builtin: Remove CallingConvention.arm_(apcs,aapcs16_vfp).
* arm_apcs is the long dead "OABI" which we never had working support for.
* arm_aapcs16_vfp is for arm-watchos-none which is a dead target that we've
  dropped support for.
2025-02-17 19:17:56 +01:00
Alex Rønne Petersen
2fe32ef847
std.Target: Remove Cpu.Arch.propeller2 and use a CPU feature instead. 2025-02-17 19:17:55 +01:00
Alex Rønne Petersen
b541a7af11
std.Target: Remove Cpu.Arch.spu_2.
This was for a hobby project that appears to be dormant for now. This can be
added back if the project is resumed in the future.
2025-02-17 19:17:55 +01:00
Frank Denis
55c46870b2
crypto.auth.Aegis128X*Mac: properly absorb tags in the first lane (#22922)
In the MAC finalization function, concatenated tags at odd positions
were not absorbed into the correct lane.

Spotted by a Tigerbeetle regression test and reported by Rafael Batiati
(@batiati) — Thanks!
2025-02-17 17:56:09 +00:00
schtvn
1b62469ec9
Fix build failure in sbrk allocator, caused by #20511 2025-02-17 15:37:19 +01:00
Mark Rushakoff
86064e66d6 std.testing: improve compile error on untagged union equality 2025-02-16 15:51:40 +01:00
Alex Rønne Petersen
ddff1fa4c6 compiler-rt: Use Windows Arm ABI routines for UEFI for now.
Until #21630 is addressed.

Closes #22893.
2025-02-16 01:15:29 +01:00
Manuel Spagnolo
9ad57515b2 remove unneeded native_os check
The check is not needed, since we are already checking for the os
at line 847 and returning at 916 when the check succeeds.
Therefore, at 926, we know the os is not windows.
2025-02-16 01:02:33 +01:00
Alex Rønne Petersen
d7f9b5a661 zig.h: Add new zig_gcc macro to indicate GCC.
As opposed to "GNU C" (zig_gnuc) which includes Clang.

This addresses #22890 but does not fix it until a zig1.wasm update.
2025-02-16 00:21:51 +01:00
Jacob Young
8c48376d64 x86_64: rewrite scalar and vector int @divTrunc 2025-02-15 03:45:21 -05:00
Benjamin Thompson
5ab5113077
added expectEqualDeep test coverage for issue 16625 (#22781) 2025-02-15 03:41:58 +01:00
LmanTW
13ad984b1f
std: add containsAtLeastScalar to mem (#22826) 2025-02-15 03:40:55 +01:00
Alex Rønne Petersen
8a3aebaee0 musl: Apply Rich Felker's CVE-2025-26519 mitigation patches.
https://www.openwall.com/lists/oss-security/2025/02/13/2

Closes #22883.
2025-02-14 06:42:57 +01:00
Hugo Beauzée-Luyssen
462d26171b glibc: don't redirect fts to fts64 before glibc 2.23 2025-02-14 02:11:26 +01:00
Ali Cheraghi
bffbc918ee std.time: more precise nanoTimestamp in windows 2025-02-13 16:55:58 +01:00
Andrew Kelley
d12123a88c std.ArrayList: initial capacity based on cache line size
also std.MultiArrayList
2025-02-13 00:19:03 -08:00
wooster0
5b9b5e45cb std.fmt.digits2: optimize for ReleaseSmall
Difference:
```
$ cat x.zig
const std = @import("std");

pub const std_options = std.Options{ .keep_sigpipe = true };

pub fn main() void {
    std.io.getStdOut().writer().print("{d}\n", .{@intFromPtr(std.os.argv.ptr)}) catch {};
}
$ zig build-exe x.zig -OReleaseSmall -fsingle-threaded -fno-unwind-tables && wc -c x
2576 x
$ zig build-exe x.zig -OReleaseSmall -fsingle-threaded -fno-unwind-tables --zig-lib-dir ../zig/lib && wc -c x
2424 x
```
2025-02-12 14:45:38 -08:00
Jacob Young
348d1773ba std: remove special cases for stage2_x86_64 that are no longer needed 2025-02-12 09:48:17 -05:00
Andrew Kelley
53216d2f22 std.ArrayHashMap: base linear_scan_max on cache line size 2025-02-12 01:55:26 -08:00
Andrew Kelley
58f928814d
Merge pull request #22862 from ziglang/fuzz
fuzzer: write inputs to shared memory before running
2025-02-11 23:36:53 -08:00
Alex Rønne Petersen
db0d9c2126
Merge pull request #22857 from nikneym/master
linux(io_uring): port new functions from liburing
2025-02-12 07:57:10 +01:00
dweiller
6dc1a4db7f compiler-rt: fix memcpy generating recursive calls
When using the LLVM backend, array copies were lowered as calls to
`llvm.memcpy.*` builtin which could cause recursive calls to memcpy to
be generated (observed with `-target x86_64-linux -mcpu x86_64+avx512vl
--debug-rt`).

By instead performing these small fixed-size copies with integers or
vectors the LLVM backend does not generate calls to the `llvm.memcpy`
builtin, and so (with `-fno-builtin`) recursive calls to memcpy will
not be generated by LLVM.

The assertions and (test build) runtime safety have been removed as they
may cause (mutually) recursive calls to memcpy in debug builds since the
panic handler generates calls to llvm.memcpy.
2025-02-11 17:40:20 -08:00
Andrew Kelley
c2a3d8cbb9 std.ArrayHashMap: introduce setKey
Only available in the "unmanaged" variant since the other one is
deprecated.
2025-02-11 17:24:59 -08:00
Meghan Denny
b2b830e0e9 std.c: was missing calloc 2025-02-11 17:21:07 -08:00
Andrew Kelley
d789f1e5cf fuzzer: write inputs to shared memory before running
breaking change to the fuzz testing API; it now passes a type-safe
context parameter to the fuzz function.

libfuzzer is reworked to select inputs from the entire corpus.

I tested that it's roughly as good as it was before in that it can find
the panics in the simple examples, as well as achieve decent coverage on
the tokenizer fuzz test.

however I think the next step here will be figuring out why so many
points of interest are missing from the tokenizer in both Debug and
ReleaseSafe modes.

does not quite close #20803 yet since there are some more important
things to be done, such as opening the previous corpus, continuing
fuzzing after finding bugs, storing the length of the inputs, etc.
2025-02-11 13:39:20 -08:00
Rafael Batiati
33f0d458cf
std.elf: fix panic while parsing header
When parsing an invalid (e.g., corrupted) ELF header, `@enumFromInt` can panic casting the exhaustive enum `ET`.
2025-02-11 21:12:44 +00:00
saurabh
4162f401cb
std.fmt: Add unit tests for all methods in the Parser struct 2025-02-11 13:34:56 +02:00
nikneym
408c817e1e linux/IoUring: add register_files_sparse 2025-02-11 13:19:05 +03:00
nikneym
6f6b85e298 linux/io_uring_sqe: add prep_files_update 2025-02-11 13:18:27 +03:00
nikneym
ecfd9cef7d linux/io_uring_sqe: add prep_cancel_fd 2025-02-11 13:17:54 +03:00
Andrew Kelley
8d914ea734 compiler_rt memcpy: avoid infinite recursion
when compiled in debug mode (--debug-rt)
2025-02-10 22:58:49 -08:00
Andrew Kelley
1d8857bbe3
Merge pull request #22695 from alexrp/glibc-2-41
glibc 2.41
2025-02-10 17:32:55 -08:00
Jacob Young
5433e0438c cbe: fix ub triggered by mulw overflowing the promoted type
Closes #21914
2025-02-10 17:22:16 -08:00
rpkak
34644511bb std.fmt: remove placeholders from binary 2025-02-10 22:52:17 +01:00
Alex Rønne Petersen
d4c85079c5
Merge pull request #22834 from krkk/hi-this-is-my-first-PR-and-heres-my-breaking-change-haha
std.c: Improve the description of getnameinfo() arguments: optional pointers and specialized `flags` type
2025-02-10 10:44:21 +01:00
Ryan Liptak
00316bfbf0 resinator: Fix some error message integration
Fixup for some of the changes in https://github.com/ziglang/zig/pull/22522
2025-02-10 01:37:04 -08:00
andrewkraevskii
6fa7d5d4ad std.mem: add missing check to lastIndexOfLinear 2025-02-10 09:27:26 +01:00
Meghan Denny
9142482372
std.ArrayList: popOrNull() -> pop() [v2] (#22720) 2025-02-10 04:21:31 +00:00
Linus Groh
75df7e502c std.c: Fix definition of stack_t on OpenBSD
The size field is not supposed to be signed.
See: https://man.openbsd.org/sigaltstack.2
2025-02-09 22:17:35 +01:00
Karol Kosek
2ccfb1dafd std.c: Use std.c.NI as the flags type in getnameinfo
std.c.NI was never used in the source, so let's finally use it and make
the function more clear!

This is a breaking change, although a minor one: If you previously passed 0 here
(meaning no flags), then now you have to pass an empty struct (.{}) instead.
Otherwise, you probably used @bitCast() shenanigans here (like
@bitCast(c.NI { .NUMERICHOST = true }) and that will still work, but you can
also get rid of the @bitCast() now!
2025-02-09 16:40:21 +01:00
Karol Kosek
18ffd48b60 std.c: Support optional addr and host arguments in getnameinfo
The POSIX spec allows passing null here
https://pubs.opengroup.org/onlinepubs/9799919799/functions/getnameinfo.html
2025-02-09 16:06:38 +01:00
Meghan Denny
933ba935c5
std.BoundedArray: popOrNull() -> pop() [v2] (#22723) 2025-02-09 11:46:15 +00:00
Jacob Young
4e4775d6bd x86_64: implement conversions between scalar floats and ints
Closes #22797
2025-02-09 00:42:55 -08:00
Pat Tullmann
138d30bb47 wasi: fix wasm-wasi-musl constants
Zig's copy of the `SYMLINK_{NO,}FOLLOW` constants from wasi-musl was
wrong, as were the `IFIFO` and `IFSOCK` file type flags.  Fix these up,
and add comments pointing to exactly where they come from (as the
wasi-musl source has lots of unused, different definitions of these
constants).

Add tests for the Zig convention that WASM preopen 3 is the current
working directory.   This is true for WASM with or without libc.

Enable several fs and posix tests that are now passing (not necessarily
because of this change) on wasm targets.

Fixes #20890.
2025-02-09 09:08:11 +01:00