Commit Graph

30195 Commits

Author SHA1 Message Date
poypoyan
939fcce5ef
std.mem.readVarInt: fix for 8-bits and below (Reloaded) (#20513) 2024-07-28 20:26:36 -07:00
Andrew Kelley
08e83fee57
Merge pull request #20297 from sno2/wtf8-conversion-buffer-overflows
std: fix buffer overflows from improper WTF encoding
2024-07-28 20:24:31 -07:00
Carter Snook
219acaa1d6 std.fs.Dir: Refactor atomicSymLink from std.fs
Deprecates std.fs.atomicSymLink and removes the allocator requirement
from the new std.fs.Dir.atomicSymLink. Replaces the two usages of this
within std.

I did not include the TODOs from the original code that were based
off of `switch (err) { ..., else => return err }` not having correct
inference that cases handled in `...` are impossible in the error
union return type because these are not specified in many places but
I can add them back if wanted.

Thank you @squeek502 for help with fixing buffer overflows!
2024-07-28 20:08:52 -07:00
Cheng Sheng
4a77c7f258
Condense and extend std.Treap's traversal functionalities. (#20002)
The core functionalities are now in two general functions
`extremeInSubtreeOnDirection()` and `nextOnDirection()` so all the other
traversing functions (`getMin()`, `getMax()`, and `InorderIterator`) are
all just trivial calls to these core functions.

The added two functions `Node.next()` and `Node.prev()` are also just
trivial calls to these.

* std.Treap traversal direction: use u1 instead of usize.

* Treap: fix getMin() and getMax(), and add tests for them.
2024-07-28 19:47:55 -07:00
Alex Rønne Petersen
d1d95294fd std.Target.Cpu.Arch: Remove the aarch64_32 tag.
This is a misfeature that we inherited from LLVM:

* https://reviews.llvm.org/D61259
* https://reviews.llvm.org/D61939

(`aarch64_32` and `arm64_32` are equivalent.)

I truly have no idea why this triple passed review in LLVM. It is, to date, the
*only* tag in the architecture component that is not, in fact, an architecture.
In reality, it is just an ILP32 ABI for AArch64 (*not* AArch32).

The triples that use `aarch64_32` look like `aarch64_32-apple-watchos`. Yes,
that triple is exactly what you think; it has no ABI component. They really,
seriously did this.

Since only Apple could come up with silliness like this, it should come as no
surprise that no one else uses `aarch64_32`. Later on, a GNU ILP32 ABI for
AArch64 was developed, and support was added to LLVM:

* https://reviews.llvm.org/D94143
* https://reviews.llvm.org/D104931

Here, sanity seems to have prevailed, and a triple using this ABI looks like
`aarch64-linux-gnu_ilp32` as you would expect.

As can be seen from the diffs in this commit, there was plenty of confusion
throughout the Zig codebase about what exactly `aarch64_32` was. So let's just
remove it. In its place, we'll use `aarch64-watchos-ilp32`,
`aarch64-linux-gnuilp32`, and so on. We'll then translate these appropriately
when talking to LLVM. Hence, this commit adds the `ilp32` ABI tag (we already
have `gnuilp32`).
2024-07-28 19:44:52 -07:00
Ketan Reynolds
0403c4b05c std.posix: handle INVAL in openatWasi
In accordance with https://github.com/ziglang/zig/pull/19833#issuecomment-2089262607
2024-07-28 19:01:55 -07:00
Ketan Reynolds
b4e7b6fdba std.posix: handle INVAL in openZ and openatZ
Contributes to #15607

Although the case is not handled in `openatWasi` (as I could not get a
working wasi environment to test the change) I have added a FIXME
addressing it and linking to the issue.
2024-07-28 19:01:55 -07:00
Alex Rønne Petersen
c157550928 link.Coff: Basic support for /Brepro in the self-hosted linker.
Just keep things simple and zero the timestamp. It's not obvious that there's
any real benefit to adding complexity and harming performance by computing a
hash of the whole file for the timestamp value.

See:

* https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#general-concepts
* https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#debug-type

In the future, we should at least add an empty `IMAGE_DEBUG_TYPE_REPRO` entry to
the debug data directory for this case, but I didn't want to do too much surgery
right now since it's early days for COFF support in the self-hosted linker.
2024-07-28 22:49:41 +02:00
Alex Rønne Petersen
b03a04c7fc
musl: Build with -fexcess-precision=standard -frounding-math.
Clang supports these now.
2024-07-28 15:42:02 +02:00
Alex Rønne Petersen
243bb87db0
musl: Build with -fno-strict-aliasing like upstream. 2024-07-28 15:41:35 +02:00
Matthew Ettler
d30d37e356
feat(std.os.uefi.protocol): add Serial IO 2024-07-28 12:37:53 +00:00
Alex Rønne Petersen
642cd730c8 link: Accept -Brepro linker option and pass it to LLD.
Enable it by default when building Zig code in release modes.

Contributes to #9432.
2024-07-28 14:37:03 +02:00
Jakub Konka
91c17979f1
Merge pull request #20807 from Rexicon226/riscv
riscv: more backend progress
2024-07-28 11:34:23 +02:00
Jakub Konka
1fba9e1280
Merge pull request #20834 from ziglang/macho-boundary-typo-fix
macho: fix typo in boundary symbols handling
2024-07-28 10:30:26 +02:00
Jakub Konka
58defeeaa6 macho: test section$end$ boundary symbol handling 2024-07-28 06:59:21 +02:00
Linus Groh
a84951465b translate-c: Use mangled name for local extern in condition/loop 2024-07-28 02:58:49 +03:00
Jakub Konka
77476a03e8 macho: fix typo in boundary symbol tag: $stop -> $end 2024-07-27 23:56:18 +02:00
Jarrod Meyer
2de0e2eca3 Watch.zig: add initial windows implementation 2024-07-27 11:32:43 -04:00
Jarrod Meyer
2b8f444dde windows: reintroduce ReadDirectoryChangesW
- additionally, introduces FileNotifyChangeFilter to improve use/readability
2024-07-27 11:32:43 -04:00
Jarrod Meyer
9323a00067 windows: add Timeout status result for GetQueuedCompletionStatus 2024-07-27 11:32:43 -04:00
Jarrod Meyer
7434accc3d windows: make the WaitForMultipleObjectsEx assertion inclusive
- additionally, the parameter must be nonzero: https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitformultipleobjects
2024-07-27 11:32:43 -04:00
David Rubin
b20007daf7
riscv: correct airAsm to generate correct jalr call 2024-07-27 08:14:09 -07:00
Alex Rønne Petersen
66b71273a2 std.os.linux: Fix default value for perf_event_attr.clockid field.
Closes #20810.
2024-07-26 18:21:10 -07:00
Andrew Kelley
eab934814f docs: ArrayHashMap: warn against the shrink footgun 2024-07-26 15:24:25 -07:00
David Rubin
8f84212855
riscv: make multi-threaded enabled compilation the default 2024-07-26 14:53:55 -07:00
David Rubin
c20def73af
riscv: workarounds for riscv threading 2024-07-26 14:53:50 -07:00
Karim Mk
3b3c9d2081 Fix typo in init files. 2024-07-26 14:33:59 -07:00
David Rubin
a7498a6a53
comp: enable compilation of zig_libc 2024-07-26 14:02:48 -07:00
David Rubin
846bd40361
riscv: implement @cmpxchg* and remove fixes 2024-07-26 12:43:47 -07:00
Andrew Kelley
5d3a1cfdf5 update init template
* add fuzz example
* explain that you might want to delete main.zig or root.zig
2024-07-26 12:18:23 -07:00
David Rubin
9752bbfeb3
riscv: implement basic tlv loads and stores 2024-07-26 08:49:34 -07:00
Andrew Kelley
208baa37ca frontend: add missed cache hash on --debug-rt
Makes adding --debug-rt correctly invalidate the cache for compiler_rt
and libfuzzer.
2024-07-26 08:42:40 -07:00
kcbanner
2a0238e5e3 zig.h: fixup pointer atomic load definitions 2024-07-26 10:42:10 -04:00
Jakub Konka
1240134c8b
Merge pull request #20788 from alexrp/elf-dt
`std.elf`: Add some definitions for the newer RELR relocations
2024-07-26 15:02:19 +02:00
Andrew Kelley
80269c1f53 remove deprecated --mod CLI now that a zig1.wasm update happened 2024-07-26 05:07:18 -07:00
David Rubin
8da212c11b
riscv: update tests and fix reuse bug 2024-07-26 04:19:58 -07:00
David Rubin
046001a34a
riscv implement @popCount 2024-07-26 04:19:57 -07:00
David Rubin
7ff5709e1b
riscv: implement lr/sr loop logic for non-native atomics 2024-07-26 04:19:57 -07:00
David Rubin
a1f6a8ef90
riscv: airAsm rewrite
with this rewrite we can call functions inside of
inline assembly, enabling us to use the default start.zig logic

all that's left is to implement lr/sc loops for atomically manipulating
1 and 2 byte values, after which we can use the segfault handler logic.
2024-07-26 04:19:55 -07:00
David Rubin
b533e848a2
riscv: enable passing tests 2024-07-26 04:19:17 -07:00
David Rubin
c00a5ff792
riscv: implement @floatFromInt 2024-07-26 04:19:16 -07:00
David Rubin
1a7d89a84d
riscv: clean up and unify encoding logic 2024-07-26 04:19:13 -07:00
David Rubin
574028ed5e
riscv: boilerplate for creating lazy functions 2024-07-26 04:05:44 -07:00
David Rubin
9bc7e8c852
riscv: update tests 2024-07-26 04:05:43 -07:00
David Rubin
64c6473443
riscv: implement add_sat and ptr_slice_len_ptr
this is enough to use the basic functions of an ArrayList!
2024-07-26 04:05:43 -07:00
David Rubin
45443f9c37
cmake: update to reflect added riscv64 backend files 2024-07-26 04:05:43 -07:00
David Rubin
6ac1b2d82a
riscv: add 32-bit support to integer @abs 2024-07-26 04:05:42 -07:00
David Rubin
1820f44104
riscv: implement sub-byte addition 2024-07-26 04:05:42 -07:00
David Rubin
81ca3a1d59
riscv: fix logic bug in ptr_elem_ptr
I was doing duplicate work with `elemOffset` multiplying by the abi size and then the `ptr_add` `genBinOp` also multiplying.

This led to having writes happening in the wrong place.
2024-07-26 04:05:41 -07:00
David Rubin
cde6956b21
riscv: remove redundant assert in genBinOp 2024-07-26 04:05:41 -07:00