5849 Commits

Author SHA1 Message Date
daurnimator
c0c8ee5ae9 Add reboot syscall
Only linux for now
2022-10-27 20:39:35 -04:00
Frank Denis
9c0d975a09
Revamp the ed25519 API (#13309) 2022-10-27 19:07:42 +02:00
Luuk de Gram
875e98a57d
Merge pull request #13287 from Luukdegram/wasm-features
wasm-linker: feature compatibility validation
2022-10-26 14:04:16 +02:00
Jakub Konka
d42a719e8f
Merge pull request #13299 from ziglang/darwin-autumn-cleaning
Darwin autumn cleaning: x86_64-macos.13 and aarch64-macos.13 support
2022-10-26 13:56:02 +02:00
Naoki MATSUMOTO
cd4865d88c
std.crypto.sign.ecdsa: accepts unusual parameters like EcdsaP384Sha256 (#13302)
This commit accepts unusual parameters like EcdsaP384Sha256.
Some certifictes(below certs are in /etc/ssl/certs/ca-certificates.crt on Ubuntu 22.04) use EcdsaP384Sha256 to sign itself.
- Subject: C=GR, L=Athens, O=Hellenic Academic and Research Institutions Cert. Authority, CN=Hellenic Academic and Research Institutions ECC RootCA 2015
- Subject: C=US, ST=Texas, L=Houston, O=SSL Corporation, CN=SSL.com EV Root Certification Authority ECC
- Subject: C=US, ST=Texas, L=Houston, O=SSL Corporation, CN=SSL.com Root Certification Authority ECC

In verify(), hash array `h` is allocated to be larger than the scalar.encoded_length.
The array is regarded as big-endian.
Hash values are filled in the back of the array and the rest bytes in front are filled with zero.

In sign(), the hash array is allocated and filled as same as verify().
In deterministicScalar(), hash bytes are insufficient to generate `k`
To generate `k` without narrowing its value range,
this commit uses algorithm stage h. in  "Section 3.2 Generation of k" in RFC6979.
2022-10-26 13:18:06 +02:00
Frank Denis
22b71b1376 crypto/bcrypt: don't reimplement base64, just use a custom alphabet
Now that std.base64 supports everything bcrypt needs to encode its
parameters, we don't need to include another implementation.
2022-10-25 21:52:03 -07:00
Luuk de Gram
b14f605dd7
CheckObjectStep: parse and dump target_features
When an object file or binary contains the target_features section
we can now parse and then dump its contents in string format so
we can use them in our linker tests to verify the features section.
2022-10-25 20:48:08 +02:00
Jakub Konka
2d03f38988 darwin: bump minimum supported version to 11.7.1
Drop Catalina support.
2022-10-25 20:31:48 +02:00
Jakub Konka
98285b17b3 darwin: bump max macOS version to 13.0 2022-10-25 20:31:31 +02:00
Jacob Young
55c5da1b20 fmt: fix f80 hex formatting
These ifs were missing a case for f80 which should have shifted by one,
but we can just compute the correct value instead.  Also, we want the
fractional bits to be a multiple of four, not the mantissa bits, since
the mantissa could have a leading one which we want to be separated.
2022-10-25 09:04:04 -07:00
Andrew Kelley
09236d29b7
Merge pull request #12837 from topolarity/err-ret-trace-improvements-1923
stage2: Pop error trace frames for handled errors (#1923)
2022-10-21 20:24:37 -07:00
Louis Pearson
8d4778b4f9
Support compiling for the android NDK (#13245) 2022-10-21 18:32:56 -04:00
Cody Tapscott
a4523a2d4a builtin.zig: Do not overwrite error frames when trace full
Previously, we'd overwrite the errors in a circular buffer. Now that
error return traces are intended to follow a stack discipline, we no
longer have to support the index rolling over. By treating the trace
like a saturating stack, any pop/restore code still behaves correctly
past-the-end of the trace.

As a bonus, this adds a small blurb to let the user know when the trace
saturated and x number of frames were dropped.
2022-10-21 12:40:33 -07:00
David Gonzalez Martin
680d3cd1fc UEFI: Querying memory map size with no allocation
This makes possible to query the memory map size from EFI firmware
without making any allocation beforehand. This makes possible to be
precise about the size of the allocation which will own a copy of
the memory map from the UEFI application.
2022-10-21 12:17:41 +02:00
Andrew Kelley
0f00766661 Revert "add std.debug.todo"
This reverts commit 80ac022c4667e1995ccdf70fff90e5af26b6eb97.

I changed my mind on this one, sorry. I don't think this belongs in the
standard library.
2022-10-20 18:34:40 -07:00
Andrew Kelley
5b9c8d1d6f add m68k target CPU features 2022-10-20 09:21:06 -07:00
Matheus C. França
b41b35f578
crypto/benchmark - replace testing allocator
Fix error: Cannot use testing allocator outside of test block
2022-10-20 14:04:59 +03:00
LordMZTE
3f577f06a0 build: added unwind_tables to LibExeObjStep 2022-10-19 13:24:06 -04:00
Andrew Kelley
8a344fab39
Merge pull request #13036 from BratishkaErik/fix-installing 2022-10-19 09:34:35 -04:00
Luuk de Gram
7d6596e979
Merge pull request #13218 from Luukdegram/fix-emulatable-step
std: CheckObject - correctly depend on its own step when creating an EmulatableRunStep
2022-10-19 08:36:14 +02:00
Andrew Kelley
1952dd6437 Revert recent std.Progress implementation changes
I have noticed this causing my terminal to stop accepting input
sometimes. The previous implementation with all of its flaws was better
in the sense that it never caused this to happen.

This commit has multiple reverts in it:

Revert "Merge pull request #13148 from r00ster91/progressfollowup"

This reverts commit cb257d59f97ea5655bf453d8e7f07bbfb0a88e58, reversing
changes made to f5f28e0d2c49d5c62914edf0bff8f1941eef721f.

Revert "`std.Progress`: fix inaccurate line truncation and use optimal
max terminal width (#12079)"

This reverts commit cd3d8f3a4ee22a41098b1daf2a36d7fbb342d0fa.
2022-10-18 18:53:44 -07:00
Andrew Kelley
9ee4530b9b std.os.windows.OpenFile: handle INVALID_HANDLE ntstatus 2022-10-18 16:52:43 -07:00
Andrew Kelley
c7772dd694 std.zig.system.NativePaths: avoid calling std.os.getenv on Windows 2022-10-18 16:52:43 -07:00
Andrew Kelley
b120c819db
Merge pull request #13055 from alichraghi/m2m
all: rename `@maximum` to `@max` and `@minimum` to `@min`
2022-10-18 14:42:55 -04:00
Andrew Kelley
4962f36b0f synchronize target CPU features with LLVM 15.0.3 2022-10-18 10:18:09 -07:00
Motiejus Jakštys
fd10baf748 os.copy_file_range: save a syscall for most operations
Currenty copy_file_range always uses at least two syscalls:

1. As many as it needs to do the initial copy (always 1 during my
   testing)
2. The last one is always when offset is the size of the file.

The second syscall is used to detect the terminating condition. However,
because we do a stat for other reasons, we know the size of the file,
and we can skip the syscall.

Sparse files: since copy_file_range expands holes of sparse files, I
conclude that this layer was not intended to work with sparse files. In
other words, this commit does not make it worse for sparse file society.

Test program
------------

    const std = @import("std");

    pub fn main() !void {
        const arg1 = std.mem.span(std.os.argv[1]);
        const arg2 = std.mem.span(std.os.argv[2]);
        try std.fs.cwd().copyFile(arg1, std.fs.cwd(), arg2, .{});
    }

Test output (current master)
----------------------------

Observe two `copy_file_range` syscalls: one with 209 bytes, one with
zero:

    $ zig build-exe cp.zig
    $ strace ./cp ./cp.zig ./cp2.zig |& grep copy_file_range
    copy_file_range(3, [0], 5, [0], 4294967295, 0) = 209
    copy_file_range(3, [209], 5, [209], 4294967295, 0) = 0
    $

Test output (this diff)
-----------------------

Observe a single `copy_file_range` syscall with 209 bytes:

    $ /code/zig/build/zig build-exe cp.zig
    $ strace ./cp ./cp.zig ./cp2.zig |& grep copy_file_range
    copy_file_range(3, [0], 5, [0], 4294967295, 0) = 209
    $
2022-10-18 12:57:21 -04:00
Luuk de Gram
10b56b21d4
CheckObjectStep: correctly depend on its own step
When creating an `EmulatableRunStep`, it now correctly depends
on its own step rather than only the executable that was created.
This means we do not need to add extra `dependOn` statements on
both the emulatable step as well as the check object step.
2022-10-18 17:15:58 +02:00
Veikka Tuominen
71e0ab4ec7 zig fmt: rewrite @maximum and @minimum 2022-10-18 14:16:24 +03:00
Ali Chraghi
ca27055cda all: rename @maximum to @max and @minimum to @min 2022-10-18 14:15:16 +03:00
Meghan
759f72fcfe std.debug: define error set in DebugInfo.lookupModuleDl 2022-10-18 13:03:49 +02:00
Xavier Bouchoux
23e212a9d0 std: check for overflow in dumpStackTraceFromBase
same change as [68e26a2ceea85a1] "std: check for overflow in writeCurrentStackTrace"

On arm64 macOS, the address of the last frame is 0x0 rather than
a positive value like 0x1 on x86_64 macOS, therefore, we overflow
an integer trying to subtract 1 when printing the stack trace. This
patch fixes it by first checking for this condition before trying
to subtract 1.

Same behaviour on i386-windows-msvc.

Note that we do not need to signal the `SignalIterator` about this
as it will correctly detect this condition on the subsequent iteration
and return `null`, thus terminating the loop.
2022-10-18 13:03:22 +02:00
jacobly0
bd0dd225e8
Sema: implement linksection on functions
* Sema: implement linksection on functions

 * Implement function linksection in Sema.
 * Don't clobber function linksection/align/addrspace in Sema.
 * Fix copy-paste typo in tests.
 * Add a bunch of missing test_step.dependOn.
 * Fix checkInSymtab match.

Closes #12546
2022-10-18 14:02:10 +03:00
jumpnbrownweasel
71f8762959
Fix for #13163: DefaultRwLock accumulates write-waiters, eventually fails to write lock (#13180)
* Fix for: DefaultRwLock accumulates write-waiters, eventually fails to write lock #13163

* Comment out debug.print at the end of the last test.

* Code formatting

* - use equality test after lock/unlock rather than peeking into internals.
  however, this is still implementation specific and only done for
  DefaultRwLock.
- add num_reads maximum to ensure that reader threads stop if writer threads are
  starved
- use relaxed orderings for the read atomic counter
- don't check at the end for non-zero read ops, since the reader threads may
  only run once if they are starved

* More review changes
- Monotonic is sufficient for incrementing the reads counter
2022-10-17 18:15:15 -05:00
Yujiri
8aa21ade8c add tcdrain on linux 2022-10-17 18:01:05 -04:00
Naoki MATSUMOTO
059e397ffc std.os: handle error.UnreachableAddress in send() 2022-10-17 13:10:23 +02:00
Jens Goldberg
1459231624 fix setsockopt returning ENODEV 2022-10-17 12:55:12 +02:00
Ali Chraghi
5127dae7a2 std.os: fix execv* doc comment 2022-10-16 11:38:22 -04:00
dan
ca1c185eb6
std.zig: search include dir and lib dir from environment variables (#13145)
* minor fix based on feedback from @marler8997

Co-authored-by: dan <i@dan.games>
2022-10-16 11:37:35 -04:00
bfredl
c750d95417 os.linux: some fixes to BPF module
- For ALU operations, src should be allowed to be an explicit Reg.
- Expose AluOp and JmpOp as public types.
  This makes code generation using BPF as a backend easier,
  as AluOp and JmpOp can be used directly as part of an IR
2022-10-16 11:36:11 -04:00
Evin Yulo
b346d48572 Simplify code in std.meta.isTag 2022-10-16 11:35:27 -04:00
Isaac Yonemoto
99c3578f69
adds isTag function to std.meta (#11895) 2022-10-15 14:32:05 -04:00
Andrew Kelley
c0d7f64036
Merge pull request #12448 from r00ster91/ultimateascii
std.ascii: rename functions and other improvements
2022-10-15 14:28:33 -04:00
Andrew Kelley
c289794f0d nvptx: add TODO comment regarding abuse of llvm builtins 2022-10-15 10:50:02 -07:00
Guillaume Wenzek
24c749473a implement os.abort and panic for cuda 2022-10-15 10:39:19 -07:00
Guillaume Wenzek
aad983cf40 sanitize qualified name for nvptx backend 2022-10-15 10:39:19 -07:00
Andrew Kelley
66d6183001 Merge branch 'amdgpu-improvements' of https://github.com/Snektron/zig into Snektron-amdgpu-improvements 2022-10-15 10:36:10 -07:00
Andrew Kelley
16cc65242f
Merge pull request #12918 from jacobly0/math-cast-comptime-int
std.math: fix behavior relating to comptime_int arguments
2022-10-15 12:11:55 -04:00
xEgoist
ae39e7867d Added os check for std.fs.setAsCwd() to work with windows
Due to the unavailability of fchdir in Windows, a call for setting the
CWD needs to either call chdir with the path string or call
SetCurrentDirectory.
Either way, since we are dealing with a Handle in Windows, a call for
GetFinalPathNameByHandle is necessary for getting the file path first.
2022-10-15 11:05:15 -04:00
Andrew Kelley
b4e3424594
Merge pull request #13100 from topolarity/powerpc64le
stage2: Fix softfloat support for PPC64(LE)
2022-10-15 10:05:00 -04:00
Ryan Liptak
8bb2e96ac3 std.os.windows: Change HKEY to *opaque {}
The definition of HKEY__ as a struct with an unused int field is only the case in the Windows headers when `STRICT` is defined. From https://learn.microsoft.com/en-us/windows/win32/winprog/enabling-strict:

> When STRICT is defined, data type definitions change as follows:
>
> -  Specific handle types are defined to be mutually exclusive; for example, you will not be able to pass an HWND where an HDC type argument is required. Without STRICT, all handles are defined as HANDLE, so the compiler does not prevent you from using one type of handle where another type is expected.

Zig's `opaque {}` already gives this benefit to us, so the usage of a struct with an unused field is unnecessary, and it was causing HKEY to have an alignment of 4, which is a problem because there are HKEY constants like HKEY_LOCAL_MACHINE (0x80000002) that are not 4-byte aligned. Without this change, the compiler would not allow something like HKEY_LOCAL_MACHINE to be defined since it enforces pointer alignment.
2022-10-14 15:23:13 -04:00