Commit graph

200 commits

Author SHA1 Message Date
JonathanHallstrom
5ce17ecfa7 remove unnecessary cast 2024-10-29 01:48:13 +01:00
Alex Rønne Petersen
95674fca0c
std.Thread: Use loongarch freeAndExit() implementation for loongarch32 too. 2024-10-16 01:10:36 +02:00
Andrew Kelley
04e694ad11 move std.time.sleep to std.Thread.sleep 2024-09-26 12:35:14 -07:00
Alex Rønne Petersen
af04404b49 std: Fix assembler comment syntax for sparc. 2024-09-07 13:16:22 -07:00
mlugg
0fe3fd01dd
std: update std.builtin.Type fields to follow naming conventions
The compiler actually doesn't need any functional changes for this: Sema
does reification based on the tag indices of `std.builtin.Type` already!
So, no zig1.wasm update is necessary.

This change is necessary to disallow name clashes between fields and
decls on a type, which is a prerequisite of #9938.
2024-08-28 08:39:59 +01:00
Alex Rønne Petersen
f0d6a211e0 std.Thread: Implement freeAndExit() for hexagon. 2024-08-19 08:38:05 +02:00
Alex Rønne Petersen
8e4feca8ab std.Thread: Implement freeAndExit() for s390x. 2024-08-19 08:38:05 +02:00
Alex Rønne Petersen
0f78f8244f std.Thread: Use zero exit code in freeAndExit() for sparc64. 2024-08-19 08:38:05 +02:00
Alex Rønne Petersen
d79e2822b0 std.Thread: Implement freeAndExit() for sparc32. 2024-08-19 08:38:05 +02:00
Alex Rønne Petersen
dc77d1b66d std.Thread: Merge riscv32/riscv64 assembly in freeAndExit(). 2024-08-13 23:53:57 -07:00
Alex Rønne Petersen
e725d1e226 std.Thread: Fix freeAndExit() syscall numbers for mips64.
These just seem to have been copy/pasted from mips32.
2024-08-13 00:56:35 -07:00
Alex Rønne Petersen
d0ae803a77 std.Thread: Fix freeAndExit() assembly for powerpc.
Wrong source/destination register order.
2024-08-13 00:56:14 -07:00
Alex Rønne Petersen
6d23850108 std.Thread: Explain apparently pointless mips instruction in freeAndExit().
https://git.musl-libc.org/cgit/musl/commit/?id=ce3688eca920aa77549323f84e21f33522397115
2024-08-12 16:07:46 -07:00
YANG Xudong
a9b65b6fd4
std: add loongarch64 support (#20915)
Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
2024-08-09 00:30:57 +00:00
Alex Rønne Petersen
b52e054261
std.os.linux.tls: Refactor and improve documentation.
* Elaborate on the sub-variants of Variant I.
* Clarify the use of the TCB term.
* Rename a bunch of stuff to be more accurate/descriptive.
* Follow Zig's style around namespacing more.
* Use a structure for the ABI TCB.

No functional change intended.
2024-07-30 02:32:32 +02:00
Alex Rønne Petersen
a59ab5ffa5
std.Thread: Add some syscall comments to LinuxThreadImpl.ThreadCompletion.freeAndExit(). 2024-07-29 09:50:40 +02:00
Alex Rønne Petersen
b83d10214b
std.Thread: Implement LinuxThreadImpl.ThreadCompletion.freeAndExit() for riscv32. 2024-07-29 09:50:09 +02: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
David Rubin
c20def73af
riscv: workarounds for riscv threading 2024-07-26 14:53:50 -07:00
Lucas Santos
1e74904aa2 Replace some dynamic functions with static ones.
PR [19271](https://github.com/ziglang/zig/pull/19271) added some static function implementations from kernel32, but some parts of the library still used the dynamically loaded versions.
2024-07-24 01:04:38 -07:00
Lucas Santos
89942ebd03
Better implementation of GetLastError. (#20623)
Instead of calling the dynamically loaded kernel32.GetLastError, we can extract it from the TEB.
As shown by [Wine](34b1606019/include/winternl.h (L439)), the last error lives at offset 0x34 of the TEB in 32-bit Windows and at offset 0x68 in 64-bit Windows.
2024-07-15 10:49:51 -07:00
mochalins
c8e0095362 test: Add spawn behavior test 2024-07-09 21:15:29 -04:00
Jacob Young
166402c16b bootstrap: fix build 2024-07-07 22:59:52 -04:00
Bram
5f58956264 std: Extended type checks for Thread startFn return type 2024-06-23 04:35:00 +01:00
Isaac Freund
a1777cb5cb
std: fix pthread_{get,set}name_np return type ABI
I believe this was accidentally broken when the E enum for errno values
was introduces. These functions are quite the special case in that they
return the error value directly rather than returning -1 and passing the
error value through the errno variable.

In any case, using a u16 as the return type at the ABI boundary where a
c_int is expected is asking for trouble.
2024-06-17 23:26:53 +02:00
Jakub Konka
2e1fc0dd14 handle visionos target OS tag in the compiler
* rename .xros to .visionos as agreed in the tracking issue
* add support for VisionOS platform in the MachO linker
2024-05-09 15:04:15 +02:00
Frank Denis
fefdbca6e6 Fix WASI threads, again
Properly call the entrypoint when it doesn't return an optional error,
and use the per-thread copy of the arguments list.
2024-04-22 15:27:05 -07:00
Andrew Kelley
54c08579e4
Merge pull request #19348 from jedisct1/wasi-threads-compfix
Unbreak support for WASI threads
2024-03-21 15:13:15 -07:00
Michael Dusan
e4ed63f138 bsd: followup to std.posix extraction from std.os
netbsd fix:
- `Futex.zig:542:56: error: expected error union type, found 'c_int'`

openbsd fix:
- `emutls.zig:10:21: error: root struct of file 'os' has no member named 'abort'`
- `Thread.zig:627:22: error: expected 6 argument(s), found 5`
2024-03-20 14:06:35 -07:00
Andrew Kelley
cd62005f19 extract std.posix from std.os
closes #5019
2024-03-19 11:45:09 -07:00
Frank Denis
9b454a8ce2 WASI-thread: panic if no allocator is given 2024-03-19 13:11:33 +01:00
Frank Denis
c470016743 Unbreak support for WASI threads 2024-03-18 16:51:41 +01:00
Stephen Gregoratto
9532f72937 Windows: Replace CreatePipe with ntdll implementation
This implementation is now a direct replacement for the `kernel32` one.
New bitflags for named pipes and other generic ones were added based on
browsing the ReactOS sources.

`UNICODE_STRING.Buffer` has also been changed to be nullable, as
this is what makes the implementation work.
This required some changes to places accesssing the buffer after a
`SUCCESS`ful return, most notably `QueryObjectName` which even referred
to it being nullable.
2024-03-16 23:37:50 +11:00
Tristan Ross
6067d39522
std.builtin: make atomic order fields lowercase 2024-03-11 07:09:10 -07:00
Ryan Liptak
726a1149e0 Change many test blocks to doctests/decltests 2024-02-26 15:18:31 -08:00
Ryan Liptak
16b3d1004e Remove redundant test name prefixes now that test names are fully qualified
Follow up to #19079, which made test names fully qualified.

This fixes tests that now-redundant information in their test names. For example here's a fully qualified test name before the changes in this commit:

"priority_queue.test.std.PriorityQueue: shrinkAndFree"

and the same test's name after the changes in this commit:

"priority_queue.test.shrinkAndFree"
2024-02-26 15:18:31 -08:00
Ryan Liptak
68b87918df Fix handling of Windows (WTF-16) and WASI (UTF-8) paths
Windows paths now use WTF-16 <-> WTF-8 conversion everywhere, which is lossless. Previously, conversion of ill-formed UTF-16 paths would either fail or invoke illegal behavior.

WASI paths must be valid UTF-8, and the relevant function calls have been updated to handle the possibility of failure due to paths not being encoded/encodable as valid UTF-8.

Closes #18694
Closes #1774
Closes #2565
2024-02-24 14:05:24 -08:00
Ryan Liptak
80508b98c2 Update deprecated std.unicode function usages 2024-02-24 14:04:59 -08:00
Andrew Kelley
9f3165540e std.os.linux.MAP: use a packed struct
Introduces type safety to this constant. Eliminates one use of
`usingnamespace`.
2024-02-06 21:12:11 -07:00
Christian Flicker
9c7fa358c1
std.Thread: fix off-by-one in PosixThreadImpl (#18711)
by removing ZST special case
2024-01-29 11:07:21 -05:00
Leonardo Gatti
4129996211 doc: possible typo at std.Thread.spawn comment 2023-12-30 14:17:36 +02:00
Andrew Kelley
70931dbdea rework std.atomic
* move std.atomic.Atomic to std.atomic.Value
* fix incorrect argument order passed to testing.expectEqual
* make the functions be a thin wrapper over the atomic builtins and
  stick to the naming conventions.
* remove pointless functions loadUnchecked and storeUnchecked. Instead,
  name the field `raw` instead of `value` (which is redundant with the
  type name).
* simplify the tests by not passing every possible combination. Many
  cases were iterating over every possible combinations but then not
  even using the for loop element value!
* remove the redundant compile errors which are already implemented by
  the language itself.
* remove dead x86 inline assembly. this should be implemented in the
  language if at all.
2023-11-22 19:08:55 -07:00
XXIV
34aac2bae1
std/Thread: remove unnecessary @ptrCast (#17766) 2023-10-31 00:17:39 -04:00
Stephen Gregoratto
285970982a Add illumos OS tag
- Adds `illumos` to the `Target.Os.Tag` enum. A new function,
  `isSolarish` has been added that returns true if the tag is either
  Solaris or Illumos. This matches the naming convention found in Rust's
  `libc` crate[1].
- Add the tag wherever `.solaris` is being checked against.
- Check for the C pre-processor macro `__illumos__` in CMake to set the
  proper target tuple. Illumos distros patch their compilers to have
  this in the "built-in" set (verified with `echo | cc -dM -E -`).

  Alternatively you could check the output of `uname -o`.

Right now, both Solaris and Illumos import from `c/solaris.zig`. In the
future it may be worth putting the shared ABI bits in a base file, and
mixing that in with specific `c/solaris.zig`/`c/illumos.zig` files.

[1]: 6e02a329a2/src/unix/solarish
2023-10-02 15:31:49 -06:00
Andrew Kelley
e84cda0ebf
Merge pull request #16622 from jacobly0/cbe-asm-compat
CBE: fix regressions and get new targets passing behavior tests
2023-07-31 15:34:32 -07:00
Andrew Kelley
1b9ffa0824 Revert "std.Thread: refining stack size from platform minimum, changes more targetted towards platform like Linux/musl (#15791)"
This reverts commit 41502c6aa5.
2023-07-31 10:54:35 -07:00
Jacob Young
817fa3af86 std: cleanup asm usage
After fixing some issues with inline assembly in the C backend, the std
cleanups have the side effect of making these functions compatible with
the backend, allowing it to be used on linux without linking libc.
2023-07-31 01:58:10 -04:00
Jim Price
584b062a30
Fix counting in SingleThreadedRwLock's tryLockShared (#16560)
Additionally we add RwLock to Thread.zig's list of tests
2023-07-26 08:19:52 -05:00
Luuk de Gram
87b8a0567b
default to single-threaded for WebAssembly
When targeting WebAssembly, we default to building a single-threaded build
as threads are still experimental. The user however can enable a multi-
threaded build by specifying '-fno-single-threaded'. It's a compile-error
to enable this flag, but not also enable shared-memory.
2023-06-26 20:00:58 +02:00
Luuk de Gram
e06ab1b010
std: implement detach for WASI-threads
When a thread is detached from the main thread, we automatically
cleanup any allocated memory. For this we first reset the stack-pointer
to the original stack-pointer of the main-thread so we can safely clear
the memory which also contains the thread's stack.
2023-06-26 20:00:58 +02:00