Commit graph

8677 commits

Author SHA1 Message Date
Andrew Kelley
a8e2a21a86 std.array_list: promote tests to doctests
This moves most tests from ArrayList and ArrayListUnmanaged into the
corresponding namespace and provides a doctest for nearly every method.
2024-03-13 15:56:52 -07:00
Andrew Kelley
e5a95c6af1 std: promote tests to doctests
Now these show up as "example usage" in generated documentation.
2024-03-13 15:56:09 -07:00
Andrew Kelley
d029e0e972 std: remove one layer of redundant parse_float namespace
there are still more, though.

This provides a doctest for the `parseFloat` function.
2024-03-12 15:46:14 -07:00
Frank Denis
b8920bceb7
ml_kem.zig: inLen -> in_len (#19269)
Don't use camelCase for variable names, especially just for that one.
2024-03-12 19:52:06 +00:00
Andrew Kelley
da5b16f9e2
Merge pull request #19238 from dweiller/ring-buffer
std.RingBuffer: minor cleanup and doc improvements
2024-03-11 18:49:16 -07:00
Andrew Kelley
cb4e087fda
Merge pull request #19239 from jedisct1/ml-kem
std.crypto: add support for ML-KEM
2024-03-11 18:48:08 -07:00
Andrew Kelley
bd24e66379
Merge pull request #19229 from tiehuis/ryu-128
std.fmt: add ryu floating-point formatting implementation
2024-03-11 18:46:26 -07:00
Andrew Kelley
0c61466771
Merge pull request #19174 from squeek502/lazy-resinator
Lazily compile the `zig rc` subcommand and use it during `zig build-exe`, etc
2024-03-11 17:18:09 -07:00
Andrew Kelley
f60c24c73c
Merge pull request #19155 from ianic/tar_max_file_size
std.tar: error on insufficient buffers provided to iterator
2024-03-11 17:03:44 -07:00
tinusgraglin
26e895e3dc math.big.int: fix incorrect bitAnd behavior 2024-03-11 16:52:03 -07:00
Tristan Ross
6067d39522
std.builtin: make atomic order fields lowercase 2024-03-11 07:09:10 -07:00
Tristan Ross
c260b4c753
std.builtin: make global linkage fields lowercase 2024-03-11 07:09:10 -07:00
Tristan Ross
aab84a3dec
std.builtin: make float mode fields lowercase 2024-03-11 07:09:10 -07:00
Tristan Ross
9d70d614ae
std.builtin: make link mode fields lowercase 2024-03-11 07:09:10 -07:00
Tristan Ross
099f3c4039
std.builtin: make container layout fields lowercase 2024-03-11 07:09:07 -07:00
Ryan Liptak
b16890e6dd ErrorBundle: Fix potential writes to stale/freed memory 2024-03-11 05:06:17 -07:00
Ryan Liptak
dc4b05894d ErrorBundle: Add support for reference traces in addOtherSourceLocation
Also adds a test for addBundleAsRoots, which uses addOtherSourceLocation.
2024-03-11 05:06:17 -07:00
Igor Anić
0cca7e732e std.tar: fix broken public interface 2024-03-11 12:25:51 +01:00
Igor Anić
c4868b2bbc std.tar: use doctest
Make std.tar look better in docs. Remove from public interface what is
not necessary. Add comment to the public methods. Add doctest as usage
examples for iterator and pipeToFileSystem.
2024-03-11 12:25:03 +01:00
Igor Anić
a9e7abda20 std.tar: fix test hanging on windows
Problem was manifested only on windows with target `-target
aarch64-windows-gnu`.

I was creating new files but not closing any of them. Tmp dir cleanup
hangs looping in deleteTree forever.
2024-03-11 12:24:11 +01:00
Igor Anić
8ec990d6d7 disable test which is hanging on windows in ci
When this test is enabled something like:
`zig build test docs --zig-lib-dir .\lib\ -Dstatic-llvm -Dskip-non-native -Denable-symlinks-windows`
never finishes.

Those are failed runs from ci:
https://github.com/ziglang/zig/actions/runs/8137710393
https://github.com/ziglang/zig/actions/runs/8129619923
https://github.com/ziglang/zig/actions/runs/8125845128

Isolating that test and running it is not a problem. Running something
like `zig test .\lib\std\std.zig  --zig-lib-dir .\lib\` is fine.
2024-03-11 12:24:11 +01:00
Igor Anić
8cc35a0255 std.tar: fix path testing on windows
Fixing ci error: error:

'tar.test.test.pipeToFileSystem' failed: slices differ. first difference occurs at index 2 (0x2)

============ expected this output: =============  len: 9 (0x9)

2E 2E 2F 61 2F 66 69 6C  65                       ../a/file

============= instead found this: ==============  len: 9 (0x9)

2E 2E 5C 61 5C 66 69 6C  65                       ..\a\file

After #19136 dir.symlink changes path separtors to \ on windows.
2024-03-11 12:24:11 +01:00
Igor Anić
67336ca8c6 std.tar: fix build on 32 bit platform
Fixing error from ci:

std/tar.zig:423:54: error: expected type 'usize', found 'u64'
std/tar.zig:423:54: note: unsigned 32-bit int cannot represent all possible unsigned 64-bit values
2024-03-11 12:24:11 +01:00
Igor Anić
f5fd4691e5 std.tar: document iterator interface with example 2024-03-11 12:24:06 +01:00
Igor Anić
614161a7cf std.tar make iterator interface more ergonomic
for the then end users:

1. Don't require user to call file.skip() on file returned from
iterator.next if file is not read. Iterator will now handle this.
Previously that returned header parsing error, without knowing some tar
internals it is hard to understand what is required from user.

2. Use iterator.File.kind enum which is similar to fs.File.Kind,
something familiar. Internal Header.Kind has many types which are not
exposed but the user needs to have else in kind switch to cover those
cases.

3. Add reader interface to the iterator.File.
2024-03-11 12:22:12 +01:00
Igor Anić
5ccbb196ad std.tar: don't return in iterator init
Don't assert min buffer size on iterator init. That was changing public
interface. This way we don't break that interface.
2024-03-11 12:22:12 +01:00
Igor Anić
10add7c677 std.tar: remove redundant test name prefixes 2024-03-11 12:22:12 +01:00
Igor Anić
04e8bbd932 std.tar: test buffers provided to the iterator
Tar header stores name in max 256 bytes and link name in max 100 bytes.
Those are minimums for provided buffers. Error is raised during iterator
init if buffers are not long enough.

Pax and gnu extensions can store longer names. If such extension is
reached during unpack and don't fit into provided buffer error is
returned.
2024-03-11 12:22:12 +01:00
Igor Anić
af0502f6c4 std.tar: add tests for file and symlink create
Should do that before I broke package manager!
2024-03-11 12:22:00 +01:00
Andrew Kelley
d0c06ca712
Merge pull request #19208 from ziglang/rework-autodoc
Redesign How Autodoc Works
2024-03-11 01:37:50 -07:00
Frank Denis
eaca8626b2
std.crypto.pcurves fixes (#19245)
Fixes compilation errors in functions that are syntaxic sugar
to operate on serialized scalars.

Also make it explicit that square roots in fields whose size is
not congruent to 3 modulo 4 are not an error, they are just
not implemented yet.

Reported by @vitalonodo - Thanks!
2024-03-11 09:00:15 +01:00
Andrew Kelley
aa852f737b improve documentation in std
A lot of these "shorthand" doc comments were redundant, low quality
filler content. Better to let the actual modules speak for themselves
with top level doc comments rather than trying to document their
aliases.
2024-03-10 18:13:30 -07:00
Andrew Kelley
3efdfe612e std.Thread.WaitGroup: add spawnManaged
Provides a convenient way to spawn a new thread that bypasses a thread
pool. Appropriate when the spawned thread delegates all of its work.
2024-03-10 17:51:07 -07:00
Andrew Kelley
ffd53a459e -femit-docs: creating sources.tar
It's always a good day when you get to use File.writeFileAll 😎
2024-03-10 17:51:07 -07:00
Andrew Kelley
b7ba0b69b1 std.io.Writer: add writeFile method 2024-03-10 17:51:06 -07:00
Techatrix
40e64245fc std: expose Config struct of GeneralPurposeAllocator 2024-03-10 14:08:02 -07:00
Frank Denis
2dba5eaa64 Fix typo in an old comment, and avoid useless hash 2024-03-10 19:54:38 +01:00
Frank Denis
1ca3a48b87 std.crypto: add support for ML-KEM
ML-KEM is the Kyber post-quantum secure key encapsulation mechanism,
as being standardized by NIST.

Too bad, they decided to rename it; the "Kyber" name was so much
better!

This implements the current draft (NIST FIPS-203), which is already
being deployed even though the specification is not finalized.
2024-03-10 15:48:38 +01:00
dweiller
6fe2b40778 std.RingBuffer: use sliceAt/sliceFirst in read*AssumeLength 2024-03-10 18:17:23 +11:00
dweiller
d942096a44 std.RingBuffer: improve doc comments and assertions 2024-03-10 18:13:53 +11:00
Marc Tiehuis
da4acf9a48 std.fmt: fix std-cases and perform round-trip check in ryu unit tests 2024-03-09 22:23:14 +13:00
Marc Tiehuis
b6695f0542 std.json: update tests to match new floating point formatting 2024-03-09 17:03:05 +13:00
Marc Tiehuis
04fd113e22 std.fmt: add ryu upstream unit tests 2024-03-09 16:26:10 +13:00
Marc Tiehuis
c6ad551cd2 std.fmt: add ryu floating-point formatting
This replaces the errol backend with one based on ryu. The 128-bit
backend only is implemented. This supports all floating-point types and
does not use fp logic to print.

Closes #1181.
Closes #1299.
Closes #3612.
2024-03-09 15:57:25 +13:00
mlugg
265f42d472
std.os.linux: rework io_uring support
* `linux.IO_Uring` -> `linux.IoUring` to align with naming conventions.
* All functions `io_uring_prep_foo` are now methods `prep_foo` on `io_uring_sqe`, which is in a file of its own.
* `SubmissionQueue` and `CompletionQueue` are namespaced under `IoUring`.

This is a breaking change.

The new file and namespace layouts are more idiomatic, and allow us to
eliminate one more usage of `usingnamespace` from the standard library.
2 remain.
2024-03-08 08:02:45 +00:00
mlugg
a7f6e73812
std.os.windows: eliminate usage of usingnamespace
Some of the structs I shuffled around might be better namespaced under
CONTEXT, I'm not sure. However, for now, this approach preserves
backwards compatibility.

Eliminates one more usage of `usingnamespace` from the standard library.
3 remain.
2024-03-08 08:02:45 +00:00
mlugg
f4bf061d8a
std.c: remove unnecessary use of usingnamespace
Thanks to Zig's lazy analysis, it's fine for these symbols to be
declared on platform they won't exist on. This is already done in
several places in this file; e.g. `pthread` functions are declared
unconditionally.

Eliminates one more usage of `usingnamespace` from the standard library.
4 remain.
2024-03-08 08:02:45 +00:00
mlugg
508a8739e2
std.c.openbsd: remove nop usingnamespace
I have no idea why this was even here...

Eliminates one more usage of `usingnamespace` from the standard library.
5 remain.
2024-03-08 08:02:45 +00:00
mlugg
474d17c13a
std.c: do not use usingnamespace to define getcontext
Eliminates one more usage of `usingnamespace` from the standard library.
2024-03-08 08:02:44 +00:00
mlugg
17f83ace03
std.enums: remove IndexedMap, IndexedArray, IndexedSet
Searching GitHub indicated that the only use of these types in the wild is
support in getty-zig, and testing for that support. This eliminates 3 more uses
of usingnamespace from the standard library, and removes some unnecessarily
complex generic code.
2024-03-08 08:02:44 +00:00