Commit graph

100 commits

Author SHA1 Message Date
Andrew Kelley
ed36dbbd9c
mv std/ lib/
that's all this commit does. further commits will fix cli flags and
such.

see #2221
2019-09-25 23:35:41 -04:00
Andrew Kelley
d1705baa74
enable test coverage for armv8-linux-musleabihf
* fix libc prototypes of offsets to have correct integer sizes and
   signedness. This gets all behavior tests to pass for
   armv8-linux-musleabihf
 * fix linux mmap syscall to have correct integer size and signedness
   for offset
 * disable failing armv8-linux-musleabihf std lib tests. See 3289. I
   suspect compiler-rt issue. Note these tests fail with this target
   triple regardless of whether musl is actually linked (-lc).
2019-09-25 16:21:04 -04:00
Tetralux
86b6790b6a
Remove 'inline', as per @andrewrk 2019-09-21 15:42:26 +00:00
Tetralux
537b260349
Add FixedBufferAllocator.reset 2019-09-16 02:40:14 +00:00
Andrew Kelley
0041e00a78
fixups
* move LoggingAllocator to its own file
 * style conventions
 * add documentation
 * use `anyerror` instead of `error{}` for the stream
2019-06-27 12:04:14 -04:00
Andrew Kelley
c346b257bb
Merge branch 'logging-allocator' of https://github.com/daurnimator/zig into daurnimator-logging-allocator 2019-06-27 11:20:00 -04:00
Andrew Kelley
036cc48a82
Merge remote-tracking branch 'origin/master' into copy-elision-3 2019-06-23 01:29:48 -04:00
Sahnvour
987c209b40 heap: make one global instance of DirectAllocator
it is now stateless, so the de/init are not necessary anymore
2019-06-22 14:10:53 -04:00
Andrew Kelley
726674b2bd
fix ArenaAllocator 2019-06-22 01:13:10 -04:00
Andrew Kelley
727af307c6
fix return result loc and then switch with range...
...implicit casted to error union
2019-06-21 18:21:12 -04:00
daurnimator
b0648bfbd3
std.heap.ArenaAllocator: use singly linked list 2019-06-10 15:41:40 +10:00
daurnimator
ed41d10a06
std: existing LinkedList is actually a TailQueue 2019-06-10 15:41:40 +10:00
Andrew Kelley
129714d077
more fixes for windows and wasi 2019-05-27 01:35:58 -04:00
Andrew Kelley
6be79d79aa
fixes for Windows and WASI 2019-05-27 00:48:56 -04:00
Andrew Kelley
0c6ab61b22
tests passing on linux 2019-05-26 23:35:26 -04:00
Andrew Kelley
2b42e910bf
behavior tests passing on Linux 2019-05-26 19:56:37 -04:00
Andrew Kelley
2f040a23c8
clean up references to os 2019-05-26 18:32:44 -04:00
Andrew Kelley
7cb6279ac0
clean up references to posix 2019-05-26 18:32:44 -04:00
Shawn Landden
1fdb24827f
breaking changes to all bit manipulation intrinsics
* `@clz`, `@ctz`, `@popCount`, `@bswap`, `@bitreverse` now
   have a type parameter
 * rename @bitreverse to @bitReverse
 * rename @bswap to @byteSwap

Closes #2119
Closes #2120
2019-05-16 16:37:58 -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
Sahnvour
d665948dcf Duplicate windows's DirectAllocator as HeapAllocator, which it is in reality. 2019-05-08 18:19:36 +02: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
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
f86b8e4535 WasmAllocator: compileError on non-wasm arch 2019-05-03 16:21:33 -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
daurnimator
ad7927a748
std: add LoggingAllocator prototype 2019-04-27 15:36:53 +10:00
Ryan Liptak
afc33f00ee heap: fixup style of realloc memory copies 2019-04-25 13:41:19 -07:00
Ryan Liptak
57f545eed8 std.heap.DirectAllocator: reduce the amount of redundant memcpy calls on Windows
Previously the memory would be copied to a different aligned address in some cases where the old offset could have been used. This fixes it so that it will always try to use the old offset when possible, and only uses a different offset if the old one is truly invalid (not aligned or not enough space to store the alloc at the old offset).
2019-04-25 13:35:45 -07:00
Ryan Liptak
8ce130de3c Bump up FixedBufferAllocator test memory to account for new tests 2019-04-22 02:25:57 -07:00
Ryan Liptak
b3598163df std.heap.DirectAllocator: Fix aligned reallocs on Windows 2019-04-22 02:20:01 -07:00
Ryan Liptak
66020856b2 fix heap allocators when shrinking an object but growing its alignment 2019-04-20 23:56:39 -07:00
tgschultz
22f5e5fd3e Fixes DirectAllocator Windows implementation to call HeapFree when new_size == 0 2019-04-20 14:04:09 -04:00
Ryan Liptak
1030cc97ca fix DirectAllocator not unmapping unused pages on large alignments
Fixes #2306
2019-04-20 02:21:42 -04:00
Andrew Kelley
4c03746926
Revert "DirectAllocator: on windows, use HeapFree instead of HeapReAlloc to free memory."
This reverts commit 71bb8cd537.

This broke the CI on Windows.
2019-04-16 19:11:37 -04:00
Andrew Kelley
52caf311bb
Merge pull request #2286 from shritesh/wasm_alloc
WasmAllocator: WebAssembly Memory Allocator
2019-04-16 13:27:56 -04:00
Shritesh Bhattarai
0c28a18d96 WasmAllocator: cleanup 2019-04-16 12:23:45 -05:00
Sahnvour
71bb8cd537 DirectAllocator: on windows, use HeapFree instead of HeapReAlloc to free memory. 2019-04-16 13:18:21 -04:00
Shritesh Bhattarai
4235982fe6 fmt wasm_allocator 2019-04-16 01:42:11 -05:00
Shritesh Bhattarai
aa3f31ac0a wasm: add WasmAllocator 2019-04-16 01:40:16 -05:00
Shritesh Bhattarai
f2119f9961 wasm: WasmAllocator that uses fixed 64kb pages 2019-04-15 21:21:46 -05: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
Andrew Kelley
d633dcd07a
remove the valgrind integration with std.mem.Allocator
See #1837
2019-03-11 13:34:51 -04:00
Andrew Kelley
5362ca204f
Merge branch 'valgrind' of https://github.com/daurnimator/zig into daurnimator-valgrind 2019-03-11 13:27:04 -04:00
Andrew Kelley
e402455704
rename std lib files to new convention 2019-03-02 16:46:04 -05:00
daurnimator
d68ae35c11
std: when a FixedBufferAllocator is initialised, set the buffer to undefined 2019-02-20 16:52:23 +11:00
Maya Rashish
bc10382ec1 Add NetBSD support
Mostly picking the same paths as FreeBSD.
We need a little special handling for crt files, as netbsd uses its
own (and not GCC's) for those, with slightly different names.
2019-02-17 09:17:34 +02:00
Andrew Kelley
c2db077574
std.debug.assert: remove special case for test builds
Previously, std.debug.assert would `@panic` in test builds,
if the assertion failed. Now, it's always `unreachable`.

This makes release mode test builds more accurately test
the actual code that will be run.

However this requires tests to call `std.testing.expect`
rather than `std.debug.assert` to make sure output is correct.

Here is the explanation of when to use either one, copied from
the assert doc comments:

Inside a test block, it is best to use the `std.testing` module
rather than assert, because assert may not detect a test failure
in ReleaseFast and ReleaseSafe mode. Outside of a test block, assert
is the correct function to use.

closes #1304
2019-02-08 18:23:38 -05:00