139 Commits

Author SHA1 Message Date
mlugg
51595d6b75
lib: correct unnecessary uses of 'var' 2023-11-19 09:55:07 +00:00
dweiller
138a35df8f zstandard: fix division by zero when using RingBuffer
This change fixes some division-by-zero bugs introduced by the optimized
ring buffer read/write functions in d8c067966.

There are edge cases where decompression can use a length zero ring
buffer as the size of the ring buffer used is exactly the the window
size specified by a Zstandard frame, and this can be zero. Switching
away from loops to mem copies means that we need to ensure ring buffers
do not have length zero ring when attempting to read/write from them.
2023-11-10 15:18:16 -05:00
Jacob Young
509be7cf1f x86_64: fix std test failures 2023-11-03 23:18:21 -04:00
dweiller
f6de3ec963 zstandard: fix incorrect RLE decompression into ring buffer
This reverts a change introduced in #17400 causing a bug when
decompressing an RLE block into a ring buffer.

RLE blocks contain only a single byte of data to copy into the output,
so attempting to copy a slice causes buffer overruns and incorrect
decompression.
2023-11-03 23:03:43 -04:00
Andrew Kelley
3fc6fc6812 std.builtin.Endian: make the tags lower case
Let's take this breaking change opportunity to fix the style of this
enum.
2023-10-31 21:37:35 -04:00
Jacob Young
d890e81761 mem: fix ub in writeInt
Use inline to vastly simplify the exposed API.  This allows a
comptime-known endian parameter to be propogated, making extra functions
for a specific endianness completely unnecessary.
2023-10-31 21:37:35 -04:00
Jacob Young
b0cf620fe3 x86_64: fix cond_br 2023-10-27 03:33:49 -04:00
Jacob Young
6ad22cd964 x86_64: add missing spills 2023-10-26 22:35:38 -04:00
Jacob Young
b55377a5ab x86_64: pass more tests
* 128-bit integer multiplication with overflow
 * more instruction encodings used by std inline asm
 * implement the `try_ptr` air instruction
 * follow correct stack frame abi
 * enable full panic handler
 * enable stack traces
2023-10-25 04:28:30 -04:00
Jacob Young
8f69e977f1 x86_64: implement 128-bit builtins
* `@clz`
 * `@ctz`
 * `@popCount`
 * `@byteSwap`
 * `@bitReverse`
 * various encodings used by std
2023-10-23 22:42:18 -04:00
Jacob Young
27fe945a00 Revert "Revert "Merge pull request #17637 from jacobly0/x86_64-test-std""
This reverts commit 6f0198cadbe29294f2bf3153a27beebd64377566.
2023-10-22 15:46:43 -04:00
Andrew Kelley
6f0198cadb Revert "Merge pull request #17637 from jacobly0/x86_64-test-std"
This reverts commit 0c99ba1eab63865592bb084feb271cd4e4b0357e, reversing
changes made to 5f92b070bf284f1493b1b5d433dd3adde2f46727.

This caused a CI failure when it landed in master branch due to a
128-bit `@byteSwap` in std.mem.
2023-10-22 12:16:35 -07:00
Andrew Kelley
d8c067966f
Merge pull request #17400 from joadnacer/ringbuffer-optim
std.RingBuffer: Implement mem.copy read/write
2023-10-22 13:19:22 -04:00
joadnacer
a8eb70c9d7 compress: Improve RingBuffer usage 2023-10-21 19:20:12 +01:00
Jacob Young
32e85d44eb x86_64: disable failing tests, enable test-std testing 2023-10-21 10:55:41 -04:00
Jacob Young
2e6e39a700 x86_64: fix bugs and disable erroring tests 2023-10-21 10:55:41 -04:00
David
364c54460f
Deflate: fix missing value in reset 2023-10-17 21:46:47 +00:00
mlugg
f26dda2117 all: migrate code to new cast builtin syntax
Most of this migration was performed automatically with `zig fmt`. There
were a few exceptions which I had to manually fix:

* `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten
* `@truncate`'s fixup is incorrect for vectors
* Test cases are not formatted, and their error locations change
2023-06-24 16:56:39 -07:00
Eric Joldasov
50339f595a all: zig fmt and rename "@XToY" to "@YFromX"
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-19 12:34:42 -07:00
Xavier Bouchoux
67b3e07260 zlib: naming convention
Adress review comments from https://github.com/ziglang/zig/pull/13977
by using the same naming convention as zstd.

And by using `finish()` instead of `close()` for the finalisation of the compressed stream.
rationale:
  - it is not the same as how close() is usually used, since it must be called to flush and write the final bytes. And as such it may fail.
  - it is not the same `flush` in the deflate code, which allows to keep writting more bytes later, and doesn't write the final checksum.
  - it is the same name as used in the original zlib library (Z_FINISH)

Also, use a packed struct for the header, which seems a better fit.
2023-06-17 14:08:05 -07:00
dantecatalfamo
8b92354396 std: add zlib stream writer 2023-06-17 14:07:45 -07:00
r00ster91
2593156068 migration: std.math.{min, min3, max, max3} -> @min & @max 2023-06-16 13:44:09 -07:00
Ali Chraghi
3db3cf7790 std.sort: add pdqsort and heapsort 2023-05-23 17:55:59 -07:00
dweiller
bd3360e03d convert s[start..start+len] to s[start..][0..len] 2023-05-07 15:55:21 +10:00
Linus Groh
94e30a756e std: fix a bunch of typos
The majority of these are in comments, some in doc comments which might
affect the generated documentation, and a few in parameter names -
nothing that should be breaking, however.
2023-04-30 18:16:04 -07:00
Andrew Kelley
125221cce9 std: update to use @memcpy directly 2023-04-28 13:24:43 -07:00
Andrew Kelley
6261c13731 update codebase to use @memset and @memcpy 2023-04-28 13:24:43 -07:00
zooster
bc8e1e1de4
Improvements to docs and text
* docs(std.math): elaborate on difference between absCast and absInt

* docs(std.rand.Random.weightedIndex): elaborate on likelihood

I think this makes it easier to understand.

* langref: add small reminder

* docs(std.fs.path.extension): brevity

* docs(std.bit_set.StaticBitSet): mention the specific types

* std.debug.TTY: explain what purpose this struct serves

This should also make it clearer that this struct is not supposed to provide unrelated terminal manipulation functionality such as setting the cursor position or something because terminals are complicated and we should keep this struct simple and focused on debugging.

* langref(package listing): brevity

* langref: explain what exactly `threadlocal` causes to happen

* std.array_list: link between swapRemove and orderedRemove

Maybe this can serve as a TLDR and make it easier to decide.

* PrefetchOptions.locality: clarify docs that this is a range

This confused me previously and I thought I can only use either 0 or 3.

* fix typos and more

* std.builtin.CallingConvention: document some CCs

* langref: explain possibly cryptic names

I think it helps knowing what exactly these acronyms (@clz and @ctz) and
abbreviations (@popCount) mean.

* variadic function error: add missing preposition

* std.fmt.format docs: nicely hyphenate

* help menu: say what to optimize for

I think this is slightly more specific than just calling it
"optimizations". These are speed optimizations. I used the word
"performance" here.
2023-04-23 21:06:21 +03:00
dweiller
32cf1d7cbf std.compress.zstandard: fix error sets for streaming API 2023-02-21 22:06:25 +11:00
dweiller
c6ef83efe5 std.compress.zstandard: clean up streaming API 2023-02-21 14:53:02 +11:00
dweiller
c7c35bf9e6 std.RingBuffer: add (non-concurrent) RingBuffer implementation 2023-02-21 12:58:34 +11:00
dweiller
1c518bd993 std.compress.zstandard: rename ZStandardStream -> DecompressStream 2023-02-21 12:58:27 +11:00
dweiller
12d9f73ce8 std.compress.zstandard: remove use of usingnamespace 2023-02-21 12:09:27 +11:00
dweiller
a74f800dd7 std.compress.zstandard: update for multi-for-loop change 2023-02-20 16:58:48 +11:00
dweiller
2766b704c1 std.compress.zstandard: add DictionaryIdFlagUnsupported ZstandardStream.Error 2023-02-20 09:09:06 +11:00
dweiller
1a862175d5 std.compress.zstandard: fix zstandardStream content size validation 2023-02-20 09:09:06 +11:00
dweiller
12aa478db0 std.compress.zstandard: also check block size when sequence count is 0 2023-02-20 09:09:06 +11:00
dweiller
a53cf299a6 std.compress.zstandard: add error condition to ring buffer decoding
Previously `executeSequenceRingBuffer()` would not verify the offset
against the number of bytes already decoded, so it would happily copy
garbage bytes rather than return an error before the window was filled.

To fix this a new `written_count` is added to the decode state that
tracks the total number of bytes decoded.
2023-02-20 09:09:06 +11:00
dweiller
5a31fc2014 std.compress.zstandard: fix erroneous literal stream empty checks 2023-02-20 09:09:06 +11:00
dweiller
8fd41314bd std.compress.zstandard: remove unneeded branch 2023-02-20 09:09:06 +11:00
dweiller
476d2fe1fa std.compress.zstandard: fix zstandardStream finishing early 2023-02-20 09:09:06 +11:00
dweiller
373d8ef26e std.compress.zstandard: check FSE bitstreams are fully consumed 2023-02-20 09:09:06 +11:00
dweiller
1530e73648 std.compress.zstandard: bytes read assert to error in decodeBlockReader 2023-02-20 09:09:06 +11:00
dweiller
ee5af3c74c std.compress.zstandard: cleanup high-level api docs and error sets 2023-02-20 09:09:06 +11:00
dweiller
31cc4605ab std.compress.zstandard: fix errors and crashes in ZstandardStream 2023-02-20 09:09:06 +11:00
dweiller
55e6e9409c std.compress.zstandard: fix content size check 2023-02-20 09:09:06 +11:00
dweiller
6d48b055af std.compress.zstandard: add decodeFrameHeader
Also do some other minor API cleanup
2023-02-20 09:09:06 +11:00
dweiller
3975a9d7ca std.compress.zstandard: error when FSE bitstream is no fully consumed 2023-02-20 09:09:06 +11:00
dweiller
77ca1f7859 std.compress.zstandard: remove UnusedBitSet error 2023-02-20 09:09:06 +11:00
dweiller
d9a90e1818 std.compress.zstandard: fix decodeAlloc() and remove decodeFrameAlloc() 2023-02-20 09:09:06 +11:00