6605 Commits

Author SHA1 Message Date
Jacob Young
c29c4c6f70 tools: add lldb pretty printer for std.MultiArrayList.Slice 2023-03-06 05:58:46 -05:00
Andrew Kelley
8558983c86 std.os.abort: take advantage of @trap 2023-03-05 17:29:28 -07:00
Andrew Kelley
7b01af2bfd
Merge pull request #14745 from jacobly0/bigint
CBE: add support for integers larger than 128 bits (and apparently vectors too)
2023-03-05 14:48:06 -05:00
jim price
a63134a4a5 std.os: Add DeviceBusy as a possible write error
In Linux when writing to various files in the virtual file system,
for example /sys/fs/cgroup, if you write an invalid value to a file
you'll get errno 16.

This change allows for these specific cases to be caught instead of
being lumped together in UnexpectedError.
2023-03-05 17:56:44 +02:00
Jacob Young
874ae81f1b CBE: implement big integer literals 2023-03-05 02:59:01 -05:00
Andrew Kelley
653814f76b std.Build.addModule: return the created module 2023-03-04 05:39:14 -05:00
r00ster91
e0d3904638 Ast: properly handle sentinel-terminated slices in tuple
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2023-03-04 01:08:03 +02:00
Ali Chraghi
75ff34db9e std.Build.Cache: remove 'test-filetimestamp.tmp' once timestamp returned 2023-03-03 13:50:44 -05:00
Frank Denis
fdee558e45 crypto.25519.field: de-inline _sq()
May fix #14764
2023-03-03 07:51:23 -05:00
Andrew Kelley
aaaaab9ec2 std.process.Child: remove pid and handle, add id
Previously, this API had pid, to be used on POSIX systems, and handle,
to be used on Windows.

This commit unifies the API, defining an Id type that is either the pid
or the HANDLE depending on the target OS.

This commit also prepares for the future by allowing one to import via
`std.process.Child` which is the fully qualified namespace that I intend
to migrate to in the future.
2023-03-03 07:49:05 -05:00
Andrew Kelley
bb5006d728 std: add fchmodat
Also add `std.fs.has_executable_bit` for doing conditional compilation.

This adds the linux syscalls for chmod and fchmodat, as well as the
extern libc function declarations.

Only `fchmodat` is added to `std.os`, and it is not yet added to std.fs.
2023-03-03 02:37:45 -05:00
Andrew Kelley
426c13dddf add doc comments to std.fs.File.default_mode 2023-03-03 01:00:44 -05:00
Frank Denis
4789cc0249
crypto.KeccakF: compute rotations at comptime, add a test with f=800 (#14760) 2023-03-02 19:14:41 +00:00
Frank Denis
28364166e8
crypto.hash.sha3: make permutation generic and public, add SHAKE (#14756)
Make the Keccak permutation public, as it's useful for more than
SHA-3 (kMAC, SHAKE, TurboSHAKE, TupleHash, etc).

Our Keccak implementation was accepting f as a comptime parameter,
but always used 64-bit words and 200 byte states, so it actually
didn't work with anything besides f=1600.

That has been fixed. The ability to use reduced-round versions
was also added in order to support M14 and K12.

The state was constantly converted back and forth between bytes
and words, even though only a part of the state is actually used
for absorbing and squeezing bytes. It was changed to something
similar to the other permutations we have, so we can avoid extra
copies, and eventually add vectorized implementations.

In addition, the SHAKE extendable output function (XOF) was
added (SHAKE128, SHAKE256). It is required by newer schemes,
such as the Kyber post-quantum key exchange mechanism, whose
implementation is currently blocked by SHAKE missing from our
standard library.

Breaking change: `Keccak_256` and `Keccak_512` were renamed to
`Keccak256` and `Keccak512` for consistency with all other
hash functions.
2023-03-02 06:13:40 +00:00
Andrew Kelley
874d3a17ae
Merge pull request #14744 from ziglang/std.io.poll
introduce std.io.poll
2023-03-01 18:08:43 -05:00
Jonathan Marler
f2b15420ad std.io.poll: remove done function 2023-03-01 12:21:53 -05:00
Jonathan Marler
138e8b162a std.child_process: use std.io.poll for collectOutput 2023-03-01 12:21:53 -05:00
Jonathan Marler
4f58a80735 std.io.zig: fmt 2023-03-01 12:21:53 -05:00
Binary Craft
a7a709aaa9 Fixes #13893 - some standard library networking tests are failing on Windows 2023-03-01 02:54:43 -05:00
Jonathan Marler
ef72cd6698 std.io.poll initial windows implementation 2023-02-28 15:00:51 -05:00
Andrew Kelley
d8c3738e21 redo std.io.poll with only outputs 2023-02-27 22:39:47 -07:00
Andrew Kelley
814de45bd2 add std.io.poll and implement it for POSIX
I think having inputs is problematic here, it should only be for
outputs.
2023-02-27 22:06:18 -07:00
Andrew Kelley
5236842a9d std.heap.GeneralPurposeAllocator: add doc comment for deinit 2023-02-27 22:04:29 -07:00
Andrew Kelley
f33af7af40 delete a subtly incorrect Haiku collectOutput implementation
It's not OK to half-ass this function. Please implement it correctly, or
not at all.
2023-02-27 20:42:13 -07:00
Jacob Young
a3529c2dea tools: implement more lldb pretty printers 2023-02-27 05:37:03 -05:00
Andrew Kelley
f6c9346773 std.Build.CompileStep.installConfigHeader: add missing step dependency 2023-02-25 23:22:17 -05:00
Andrew Kelley
26196be344 rename std.Build.InstallRawStep to ObjCopyStep
And make it not do any installation, only objcopying. We already have
install steps for doing installation.

This commit also makes ObjCopyStep properly integrate with caching.
2023-02-24 23:48:03 -05:00
Frank Denis
c7f479c3cb
crypto/benchmark.zig: fix pointer capture of non pointer type (#14722) 2023-02-24 19:45:24 +00:00
Gaëtan S
5f70c36fa8 fix RegQueryValueExW api 2023-02-24 13:22:12 -05:00
Andrew Kelley
d3c9bfada6 std.Build.WriteFileStep: integrate with cache system
And additionally support writing files to source files. This means a
custom build step in zig's own build.zig is no longer needed for copying
zig.h because it is handled by WriteFileStep.
2023-02-23 01:08:23 -05:00
Andrew Kelley
c9e02d3e69
Merge pull request #14691 from jacobly0/ctype 2023-02-22 11:06:13 -05:00
Andrew Kelley
b52be973df
Merge pull request #14394 from dweiller/zstandard
Zstandard decompressor
2023-02-21 13:59:14 -05:00
Alexis Brodeur
98dd041d53 Relax std.sort.binarySearch requirements
Forcing the key to be of the same type as the sorted items used during
the search is a valid use case.

There, however, exists some cases where the key and the items are of
heterogeneous types, like searching for a code point in ordered ranges
of code points:

```zig
const CodePoint = u21;
const CodePointRange = [2]CodePoint;

const valid_ranges = &[_]CodePointRange{
    // an ordered array of ranges
};

fn orderCodePointAndRange(
    context: void,
    code_point: CodePoint,
    range: CodePointRange
) std.math.Order {
    _ = context;
    if (code_point < range[0]) {
        return .lt;
    }
    if (code_point > range[1]) {
        return .gt;
    }
    return .eq;
}

fn isValidCodePoint(code_point: CodePoint) bool {
    return std.sort.binarySearch(
        CodePointRange,
        code_point,
        valid_ranges,
        void,
        orderCodePointAndRange
    ) != null;
}
```

It is so expected that `std.sort.binarySearch` should therefore support
both homogeneous and heterogeneous keys.
2023-02-21 12:28:43 -05:00
Komari Spaghetti
2737dce84f
Introduce ChildProcess.collectOutput (#12295)
All the code for this function already exists, but only
ChildProcess.exec was allowed to use the code.
2023-02-21 12:26:55 -05:00
dweiller
765a6d3413 std.compress.zstd: renamed from std.compress.zstandard 2023-02-22 00:11:20 +11:00
dweiller
32cf1d7cbf std.compress.zstandard: fix error sets for streaming API 2023-02-21 22:06:25 +11:00
Jacob Young
828ac637b2 MultiArrayList: delete pessimizing vector usage
By factoring out the comptime parts of this computation, vectors are no
longer useful in this function.
2023-02-21 00:27:12 -05:00
Jacob Young
1a1598daf0 hash map: remove extra argument 2023-02-21 00:27:12 -05:00
dweiller
c6ef83efe5 std.compress.zstandard: clean up streaming API 2023-02-21 14:53:02 +11:00
mlugg
09a84c8384
Update std.Build to new module CLI, update zig1 and CMakeLists
Resolves: #14667
2023-02-21 01:59:37 +00: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
a34c2de7bc std.hash: use std.math.rotl in Xxhash64 and Xxhash32 2023-02-21 12:09:27 +11:00
Frank Denis
6214f66dc1 trim(Left|Right): clarify that values_to_strip is a set
The parameter could be confused with a prefix or suffix, instead
of a set of values.
2023-02-20 13:55:45 -05: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