aboutsummaryrefslogtreecommitdiff
path: root/std/heap.zig
AgeCommit message (Collapse)Author
2019-02-07Make ThreadSafeFixedBufferAllocator alias FixedBufferAllocator when ↵John Schmidt
--single-threaded Fixes #1910
2019-02-06thread local storage working for linux x86_64Andrew Kelley
2019-02-03`std.mem.Allocator.create` replaced with better APIAndrew Kelley
`std.mem.Allocator.createOne` is renamed to `std.mem.Allocator.create`. The problem with the previous API is that even after copy elision, the initalization value passed as a parameter would always be a copy. With the new API, once copy elision is done, initialization functions can directly initialize allocated memory in place. Related: * #1872 * #1873
2018-12-12breaking API changes to all readInt/writeInt functions & moreAndrew Kelley
* add `@bswap` builtin function. See #767 * comptime evaluation facilities are improved to be able to handle a `@ptrCast` with a backing array. * `@truncate` allows "truncating" a u0 value to any integer type, and the result is always comptime known to be `0`. * when specifying pointer alignment in a type expression, the alignment value of pointers which do not have addresses at runtime is ignored, and always has the default/ABI alignment * threw in a fix to freebsd/x86_64.zig to update syntax from language changes * some improvements are pending #863 closes #638 closes #1733 std lib API changes * io.InStream().readIntNe renamed to readIntNative * io.InStream().readIntLe renamed to readIntLittle * io.InStream().readIntBe renamed to readIntBig * introduced io.InStream().readIntForeign * io.InStream().readInt has parameter order changed * io.InStream().readVarInt has parameter order changed * io.InStream().writeIntNe renamed to writeIntNative * introduced io.InStream().writeIntForeign * io.InStream().writeIntLe renamed to writeIntLittle * io.InStream().writeIntBe renamed to writeIntBig * io.InStream().writeInt has parameter order changed * mem.readInt has different parameters and semantics * introduced mem.readIntNative * introduced mem.readIntForeign * mem.readIntBE renamed to mem.readIntBig and different API * mem.readIntLE renamed to mem.readIntLittle and different API * introduced mem.readIntSliceNative * introduced mem.readIntSliceForeign * introduced mem.readIntSliceLittle * introduced mem.readIntSliceBig * introduced mem.readIntSlice * mem.writeInt has different parameters and semantics * introduced mem.writeIntNative * introduced mem.writeIntForeign * mem.writeIntBE renamed to mem.readIntBig and different semantics * mem.writeIntLE renamed to mem.readIntLittle and different semantics * introduced mem.writeIntSliceForeign * introduced mem.writeIntSliceNative * introduced mem.writeIntSliceBig * introduced mem.writeIntSliceLittle * introduced mem.writeIntSlice * removed mem.endianSwapIfLe * removed mem.endianSwapIfBe * removed mem.endianSwapIf * added mem.littleToNative * added mem.bigToNative * added mem.toNative * added mem.nativeTo * added mem.nativeToLittle * added mem.nativeToBig
2018-11-19Merge branch 'freebsd-up' of https://github.com/myfreeweb/zig into freebsd2Andrew Kelley
2018-11-13New Zig formal grammar (#1685)Jimmi Holst Christensen
Reverted #1628 and changed the grammar+parser of the language to not allow certain expr where types are expected
2018-10-26remove @minValue,@maxValue; add std.math.minInt,maxIntAndrew Kelley
closes #1466 closes #1476
2018-10-20Add freebsd to more thingsGreg V
2018-10-15Solve the return type ambiguity (#1628)Jimmi Holst Christensen
Changed container and initializer syntax * <container> { ... } -> <container> . { ... } * <exrp> { ... } -> <expr> . { ...}
2018-09-13remove `this`. add `@This()`.Andrew Kelley
closes #1283
2018-07-14Improve realloc on fixed buffer allocator (#1238)Bas van den Berg
* Add test to check re-use of memory * Check if realloc has to reallocate the last allocated memory block. If so extend that block instead of allocating a new one. * Also check if the realloc actually preserves the data.
2018-07-14Create unit test that tests aligned reallocation.Bas van den Berg
2018-07-09std.event.Loop multithreading for windows using IOCPAndrew Kelley
2018-07-09implement std.os.cpuCount for windowsAndrew Kelley
2018-07-07add std.os.cpuCount and have std.event.Loop use it for thread pool sizeAndrew Kelley
2018-07-07M:N threadingAndrew Kelley
* add std.atomic.QueueMpsc.isEmpty * make std.debug.global_allocator thread-safe * std.event.Loop: now you have to choose between - initSingleThreaded - initMultiThreaded * std.event.Loop multiplexes coroutines onto kernel threads * Remove std.event.Loop.stop. Instead the event loop run() function returns once there are no pending coroutines. * fix crash in ir.cpp for calling methods under some conditions * small progress self-hosted compiler, analyzing top level declarations * Introduce std.event.Lock for synchronizing coroutines * introduce std.event.Locked(T) for data that only 1 coroutine should modify at once. * make the self hosted compiler use multi threaded event loop * make std.heap.DirectAllocator thread-safe See #174 TODO: * call sched_getaffinity instead of hard coding thread pool size 4 * support for Windows and MacOS * #1194 * #1197
2018-07-02add event loop Channel abstractionAndrew Kelley
This is akin to channels in Go, except: * implemented in userland * they are lock-free and thread-safe * they integrate with the userland event loop The self hosted compiler is changed to use a channel for events, and made to stay alive, watching files and performing builds when things change, however the main.zig file exits after 1 build. Note that nothing is actually built yet, it just parses the input and then declares that the build succeeded. Next items to do: * add windows and macos support for std.event.Loop * improve the event loop stop() operation * make the event loop multiplex coroutines onto kernel threads * watch source file for updates, and provide AST diffs (at least list the top level declaration changes) * top level declaration analysis
2018-06-20remove std.mem.Allocator.construct and other fixupsAndrew Kelley
2018-06-21std: update stdlib to match updated allocator create signature; ref #733kristopher tate
2018-06-18remove []u8 casting syntax. add `@bytesToSlice` and `@sliceToBytes`Andrew Kelley
See #1061
2018-06-17remove integer and float casting syntaxAndrew Kelley
* add `@intCast` * add `@floatCast` * add `@floatToInt` * add `@intToFloat` See #1061
2018-06-10breaking syntax change: orelse keyword instead of ?? (#1096)Andrew Kelley
use the `zig-fmt-optional-default` branch to have zig fmt automatically do the changes. closes #1023
2018-06-09breaking syntax change: ??x to x.? (#1095)Andrew Kelley
See #1023 This also renames Nullable/Maybe to Optional
2018-06-05disallow unknown-length pointer to opaqueAndrew Kelley
This also means that translate-c has to detect when a pointer to opaque is happening, and use `*` instead of `[*]`. See #1059
2018-06-04Pointer Reform: proper slicing and indexing (#1053)Andrew Kelley
* enable slicing for single-item ptr to arrays * disable slicing for other single-item pointers * enable indexing for single-item ptr to arrays * disable indexing for other single-item pointers see #770 closes #386
2018-06-04disallow single-item pointer indexingAndrew Kelley
add pointer arithmetic for unknown length pointer
2018-06-01run zig fmtAndrew Kelley
2018-05-31use * for pointer type instead of &Andrew Kelley
See #770 To help automatically translate code, see the zig-fmt-pointer-reform-2 branch. This will convert all & into *. Due to the syntax ambiguity (which is why we are making this change), even address-of & will turn into *, so you'll have to manually fix thes instances. You will be guaranteed to get compile errors for them - expected 'type', found 'foo'
2018-05-29run zig fmt on the codebaseAndrew Kelley
See #1003
2018-05-01behavior tests passing with new pointer deref syntaxAndrew Kelley
2018-04-29fix std threads for macosAndrew Kelley
2018-04-28add fuzz tests for std.atomic.StackAndrew Kelley
2018-04-21Added DirectAllocator support for alignments > os.page_size on posix systemstgschultz
2018-02-12std.heap.ArenaAllocator: fix incorrectly activating safety checkAndrew Kelley
2018-02-12back to malloc instead of aligned_alloc for c_allocatorAndrew Kelley
it seems that a 7 years old standard is still too new for the libc variants that are ubiquitous (tests failing on macos for not providing C11 ABI)
2018-02-12remove std.heap.IncrementingAllocatorAndrew Kelley
Use std.heap.FixedBufferAllocator combined with std.heap.DirectAllocator instead. std.mem.FixedBufferAllocator is moved to std.heap.FixedBufferAllocator
2018-02-12introduce std.heap.ArenaAllocator and std.heap.DirectAllocatorAndrew Kelley
* DirectAllocator does the underlying syscall for every allocation. * ArenaAllocator takes another allocator as an argument and allocates bytes up front, falling back to DirectAllocator with increasingly large allocation sizes, to avoid calling it too often. Then the entire arena can be freed at once. The self hosted parser is updated to take advantage of ArenaAllocator for the AST that it returns. This significantly reduces the complexity of cleanup code. docgen and build runner are updated to use the combination of ArenaAllocator and DirectAllocator instead of IncrementingAllocator, which is now deprecated in favor of FixedBufferAllocator combined with DirectAllocator. The C allocator calls aligned_alloc instead of malloc, in order to respect the alignment parameter. Added asserts in Allocator to ensure that implementors of the interface return slices of the correct size. Fixed a bug in Allocator when you call realloc to grow the allocation.
2018-01-31*WIP* error sets converting std libAndrew Kelley
2018-01-25syntax: functions require return type. remove `->`Andrew Kelley
The purpose of this is: * Only one way to do things * Changing a function with void return type to return a possible error becomes a 1 character change, subtly encouraging people to use errors. See #632 Here are some imperfect sed commands for performing this update: remove arrow: ``` sed -i 's/\(\bfn\b.*\)-> /\1/g' $(find . -name "*.zig") ``` add void: ``` sed -i 's/\(\bfn\b.*\))\s*{/\1) void {/g' $(find ../ -name "*.zig") ``` Some cleanup may be necessary, but this should do the bulk of the work.
2018-01-09remove %% prefix operatorAndrew Kelley
See #632 closes #545 closes #510 this makes #651 higher priority
2018-01-07replace `a %% b` with `a catch b`Andrew Kelley
See #632 better fits the convention of using keywords for control flow
2018-01-07replace `%return` with `try`Andrew Kelley
See #632 better fits the convention of using keywords for control flow
2018-01-06Darwin -> MacOSX, added Zen. See #438Andrea Orru
2017-12-23move std/debug.zig to a subdirectoryAndrew Kelley
self hosted compiler parser tests do some fuzz testing
2017-12-23port most of main.cpp to self hosted compilerAndrew Kelley
2017-12-22explicitly return from blocksAndrew Kelley
instead of last statement being expression value closes #629
2017-12-06add higher level arg-parsing API + misc. changesAndrew Kelley
* add @noInlineCall - see #640 This fixes a crash in --release-safe and --release-fast modes where the optimizer inlines everything into _start and clobbers the command line argument data. If we were able to verify that the user's code never reads command line args, we could leave off this "no inline" attribute. * add i29 and u29 primitive types. u29 is the type of alignment, so it makes sense to be a primitive. probably in the future we'll make any `i` or `u` followed by digits into a primitive. * add `aligned` functions to Allocator interface * add `os.argsAlloc` and `os.argsFree` so that you can get a `[]const []u8`, do whatever arg parsing you want, and then free it. For now this uses the other API under the hood, but it could be reimplemented to do a single allocation. * add tests to make sure command line argument parsing works.
2017-11-05fix redeclaration of mem (#585)scurest
2017-11-05add test for c_allocatorscurest
2017-10-31breaking change to std.io APIAndrew Kelley
* Merge io.InStream and io.OutStream into io.File * Introduce io.OutStream and io.InStream interfaces - io.File implements both of these * Move mem.IncrementingAllocator to heap.IncrementingAllocator Instead of: ``` %return std.io.stderr.printf("hello\n"); ``` now do: ``` std.debug.warn("hello\n"); ``` To print to stdout, see `io.getStdOut()`. * Rename std.ArrayList.resizeDown to std.ArrayList.shrink.