Commit Graph

511 Commits

Author SHA1 Message Date
Andrew Kelley
32efa68f90
Merge pull request #2449 from Sahnvour/directallocator
Rework of windows' DirectAllocator
2019-05-11 13:04:20 -04:00
Sahnvour
a2d5b0fabe Implement Windows' DirectAllocator on top of VirtualAlloc and VirtualFree. 2019-05-11 16:41:13 +02:00
LemonBoy
1b23348f30 linux: Minor zig fmt induced reformatting 2019-05-11 10:34:22 +02:00
LemonBoy
715d808f14 linux: Fix clock_gettime on systems w/o VDSO 2019-05-11 10:33:41 +02:00
Andrew Kelley
9c0596e627
Merge pull request #2427 from LemonBoy/linux-tls
Proper support for TLS on linux
2019-05-07 12:26:26 -04:00
Andrew Kelley
097a62555e
Merge pull request #2439 from LemonBoy/fixes-fixes-fixes
A batch of miscellaneous fixes
2019-05-07 12:26:02 -04:00
LemonBoy
043bd71621 Add ARCH_SET_* definitions for x86_64 2019-05-07 13:19:38 +02:00
LemonBoy
b1db696c10 Less error messages
Decrease the overall size of the binary, programming errors are caught
with unreachable.
2019-05-07 13:09:20 +02:00
LemonBoy
cfcf02489d std: Implement on-demand TLS allocation 2019-05-07 13:09:19 +02:00
LemonBoy
d8ab301aa8 std: Implement TLS support for Linux
Tested on x86_64, i386, ARM, AARCH64
2019-05-07 13:09:18 +02:00
Andrew Kelley
7432fb04d6
Merge pull request #2354 from LemonBoy/iterate_phdr_impl
dl_iterate_phdr implementation
2019-05-06 15:48:37 -04:00
LemonBoy
60242e96df Fix definition of epoll_* struct on non x86_64 arches 2019-05-06 21:39:02 +02:00
LemonBoy
a095db0df7 Add a test case 2019-05-06 18:30:49 +02:00
LemonBoy
07dfccf967 Review 2019-05-05 13:00:20 +02:00
Andrew Kelley
5d347c01cf
Merge pull request #2374 from LemonBoy/fileszoff-reform
Make io offsets/sizes u64 instead of usize
2019-05-04 15:20:42 -04:00
Andrew Kelley
09cbcf8841
std lib sleep APIs: add doc comments and no @intCast
The sleep APIs are now documented as having spurious wakeups and no
precision of timing guaranteed. They also cannot fail. This commit makes
the entire range of u64 legal values to pass to std.os.time.sleep and
std.os.time.posixSleep. Values that do not fit in the native system APIs
will cause a sleep for the longest possible duration and then be handled
as a spurious wakeup.
2019-05-04 15:16:39 -04:00
Andrew Kelley
70a9ee3dd6
Merge branch 'stdlib-32b' of https://github.com/LemonBoy/zig into LemonBoy-stdlib-32b 2019-05-04 14:46:35 -04:00
Andrew Kelley
21c8d57fca
Merge pull request #2326 from daurnimator/sendmmsg
Add sendmmsg syscall wrapper
2019-05-04 14:05:55 -04:00
LemonBoy
98bc2b73bf Implement failsafe logic for posixSleep
Now we'll sleep for the specified amount of time even though the number
of seconds doesn't fit in a `isize` field.
2019-05-04 09:03:01 +02:00
LemonBoy
b612512bb5 std: Remove some assumptions about the host platform
The stdlib is now 32-bit friendly.
2019-05-04 08:44:26 +02:00
Shritesh Bhattarai
f4798297de wasi: Implement read and write with err checking 2019-05-03 17:35:42 -04:00
LemonBoy
077216b582 Address the comments of the first review round 2019-05-03 22:42:45 +02:00
Shritesh Bhattarai
a530a111a5 wasi: remove posix-y exit 2019-05-02 11:33:10 -05:00
Shritesh Bhattarai
7bbc8eb16c wasi: import all core exports 2019-04-30 23:53:17 -04:00
Shritesh Bhattarai
f53abf4063 wasi: import all constants and their types 2019-04-30 22:58:41 -04:00
Shritesh Bhattarai
d395ed2d40 wasi: implement timestamp 2019-04-30 20:43:43 -05:00
Shritesh Bhattarai
0ce05fa621 wasi: import clock and timestamp function/types 2019-04-30 20:06:39 -05:00
Shritesh Bhattarai
1fabd6bbf3 wasi: implement getRandomBytes 2019-04-30 20:50:41 -04:00
Shritesh Bhattarai
20458f56d8 wasi: add getEnvMap 2019-04-30 18:18:20 -05:00
Shritesh Bhattarai
8e700bf92a wasi: import environ_get and environ_sizes_get 2019-04-30 16:35:27 -05:00
daurnimator
fd056752da
std: add sendmmsg on linux 2019-04-30 16:47:09 +10:00
Shritesh Bhattarai
01365be82f WASI: implement argsAlloc and argsFree (#2364)
* wasi: change URL to canon WASI-core.md

* wasi: import args_get and args_sizes_get

* wasi: Implement argsAlloc and argsFree

* test return value for wasi arg syscalls

* wasi: return unexpectedErrorPosix in argsAlloc

* wasi: Add TODO for ArgIterator
2019-04-29 21:54:30 -04:00
LemonBoy
fbcc559cdb Make io offsets/sizes u64 instead of usize
Decouple the concepts of address-space size and file size.

Closes #637
2019-04-28 18:07:40 +02:00
emekoi
66f3ef06e8 fixed syntax error 2019-04-27 11:16:33 -04:00
LemonBoy
074ddf1ac6 Implementation of dl_phdr_info 2019-04-24 20:53:46 +02:00
daurnimator
217b95da31
std: add msghdr_const
As `iovec_const` is to `iovec`, `msghdr_const` is to `msghdr`
2019-04-21 21:53:24 +10:00
daurnimator
9babcac7a6
std: improve msghdr definition 2019-04-21 21:50:48 +10:00
Shritesh Bhattarai
f5d84250a3 wasi: switch to "standard" wasi_unstable module fn 2019-04-15 18:44:33 -04:00
Shritesh Bhattarai
22960a5fdf wasi: better comments 2019-04-13 22:45:31 -05:00
Shritesh Bhattarai
a2d8f03092 support extern "wasi" functions 2019-04-13 22:28:58 -05:00
Shritesh Bhattarai
93528be6b1 wasi: sigabrt at panic 2019-04-13 21:54:50 -05:00
Shritesh Bhattarai
fe9cd0b4bc wasi: use __wasi_proc_exit instead of posix.exit 2019-04-13 21:36:53 -05:00
Shritesh Bhattarai
72bcd5a4a5 WIP: hello world 2019-04-13 15:15:39 -05:00
Shritesh Bhattarai
895e6eabc2 Fix getCurrentId test for pthreads (#2197)
* Fix getCurrentId test for pthreads
2019-04-05 18:12:46 -04:00
Andrew Kelley
fd65cdc55a
fix incorrect Thread.getCurrentId test
Documentation comments copied here:

On Linux, it is possible that the thread spawned with `spawnThread`
finishes executing entirely before the clone syscall completes. In this
case, `std.os.Thread.handle` will return 0 rather than the
no-longer-existing thread's pid.
2019-04-05 16:06:35 -04:00
Andrew Kelley
e4d595a8ba
fix thread local variables for non- position independent code
This fixes comes thanks to Rich Felker from the musl libc project,
who gave me this crucial information:

"to satisfy the abi, your init code has to write the same value
to that memory location as the value passed to the [arch_prctl]
syscall"

This commit also changes the rules for when to build statically
by default. When building objects and static libraries, position
independent code is disabled if no libraries will be dynamically
linked and the target does not require position independent code.

closes #2063
2019-04-04 01:08:26 -04:00
Andrew Kelley
1d09cdaa6a munmap allows address 0
fixes test suite regression on macOS from previous commit
2019-03-25 16:04:25 -04:00
Andrew Kelley
64dddd7afe
add compile error for ignoring error
closes #772
2019-03-23 19:33:00 -04:00
Andrew Kelley
01fb421031 fix regressions on Windows from previous commit 2019-03-15 18:57:07 -04:00
Andrew Kelley
9c13e9b7ed
breaking changes to std.mem.Allocator interface API
Before, allocator implementations had to provide `allocFn`,
`reallocFn`, and `freeFn`.

Now, they must provide only `reallocFn` and `shrinkFn`.
Reallocating from a zero length slice is allocation, and
shrinking to a zero length slice is freeing.

When the new memory size is less than or equal to the
previous allocation size, `reallocFn` now has the option
to return `error.OutOfMemory` to indicate that the allocator
would not be able to take advantage of the new size.

For more details see #1306. This commit closes #1306.

This commit paves the way to solving #2009.

This commit also introduces a memory leak to all coroutines.
There is an issue where a coroutine calls the function and it
frees its own stack frame, but then the return value of `shrinkFn`
is a slice, which is implemented as an sret struct. Writing to
the return pointer causes invalid memory write. We could work
around it by having a global helper function which has a void
return type and calling that instead. But instead this hack will
suffice until I rework coroutines to be non-allocating. Basically
coroutines are not supported right now until they are reworked as
in #1194.
2019-03-15 17:57:21 -04:00