Commit Graph

40 Commits

Author SHA1 Message Date
Vincent Rischmann df4fe87163 thread: implement setName/getName 2021-07-29 12:02:12 +02:00
Andrew Kelley d17f492017 stage2: miscellaneous fixes for the branch
* Breaking language change: inline assembly must use string literal
   syntax. This is in preparation for inline assembly improvements that
   involve more integration with the Zig language. This means we cannot
   rely on text substitution.
 * Liveness: properly handle inline assembly and function calls with
   more than 3 operands.
   - More than 35 operands is not yet supported. This is a low priority
     to implement.
   - This required implementation in codegen.zig as well.
 * Liveness: fix bug causing incorrect tomb bits.
 * Sema: enable switch expressions that are evaluated at compile-time.
   - Runtime switch instructions still need to be reworked in this
     branch. There was a TODO left here (by me) with a suggestion to do
     some bigger changes as part of the AIR memory reworking. Now that
     time has come and I plan to honor the suggestion in a future commit
     before merging this branch.
 * AIR printing: fix missing ')' on alive instructions.

We're back to "hello world" working for the x86_64 backend.
2021-07-20 12:19:16 -07:00
kprotty c8f90a7e7e zig fmt 2021-07-03 11:49:07 -05:00
kprotty 483eb8e057 std.Thread: move linux detach code to inline asm 2021-07-01 17:34:23 -05:00
kprotty 98106b09d5 zig fmt 2021-06-30 21:49:38 -05:00
kprotty 2309c81a78 std.Thread: non-zero child_tid to avoid racy join() 2021-06-30 21:49:00 -05:00
kprotty 2a6ba41020 std.Thread: add CLONE_CHILD_SETTID to fix join() 2021-06-30 21:49:00 -05:00
kprotty 6dd6604638 std.Thread: fix tls 9386 linux typo 2021-06-30 21:49:00 -05:00
kprotty f0fa129e9b std.Thread: more cleanup & testing 2021-06-30 21:49:00 -05:00
kprotty 7b323f84ca std.Thread: more fixes 2021-06-30 21:49:00 -05:00
kprotty c6fb968a3d std.Thread: fix posix 2021-06-30 21:49:00 -05:00
kprotty fd4a607bb2 std.Thread: fix futex test + thread errors 2021-06-30 21:49:00 -05:00
kprotty 6a903fc4c0 std.Thread: more typo fixes 2021-06-30 21:49:00 -05:00
kprotty 009c95b8ec std.Thread: more fixes 2021-06-30 21:49:00 -05:00
kprotty 5f4a40e6aa std.Thread: typo fixes 2 2021-06-30 21:49:00 -05:00
kprotty b1f37b4ead std.Thread: uh more typo fixes 2021-06-30 21:49:00 -05:00
kprotty d016caaccb std.Thread: more compile error fixes 2021-06-30 21:49:00 -05:00
kprotty ca1e61b851 std.Thread: fix some typos 2021-06-30 21:49:00 -05:00
kprotty 6ff64895cf std.Thread: add tests + getCurrentId() returns ints when possible 2021-06-30 21:49:00 -05:00
kprotty 235fcc5ba6 std.Thread: another typo fix 2021-06-30 21:48:59 -05:00
kprotty e16d3d162a std.Thread: rewrite + extensions 2021-06-30 21:48:59 -05:00
Jacob G-W 641ecc260f std, src, doc, test: remove unused variables 2021-06-21 17:03:03 -07:00
protty 2ba68f9f4c std.Thread.Futex addition (#9070)
* std.Thread.Futex: implementation + tests

* std.Thread.Futex: fix darwin compile errors

* std.Thread.Futex: fix wait() documentation typo

* std.Thread.Futex: fix darwin version check

* std.Thread.Futex: remove unnecessary comptime keyword
2021-06-12 08:51:37 -05:00
protty eb6975f088 std.sync.atomic: extended atomic helper functions (#8866)
- deprecates `std.Thread.spinLoopHint` and moves it to `std.atomic.spinLoopHint`
- added an Atomic(T) generic wrapper type which replaces atomic.Bool and atomic.Int
- in Atomic(T), selectively expose member functions depending on T and include bitwise atomic methods when T is an Integer
- added fence() and compilerFence() to std.atomic
2021-05-31 11:11:30 -05:00
Michael Dusan 0f26120377 overhaul elf csu (c-runtime startup) logic
- more support for linux, android, freebsd, netbsd, openbsd, dragonfly
- centralize musl utils; musl logic is no longer intertwined with csu
- fix musl compilation to build crti/crtn for full archs list
- fix openbsd to support `zig build-lib -dynamic`
- initial dragonfly linking success (with a warning)

ancillary:

- fix emutls (openbsd) tests to use `try`
2021-05-23 15:38:57 -04:00
Isaac Freund 5b850d5c92 Run zig fmt on src/ and lib/std/
This replaces callconv(.Inline) with the more idiomatic inline keyword.
2021-05-20 17:14:18 +02:00
LemonBoy a7f3e12d23 std: Add fallback on pre-v6 ARM targets
Thanks xackus for noticing the missing else branch.
2021-05-03 12:32:13 +02:00
LemonBoy 792cf925ec std: Fix missing CPU feature check
We need both the v6k and the v6m checks.
2021-05-03 12:32:13 +02:00
LemonBoy 807bb7c03f std: Improve spinloop hint
* Add a yield pattern for PowerPC64
* Fix compile error on pre-v6 ARM targets
* Use isb instead of yield on AArch64 to give the CPU a chance to enter
  low-power states.
* Make the hint an inline function, the call overhead can be avoided.
2021-04-30 17:11:03 +02:00
Andrew Kelley ddf9ff79bd Revert "thread: simplify and remove useless return in spawn (#8621)"
This reverts commit 77cb45f59f.

Zig's error return traces will point to the return token if they
happen to occur, so having multiple return statements makes those
stack traces really helpful. This destroys debuggability.
2021-04-26 10:44:40 -07:00
Vincent Rischmann 77cb45f59f thread: simplify and remove useless return in spawn (#8621) 2021-04-26 18:03:32 +02:00
LemonBoy 5a94794b73 std: Fix thread creation with field-less context type
Closes #8524
2021-04-25 13:21:15 -04:00
Sébastien Marie 89e522b935 make std.c.getErrno() return same type as _errno() aka c_int
adjust std.os.unexpectedErrno() to be correct for all std.os.system.errno (c_int, u12, usize, ...)
2021-03-12 15:04:36 +01:00
LemonBoy 566adc2510 std: Swap arguments in Thread.spawn
Beside the new order being consistent with the ThreadPool API and making
more sense, this shuffling allows to write the context argument type in
terms of the startFn arguments, reducing the use of anytype (eg. less
explicit casts when using comptime_int parameters, yay).

Sorry for the breakage.

Closes #8082
2021-02-28 14:03:19 +01:00
Andrew Kelley 37a1d08de2 haiku: minor fixups
* no isHaiku() function since there is not more than one os tag that
   this applies to.
 * clean up some control flow into a switch
 * add some TODO comments to investigate panics that suspiciously look
   like they should be compile errors (see #363)
2021-02-25 16:54:32 -07:00
Al Hoang c17396691c initial support for haiku sync update
* add cpu count
* use haiku find_directory
* add definitions and exports for building in haiku
2021-02-25 16:41:42 -07:00
Andrew Kelley 5f35dc0c0d zig fmt the std lib 2021-02-24 21:29:23 -07:00
LemonBoy 134f5fd3d6 std: Update test "" to test where it makes sense 2021-01-22 15:46:58 +01:00
Andrew Kelley 19f893c6bb std.Thread: avoid compile errors for single-threaded OS's 2021-01-14 22:42:29 -07:00
Andrew Kelley a9667b5a85 organize std lib concurrency primitives and add RwLock
* move concurrency primitives that always operate on kernel threads to
   the std.Thread namespace
 * remove std.SpinLock. Nobody should use this in a non-freestanding
   environment; the other primitives are always preferable. In
   freestanding, it will be necessary to put custom spin logic in there,
   so there are no use cases for a std lib version.
 * move some std lib files to the top level fields convention
 * add std.Thread.spinLoopHint
 * add std.Thread.Condition
 * add std.Thread.Semaphore
 * new implementation of std.Thread.Mutex for Windows and non-pthreads Linux
 * add std.Thread.RwLock

Implementations provided by @kprotty
2021-01-14 20:41:37 -07:00