aboutsummaryrefslogtreecommitdiff
path: root/lib/std/std.zig
AgeCommit message (Collapse)Author
2021-01-14organize std lib concurrency primitives and add RwLockAndrew Kelley
* move concurrency primitives that always operate on kernel threads to the std.Thread namespace * remove std.SpinLock. Nobody should use this in a non-freestanding environment; the other primitives are always preferable. In freestanding, it will be necessary to put custom spin logic in there, so there are no use cases for a std lib version. * move some std lib files to the top level fields convention * add std.Thread.spinLoopHint * add std.Thread.Condition * add std.Thread.Semaphore * new implementation of std.Thread.Mutex for Windows and non-pthreads Linux * add std.Thread.RwLock Implementations provided by @kprotty
2021-01-06std.SpinLock: flatten and remove init/deinitAndrew Kelley
structs which are intended to be directly initialized and support static initialization should not have init/deinit methods.
2021-01-04std: skip more tests on Windows to save CI memoryAndrew Kelley
I've enabled only the tests that check things specific to Windows that are not tested by other systems.
2020-12-31Year++Frank Denis
2020-12-24Merge pull request #7531 from Vexu/orphanageVeikka Tuominen
Move ArrayListSentineled to std lib orphanage
2020-12-23rework std.ResetEvent, improve std lib Darwin integrationAndrew Kelley
* split std.ResetEvent into: - ResetEvent - requires init() at runtime and it can fail. Also requires deinit(). - StaticResetEvent - can be statically initialized and requires no deinitialization. Initialization cannot fail. * the POSIX sem_t implementation can in fact fail on initialization because it is allowed to be implemented as a file descriptor. * Completely define, clarify, and explain in detail the semantics of these APIs. Remove the `isSet` function. * `ResetEvent.timedWait` returns an enum instead of a possible error. * `ResetEvent.init` takes a pointer to the ResetEvent instead of returning a copy. * On Darwin, `ResetEvent` is implemented using Grand Central Dispatch, which is exposed by libSystem. stage2 changes: * ThreadPool: use a single, pre-initialized `ResetEvent` per worker. * WaitGroup: now requires init() and deinit() and init() can fail. - Add a `reset` function. - Compilation initializes one for the work queue in creation and re-uses it for every update. - Rename `stop` to `finish`. - Simplify the implementation based on the usage pattern.
2020-12-23move ArrayListSentineled to std lib orphanageVeikka Tuominen
2020-12-20std.Progress: make the API thread-safeAndrew Kelley
We generally get away with atomic primitives, however a lock is required around the refresh function since it traverses the Node graph, and we need to be sure no references to Nodes remain after end() is called.
2020-11-30move std.SegmentedList to the std-lib-orphanageAndrew Kelley
I spent a long time working on this data structure, and I still think it's a neat idea, but it has no business being in the std lib. I'm aware of the few remaining references to SegmentedList that exist in the std lib, but they are dead code, and so I'm leaving the dead references as a clue that the code is dead. Cleaning up dead code will be a separate effort that involves code coverage tools to make sure we find it all. std-lib-orphanage commit: 2c36a7894c689ecbaf63d5f489bb0c68773410c4 closes #7190
2020-11-16Move leb128 and remove trivial *mem functions as discussed in #5588 (#6876)tgschultz
* Move leb128 out of debug and remove trivial *mem functions as discussed in #5588 * Turns out one of the *Mem functions was used by MachO. Replaced with trivial use of FixedBufferStream.
2020-11-06std: Introduce SemanticVersion data structureJay Petacat
This will parse, format, and compare version strings following the SemVer 2 specification. See: https://semver.org Updates #6466
2020-10-15std: move std.meta.refAllDecls to std.testingTadeo Kondrak
2020-10-11AutoResetEventkprotty
2020-09-30Merge pull request #6250 from ziglang/stage2-zig-ccAndrew Kelley
move `zig cc`, `zig translate-c`, `zig libc`, main(), and linking from stage1 to stage2
2020-09-29move std.http to the standard library orphanageAndrew Kelley
I want to take the design of this in a different direction. I think this abstraction is too high level. I want to start bottom-up. std-lib-orphanage commit 179ae67d61455758d71037434704fd4a17a635a9
2020-09-29Merge remote-tracking branch 'origin/master' into stage2-zig-ccAndrew Kelley
This merges in the revert that fixes the broken Windows build of master branch.
2020-09-29move std.BloomFilter to the standard library orphanageAndrew Kelley
2020-09-29move std.rb to the standard library orphanageAndrew Kelley
https://github.com/ziglang/std-lib-orphanage/ This code is not used by anything else in the standard library or by the compiler or any of its tools and therefore it's a great candidate to be maintained by a third party.
2020-09-14move std.cache_hash from std to stage2Andrew Kelley
The API is pretty specific to the implementationt details of the self-hosted compiler. I don't want to have to independently support and maintain this as part of the standard library, and be obligated to not make breaking changes to it with changes to the implementation of stage2.
2020-09-07std: Add DEFLATE and zlib decompressorsLemonBoy
2020-09-02hash_map: rename to ArrayHashMap and add new HashMap implementationSahnvour
2020-08-20add license header to all std lib filesAndrew Kelley
add SPDX license identifier copyright ownership is zig contributors
2020-08-07improvements & fixes for general purpose allocator integrationAndrew Kelley
* std.Mutex API is improved to not have init() deinit(). This API is designed to support static initialization and does not require any resource cleanup. This also happens to work around some kind of stage1 behavior that wasn't letting the new allocator mutex code get compiled. * the general purpose allocator now returns a bool from deinit() which tells if there were any leaks. This value is used by the test runner to fail the tests if there are any. * self-hosted compiler is updated to use the general purpose allocator when not linking against libc.
2020-07-13std: add StringHashMapUnmanageddaurnimator
2020-07-06std: expose unmanaged hash mapsAndrew Kelley
These are useful when you have many of them in memory, and already have the allocator stored elsewhere.
2020-06-17Introduce std.logIsaac Freund
std.log provides 8 log levels and corresponding logging functions. It allows the user to override the logging "backend" by defining root.log and to override the default log level by defining root.log_level. Logging functions accept a scope parameter which allows the implementer of the logging "backend" to filter logging by library as well as level. Using the standardized syslog [1] log levels ensures that std.log will be flexible enough to work for as many use-cases as possible. If we were to stick with only 3/4 log levels, std.log would be insufficient for large and/or complex projects such as a kernel or display server. [1]: https://tools.ietf.org/html/rfc5424#section-6.2.1
2020-05-26Add std.ComptimeStringMapRyan Liptak
2020-05-25Partially implement cache hash API in zigLeRoyce Pearson
2020-05-10rework self-hosted compiler for incremental buildsAndrew Kelley
* introduce std.ArrayListUnmanaged for when you have the allocator stored elsewhere * move std.heap.ArenaAllocator implementation to its own file. extract the main state into std.heap.ArenaAllocator.State, which can be stored as an alternative to storing the entire ArenaAllocator, saving 24 bytes per ArenaAllocator on 64 bit targets. * std.LinkedList.Node pointer field now defaults to being null initialized. * Rework self-hosted compiler Package API * Delete almost all the bitrotted self-hosted compiler code. The only bit rotted code left is in main.zig and compilation.zig * Add call instruction to ZIR * self-hosted compiler ir API and link API are reworked to support a long-running compiler that incrementally updates declarations * Introduce the concept of scopes to ZIR semantic analysis * ZIR text format supports referencing named decls that are declared later in the file * Figure out how memory management works for the long-running compiler and incremental compilation. The main roots are top level declarations. There is a table of decls. The key is a cryptographic hash of the fully qualified decl name. Each decl has an arena allocator where all of the memory related to that decl is stored. Each code block has its own arena allocator for the lifetime of the block. Values that want to survive when going out of scope in a block must get copied into the outer block. Finally, values must get copied into the Decl arena to be long-lived. * Delete the unused MemoryCell struct. Instead, comptime pointers are based on references to Decl structs. * Figure out how caching works. Each Decl will store a set of other Decls which must be recompiled when it changes. This branch is still work-in-progress; this commit breaks the build.
2020-04-21Remove std.lazyInitHaze Booth
2020-04-18std: Introduce the Once synchronization primitiveLemonBoy
The Once object allows the user to execute a function just once in a thread-safe way.
2020-04-01(breaking) std.Buffer => std.ArrayListSentineled(u8, 0)Andrew Kelley
This new name (and the fact that it is a function returning a type) will make it more clear which use cases are better suited for ArrayList and which are better suited for ArrayListSentineled. Also for consistency with ArrayList, * `append` => `appendSlice` * `appendByte` => `append` Thanks daurnimator for pointing out the confusion of std.Buffer.
2020-03-10(breaking) improve and simplify fixed buffer streams APIAndrew Kelley
2019-12-12un-special-case startup code in the std libAndrew Kelley
Previously, the compiler had special logic to determine whether to include the startup code, which was in `std/special/start.zig`. Now, the file is moved to `std/start.zig`, and there is no special logic in the compiler. Instead, the standard library unconditionally imports the `start.zig` file, which then has a `comptime` block that does the logic of determining what, if any, start symbols to export. Instead of `start.zig` being in its own special package, it is just another normal file that is part of the standard library. `std.builtin.TestFn` is now part of the standard library rather than specially generated by the compiler.
2019-12-12allow custom OS entrypointChristine Dodrill
Also: * Expose `std.start.callMain`. * Other fixes added to fix issues found in development.
2019-11-26replace ThreadParker with ResetEvent + WordLock mutexkprotty
2019-11-08Merge branch 'adaptive_lock' of https://github.com/kprotty/zig into ↵Andrew Kelley
kprotty-adaptive_lock
2019-11-05ThreadParker implementationkprotty
2019-11-04std: Add fifo useful for buffersdaurnimator
2019-11-03Remove StaticallyInitializedMutexkprotty
2019-10-24refAllDecls in a test block to limit when it gets runAndrew Kelley
2019-10-23move types from builtin to stdAndrew Kelley
* All the data types from `@import("builtin")` are moved to `@import("std").builtin`. The target-related types are moved to `std.Target`. This allows the data types to have methods, such as `std.Target.current.isDarwin()`. * `std.os.windows.subsystem` is moved to `std.Target.current.subsystem`. * Remove the concept of the panic package from the compiler implementation. Instead, `std.builtin.panic` is always the panic function. It checks for `@hasDecl(@import("root"), "panic")`, or else provides a default implementation. This is an important step for multibuilds (#3028). Without this change, the types inside the builtin namespace look like different types, when trying to merge builds with different target settings. With this change, Zig can figure out that, e.g., `std.builtin.Os` (the enum type) from one compilation and `std.builtin.Os` from another compilation are the same type, even if the target OS value differs.
2019-10-17rework the progress module and integrate with stage1Andrew Kelley
2019-10-16ref more math decls for better docsAndrew Kelley
2019-10-08generated docs contain generic instantiations and comptime callsAndrew Kelley
2019-09-25mv std/ lib/Andrew Kelley
that's all this commit does. further commits will fix cli flags and such. see #2221