Andrew Kelley
2ef2f9d71f
Merge pull request #2475 from LemonBoy/linux-wo-vdso
...
Fix clock_gettime on systems without VDSO
2019-05-11 12:01:52 -04:00
Sahnvour
cd537f822b
Use unprotected heap when in single_threaded mode.
2019-05-11 16:41:13 +02:00
Sahnvour
a2d5b0fabe
Implement Windows' DirectAllocator on top of VirtualAlloc and VirtualFree.
2019-05-11 16:41:13 +02:00
daurnimator
3d93c89fc5
std: the failing allocator didn't actually count allocations
...
Add a field '.allocations' to actually track the number of allocations.
Additionally, only increment '.deallocations' when memory is freed
2019-05-11 09:55:41 -04:00
LemonBoy
6756e545f4
Fix more corner cases in LEB128 parsing
2019-05-11 09:54:48 -04: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
bcf4d20289
Merge pull request #2465 from LemonBoy/builtins-for-wasm
...
A few builtins for wasm
2019-05-10 08:44:27 -04:00
LemonBoy
1606dae728
Fix erroneous test case
...
The *Mem variants cannot return EndOfStream and are generally unsafe to
use.
Proper order of checks, try both the variants and make sure they return
the same error/result.
Run the leb128.zig tests.
2019-05-10 08:40:36 -04:00
LemonBoy
7fb55ce2bb
compiler-rt: Add __ashrti3
2019-05-10 13:26:33 +02:00
LemonBoy
fbffece1b5
compiler-rt: Add __lshrti3
2019-05-10 13:26:33 +02:00
LemonBoy
7db2aa1c25
compiler-rt: Add __ashlti3
2019-05-10 13:26:33 +02:00
LemonBoy
8cc4eaea9f
Use matching types when parsing fields
2019-05-10 00:44:24 +02:00
LemonBoy
4d8f96dd88
Fix minor bug in LEB128 parsing
2019-05-10 00:41:05 +02:00
Andrew Kelley
72899da44b
fix std.os.copyFile
...
closes #2454
2019-05-09 13:05:06 -04:00
Andrew Kelley
a7346ea49f
fix build on macOS
...
Sadly due to a workaround for LLD linker limitations on macOS
we cannot put libuserland into an .a file; instead we have to use object
files. Again due to linker limitations, bundling compiler_rt.o into
another relocatable object also doesn't work. So we're left with
disabling stack probing on macOS for the stage1 self-hosted code.
These workarounds could all be removed if the macos support in the LLD
linker improved, or if Zig project had its own linker that did not have
these issues.
2019-05-08 22:45:49 -04:00
Andrew Kelley
4b9e12be50
Merge pull request #2452 from LemonBoy/more-more-builtins
...
More more builtins
2019-05-08 22:24:12 -04:00
Andrew Kelley
9bbd71c9ab
add --bundle-compiler-rt function to link options
...
and use it when building libuserland.a
The self-hosted part of stage1 relies on zig's compiler-rt, and so we
include it in libuserland.a.
This should potentially be the default, but for now it's behind a linker
option.
self-hosted translate-c: small progress on translating functions.
2019-05-08 20:51:49 -04:00
Andrew Kelley
9c12237d2d
std.debug: fix stack trace iteration code
...
Previously, the stack trace iteration code was using the number of
frames collected as the number of frames to print, not recognizing the
fixed size of the buffer. So it would redundantly print items, matching
the total number of frames ever collected.
Now the iteration code is limited to the actual stack trace frame count,
and will not print duplicate frames.
Closes #2447
Closes #2151
2019-05-08 19:11:01 -04:00
LemonBoy
4208fa9ad9
compiler-rt: add __floatsitf
2019-05-09 00:25:50 +02:00
LemonBoy
383b8a032e
compiler-rt: Add __aeabi_unwind_cpp_pr{0,1,2}
2019-05-09 00:07:46 +02:00
LemonBoy
2dce137d92
compiler-rt: Add __extendsfdf2
...
Add AEABI builtin __aeabi_f2d
2019-05-09 00:07:46 +02:00
LemonBoy
2be066d057
compiler-rt: Add __floatdidf
...
Add AEABI builtin __aeabi_l2d
2019-05-08 23:57:09 +02:00
LemonBoy
d4434dfb67
compiler-rt: Add __floatundidf & __floatunsidf
...
Add AEABI builtins __aeabi_ul2d, __aeabi_ui2d
2019-05-08 23:57:09 +02:00
LemonBoy
92fd2df054
compiler-rt: Add __truncdfsf2
...
Add AEABI builtin __aeabi_d2f
2019-05-08 23:57:09 +02:00
LemonBoy
c00167e91a
compiler-rt: More division intrinsics
2019-05-08 22:30:20 +02:00
LemonBoy
917103710e
compiler-rt: Add __floatsidf & __floatsisf
...
Also add their AEABI aliases, __aeabi_i2f & __aeabi_i2d
2019-05-08 22:26:54 +02:00
LemonBoy
be7cacfbbe
Implement stack probes for x86/x86_64
...
Enabled on non-Windows systems only since it already requires stack
probes.
2019-05-08 12:36:54 -04:00
Sahnvour
d665948dcf
Duplicate windows's DirectAllocator as HeapAllocator, which it is in reality.
2019-05-08 18:19:36 +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
2f041239cb
Always initialize the TLS
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
LemonBoy
4ab7b459df
Avoid endless recursion in __extendhfsf2
...
On some platforms the conversion ended up creating a dangerous recursive
loop that ate all the stack.
The conversion to f16 is also pointless since we're operating on the raw
bits anyway.
2019-05-07 11:47:23 +02:00
LemonBoy
94b504c9e4
Fix float comparison result in __aeabi_{f,d}cmp*
2019-05-07 11:47:23 +02:00
LemonBoy
a3beda27fc
Add missing cast to usize
2019-05-07 11:47:23 +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
939ec878a0
Fix edge case in addXf3
...
The operands may be zero, use the wrapping operators and avoid a
spurious integer-overflow error.
2019-05-06 21:41:08 +02: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
Andrew Kelley
7a41af2632
Merge pull request #2422 from tgschultz/stdlib-packed-int-array
...
Added PackedIntArray, PackedIntSlice to std
2019-05-05 15:25:17 -04: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
6f0aa801c8
Merge pull request #2404 from squeek502/hash-map-ensure-cap
...
std.HashMap: add public ensureCapacity fn
2019-05-04 14:13:18 -04:00
Andrew Kelley
21c8d57fca
Merge pull request #2326 from daurnimator/sendmmsg
...
Add sendmmsg syscall wrapper
2019-05-04 14:05:55 -04:00
tgschultz
14a00d3825
zig fmt
2019-05-04 16:19:26 +00:00
tgschultz
8c28b59605
Added ability to specify endianess of PackedInt(Array/Slice)
2019-05-04 16:17:12 +00:00
tgschultz
27ed525e03
zig fmt
2019-05-04 13:31:53 +00: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
Ryan Liptak
cf8dde2d68
std.HashMap: cleanup ensureCapacity + add test
...
- Cleaned up some comments
- Removed the "is power of two" check from optimizedCapacity since the * 5 / 3 is unlikely to end up with a power of two, so it's a wasted check the majority of the time
- Made ensureCapacity/ensureCapacityExact increment the modification count if they resize the hash map so that we can catch resizes while iterating, which would likely break the iterator state
2019-05-03 21:15:00 -07:00
tgschultz
4dfd1f54db
Ugh. I updated these but forgot to git add.
2019-05-04 03:08:33 +00:00
tgschultz
7dc71cdc4a
and again
2019-05-04 02:39:55 +00:00
tgschultz
3e3bdd577c
Fixed some comments
2019-05-04 02:38:16 +00:00
tgschultz
e2fd37e75b
Added PackedIntArray, PackedIntSlice to std
2019-05-04 00:28:51 +00:00
Shritesh Bhattarai
f4798297de
wasi: Implement read and write with err checking
2019-05-03 17:35:42 -04:00
LemonBoy
2f3b461703
compiler-rt: Add __modsi3, __umodsi3
2019-05-03 17:12:33 -04:00
LemonBoy
1be4e87f0b
compiler-rt: Add __moddi3, __divdi3
2019-05-03 17:12:33 -04:00
LemonBoy
077216b582
Address the comments of the first review round
2019-05-03 22:42:45 +02:00
Andrew Kelley
584dd2863a
Merge pull request #2409 from shritesh/wasi_native
...
WASI std: implement native os.exit and os.abort
2019-05-03 16:24:00 -04:00
Shritesh Bhattarai
f86b8e4535
WasmAllocator: compileError on non-wasm arch
2019-05-03 16:21:33 -04:00
daurnimator
fca3e3a73f
std: add std.ArrayList.orderedRemove
2019-05-03 01:54:49 -04:00
Andrew Kelley
3552180143
optimize @memset
with undefined
...
When using `@memset` to set bytes to `undefined`, Zig notices this
case and does a single Valgrind client request rather than N.
Speeds up all allocators in safe modes.
Closes #2388
2019-05-03 01:25:03 -04:00
Ryan Liptak
13a7b8586a
std.HashMap: make ensureCapacityExact private
2019-05-02 17:43:51 -07:00
Ryan Liptak
26591d4f22
std.HashMap: add putAssumeCapacity fn
2019-05-02 17:42:38 -07:00
Ryan Liptak
4d42275d03
std.HashMap: make ensureCapacity optimize for the expected count, add ensureCapacityExact
2019-05-02 17:01:30 -07:00
Shritesh Bhattarai
a530a111a5
wasi: remove posix-y exit
2019-05-02 11:33:10 -05:00
Shritesh Bhattarai
84682eb862
wasi: implement os.exit
2019-05-02 11:26:33 -05:00
Shritesh Bhattarai
6fb677c4f6
wasi: native os.abort
2019-05-02 11:25:25 -05:00
Ryan Liptak
0afa2d040a
make std.HashMap.ensureCapacity round up to the nearest power of two
2019-05-02 00:58:26 -07:00
Marc Tiehuis
3370e60dd9
std.math: Correct math.nan usage in cos
2019-05-02 19:03:49 +12:00
Ryan Liptak
8b7c59a414
std.HashMap: add public ensureCapacity fn
2019-05-01 23:46:52 -07:00
Marc Tiehuis
89d71a960b
std.math: Add documentation for all functions and algorithm sources
2019-05-01 18:37:46 +12:00
Marc Tiehuis
f94964cd05
std.math: Add upstream changes/fixes and simplify go derived code
...
This also starts the documentation effort for the math/ subdirectory.
The intent is to use this as a somewhat representative test-case for any
work on the documentation generator.
2019-05-01 18:13:33 +12: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
0a693b70e4
wasi: use mem.separate instead
2019-04-30 18:43:43 -05: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
b1a61a6d51
compiler-rt: Add __mulodi4
2019-04-29 18:55:20 -04:00
Andrew Kelley
d2328ac71a
Merge pull request #2372 from LemonBoy/aeabi_idiv
...
compiler-rt: Add __divsi3, __aeabi_idiv
2019-04-29 18:54:21 -04:00
Andrew Kelley
e3452ba21b
json tests do not need this prefix anymore
2019-04-29 14:04:31 -04:00
Andrew Kelley
da28811c50
enable more json tests
...
I think it was a mistake that these weren't getting automatically run by
the test suite.
2019-04-29 14:02:19 -04:00
Andrew Kelley
4b6f350369
DirectAllocator: move if > 0 condition above @memcpy
...
Minor improvement to 3c13aa17
as noted by daurnimator
2019-04-29 13:48:15 -04:00
Shawn Landden
3c13aa178b
std.heap: do not excessively call mmap, and munmap in direct allocator
2019-04-29 13:47:24 -04:00
LemonBoy
4e241263ff
compiler-rt: Add __divmodsi4, __aeabi_idivmod
2019-04-29 19:17:48 +02:00
LemonBoy
738562e990
compiler-rt: Add __divsi3, __aeabi_idiv
2019-04-29 19:17:48 +02: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
Ryan Liptak
205e501e42
std.fmt: add max_depth to avoid infinite recursion from self-references
2019-04-27 11:20:10 -04:00
daurnimator
bc1840e18f
Revert "std: Add mem.nativeIntToBig and mem.nativeIntToLittle"
...
This reverts commit 211f0a2226
.
The functions `mem.nativeToBig` and `mem.nativeToLittle` already existed.
2019-04-27 11:18:53 -04:00