Commit graph

138 commits

Author SHA1 Message Date
Andrew Kelley
38152c2d1c revert std.Thread.Pool for now
and move the Io impl to a separate file
2025-07-20 10:38:39 -07:00
Andrew Kelley
80d4655bb1 update to sync with master 2025-07-20 10:38:39 -07:00
Andrew Kelley
13e30c4fd2 std.Io.EventLoop: implement select 2025-07-20 10:38:39 -07:00
Andrew Kelley
0f67ea4fa4 introduce Io.select and implement it in thread pool 2025-07-20 10:38:39 -07:00
Jacob Young
7b5886118d Io.Condition: implement full API 2025-07-20 10:38:39 -07:00
Andrew Kelley
74969d1c40 std.Io.Condition: change primitive to support only one
and no timer
2025-07-20 10:38:39 -07:00
Jacob Young
f3553049cb Io: implement faster mutex 2025-07-20 10:38:39 -07:00
Andrew Kelley
ebf92042e3 std.Io: add detached async 2025-07-20 10:38:39 -07:00
Andrew Kelley
a7790bd32e implement Mutex, Condition, and Queue 2025-07-20 10:38:38 -07:00
Jacob Young
012ef81b8b Io: implement sleep and fix cancel bugs 2025-07-20 10:38:38 -07:00
Jacob Young
1fbc251ccd EventLoop: implement thread-local queues and cancellation 2025-07-20 10:38:38 -07:00
Andrew Kelley
988f58341b std.Io: introduce cancellation 2025-07-20 10:38:38 -07:00
Andrew Kelley
d4ff3745d5 start adding fs functions to std.Io 2025-07-20 10:38:38 -07:00
Andrew Kelley
db499b82b5 free freeing wrong amount in thread pool impl 2025-07-20 10:38:38 -07:00
Andrew Kelley
ad3c5f0292 fix context passing in threaded Io impl 2025-07-20 10:38:38 -07:00
Andrew Kelley
6ae18714b7 make thread pool satisfy async/await interface 2025-07-20 10:38:38 -07:00
Andrew Kelley
5b2f54fc80 introduce std.Io interface
which is planned to have all I/O operations in the interface, but for
now has only async and await.
2025-07-20 10:38:38 -07:00
Linus Groh
eb37552536 Remove numerous things deprecated during the 0.14 release cycle
Basically everything that has a direct replacement or no uses left.

Notable omissions:

- std.ArrayHashMap: Too much fallout, needs a separate cleanup.
- std.debug.runtime_safety: Too much fallout.
- std.heap.GeneralPurposeAllocator: Lots of references to it remain, not
  a simple find and replace as "debug allocator" is not equivalent to
  "general purpose allocator".
- std.io.Reader: Is being reworked at the moment.
- std.unicode.utf8Decode(): No replacement, needs a new API first.
- Manifest backwards compat options: Removal would break test data used
  by TestFetchBuilder.
- panic handler needs to be a namespace: Many tests still rely on it
  being a function, needs a separate cleanup.
2025-07-11 08:17:43 +02:00
Pat Tullmann
cfe5defd02 linux: futex v1 API cleanup
* Use `packed struct` for flags arguments.  So, instead of
  `linux.FUTEX.WAIT` use `.{ .cmd = .WAIT, .private = true }`

* rename `futex_wait` and `futex_wake` which didn't actually specify
  wait/wake, as `futex_3arg` and `futex_4arg` (as its the number
  of parameters that is different, the `op` is whatever is specified.

* expose the full six-arg flavor of the syscall (for some of the advanced
  ops), and add packed structs for their arguments.

* Use a `packed union` to support the 4th parameter which is sometimes a
  `timespec` pointer, and sometimes a `u32`.

* Add tests that make sure the structure layout is correct and that the
  basic argument passing is working (no actual futexes are contended).
2025-06-17 22:06:39 -07:00
Alex Rønne Petersen
9d534790eb std.Target: Introduce Cpu convenience functions for feature tests.
Before:

* std.Target.arm.featureSetHas(target.cpu.features, .has_v7)
* std.Target.x86.featureSetHasAny(target.cpu.features, .{ .sse, .avx, .cmov })
* std.Target.wasm.featureSetHasAll(target.cpu.features, .{ .atomics, .bulk_memory })

After:

* target.cpu.has(.arm, .has_v7)
* target.cpu.hasAny(.x86, &.{ .sse, .avx, .cmov })
* target.cpu.hasAll(.wasm, &.{ .atomics, .bulk_memory })
2025-06-05 06:12:00 +02:00
Andrew Kelley
1639fcea43 de-genericify SinglyLinkedList
by making it always intrusive, we make it a more broadly useful API, and
avoid binary bloat.
2025-04-03 14:55:04 -07:00
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
Chris Boesch
58c00a829e
std.posix: Use separate clock ID enums for clock_gettime() and timerfd_create() (#22627) 2025-02-01 06:53:57 +00:00
Jacob Young
8c8dfb35f3 x86_64: fix crashes compiling the compiler and tests 2025-01-16 20:47:30 -05:00
Jacob Young
e5d5a8bc4e x86_64: implement switch jump tables 2025-01-16 20:42:08 -05:00
Alex Rønne Petersen
6cf01a679f std.Thread.Futex: Mark inline asm volatile in WasmImpl.
Closes #22082.
2024-11-27 23:24:37 +01:00
Andrew Kelley
862266514a Revert "Enable thread_pool function to throw errors (#20260)"
This reverts commit d346d074eb.

I would like a chance to review this, please.
2024-11-11 14:07:07 -08:00
ippsav
d346d074eb
Enable thread_pool function to throw errors (#20260)
* std.ThreadPool: allow error union return type

* allow noreturn in Pool.zig
2024-11-11 15:34:24 -06:00
Andrew Kelley
ba71079837 combine codegen work queue and linker task queue
these tasks have some shared data dependencies so they cannot be done
simultaneously. Future work should untangle these data dependencies so
that more can be done in parallel.

for now this commit ensures correctness by making linker input parsing
and codegen tasks part of the same queue.
2024-10-23 16:27:39 -07:00
David Rubin
043b1adb8d
remove @fence (#21585)
closes #11650
2024-10-04 22:21:27 +00:00
David Rubin
421fbd939c
thread: don't leak the thread in spawnManager (#21379) 2024-09-11 01:04:59 +00:00
mlugg
6808ce27bd
compiler,lib,test,langref: migrate @setCold to @branchHint 2024-08-27 00:44:35 +01:00
Andrew Kelley
e8c4e79499 std.c reorganization
It is now composed of these main sections:
* Declarations that are shared among all operating systems.
* Declarations that have the same name, but different type signatures
  depending on the operating system. Often multiple operating systems
  share the same type signatures however.
* Declarations that are specific to a single operating system.
  - These are imported one per line so you can see where they come from,
    protected by a comptime block to prevent accessing the wrong one.

Closes #19352 by changing the convention to making types `void` and
functions `{}`, so that it becomes possible to update `@hasDecl` sites
to use `@TypeOf(f) != void` or `T != void`. Happily, this ended up
removing some duplicate logic and update some bitrotted feature
detection checks.

A handful of types have been modified to gain namespacing and type
safety. This is a breaking change.

Oh, and the last usage of `usingnamespace` site is eliminated.
2024-07-19 00:30:32 -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
mochalins
6446596ba1 fix: Update spawn's' runFn signature 2024-07-09 21:15:29 -04:00
Jacob Young
65ced4a334 Compilation: put supported codegen backends on a separate thread
(There are no supported backends.)
2024-07-08 11:00:38 -04:00
Jacob Young
bdae01ab04 InternPool: implement and use thread-safe list for extra and limbs 2024-07-07 22:59:52 -04:00
Jacob Young
383cffbfae InternPool: temporarily disable multi-threaded behavior
This reduces the cost of the new data structure until the multi-threaded
behavior is actually used.
2024-07-07 22:59:52 -04:00
Jacob Young
cda716ecc4 InternPool: implement thread-safe hash map 2024-07-07 22:59:52 -04:00
Jacob Young
525f341f33 Zcu: introduce PerThread and pass to all the functions 2024-07-07 22:59:52 -04:00
Andrew Kelley
5fc1f8a32b std.Thread.Mutex.Recursive: alternate implementation
This version is simpler. Thanks King!
2024-06-12 18:07:39 -07:00
Andrew Kelley
506b3f6db6 introduce std.Thread.Mutex.Recursive 2024-06-12 17:43:49 -07:00
Andrew Kelley
a72292513e add std.Thread.Pool.spawnWg
This function accepts a WaitGroup parameter and manages the reference
counting therein. It also is infallible.

The existing `spawn` function is still handy when the job wants to
further schedule more tasks.
2024-05-03 20:58:02 -07:00
IntegratedQuantum
1a6485d111
Clarify the blocking behavior of RwLock.lockShared(). (#19752) 2024-04-24 10:41:13 -05:00
GethDW
db96ad4a16 std: fix Thread.Pool.spawn
`@alignCast` was required for args with greater alignment than that of a pointer.
2024-04-19 13:49:06 -07:00
Jacob Young
eb723a4070 Update uses of @fieldParentPtr to use RLS 2024-03-30 20:50:48 -04:00
Jacob Young
e409afb79b Update uses of @fieldParentPtr to pass a pointer type 2024-03-30 20:50:48 -04: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