Commit Graph

9786 Commits

Author SHA1 Message Date
Alex Rønne Petersen
26d35cc112
Merge pull request #21524 from alexrp/fix-reader-test
`std.io.Reader`: Fix test erroneously using `undefined`.
2024-10-02 23:54:23 +02:00
Alex Rønne Petersen
038e002b1c
Merge pull request #21527 from alexrp/elf-emulations
`link.Elf`: Make `getLDMOption()` exhaustive with regards to LLD's `parseEmulation()`.
2024-10-02 23:22:44 +02:00
Alex Rønne Petersen
e652318c13
Merge pull request #21513 from pseudocc/rtattr
std.os.linux: extend rtattr.type to support IFA_*
2024-10-02 22:59:57 +02:00
Michael Ortmann
3b465ebec5
std.start: dont query stack limit for wanted stack size 0 (#21533) 2024-09-28 23:06:28 -07:00
Andrew Kelley
7f4c0e010d update safety test cases to new panic API
although they would also pass simply reverted to master branch because
I made the deprecated API still work for now (to be removed after 0.14.0
is tagged)
2024-09-26 17:14:17 -07:00
Andrew Kelley
db8c074476 fix still calling std.builtin.panic sometimes 2024-09-26 16:46:02 -07:00
Andrew Kelley
1b491e640d fixes and make sema report errors when std.builtin wrong
instead of panicking
2024-09-26 16:06:05 -07:00
Andrew Kelley
c9c080a187 embrace panic helpers
Introduces `std.builtin.Panic` which is a complete interface for
panicking. Provide `std.debug.FormattedPanic` and
`std.debug.SimplePanic` and let the user choose, or make their own.
2024-09-26 16:06:05 -07:00
Andrew Kelley
fcfbedc2f0 work around riscv64 backend deficiencies 2024-09-26 16:06:05 -07:00
Alex Rønne Petersen
59ae51199e
std.Target: Return EM_ARC_COMPACT instead of EM_ARC_COMPACT2 for arc.
Also fix an incorrect related comment in start.zig.
2024-09-26 21:45:49 +02:00
Alex Rønne Petersen
2e3599c7d0
std.Target: Handle ve in toElfMachine(). 2024-09-26 21:44:27 +02:00
Andrew Kelley
f2c8940aa6 reintroduce the std.builtin safety panic helpers
motivated by performance
2024-09-26 12:35:14 -07:00
Andrew Kelley
76f0b6e7d8 delete the old panic stuff again
now that we have a zig1.wasm update it's not needed
2024-09-26 12:35:14 -07:00
Andrew Kelley
9ccf8d3332 fixes for this branch
I had to bring back some of the old API so that I could compile the new
compiler with an old compiler.
2024-09-26 12:35:14 -07:00
Andrew Kelley
4f8d244e7e remove formatted panics
implements #17969
2024-09-26 12:35:14 -07:00
Andrew Kelley
04e694ad11 move std.time.sleep to std.Thread.sleep 2024-09-26 12:35:14 -07:00
Alex Rønne Petersen
2db3c77060
std.io.Reader: Fix test erroneously using undefined. 2024-09-26 17:04:36 +02:00
dave caruso
085cc54aad replace TranslateC.addIncludeDir with variants with LazyPath/library names 2024-09-25 21:50:55 -07:00
pseudoc
0d00c733de std.os.linux: extend rtattr.type to support IFA_*
This is a breaking change which updates the `rtattr.type` from `IFLA` to
`union { IFLA, IFA }`. `IFLA` is for the `RTM_*LINK` messages and `IFA`
is for the `RTM_*ADDR` messages.
2024-09-26 10:54:18 +08:00
Andrew Kelley
4442288656 std: fix inappropriate use of unreachable in fanotify_init 2024-09-25 16:07:04 -07:00
Andrew Kelley
efc98fcbeb disallow non-scalar sentinel types
see #17969
2024-09-25 03:02:05 -07:00
matt
7f6b7c5608 fix THREAD_STATE_NONE on darwin
#21094
2024-09-24 22:41:00 -07:00
Meghan Denny
5e4da1ff30
std: add arch bits for s390x-linux (#21342)
see #21402
2024-09-24 13:35:12 -07:00
Nameless
8d76c02f9a uefi: erroneous alignment check in pool_allocator
Fixes #21446

Both UefiPoolAllocator and UefiRawPoolAllocator were
passing the value of `log2_ptr_align` directly to
`mem.alignAllocLen` which expects a alignment value.

Both of these calls to `mem.alignAllocLen` are pointless
and the result of the alignment both always true, and
was thrown away anyway.

I have removed these calls entirely.
2024-09-24 13:30:53 -07:00
WillLillis
37cd21eb5f fix: disallow discard as errdefer capture 2024-09-24 13:21:06 -07:00
Alex Kladov
ffd071f558 fix IB in fifoToOwnedArrayList
memcpy requires non-overlapping arguments.

fifo.realign() handles this case correctly and tries to provide an
optimized implementation.

This probably wasn't hit in practice, as, in a typical usage, fifo's
head is not advanced.
2024-09-24 13:19:06 -07:00
Frank Denis
c062c532d7 Add post-quantum key agreement X25519MLKEM768
X25519MLKEM768 replaces X25519Kyber768Draft00 now that NIST has
released ML-KEM.

IANA has assigned the codepoint 0x11ec:
https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-8
2024-09-24 13:18:32 -07:00
Lucas Santos
b19d0fb0fd
Improve efficiency of buffered_reader. (#21256)
The previous implementation of buffered_reader always reads from the
unbuffered reader into the internal buffer, and then dumps the data onto
the destination. This is inefficient, as sometimes it's possible to read
directly into the destination. The previous strategy generates more
memory copies and unbuffered reads than necessary.
2024-09-23 17:20:27 -07:00
Alex Rønne Petersen
d1901c744c std.Target: Remove Cpu.Arch.dxil and ObjectFormat.dxcontainer.
See: https://devblogs.microsoft.com/directx/directx-adopting-spir-v

Since we never hooked up the (experimental) DirectX LLVM backend, we've never
actually supported targeting DXIL in Zig. With Microsoft moving away from DXIL,
that seems very unlikely to change.
2024-09-23 17:17:25 -07:00
Fri3dNstuff
b2c53eb0d7
std.math: change gcd's implementation to use Stein's algorithm instead of Euclid's (#21077) 2024-09-23 17:15:57 -07:00
Igor Stojković
0676c04681
tokenizer: fix 0 byte following invalid (#21482)
closes #21481
2024-09-23 13:06:30 -07:00
Lucas Santos
509639717a std.equalRange: Compute lower and upper bounds simultaneously
The current implementation of `equalRange` just calls `lowerRange` and `upperRange`, but a lot of
the work done by these two functions can be shared. Specifically, each iteration gives information about whether the lower bound or the upper bound can be tightened. This leads to fewer iterations and, since there is one comparison per iteration, fewer comparisons.
Implementation adapted from [GCC](519ec1cfe9/libstdc%2B%2B-v3/include/bits/stl_algo.h (L2063)).
This sample demonstrates the difference between the current implementation and mine:

```zig
fn S(comptime T: type) type {
    return struct {
        needle: T,
        count: *usize,

        pub fn order(context: @This(), item: T) std.math.Order {
            context.count.* += 1;
            return std.math.order(item, context.needle);
        }
        pub fn orderLength(context: @This(), item: []const u8) std.math.Order {
            context.count.* += 1;
            return std.math.order(item.len, context.needle);
        }
    };
}
pub fn main() !void {
    var count: usize = 0;

    try std.testing.expectEqual(.{ 0, 0 }, equalRange(i32, &[_]i32{}, S(i32){ .needle = 0, .count = &count }, S(i32).order));
    try std.testing.expectEqual(.{ 0, 0 }, equalRange(i32, &[_]i32{ 2, 4, 8, 16, 32, 64 }, S(i32){ .needle = 0, .count = &count }, S(i32).order));
    try std.testing.expectEqual(.{ 0, 1 }, equalRange(i32, &[_]i32{ 2, 4, 8, 16, 32, 64 }, S(i32){ .needle = 2, .count = &count }, S(i32).order));
    try std.testing.expectEqual(.{ 2, 2 }, equalRange(i32, &[_]i32{ 2, 4, 8, 16, 32, 64 }, S(i32){ .needle = 5, .count = &count }, S(i32).order));
    try std.testing.expectEqual(.{ 2, 3 }, equalRange(i32, &[_]i32{ 2, 4, 8, 16, 32, 64 }, S(i32){ .needle = 8, .count = &count }, S(i32).order));
    try std.testing.expectEqual(.{ 5, 6 }, equalRange(i32, &[_]i32{ 2, 4, 8, 16, 32, 64 }, S(i32){ .needle = 64, .count = &count }, S(i32).order));
    try std.testing.expectEqual(.{ 6, 6 }, equalRange(i32, &[_]i32{ 2, 4, 8, 16, 32, 64 }, S(i32){ .needle = 100, .count = &count }, S(i32).order));
    try std.testing.expectEqual(.{ 2, 6 }, equalRange(i32, &[_]i32{ 2, 4, 8, 8, 8, 8, 15, 22 }, S(i32){ .needle = 8, .count = &count }, S(i32).order));
    try std.testing.expectEqual(.{ 2, 2 }, equalRange(u32, &[_]u32{ 2, 4, 8, 16, 32, 64 }, S(u32){ .needle = 5, .count = &count }, S(u32).order));
    try std.testing.expectEqual(.{ 1, 1 }, equalRange(f32, &[_]f32{ -54.2, -26.7, 0.0, 56.55, 100.1, 322.0 }, S(f32){ .needle = -33.4, .count = &count }, S(f32).order));
    try std.testing.expectEqual(.{ 3, 5 }, equalRange(
        []const u8,
        &[_][]const u8{ "Mars", "Venus", "Earth", "Saturn", "Uranus", "Mercury", "Jupiter", "Neptune" },
        S(usize){ .needle = 6, .count = &count },
        S(usize).orderLength,
    ));

    std.debug.print("Count: {}\n", .{count});
}
```
For each comparison, we bump the count. With the current implementation, we get 57 comparisons. With mine, we get 43.

With contributions from @Olvilock.
This is my second attempt at this, since I messed up the [first one](https://github.com/ziglang/zig/pull/21290).
2024-09-23 13:03:06 -07:00
Andrew Kelley
075ec55552 disable failing test
tracked by #21457
2024-09-19 18:20:22 -07:00
Alex Rønne Petersen
916eaad1ef std.Target: Update CPU models/features for LLVM 19.1.0. 2024-09-19 18:20:22 -07:00
Alex Rønne Petersen
9b60aa0adc std.zig.system.darwin.macos: Enable Apple M4 CPU detection. 2024-09-19 18:20:21 -07:00
Alex Rønne Petersen
a4d0a01243 std.Target: Add bridgeos tag to Os. 2024-09-19 18:20:21 -07:00
Alex Rønne Petersen
da8b7fb0c0 std.Target: Update CPU models/features for LLVM 19. 2024-09-19 18:20:21 -07:00
Juan Julián Merelo Guervós
8b82a0e0fc
std.DynamicBitSet: remove wrong and useless comments (#21418) 2024-09-19 17:06:23 -07:00
Linus Groh
72fc164178 std.os.linux: Fix tc_oflag_t for PowerPC
std/os/linux.zig:6504:20: error: expected type 'os.linux.NLDLY__enum_11313', found 'comptime_int'
2024-09-19 16:55:00 -07:00
Jay Petacat
812557bfde std: Restore conventional compareFn behavior for binarySearch
PR #20927 made some improvements to the `binarySearch` API, but one
change I found surprising was the relationship between the left-hand and
right-hand parameters of `compareFn` was inverted. This is different
from how comparison functions typically behave, both in other parts of
Zig (e.g. `std.math.order`) and in other languages (e.g. C's `bsearch`).
Unless a strong reason can be identified and documented for doing
otherwise, I think it'll be better to stick with convention.

While writing this patch and changing things back to the way they were,
the predicates of `lowerBound` and `upperBound` seemed to be the only
areas that benefited from the inversion. I don't think that benefit is
worth the cost, personally. Calling `Order.invert()` in the predicates
accomplishes the same goal.
2024-09-16 14:04:18 -07:00
mlugg
1365be5d02
compiler: provide correct result types to += and -=
Resolves: #21341
2024-09-16 16:42:42 +01:00
mlugg
5d7fa5513f std.Build: allow packages to expose arbitrary LazyPaths by name 2024-09-15 17:24:44 -07:00
CrazyboyQCD
8ddce90e62
std.ascii: make toLower toUpper branchless (#21369)
Co-authored-by: WX\shixi <shixi1@cnwxsoft.com>
2024-09-13 17:22:19 -07:00
Alex Rønne Petersen
b56a667ecd start: Rewrite arm code to work for thumb1 too.
0ecc6332b4 improved things for thumb2, but thumb1
has a much smaller permissible instruction set. This commit makes that work.
2024-09-12 20:10:45 -07:00
Linus Groh
e17dfb9da0 std.http.WebSocket: Make 'upgrade: websocket' check case-insensitive
I've seen implementations in the wild that send 'Upgrade: WebSocket',
which currently fails the handshake.

From https://datatracker.ietf.org/doc/html/rfc6455:

"If the response lacks an |Upgrade| header field or the |Upgrade| header
field contains a value that is not an ASCII case-insensitive match for
the value "websocket", the client MUST _Fail the WebSocket Connection_."
2024-09-12 20:02:19 -07:00
mlugg
03c363300f AstGen: do not allow unlabeled break to exit a labeled switch
`break`ing from something which isn't a loop should always be opt-in.
This was a bug in #21257.
2024-09-12 22:52:23 +01:00
Linus Groh
8588964972 Replace deprecated default initializations with decl literals 2024-09-12 16:01:23 +01:00
Andrew Kelley
eccd06f5d0
Merge pull request #21370 from ziglang/fuzz
rework fuzzing API to accept a function pointer parameter
2024-09-11 23:41:51 -07:00
Andrew Kelley
e3f58bd551 add runs per second to fuzzing ui
closes #21025
2024-09-11 19:53:29 -07:00
Andrew Kelley
4fba7336a9
Merge pull request #21269 from alexrp/soft-float
Fix soft float support, split musl triples by float ABI, and enable CI
2024-09-11 17:41:55 -07:00