Commit graph

5916 commits

Author SHA1 Message Date
Andrew Kelley
06dfa88d3f fix CPU model detection for neoverse_n1 on aarch64-linux
see #10086
2023-01-09 14:34:40 -07:00
Ali Chraghi
1702404adf os: windows: fix unhandled error 2023-01-09 14:29:59 -07:00
remeh
a5bcdfd27e std.array_list: add a comment on every methods invalidating pointers.
While it is already mentioned on the `items` attributes of the structs, it is
interesting to comment in every method potentially invalidating pointers to items
that they may do so.
2023-01-09 14:18:45 -07:00
Guillaume Wenzek
91b8d9e370 fix Nvptx backend outputing files at the top level of zig-cache 2023-01-09 14:17:29 -07:00
Veikka Tuominen
4ed0cd51c0 Merge pull request #13558 from Vexu/stage2-fixes
Stage2 bug fixes to get third party projects building
2023-01-09 14:06:50 -07:00
GethDW
6494cec59c std.build: fix typo
This would only fail to compile when building *on* WASI.
2023-01-09 14:06:13 -07:00
Hayden Pope
2d623d7774 std.os.linux: Add setitimer and getitimer syscalls 2023-01-09 14:05:18 -07:00
Frank Denis
b239a178c5 crypto.bcrypt: fix massive speed regression when using stage2 (#13518)
state: State -> state: *const State
Suggested by @nektro

Fixes #13510
2023-01-09 14:03:11 -07:00
Jonathan
568a619251 pthread_sigmask 2023-01-09 14:01:57 -07:00
Jakub Konka
56195aa73c pdb: make SuperBlock def public 2023-01-09 14:00:21 -07:00
Veikka Tuominen
95ecd521b8 Merge pull request #13418 from ryanschneider/signal-alignment-13216
std.os: fix alignment of Sigaction.handler_fn
2023-01-09 13:56:41 -07:00
IntegratedQuantum
11c1ddfc97 Handle sentinel slices in std.mem.zeroes
Fixes #13256
2023-01-09 13:56:20 -07:00
bfredl
a0dd11c479 Fixes to linux/bpf/btf.zig
- the meaning of packed structs changed in zig 0.10. adjust accordingly.
  Use "extern struct" for the cases that directly map to C structs.

- Add new type info kinds, like enum64 and DeclTag

- change the Type enum to use the canonical names from libbpf.
  This is more predictable when comparing with external BPF
  documentation (than invented synonyms that need to be guessed)
2023-01-09 13:55:53 -07:00
Frank Denis
6a94bcbbc6 crypto.core.aes: process 6 block in parallel instead of 8 on aarch64 (#13473)
* crypto.core.aes: process 6 block in parallel instead of 8 on aarch64

At least on Apple Silicon, this is slightly faster than 8 blocks.

* AES: add parallel blocks for tigerlake, rocketlake, alderlake, zen3
2023-01-09 13:52:02 -07:00
Frank Denis
30d392a87e crypto.salsa20: make the number of rounds a comptime parameter (#13442)
...instead of hard-coding it to 20.

- This is consistent with the ChaCha implementation
- NaCl and libsodium, that this API is designed to interop with,
also support 8 and 12 round variants. The 12 round variant, in
particular, provides the same security level as the 20 round variant,
but is obviously faster.
- scrypt currently uses its own non optimized version of Salsa, just
because it use 8 rounds instead of 20. This will help remove code
duplication.

No behavior nor public API changes. The Salsa20 and XSalsa20 still
represent the 20-round variant.
2023-01-09 13:51:56 -07:00
r00ster91
5f74bec076 std.os.linux.T: translate more MIPS values
This fixes the broken terminal for me and thus fixes #13198.
2023-01-09 13:50:39 -07:00
delitako
3608b1d036 Improve doc comments for two functions (#13456)
* std.heap: fix function name in doc comment

* std.mem: document return value of `replace`
2023-01-09 13:49:43 -07:00
Veikka Tuominen
b511231f95 Merge pull request #13338 from Vexu/stage2-compile-errors
Improve some error messages
2023-01-09 13:48:34 -07:00
Yujiri
d8970de510 Add docstrings to some functions in std.meta 2023-01-09 13:46:58 -07:00
Frank Denis
72199c26b9 std.crypto.pwhash.bcrypt: inline the Feistel network function (#13416)
std/crypto/benchmark.zig results:

* Intel i5

before: 3.144 s/ops
 after: 1.922 s/ops

* Apple M1

before: 2.067 s/ops
 after: 1.373 s/ops
2023-01-09 13:46:46 -07:00
Nathan Bourgeois
ab4b538d91 Translate-C Remainder Macro Fix 2023-01-09 13:45:42 -07:00
Frank Denis
ee8af8cffb std.crypto.ed25519 incremental signatures: hash the fallback noise (#13643)
If the noise parameter was null, we didn't use any noise at all.

We unconditionally generated random noise (`noise2`) but didn't use it.

Spotted by @cryptocode, thanks!
2022-12-22 23:06:28 +01:00
Andrew Kelley
a0ac10d903 Merge pull request #13389 from jacobly0/fix-only-c
cbe: enough fixes for `-Donly-c` to be able to produce an executable
2022-11-02 14:11:31 -07:00
Andrew Kelley
57caec8585 Merge pull request #13368 from jacobly0/fix-aarch64-c 2022-11-02 14:09:45 -07:00
mnordine
5aa146c2d2 Fix variable name in documentation sample (#13391) 2022-11-02 14:09:30 -07:00
Frank Denis
5e4000ee69 ed25519: recommend using the seed to recover a key pair 2022-11-02 14:09:24 -07:00
Frank Denis
26e7d4c9a3 Ed25519.KeyPair.fromSecretKey() didn't compile after the API changes (#13386)
Fixes #13378
2022-11-02 14:09:18 -07:00
Andrew Kelley
d02242661e std.heap: make wasm32 PageAllocator handle large allocation
When a number of bytes to be allocated is so great that alignForward()
is not possible, return `error.OutOfMemory`.

Companion commit to 3f3003097c.
2022-10-30 19:28:26 -07:00
Andrew Kelley
3f3003097c std.heap.PageAllocator: add check for large allocation
Instead of making the memory alignment functions more complicated, I
added more API documentation for their existing semantics.

closes #12118
closes #12135
2022-10-30 16:10:20 -07:00
Nameless
40e84a27d6
change uefi packed structs to new integer backed syntax (#13173)
* std.os.uefi: integer backed structs, add tests to catch regressions

device_path_protocol now uses extern structs with align(1) fields because
the transition to integer backed packed struct broke alignment

added comptime asserts that device_path_protocol structs do not violate
alignment and size specifications
2022-10-30 15:08:32 -04:00
Andrew Kelley
5339cac2ef std: re-enable auto hash test
It was temporarily disabled due to a self-hosted compiler
miscompilation.

closes #12178
2022-10-30 01:09:31 -07:00
Andrew Kelley
209a0d2a83
Merge pull request #13153 from squeek502/iterator-filename-limits
Windows: Fix Iterator name buffer size not handling all possible file name components
2022-10-29 23:50:37 -04:00
Andrew Kelley
5f5a20ebaf
Merge pull request #13093 from jacobly0/backend-fixes
C backend fixes
2022-10-29 23:06:59 -04:00
kkHAIKE
949cca9f2a Allocator: fix len_align calc in large type size case 2022-10-29 17:53:56 -04:00
Ryan Liptak
db80225a97 fs: Some NAME_MAX/MAX_NAME_BYTES improvements 2022-10-29 14:30:46 -07:00
Ryan Liptak
348f73502e Make MAX_NAME_BYTES on WASI equivalent to the max of the other platforms
Make the test use the minimum length and set MAX_NAME_BYTES to the maximum so that:
- the test will work on any host platform
- *and* the MAX_NAME_BYTES will be able to hold the max file name component on any host platform
2022-10-29 14:30:46 -07:00
Ryan Liptak
c5d23161fc Set wasi MAX_NAME_BYTES to minimum of the rest of the supported platforms
This is a slightly weird situation, because the 'real' value may depend on the host platform that the WASI is being executed on.
2022-10-29 14:30:45 -07:00
Ryan Liptak
dd0962d5ea Add wasi branch to MAX_NAME_BYTES 2022-10-29 14:30:45 -07:00
Ryan Liptak
c6ff1a7160 Windows: Fix iterator name buffer size not handling all possible file name components
Each u16 within a file name component can be encoded as up to 3 UTF-8 bytes, so we need to use MAX_NAME_BYTES to account for all possible UTF-8 encoded names.

Fixes #8268
2022-10-29 14:30:44 -07:00
Ryan Liptak
33fdc43714 std.fs: Add MAX_NAME_BYTES
Also add some NAME_MAX or equivalent definitions where necessary
2022-10-29 14:30:43 -07:00
fn ⌃ ⌥
a70c86e661 Fix deprecation docs for isAlpha and isCntrl 2022-10-29 15:22:05 -04:00
Jacob Young
48a2783969 cbe: implement optional slice representation change 2022-10-29 05:58:41 -04:00
Andrew Kelley
20925b2f5c
Merge pull request #13272 from topolarity/sha2-intrinsics
crypto.sha2: Use intrinsics for SHA-256 on x86-64 and AArch64
2022-10-29 03:31:42 -04:00
Andrew Kelley
c36eb4ede9
Merge pull request #13221 from topolarity/packed-mem
Introduce `std.mem.readPackedInt` and improve bitcasting of packed memory layouts
2022-10-28 21:15:16 -04:00
Zhora Trush
c66d3f6bf6 Enhance indexOfIgnoreCase with Boyer-Moore-Horspool algorithm 2022-10-28 20:29:41 -04:00
Cody Tapscott
67fa3262b1 std.crypto: Use featureSetHas to gate intrinsics
This also fixes a bug where the feature gating was not taking
effect at comptime due to https://github.com/ziglang/zig/issues/6768
2022-10-28 17:17:08 -07:00
Cody Tapscott
f9fe548e41 std.crypto: Add isComptime guard around intrinsics
Comptime code can't execute assembly code, so we need some way to
force comptime code to use the generic path. This should be replaced
with whatever is implemented for #868, when that day comes.

I am seeing that the result for the hash is incorrect in stage1 and
crashes stage2, so presumably this never worked correctly. I will follow
up on that soon.
2022-10-28 15:21:10 -07:00
Cody Tapscott
4c1f71e866 std.crypto: Optimize SHA-256 intrinsics for AMD x86-64
This gets us most of the way back to the performance I had when
I was using the LLVM intrinsics:
  - Intel Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz:
       190.67 MB/s (w/o intrinsics) -> 1285.08 MB/s
  - AMD EPYC 7763 (VM) @ 2.45 GHz:
       240.09 MB/s (w/o intrinsics) -> 1360.78 MB/s
  - Apple M1:
       216.96 MB/s (w/o intrinsics) -> 2133.69 MB/s

Minor changes to this source can swing performance from 400 MB/s to
1400 MB/s or... 20 MB/s, depending on how it interacts with the
optimizer. I have a sneaking suspicion that despite LLVM inheriting
GCC's extremely strict inline assembly semantics, its passes are
rather skittish around inline assembly (and almost certainly, its
instruction cost models can assume nothing)
2022-10-28 15:21:10 -07:00
Cody Tapscott
ee241c47ee std.crypto: SHA-256 Properly gate comptime conditional
This feature detection must be done at comptime so that we avoid
generating invalid ASM for the target.
2022-10-28 15:21:10 -07:00
Cody Tapscott
10edb6d352 crypto.sha2: Use intrinsics for SHA-256 on x86-64 and AArch64
There's probably plenty of room to optimize these further in the
future, but for the moment this gives ~3x improvement on Intel
x86-64 processors, ~5x on AMD, and ~10x on M1 Macs.

These extensions are very new - Most processors prior to 2020 do
not support them.

AVX-512 is a slightly older alternative that we could use on Intel
for a much bigger performance bump, but it's been fused off on
Intel's latest hybrid architectures and it relies on computing
independent SHA hashes in parallel. In contrast, these SHA intrinsics
provide the usual single-threaded, single-stream interface, and should
continue working on new processors.

AArch64 also has SHA-512 intrinsics that we could take advantage
of in the future
2022-10-28 15:21:10 -07:00