diff options
| author | Polesznyák Márk <contact@pml68.dev> | 2026-04-14 10:45:32 +0200 |
|---|---|---|
| committer | Polesznyák Márk <contact@pml68.dev> | 2026-04-14 23:33:36 +0200 |
| commit | 8a4664ac4c0e3c68a6a32bf451d35452c9409f2b (patch) | |
| tree | bd83026cca79d388ff072cbdc0a8cee89def56f8 /pthread.ha | |
| parent | feat: Hare updates (rt -> sys), fix sorting and parsing (diff) | |
| download | hare-1brc-8a4664ac4c0e3c68a6a32bf451d35452c9409f2b.tar.gz | |
feat: mmap + multithreading, down to 7s on i5 9400f
Diffstat (limited to '')
| -rw-r--r-- | pthread.ha | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/pthread.ha b/pthread.ha new file mode 100644 index 0000000..82c4900 --- /dev/null +++ b/pthread.ha @@ -0,0 +1,28 @@ +use sys::{errno}; + +def __SIZEOF_PTHREAD_CONDATTR_T: size = 56; + +type pthread_attr_t = union { + __size: [__SIZEOF_PTHREAD_CONDATTR_T]i8, + __align: i64 +}; + +type pthread_t = u64; + +@symbol("pthread_create") fn _pthread_create(thread: *pthread_t, attr: const nullable *pthread_attr_t, start_routine: *fn(arg: *opaque) nullable *opaque, arg: *opaque) int; + +fn pthread_create(thread: *pthread_t, attr: const nullable *pthread_attr_t, start_routine: *fn(arg: *opaque) nullable *opaque, arg: *opaque) (void | errno) = { + const ret = _pthread_create(thread, attr, start_routine, arg); + + if (ret != 0) + return ret: errno; +}; + +@symbol("pthread_join") fn _pthread_join(thread: pthread_t, value_ptr: nullable **opaque) int; + +fn pthread_join(thread: pthread_t, value_ptr: nullable **opaque) (void | errno) = { + const ret = _pthread_join(thread, value_ptr); + + if (ret != 0) + return ret: errno; +}; |
