Commit Graph

52 Commits

Author SHA1 Message Date
Zachary Raineri 49244dc0ca std: remove some unused imports (#16710) 2023-08-06 15:18:50 -04:00
r00ster91 2593156068 migration: std.math.{min, min3, max, max3} -> @min & @max 2023-06-16 13:44:09 -07:00
Eric Joldasov c46e5eb3e1 std.fifo.LinearFifo: remove ensureCapacity (deprecated in 0.9)
Followup to 902df103c6.
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-13 23:45:12 +06:00
Andrew Kelley 6261c13731 update codebase to use @memset and @memcpy 2023-04-28 13:24:43 -07:00
Andrew Kelley a5c910adb6 change semantics of @memcpy and @memset
Now they use slices or array pointers with any element type instead of
requiring byte pointers.

This is a breaking enhancement to the language.

The safety check for overlapping pointers will be implemented in a
future commit.

closes #14040
2023-04-25 11:23:40 -07:00
Andrew Kelley 4f1382e581 add std.LinearFifo.readableSliceOfLen 2023-03-15 10:48:15 -07:00
Andrew Kelley 53fb59ea9b std.fifo: make toOwnedSlice support head != 0 2023-03-15 10:48:14 -07:00
Andrew Kelley c583d14013 std.fifo: add toOwnedSlice method 2023-03-15 10:48:13 -07:00
Lee Cannon 85de022c56 allocgate: std Allocator interface refactor 2021-11-30 23:32:47 +00:00
Andrew Kelley 902df103c6 std lib API deprecations for the upcoming 0.9.0 release
See #3811
2021-11-30 00:13:07 -07:00
Ryan Liptak cfe71cb67a std.fifo.LinearFifo: ensureUnusedCapacity and ensureTotalCapacity
Same as c8ae581fef, but for LinearFifo.
2021-09-19 13:52:56 +02:00
Andrew Kelley d29871977f remove redundant license headers from zig standard library
We already have a LICENSE file that covers the Zig Standard Library. We
no longer need to remind everyone that the license is MIT in every single
file.

Previously this was introduced to clarify the situation for a fork of
Zig that made Zig's LICENSE file harder to find, and replaced it with
their own license that required annual payments to their company.
However that fork now appears to be dead. So there is no need to
reinforce the copyright notice in every single file.
2021-08-24 12:25:09 -07:00
Veikka Tuominen fd77f2cfed std: update usage of std.testing 2021-05-08 15:15:30 +03:00
ducdetronquito 0aef1faa82 std.fifo.LinearFifo - Expose reader and writer type. 2021-02-22 00:22:46 +02:00
rgreenblatt f9be7471bc fix readable slice bug (and add tests) 2021-02-21 11:48:38 +02:00
Jay Petacat 1595ce273e Remove deprecated stream aliases 2021-01-08 16:54:56 -05:00
LemonBoy dd973fb365 std: Use {s} instead of {} when printing strings 2021-01-02 17:12:57 -07:00
Frank Denis 6c2e0c2046 Year++ 2020-12-31 15:45:24 -08:00
Veikka Tuominen a6470088c6 Merge pull request #6434 from daurnimator/fifo.pump
std: add LinearFifo(...).pump(src_reader, dest_writer)
2020-11-18 16:35:13 +02:00
Ian Simonson eab51b7785 Make LinearFifo not crash when discarding from empty buffer
Previously if a LinearFifo was empty and discard was called
an unsigned overflow would occur. However it is safe to perform
this overflow as a bitwise & operation with 0xFFFFFFFFFFFFFF is a noop
2020-09-27 05:46:39 -04:00
daurnimator a1abbb8eac std: add LinearFifo(...).pump(src_reader, dest_writer) 2020-09-27 14:43:44 +10:00
Andrew Kelley 4a69b11e74 add license header to all std lib files
add SPDX license identifier
copyright ownership is zig contributors
2020-08-20 16:07:04 -04:00
frmdstryr fa4a9ab51f Use writer for LinearFifo instead of deprecated outStream 2020-07-27 17:05:39 +03:00
Jonathan Marler a282ac7a91 Support Reader for InStream 2020-06-09 13:36:17 -04:00
Andrew Kelley 0986dcf1cf self-hosted: fix codegen and resolve some analysis bugs 2020-05-14 13:20:27 -04:00
daurnimator 34524a1792 std: add LinearFifo().inStream 2020-04-02 21:14:15 +11:00
daurnimator 2a031c8825 std: LinearFifo matches ArrayList in always having outStream method 2020-04-02 21:07:44 +11:00
Tetralux d57b5205c6 Fix std.fifo.LinearFifo
- Fix undeclared variable in 'writeItem'
- Clarify docs of `read` regarding bytes vs. items
- Normalize 'writeable' to 'writable' (the more common parlance)
2020-03-31 10:18:58 -04:00
Andrew Kelley 4905102901 fix all the TODOs from the pull request
* `std.Buffer.print` is removed; use `buffer.outStream().print`
 * `std.fmt.count` returns a `u64`
 * `std.Fifo.print` is removed; use `fifo.outStream().print`
 * `std.fmt.bufPrint` error is renamed from `BufferTooSmall`
   to `NoSpaceLeft` to match `std.os.write`.
 * `std.io.FixedBufferStream.getWritten` returns mutable buffer
   if the buffer is mutable.
2020-03-13 12:02:58 -04:00
Benjamin Feng 786216ca5a Slap in workaround for Fifo 2020-03-12 10:41:09 -05:00
xackus 783e8ad031 remove @bytesToSlice, @sliceToBytes from std lib 2020-02-21 19:46:53 +01:00
Benjamin Feng b077f3ab7d Promoted "leak_count_allocator" to the main testing.allocator 2020-01-29 22:22:00 -06:00
Benjamin Feng aa9caf5064 Create leak_count_allocator 2020-01-29 14:37:01 -06:00
Benjamin Feng 4d134a01f5 Move debug.global_allocator to testing.allocator 2020-01-29 12:21:29 -06:00
Andrew Kelley 8b2622cdd5 std.fmt.format: tuple parameter instead of var args 2019-12-08 22:53:51 -05:00
Andrew Kelley bf3ac66150 remove type coercion from array values to references
* Implements #3768. This is a sweeping breaking change that requires
   many (trivial) edits to Zig source code. Array values no longer
   coerced to slices; however one may use `&` to obtain a reference to
   an array value, which may then be coerced to a slice.

 * Adds `IrInstruction::dump`, for debugging purposes. It's useful to
   call to inspect the instruction when debugging Zig IR.

 * Fixes bugs with result location semantics. See the new behavior test
   cases, and compile error test cases.

 * Fixes bugs with `@typeInfo` not properly resolving const values.

 * Behavior tests are passing but std lib tests are not yet. There
   is more work to do before merging this branch.
2019-11-27 03:37:50 -05:00
Andrew Kelley bdf3680be1 zig fmt 2019-11-25 13:53:13 -05:00
daurnimator 1a84bcefb6 std: fix mismatched doc-comment/argument names in fifo.rewind 2019-11-25 09:26:33 +11:00
daurnimator 94485b2a58 std: clean up fifo.readableSliceMut 2019-11-25 09:26:33 +11:00
daurnimator b4091e3aec std: fifo.deinit didn't need to take a pointer 2019-11-25 09:26:33 +11:00
daurnimator 3062e0e932 std: add fifo.writeItem 2019-11-25 09:26:33 +11:00
daurnimator c393969a20 std: fix bug in fifo.unget if rewinding doesn't wrap around 2019-11-25 09:26:33 +11:00
daurnimator 61179a4d52 std: follow zig standard library convention and have fifo.read number of items 2019-11-25 09:26:33 +11:00
daurnimator 6037f89212 std: fifo rename from FixedSizeFifo to LinearFifo 2019-11-25 09:26:33 +11:00
daurnimator cd749e0416 std: fifo now has 3 modes: Static, Slice and Dynamic 2019-11-25 09:26:32 +11:00
daurnimator c0e47cb645 std: fix fifo for non-u8 types 2019-11-25 09:26:32 +11:00
daurnimator e810f485ab std: add optimization to fifo if size is power of two 2019-11-25 09:26:32 +11:00
daurnimator 01b2a56225 std: move auto_align constant to top of comptime function
At a later point in time this might be made into a parameter
2019-11-25 09:26:32 +11:00
daurnimator 52645d06e1 std: fix unfinished doc-comment in fifo 2019-11-25 09:26:32 +11:00
schroffl 6109e49c5b Fix FixedSizeFifo buffer type
Update the `.buf` property to be a slice of the type that is given as a parameter.
2019-11-24 14:42:56 -05:00