Commit Graph

9500 Commits

Author SHA1 Message Date
Jakub Konka
d1429a8fa9 lib/std/elf: refactor reloc enum values 2024-02-17 13:13:03 +01:00
Jakub Konka
5fb54736df lib/std/elf: fix typo in R_RISCV_TLSDESC 2024-02-17 12:06:33 +01:00
Jakub Konka
ace1a69a55 elf: add new R_RISCV_TLSDESC reloc type 2024-02-17 11:41:18 +01:00
Jakub Konka
975862aca9 elf: add riscv dynamic relocs 2024-02-17 11:29:06 +01:00
Jakub Konka
5122a3d2d9 lib/std/elf: use enums for relocs 2024-02-17 08:50:53 +01:00
Jakub Konka
70a5dca13e elf: add riscv reloc types 2024-02-17 08:45:42 +01:00
Andrew Kelley
0183b44bb1 std.os.windows: add error.UnrecognizedVolume
Thanks to @matklad for finding this additional NTSTATUS possibility when
calling GetFinalPathNameByHandle.
2024-02-16 00:20:57 -08:00
Andrew Kelley
57d6f789de
Merge pull request #18923 from ianic/add_flate
add deflate implemented from first principles
2024-02-15 10:55:40 -08:00
Andrew Kelley
7204eccf5c
Merge pull request #18945 from mikdusan/issue-18942
std.os.termios: fix tc flag types for macos
2024-02-15 10:43:22 -08:00
tjog
c280811d1d std.Build: fix wrong variable used in parseTargetQuery
Also address clobbering diagnostics field with an assert and
doc comment to use the Target.Query.parse function themselves.

Fixes #18876
2024-02-15 00:00:06 -08:00
Michael Dusan
2ff64c7cb2
std.os.termios: add/fix std.c.TCSA for BSDs 2024-02-15 02:40:11 -05:00
Michael Dusan
50cdb75034
std.os.termios: fix tc flag types for macos
macos uses 64-bits for the flag types.

closes #18942
2024-02-15 02:08:18 -05:00
Michael Dusan
7e83e7d9a8 bsd: debitrot type-safe std.c.O
Minor changes as per 7680c5330c mostly about pipe2() flags.

closes #18927
2024-02-14 19:26:12 -08:00
Tim Culverhouse
bec8511728 std.os: export T struct and winsize struct
Export the T struct and winsize struct for targets which have it defined
in std.c. This struct defines libc constants for ioctl syscalls.
2024-02-14 17:53:37 -08:00
Igor Anić
99cb201438 skip failing wasm tests 2024-02-15 00:35:08 +01:00
Jakub Konka
0c3d5fd1fe lib/std/elf: add aarch64 relocation kinds 2024-02-14 23:39:20 +01:00
Igor Anić
fd9db4962c reorganize compress package root folder 2024-02-14 23:34:13 +01:00
Igor Anić
2457b68b2f remove v1 deflate implementation 2024-02-14 22:34:13 +01:00
Igor Anić
e20080be13 preserve valuable tests from v1 implementation
Before removal of v1.
2024-02-14 22:12:54 +01:00
Igor Anić
0afe808928 remove testing struct sizes
It was usefull during development.

From andrewrk code review comment:
In fact, Zig does not guarantee the @sizeOf structs, and so these tests are not valid.
2024-02-14 21:06:45 +01:00
Andrew Kelley
07c1dd3d1d std.os.windows.OpenFile: add missing error
Encountered in a recent CI run on an aarch64-windows dev kit.

Pretty sure I disabled the virus scanner but it looks like it turned
itself back on with a Windows Update.

Rather than marking the new error code as unreachable in the places
where it is unexpected, this commit makes it return `error.Unexpected`.
2024-02-14 11:14:43 -08:00
Igor Anić
d49cdf5b2d skip calculating struct sizes on 32 bit platforms 2024-02-14 19:58:45 +01:00
Igor Anić
c2361bf548 fix top level docs comments
I didn't understand the difference.

ref: https://ziglang.org/documentation/0.11.0/#Comments
2024-02-14 18:28:20 +01:00
Igor Anić
5fbc371b41 fix wording in comment 2024-02-14 18:28:20 +01:00
Igor Anić
f81b3a2095 fix reading input stream during decompression
By using read instead of readAll decompression reader could get bytes
then available in the stream and then later wrongly failed with end of
stream.
2024-02-14 18:28:20 +01:00
Igor Anić
d645114f7e add deflate implemented from first principles
Zig deflate compression/decompression implementation. It supports compression and decompression of gzip, zlib and raw deflate format.

Fixes #18062.

This PR replaces current compress/gzip and compress/zlib packages. Deflate package is renamed to flate. Flate is common name for deflate/inflate where deflate is compression and inflate decompression.

There are breaking change. Methods signatures are changed because of removal of the allocator, and I also unified API for all three namespaces (flate, gzip, zlib).

Currently I put old packages under v1 namespace they are still available as compress/v1/gzip, compress/v1/zlib, compress/v1/deflate. Idea is to give users of the current API little time to postpone analyzing what they had to change. Although that rises question when it is safe to remove that v1 namespace.

Here is current API in the compress package:

```Zig
// deflate
    fn compressor(allocator, writer, options) !Compressor(@TypeOf(writer))
    fn Compressor(comptime WriterType) type

    fn decompressor(allocator, reader, null) !Decompressor(@TypeOf(reader))
    fn Decompressor(comptime ReaderType: type) type

// gzip
    fn compress(allocator, writer, options) !Compress(@TypeOf(writer))
    fn Compress(comptime WriterType: type) type

    fn decompress(allocator, reader) !Decompress(@TypeOf(reader))
    fn Decompress(comptime ReaderType: type) type

// zlib
    fn compressStream(allocator, writer, options) !CompressStream(@TypeOf(writer))
    fn CompressStream(comptime WriterType: type) type

    fn decompressStream(allocator, reader) !DecompressStream(@TypeOf(reader))
    fn DecompressStream(comptime ReaderType: type) type

// xz
   fn decompress(allocator: Allocator, reader: anytype) !Decompress(@TypeOf(reader))
   fn Decompress(comptime ReaderType: type) type

// lzma
    fn decompress(allocator, reader) !Decompress(@TypeOf(reader))
    fn Decompress(comptime ReaderType: type) type

// lzma2
    fn decompress(allocator, reader, writer !void

// zstandard:
    fn DecompressStream(ReaderType, options) type
    fn decompressStream(allocator, reader) DecompressStream(@TypeOf(reader), .{})
    struct decompress
```

The proposed naming convention:
 - Compressor/Decompressor for functions which return type, like Reader/Writer/GeneralPurposeAllocator
 - compressor/compressor for functions which are initializers for that type, like reader/writer/allocator
 - compress/decompress for one shot operations, accepts reader/writer pair, like read/write/alloc

```Zig
/// Compress from reader and write compressed data to the writer.
fn compress(reader: anytype, writer: anytype, options: Options) !void

/// Create Compressor which outputs the writer.
fn compressor(writer: anytype, options: Options) !Compressor(@TypeOf(writer))

/// Compressor type
fn Compressor(comptime WriterType: type) type

/// Decompress from reader and write plain data to the writer.
fn decompress(reader: anytype, writer: anytype) !void

/// Create Decompressor which reads from reader.
fn decompressor(reader: anytype) Decompressor(@TypeOf(reader)

/// Decompressor type
fn Decompressor(comptime ReaderType: type) type

```

Comparing this implementation with the one we currently have in Zig's standard library (std).
Std is roughly 1.2-1.4 times slower in decompression, and 1.1-1.2 times slower in compression. Compressed sizes are pretty much same in both cases.
More resutls in [this](https://github.com/ianic/flate) repo.

This library uses static allocations for all structures, doesn't require allocator. That makes sense especially for deflate where all structures, internal buffers are allocated to the full size. Little less for inflate where we std version uses less memory by not preallocating to theoretical max size array which are usually not fully used.

For deflate this library allocates 395K while std 779K.
For inflate this library allocates 74.5K while std around 36K.

Inflate difference is because we here use 64K history instead of 32K in std.

If merged existing usage of compress gzip/zlib/deflate need some changes. Here is example with necessary changes in comments:

```Zig

const std = @import("std");

// To get this file:
// wget -nc -O war_and_peace.txt https://www.gutenberg.org/ebooks/2600.txt.utf-8
const data = @embedFile("war_and_peace.txt");

pub fn main() !void {
    var gpa = std.heap.GeneralPurposeAllocator(.{}){};
    defer std.debug.assert(gpa.deinit() == .ok);
    const allocator = gpa.allocator();

    try oldDeflate(allocator);
    try new(std.compress.flate, allocator);

    try oldZlib(allocator);
    try new(std.compress.zlib, allocator);

    try oldGzip(allocator);
    try new(std.compress.gzip, allocator);
}

pub fn new(comptime pkg: type, allocator: std.mem.Allocator) !void {
    var buf = std.ArrayList(u8).init(allocator);
    defer buf.deinit();

    // Compressor
    var cmp = try pkg.compressor(buf.writer(), .{});
    _ = try cmp.write(data);
    try cmp.finish();

    var fbs = std.io.fixedBufferStream(buf.items);
    // Decompressor
    var dcp = pkg.decompressor(fbs.reader());

    const plain = try dcp.reader().readAllAlloc(allocator, std.math.maxInt(usize));
    defer allocator.free(plain);
    try std.testing.expectEqualSlices(u8, data, plain);
}

pub fn oldDeflate(allocator: std.mem.Allocator) !void {
    const deflate = std.compress.v1.deflate;

    // Compressor
    var buf = std.ArrayList(u8).init(allocator);
    defer buf.deinit();
    // Remove allocator
    // Rename deflate -> flate
    var cmp = try deflate.compressor(allocator, buf.writer(), .{});
    _ = try cmp.write(data);
    try cmp.close(); // Rename to finish
    cmp.deinit(); // Remove

    // Decompressor
    var fbs = std.io.fixedBufferStream(buf.items);
    // Remove allocator and last param
    // Rename deflate -> flate
    // Remove try
    var dcp = try deflate.decompressor(allocator, fbs.reader(), null);
    defer dcp.deinit(); // Remove

    const plain = try dcp.reader().readAllAlloc(allocator, std.math.maxInt(usize));
    defer allocator.free(plain);
    try std.testing.expectEqualSlices(u8, data, plain);
}

pub fn oldZlib(allocator: std.mem.Allocator) !void {
    const zlib = std.compress.v1.zlib;

    var buf = std.ArrayList(u8).init(allocator);
    defer buf.deinit();

    // Compressor
    // Rename compressStream => compressor
    // Remove allocator
    var cmp = try zlib.compressStream(allocator, buf.writer(), .{});
    _ = try cmp.write(data);
    try cmp.finish();
    cmp.deinit(); // Remove

    var fbs = std.io.fixedBufferStream(buf.items);
    // Decompressor
    // decompressStream => decompressor
    // Remove allocator
    // Remove try
    var dcp = try zlib.decompressStream(allocator, fbs.reader());
    defer dcp.deinit(); // Remove

    const plain = try dcp.reader().readAllAlloc(allocator, std.math.maxInt(usize));
    defer allocator.free(plain);
    try std.testing.expectEqualSlices(u8, data, plain);
}

pub fn oldGzip(allocator: std.mem.Allocator) !void {
    const gzip = std.compress.v1.gzip;

    var buf = std.ArrayList(u8).init(allocator);
    defer buf.deinit();

    // Compressor
    // Rename compress => compressor
    // Remove allocator
    var cmp = try gzip.compress(allocator, buf.writer(), .{});
    _ = try cmp.write(data);
    try cmp.close(); // Rename to finisho
    cmp.deinit(); // Remove

    var fbs = std.io.fixedBufferStream(buf.items);
    // Decompressor
    // Rename decompress => decompressor
    // Remove allocator
    // Remove try
    var dcp = try gzip.decompress(allocator, fbs.reader());
    defer dcp.deinit(); // Remove

    const plain = try dcp.reader().readAllAlloc(allocator, std.math.maxInt(usize));
    defer allocator.free(plain);
    try std.testing.expectEqualSlices(u8, data, plain);
}

```
2024-02-14 18:28:20 +01:00
Andrew Kelley
5f92558290 std.posix.termios: bring V back
In d7563a7753, I misunderstood what `cc_t`
was supposed to do. Those V enum values are indices into the array.
2024-02-13 20:10:32 -08:00
Felix Kollmann
8addf53fb5
Add timedWait to std.Thread.Semaphore (#18805)
* Add `timedWait` to `std.Thread.Semaphore`

Add example to documentation of `std.Thread.Semaphore`

* Add unit test for thread semaphore timed wait

Fix missing try

* Change unit test to be simpler

* Change `timedWait()` to keep a deadline

* Change `timedWait()` to return earlier in some scenarios

* Change `timedWait()` to keep a deadline (based on std.Timer)

(similar to std.Thread.Futex)

---------

Co-authored-by: protty <45520026+kprotty@users.noreply.github.com>
2024-02-13 11:51:42 -06:00
Andrew Kelley
ce3bd51597 std.os.termios: move it to be with the group 2024-02-12 21:58:37 -07:00
Andrew Kelley
e1ab57337f std.c.speed_t: consolidate common across os 2024-02-12 21:53:54 -07:00
Andrew Kelley
ae107cf71b std.os.speed_t: add type safety
and collect the missing flag bits from all the operating systems.
2024-02-12 21:49:09 -07:00
Andrew Kelley
a280ff2767 std.os.termios: add type safety to lflag field
This creates `tc_cflag_t` even though such a type is not defined by
libc.

I also collected the missing flag bits from all the operating systems.
2024-02-12 21:21:45 -07:00
Andrew Kelley
e97fa8b038 std.os.termios: add type safety to cflag field
This creates `tc_cflag_t` even though such a type is not defined by
libc.

I also collected the missing flag bits from all the operating systems.
2024-02-12 18:24:07 -07:00
Andrew Kelley
20abc0caee std.os.termios: add type safety to oflag field
This creates `tc_oflag_t` even though such a type is not defined by
libc.

I also collected the missing flag bits from all the operating systems.
2024-02-12 17:28:09 -07:00
Andrew Kelley
47643cc5cc std.os.termios: add type safety to iflag field
This creates `tc_iflag_t` even though such a type is not defined by
libc.

I also collected the missing flag bits from all the operating systems.
2024-02-12 16:43:51 -07:00
Andrew Kelley
0c88f927f1 std.os.termios: consolidate and correct 2024-02-12 16:21:21 -07:00
Andrew Kelley
9a64318554 std.c.NCSS: consolidate and correct 2024-02-12 15:52:13 -07:00
Andrew Kelley
9bdf1ebe36 std.c.cc_t: consolidate same OS values 2024-02-12 15:44:28 -07:00
Andrew Kelley
5258c3caad std: add type safety to cc_t 2024-02-12 15:41:38 -07:00
CPestka
0c725a354a Replaced loop with memcpys 2024-02-12 12:58:33 -08:00
Andrew Kelley
fad5e7a997
Merge pull request #18898 from psnszsn/iouring_waitid
io_uring: add waitid operation
2024-02-12 12:20:12 -08:00
Andrew Kelley
0c1b9992fd
Merge pull request #18821 from jacobly0/x86_64-tests
x86_64: pass more tests
2024-02-12 12:18:03 -08:00
Andrew Kelley
f995c1b08a std.c.O: fix illumos regression
introduced in c3eb592a34
2024-02-12 01:06:27 -07:00
Jacob Young
e27db373ec x86_64: implement @clz and @ctz of big integers 2024-02-12 05:25:07 +01:00
Jacob Young
d894727873 x86_64: implement @byteSwap of big integers 2024-02-12 05:25:07 +01:00
Jacob Young
271505cfc8 x86_64: fix compiler_rt tests 2024-02-12 05:25:07 +01:00
Jacob Young
bcbd49b2a6 x86_64: implement shifts of big integers 2024-02-12 05:25:07 +01:00
Jacob Young
9023ff04d0 x86_64: fix register clobber 2024-02-12 05:25:07 +01:00
Jacob Young
a9f738e56b x86_64: implement c abi for bool vectors 2024-02-12 05:25:07 +01:00
Jacob Young
7c9a96111c x86_64: fix assert location 2024-02-12 05:25:07 +01:00
Jacob Young
6235762c09 x86_64: implement mul, div, and mod of large integers
This enables the last compiler-rt test disabled for the x86_64 backend.
2024-02-12 05:25:07 +01:00
Andrew Kelley
7680c5330c some API work on std.c, std.os, std.os.wasi
* std.c: consolidate some definitions, making them share code. For
  example, freebsd, dragonfly, and openbsd can all share the same
  `pthread_mutex_t` definition.
* add type safety to std.c.O
  - this caught a bug where mode flags were incorrectly passed as the
    open flags.
* 3 fewer uses of usingnamespace keyword
* as per convention, remove purposeless field prefixes from struct field
  names even if they have those prefixes in the corresponding C code.
* fix incorrect wasi libc Stat definition
* remove C definitions from incorrectly being in std.os.wasi
* make std.os.wasi definitions type safe
* go through wasi native APIs even when linking libc because the libc
  APIs are problematic and wasteful
* don't expose WASI definitions in std.posix
* remove std.os.wasi.rights_t.ALL: this is a footgun. should it be all
  future rights too? or only all current rights known? both are
  the wrong answer.
2024-02-11 13:38:55 -07:00
Vlad Pănăzan
d2789908ed io_uring: add waitid operation
This is the equivalent of a waitid(2) syscall and can be used to
be notified about child process state changes.

Available since kernel 6.7
2024-02-11 15:47:03 +01:00
Vlad Pănăzan
20ea0012f0 linux: add missing io_uring opcodes 2024-02-11 15:43:12 +01:00
Jakub Konka
d12c8db642
Merge pull request #18875 from ziglang/macho-zo-dwarf
macho: emit DWARF for ZigObject relocatable
2024-02-09 23:12:04 +01:00
Prokop Randacek
6fb23542fe Buffer the logging function
The default logging function used to have no buffer. So a single log
statement could result in many individual write syscalls each writing
only a couple of bytes.

After this change the logging function now has a 4kb buffer. Only log
statements longer than 4kb now do multiple write syscalls.

4kb is the default bufferedWriter size and was choosen arbitrarily.

The downside of this is that the log function now allocates 4kb more
stack space but I think that is an acceptable trade-off.
2024-02-09 14:02:57 -08:00
Andrew Kelley
32f30399e5
Merge pull request #18867 from e4m2/random
std.rand: Move to std.Random
2024-02-09 13:42:04 -08:00
Andrew Kelley
54bbc73f85
Merge pull request #18712 from Vexu/std.options
std: make options a struct instance instead of a namespace
2024-02-09 13:38:42 -08:00
Jakub Konka
32386a06ca builtin: enable panic handler on self-hosted macho
comp: toggle compiler-rt and zig-libc caps for macho
2024-02-08 23:51:21 +01:00
e4m2
60639ec83d Fixup filename casing 2024-02-08 15:39:28 +01:00
e4m2
8d56e472c9 Replace std.rand references with std.Random 2024-02-08 15:21:35 +01:00
e4m2
9af077d71e std.rand: Move to std.Random 2024-02-08 14:43:20 +01:00
Jacob Young
919a3bae1c http: protect against zero-length chunks
A zero-length chunk marks the end of the body, so prevent any from
possibly occurring in the middle of the body.
2024-02-08 01:29:49 -08:00
Andrew Kelley
3122fd0ba0
Merge pull request #17634 from ianprime0509/type-erased-writer
Add type-erased writer and GenericWriter
2024-02-07 23:52:53 -08:00
Andrew Kelley
ba8375328c
Merge pull request #18718 from schmee/bounds
Add upperBound, lowerBound, and equalRange
2024-02-07 18:48:41 -08:00
Andrew Kelley
42fcca49c5
Merge pull request #18846 from ziglang/std.os.linux.MAP
std.os.MAP: use a packed struct
2024-02-07 13:55:03 -08:00
John Schmidt
e487b576fa Changes to lowerBound/upperBound/equalRange
The old definitions had some problems:

- In `lowerBound`, the `lhs` (left hand side) argument was passed on the
  right hand side.
- In `upperBound`, the `greaterThan` function needed to return
  `greaterThanOrEqual` for the function work, so either the name or the
  implementation is incorrect.

To fix both problems, define the functions in terms of a `lessThan` function that returns `lhs < rhs`.
The is more consistent with the rest of `sort.zig` and it's also how C++ implements lower/upperBound (1)(2).

(1) https://en.cppreference.com/w/cpp/algorithm/lower_bound
(2) https://en.cppreference.com/w/cpp/algorithm/upper_bound

- Rewrite doc comments.
- Add a couple of more test cases.
- Add docstring for std.sort.binarySearch
2024-02-07 21:00:24 +01:00
Craig O'Connor
664c18544c Add lowerBound/upperBound/equalRange
Authored by https://github.com/CraigglesO

Original Discussion: #9890

I already had to create these functions and test cases for my own
project so I decided to contribute to the main code base in hopes it
would simplify my own.

I realize this is still under discussion but this was a trivial amount
of work so I thought I could help nudge the discussion towards a
decision.

Why add these to the standard library

To better illustrate and solidify their value, the standard library's
"sort" module already contains several binary search queries on arrays
such as binarySearch and internal functions binaryFirst & binaryLast. A
final example of its use: the Zig code itself created and used a
bounding search in the linker.

There still lacks the ability to allow the programmer themselves to
search the array for a rough position and find an index to read &/
update.

Adding these functions would also help to complement dynamic structures
like ArrayList with it's insert function.

Example Case

I'm building a library in Zig for GIS geometry. To store points, lines,
and polygons each 3D point is first translated into what's called an
S2CellId. This is a fancy way of saying I reduce the Earth's spherical
data into a 1D Hilbert Curve with cm precision. This gives me 2
convenient truths:

    Hilbert Curves have locality of reference.
    All points can be stored inside a 1D array

Since lowerBound and upperBound to find data inside a radius for
instance. If I'm interested in a specific cell at a specific "level" and
want to iterate all duplicates, equalRange is a best fit.
2024-02-07 21:00:24 +01:00
Ian Kerins
ee36131e6a doc: fix typo in getEnvMap 2024-02-07 12:41:40 +02:00
Andrew Kelley
a60f219660 std.c.MAP: use a packed struct
Same as previous commit, but for the libc interface.
2024-02-06 22:06:01 -07:00
Andrew Kelley
9f3165540e std.os.linux.MAP: use a packed struct
Introduces type safety to this constant. Eliminates one use of
`usingnamespace`.
2024-02-06 21:12:11 -07:00
Matthew Lugg
0c80725068
Merge pull request #18814 from mlugg/incremental-dependencies
Begin re-implementing incremental compilation
2024-02-06 11:33:07 +00:00
Andrew Kelley
39ec3d3116
Merge pull request #18822 from alichraghi/shader
spirv: basic shader support
2024-02-05 13:30:52 -08:00
Samuel Fiedler
0266017b59 Make EfiPhysicalAddress in std/os/uefi/tables.zig public 2024-02-05 15:31:33 +00:00
Ali Chraghi
be32ae0534 std: add gpu namespace 2024-02-05 11:55:14 +03:30
Ali Chraghi
afa7793351 spirv: basic shader support 2024-02-05 11:55:14 +03:30
Robin Voetter
7634a115c5
Merge pull request #18580 from Snektron/spirv-more-vectors
spirv: more vector operations
2024-02-05 09:24:49 +01:00
Jacob Young
aebf20cc9a compiler_rt: avoid referencing symbol on versions where it doesn't exist
This change causes `__isPlatformVersionAtLeast` to no longer exist in
compiler_rt when targetting a min os version earlier than 10.15, which
is earlier than the default os version and so only affects builds that
explicitly target an older version than Zig officially supports.
2024-02-05 03:17:57 -05:00
Jacob Young
eaa6218f09 x86_64: fix errors compiling the compiler
This fixes issues targetting both `x86_64-linux` and `x86_64-macos` with
the self-hosted backend.
2024-02-04 22:58:38 -05:00
mlugg
1e91ee1e05
Zir: store extra source hashes required for incremental
Also add corresponding invaidation logic to Zcu. Therefore, the only
invalidation logic which is not yet in place is `decl_val` dependencies.
2024-02-04 18:38:39 +00:00
Robin Voetter
3ef5b80d2c
std: use simple eqlBytes for spirv
The SPIR-V backend doesn't support the advanced
eqlBytes yet, and when it does, it likely that it
will be detrimental.
2024-02-04 19:08:57 +01:00
Andrew Kelley
3c7970dc4e
Merge pull request #18801 from jacobly0/fix-cache-retry
Cache: fix logic for retrying cache hits
2024-02-04 01:45:37 -08:00
Andrew Kelley
d3fc2648cc
Merge pull request #18778 from ziglang/system-package-mode
Implement system package mode and lazy dependencies
2024-02-04 01:44:12 -08:00
Jacob Young
26cb72086a Cache: fix logic for retrying cache hits
Fixes potentially #16149
2024-02-04 03:48:29 +01:00
lockbox
a65bc8d071 fix typo in wasm atomic opcodes doc comment 2024-02-04 00:25:05 +01:00
Chadwain Holness
6030855097
std.fmt: fix formatting slices of structs with custom formatting
`hasMethod` doesn't make sense for pointers to more than one item.
2024-02-03 21:47:55 +00:00
Andrew Kelley
18091b4406 std.Build: use a runtime panic for wrong dependency API
This makes it easier to debug and avoids a false positive compile error
in the build script.
2024-02-02 20:43:01 -07:00
Andrew Kelley
a17505c711 zig build: avoid using stdout for communication with runner
Pass the required lazy dependencies from the build runner to the parent
process via a tmp file instead of stdout. I'll reproduce this comment to
explain it:

The `zig build` parent process needs a way to obtain results from the
configuration phase of the child process. In the future, the make phase
will be executed in a separate process than the configure phase, and we
can then use stdout from the configuration phase for this purpose.

However, currently, both phases are in the same process, and Run Step
provides API for making the runned subprocesses inherit stdout and stderr
which means these streams are not available for passing metadata back
to the parent.

Until make and configure phases are separated into different processes,
the strategy is to choose a temporary file name ahead of time, and then
read this file in the parent to obtain the results, in the case the child
exits with code 3.

This commit also extracts some common logic from the loop that rebuilds
the build runner so that it does not run again when the build runner is
rebuilt.
2024-02-02 20:43:01 -07:00
Andrew Kelley
252f4ab2a5 build system: implement lazy dependencies, part 1
Build manifest files support `lazy: true` for dependency sections.
This causes the auto-generated dependencies.zig to have 2 more
possibilities:
1. It communicates whether a dependency is lazy or not.
2. The dependency might be acknowledged, but missing due to being lazy
   and not fetched.

Lazy dependencies are not fetched by default, but if they are already
fetched then they are provided to the build script.

The build runner reports the set of missing lazy dependenices that are
required to the parent process via stdout and indicates the situation
with exit code 3.

std.Build now has a `lazyDependency` function. I'll let the doc comments
speak for themselves:

When this function is called, it means that the current build does, in
fact, require this dependency. If the dependency is already fetched, it
proceeds in the same manner as `dependency`. However if the dependency
was not fetched, then when the build script is finished running, the
build will not proceed to the make phase. Instead, the parent process
will additionally fetch all the lazy dependencies that were actually
required by running the build script, rebuild the build script, and then
run it again.
In other words, if this function returns `null` it means that the only
purpose of completing the configure phase is to find out all the other
lazy dependencies that are also required.
It is allowed to use this function for non-lazy dependencies, in which
case it will never return `null`. This allows toggling laziness via
build.zig.zon without changing build.zig logic.

The CLI for `zig build` detects this situation, but the logic for then
redoing the build process with these extra dependencies fetched is not
yet implemented.
2024-02-02 20:43:01 -07:00
Andrew Kelley
434a6a4f63 std.process.Child: use unreachable instead of @panic
This is how assertions work in zig.
2024-02-02 20:43:01 -07:00
Andrew Kelley
a68defbc65 std.Build: make systemIntegrationOption take a default 2024-02-02 20:43:01 -07:00
Andrew Kelley
ed4ccea7ba build system: implement --system [dir]
This prevents package fetching and enables system_package_mode in the
build system which flips the defaults for system integrations.
2024-02-02 20:43:01 -07:00
Andrew Kelley
22537873f4 build system: implement --release[=mode]
This allows a `zig build` command to specify intention to create a
release build, regardless of what per-project options exist. It also
allows the command to specify a "preferred optimization mode", which is
chosen if the project itself does not choose one (in other words, the
project gets first choice). If neither the build command nor the project
specify a preferred release mode, an error occurs.
2024-02-02 20:43:01 -07:00
Andrew Kelley
f18576afad std.Build.resolveTargetQuery: fix ignoring ofmt for native 2024-02-02 20:43:01 -07:00
Andrew Kelley
2637b57376 std.Build: make system library integrations more general
Before it was named "library" inconsistently.

Now the CLI args are -fsys=[name] and -fno-sys=[name] and it is a more
general-purpose "system integration" which could be a library name or
perhaps a project name such as "ffmpeg" or a binary such as "nasm".
2024-02-02 20:43:01 -07:00
Andrew Kelley
370438943e std.Build: revert moving some fields to Graph
On second thought, let's keep a bunch of these flags how they already
were.

Partial revert of the previous commit.
2024-02-02 20:43:01 -07:00
Andrew Kelley
105db13536 std.Build: implement --host-target, --host-cpu, --host-dynamic-linker
This also makes a long-overdue change of extracting common state from
Build into a shared Graph object.

Getting the semantics right for these flags turned out to be quite
tricky. In the end it works like this:
* The override only happens when the target is fully native, with no
  additional query parameters, such as versions or CPU features added.
* The override affects the resolved Target but leaves the original Query
  unmodified.
* The "is native?" detection logic operates on the original, unmodified
  query. This makes it possible to provide invalid host target
  information, causing confusing errors to occur. Don't do that.

There are some minor breaking changes to std.Build API such as the fact
that `b.zig_exe` is now moved to `b.graph.zig_exe`, as well as a handful
of other similar flags.
2024-02-02 20:43:01 -07:00
Andrew Kelley
bd1d2b0ae2 std.Target.Query: avoid using builtin.target.abi
This value is very likely incorrect. When glibc_version is provided but
no explicit ABI is provided, use the string "gnu" instead.
2024-02-02 20:43:01 -07:00
Andrew Kelley
8f867eaf84 build system: introduce system library integration
* New --help section
* Add b.systemLibraryOption
* Rework the build runner CLI logic a bit
2024-02-02 20:43:01 -07:00
Ryan Liptak
f2e249e920 fs tests: Make path type show up in stack traces of testWithAllSupportedPathTypes
This allows for easier debugging without the need to print out the path type to stderr.

Context: 5a3ae38f3b
2024-02-02 18:03:17 -08:00
Jacob Young
5e791e8e07 tls: support ed25519 signatures
Which were claimed to be supported during the handshake but were not
actually implemented.
2024-02-02 17:27:26 -08:00
Jakub Konka
92deebcd66 cli+build: handle -ObjC flag and route it to MachO linker 2024-02-02 22:00:16 +01:00
Andrew Kelley
5a3ae38f3b std: remove garbage being printed to stderr during unit tests 2024-02-01 18:05:14 -07:00
mlugg
8944935499 std: eliminate some uses of usingnamespace
This eliminates some simple usages of `usingnamespace` in the standard
library. This construct may in future be removed from the language, and
is generally an inappropriate way to formulate code. It is also
problematic for incremental compilation, which may not initially support
projects using it.

I wasn't entirely sure what the appropriate namespacing for the types in
`std.os.uefi.tables` would be, so I ofted to preserve the current
namespacing, meaning this is not a breaking change. It's possible some
of the moved types should instead be namespaced under `BootServices`
etc, but this can be a future enhancement.
2024-02-01 20:30:42 +00:00
Veikka Tuominen
a4f27e8987 remove std.io.Mode 2024-02-01 15:22:36 +02:00
Veikka Tuominen
b0bea72588 remove std.event 2024-02-01 15:22:36 +02:00
Veikka Tuominen
8d11ade6a7 std: change return type of wasiCwd
`fd_t` is not declared on freestanding so returning a `Dir` causes an error.
2024-02-01 15:22:36 +02:00
Veikka Tuominen
07dbff4f44 std.start: remove event loop integration 2024-02-01 15:22:36 +02:00
Veikka Tuominen
220d3264c9 std: make options a struct instance instead of a namespace 2024-02-01 15:22:36 +02:00
Jacob Young
c1e7d0c08f http: optimize allocations for proxy basic authorization 2024-01-31 15:00:27 +01:00
Jacob Young
a111f805cd http: avoid allocator use when encoding basic authorization 2024-01-31 15:00:27 +01:00
Jacob Young
82b37ea024 http: support basic access authentication 2024-01-31 12:05:12 +01:00
Gustavo C. Viegas
fc48bbdf90 std.Build.Step.TranslateC: fix use of outdated Module in createModule 2024-01-31 02:46:05 +02:00
Constantin Pestka
e460ba66a5
std: add docs about return value of submit() (#18721)
being misleading if used alongside with IORING_SETUP_SQPOLL
2024-01-29 21:26:52 -05:00
Krzysztof Wolicki
d8981dc493
std.os: fix chdirZ to compile on Windows (#18695) 2024-01-29 21:19:07 -05:00
Ian Johnson
cc25756b3f Eliminate generic duplication in allocPrint
Since `bufPrint` and `count` both control the writers used internally,
they can leverage type-erased writers while maintaining correct error
handling. This reduces generic instantiations when using `allocPrint`,
which calls both `count` and `bufPrint` internally.
2024-01-29 19:02:18 -05:00
Ian Johnson
e392c1a0b3 Add type-erased writer and GenericWriter
This is a companion to #17344 to apply the same change to the
`std.io.Writer` interface.
2024-01-29 19:02:18 -05:00
Jacob Young
4dfca01de4 gzip: implement compression 2024-01-29 14:30:23 -08:00
Ian Johnson
27d2d8e81f Apply cflags from pkg-config to all dependent modules
Closes #18628

This commit splits the arguments obtained from pkg-config into two
groups, cflags and libs, and consistently applies the cflags to each
individual module linking the library while applying the libs only once
for each compilation.
2024-01-29 14:08:41 -08:00
Christian Flicker
9c7fa358c1
std.Thread: fix off-by-one in PosixThreadImpl (#18711)
by removing ZST special case
2024-01-29 11:07:21 -05:00
Veikka Tuominen
c085c6ecdd std: remove meta.globalOption 2024-01-27 13:56:32 -08:00
Krzysztof Wolicki
190ea02e0d os.windows: Fix missing correction from #18657 2024-01-27 12:38:33 -08:00
Andrew Kelley
608d5e6fb7
Merge pull request #18676 from MrDmitry/feat/improve_cmake_replace_values
std.Build.Step.ConfigHeader (cmake): rewrite variable expansion
2024-01-27 12:38:02 -08:00
Pavel Verigo
87733171b6 parser: fix "else" followed by "comptime" 2024-01-27 16:20:47 +02:00
MrDmitry
c84e086a2f Get rid of direct dependency on std.fmt
Replace unnecessary panic with step error
2024-01-26 15:59:05 -05:00
MrDmitry
9ecbf53388 Minor formatting, removed duplicate test case 2024-01-26 13:33:17 -05:00
MrDmitry
3e6f07e617 Add escaped character processing 2024-01-26 13:33:17 -05:00
MrDmitry
834f8d45ba Rewrite replace_variables with CMake-specific version
Behavior matches CMake's CMP0053 policy that is the current standard for
variable expansion for `configure_file()`
2024-01-26 13:33:17 -05:00
Tobias Simetsreiter
20abf1394a align naming and fix module creation from TranslateC 2024-01-26 15:25:52 +02:00
Zachary Raineri
b36dd55af5 std.os.wasi | Fix comment links
Branch was renamed: master -> main
Preview 1 was moved to legacy
2024-01-26 15:24:07 +02:00
Jakub Konka
5226705b32 std.macho: add segment flags 2024-01-24 12:48:12 +01:00
Andrew Kelley
92211135f1
Merge pull request #17155 from winterqt/ignore-nix-ldflags-linkage-directives
std.zig.system.NativePaths: ignore linkage directives in `NIX_LDFLAGS`
2024-01-24 00:01:23 -08:00
Krzysztof Wolicki
eff58d6c18 os.windows: Fix error 258 name in Win32Error 2024-01-23 18:06:23 -08:00
Andrew Kelley
f37513aa68 NativePaths: support -L and -l arguments in NIX_LDFLAGS
A slightly more robust parsing of these flags in case of a separate
argument appearing after "-L" in the flags.
2024-01-23 18:01:59 -07:00
Winter
6f3ee587ba std.zig.system.NativePaths: ignore linkage directives in NIX_LDFLAGS
`NIX_LDFLAGS` typically contains just `-rpath` and `-L`, which we already
handle. However, at least one setup hook in Nixpkgs [0] adds a linkage
directive to it. To prevent library paths from being missed (as I've
observed myself with `NIX_LDFLAGS` being `-liconv ...`, making it so that
*all* paths are missed), let's just skip over them.

[0]: 08f615eb1b/pkgs/development/libraries/libiconv/setup-hook.sh
2024-01-23 17:49:25 -07:00
Khang Nguyen Duy
993a83081a std.fmt: fix unecessary deref on user-defined format function
When formatting a pointer to user type, currently it needs to be
dereferenced first, then call `formatType` on the child type.

Fix the problem by checking for "format" function on not only the type
itself, but also the struct it points to. Add hasMethod to std.meta.
2024-01-23 01:03:45 -08:00
Tristan Ross
c0e0bb385c std.process: return u64 in totalSystemMemory 2024-01-23 00:17:53 -08:00
Littleote
3331c5e7af Free threads in std.Thread.Pool.init only with pool.join
Free the allocated threads in the initialization of a thread pool only with pool.join instead of additionally calling allocator.free causing free to be called twice.

Resolves #18643
2024-01-22 11:24:35 -08:00
Tristan Ross
d0da3d731e std.io: replace readStructBig with readStructEndian 2024-01-22 10:53:27 -08:00
Andrew Kelley
ce7c66e2d0 langref: make more consistent
* moves some langref into std.builtin doc comments
* use the same way of referencing stuff from std.builtin

closes #16483
2024-01-21 20:39:50 -07:00
Andrew Kelley
2d9c4792ae std.fmt: clarify the use of "character"
Currently, std.fmt has a misguided, half-assed Unicode implementation
with an ambiguous definition of the word "character". This commit does
almost nothing to mitigate the problem, but it lets me close an open PR.

In the future I will revert 473cb1fd74 as
well as 279607cae5, and redo the whole
std.fmt API, breaking everyone's code and unfortunately causing nearly
every Zig user to have a bad day. std.fmt will go back to only dealing
in bytes, with zero Unicode awareness whatsoever. I suggest a third
party package provide Unicode functionality as well as a more advanced
text formatting function for when Unicode awareness is needed. I have
always suggested this, and I sincerely apologize for merging pull
requests that compromised my stance on this matter.

Most applications should, instead, strive to make their code independent
of Unicode, dealing strictly in encoded UTF-8 bytes, and never attempt
operations such as: substring manipulation, capitalization, alignment,
word replacement, or column number calculations.

Exceptions to this include web browsers, GUI toolkits, and terminals. If
you're not making one of these, any dependency on Unicode is probably a
bug or worse, a poor design decision.

closes #18536
2024-01-21 20:31:13 -07:00
Andrew Kelley
ac29303321
Merge pull request #18634 from MrDmitry/bug/ConfigHeader_cmake_neighbors
std.Build.Step.ConfigHeader (cmake): fix offset calculation for multiple substitutions on a single line
2024-01-21 12:45:21 -08:00
Christiano Haesbaert
bf7ebfa67a Handle all errors on std.net.Ipv4address.resolveIP
The following test fails since NonCanonical is not handled

test "foo" {
    std.net.Ip4Address.resolveIp("1.1.1.1", 0) catch unreachable;
}

/usr/lib/zig/std/net.zig:240:60: error: switch must handle all possibilities
        if (parse(name, port)) |ip4| return ip4 else |err| switch (err) {
                                                           ^~~~~~
/usr/lib/zig/std/net.zig:240:60: note: unhandled error value: 'error.NonCanonical'
referenced by:
    test.foo: src/dhcp.zig:383:23
2024-01-21 11:20:03 +02:00
MrDmitry
2dfec13ef0 Fix last_index after variable substitution
Iterative passes should start at the end of the previous substitution
2024-01-21 03:16:09 -05:00
Andrew Kelley
10aff67502
Merge pull request #18596 from ypsvlq/mingw
mingw-w64: add missing CRT sources
2024-01-20 12:01:33 -08:00
Andrew Kelley
5c4cb60f4f
Merge pull request #18622 from ziglang/zig-mod-edge-case
build system: better handle modules that do not have a zig root source file
2024-01-20 03:22:02 -08:00
expikr
b729a3f008
std.math: make hypot infer type from argument (#17910)
using peer type resolution
2024-01-20 01:32:07 -05:00
hdert
314533c28b std/math/pow: Fix #18553, isOddInteger: Return false if float value is greater than 1 << 53 (see comment), add test cases 2024-01-19 22:00:04 -08:00
Andrew Kelley
2dea375450 std.Build.Compile: handle modules sans root source files
Uses the new `-M[name][=src]` CLI syntax to omit the source when the
module does not have a zig root source file.

Only some kinds of link objects imply that this should happen.
2024-01-19 22:28:07 -07:00
Andrew Kelley
480a2f7f02
Merge pull request #18293 from g-cassie/array-list-replace-range-assume
Add replaceRangeAssumeCapacity method to ArrayList
2024-01-19 21:10:09 -08:00
Elaine Gibson
398ab5fcfb mingw: update build logic 2024-01-20 00:24:39 +00:00
Elaine Gibson
b126978555 mingw-w64: remove msvcrt sources 2024-01-20 00:21:34 +00:00
Elaine Gibson
bbecbaab0a mingw-w64: add missing CRT sources 2024-01-20 00:21:34 +00:00
Meghan Denny
46d592e485 do not enforce function parameters to be marked comptime if only called at comptime 2024-01-19 15:31:18 -08:00
Andrew Kelley
827e30634f std.ArrayList: pedantic fixups to previous commit
* fix and clarify incorrect doc comments
* unify the pattern of calling unmanaged methods
2024-01-19 16:24:51 -07:00
Gordon Cassie
4ddd0b1a1b std.ArrayList: add replaceRangeAssumeCapacity method 2024-01-19 16:24:51 -07:00
Andrew Kelley
d7b6d637df
Merge pull request #18615 from ziglang/langref
miscellaneous documentation changes
2024-01-19 12:14:30 -08:00
Andrew Kelley
3c16e80372
Merge pull request #18611 from erikarvstedt/array-list-overflow
ArrayList: remove unneeded overflow checks
2024-01-19 12:10:00 -08:00
Andrew Kelley
ab82132749 zig build: add doc comments for functions related to options
closes #18204
2024-01-18 22:01:09 -07:00
Erik Arvstedt
c50ba2d101 std.ArrayList.replaceRange: remove unneded overflow checks
The code asserted that the range to be replaced is within bounds of
`self.items`.
This is now reflected in the doc comment.
The old, wrong doc comment was copied from the `insert*` fns.

With this assertion holding true, `start + len` is always within the
address space and `start + new_items.len` is, at this point, always
strictly within bounds of `self.items`.
2024-01-19 00:55:17 +01:00
Erik Arvstedt
0bb6967d14 std.ArrayList: remove + 1 overflow checks 2024-01-19 00:55:17 +01:00
Sebastien Marie
7d81c952d5 openbsd: add proper support for aarch64
define openbsd specific elements in std/dwarf/abi.zig regBytes()

work from Jasper Lievisse Adriaanse, with register values from sys/signal.h
and https://github.com/ARM-software/abi-aa/blob/main/aadwarf64/aadwarf64.rst#dwarf-register-names
2024-01-18 15:45:42 -08:00
Nameless
a7dbc57a35 std.http.Client: read response messages with no length until eof 2024-01-18 15:43:58 -08:00
Andrew Kelley
22b9d8987d
Merge pull request #17499 from rootbeer/makepath-dangling-symlink
std.fs: tests for makePath and symlinks
2024-01-18 15:37:16 -08:00
Krzysztof Wolicki
14efbbfd89
std.Uri: change specifier for printing with scheme to semicolon ;
Fetch: print scheme when suggesting adding a ref to git URIs
2024-01-18 09:13:04 +02:00
Loris Cro
4ace1f5a7f Build: add namedWriteFiles to Build 2024-01-16 16:09:58 -08:00
Jay Petacat
fd43baa9ad byos: Ease GeneralPurposeAllocator integration
These changes enable me to use `GeneralPurposeAllocator` with my "Bring
Your Own OS" package. The previous checks for a freestanding target have
been expanded to `@hasDecl` checks.

- `root.os.heap.page_allocator` is used if it exists.
- `debug.isValidMemory` only calls `os.msync` if it's supported.
2024-01-16 15:05:38 -08:00
Andrew Kelley
a338c279f8
Merge pull request #15565 from xEgoist/spawnWindows
child_process: Add write and inheritable access to the null handle
2024-01-16 15:03:25 -08:00
melonedo
9b0da5ccef Fix TLS record overflow by limiting inner record length to 2^14
Per last paragraph of RFC 8446, Section 5.2, the length of the inner content of an encrypted record must not exceed 2^14 + 1, while that of the whole encrypted record must not exceed 2^14 + 256.
2024-01-16 14:58:56 -08:00
Pat Tullmann
ff5613873f std/fs/test.zig: Add statFile() tests of dangling symlink
Create a dangling symlink and check that statFile works with it.
2024-01-16 14:19:48 -08:00
Pat Tullmann
d35bdc8ee7 std/fs/test.zig: Try harder to clean up locking files 2024-01-16 14:19:48 -08:00
Pat Tullmann
c36962bb19 std/fs/test.zig: Factor out the symlink-creation wrappers
Because creation of a symlink can fail on Windows with an Access Denied
error (https://learn.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/create-symbolic-links)
any tests that need a symbolic link "skip" if they run into this problem.

This change factors out a "setupSymbolicLink()" routine to make this
clearer, a bit tighter, and easier to use in future tests.

I also collapsed the "symlink in parent directory" test into the existing
"Dir.readlink" test, because the latter uses the more comprehensive
testWithAllSupportedPathTypes wrapper.
2024-01-16 14:19:48 -08:00
Pat Tullmann
95a0e127b3 std/fs/test.zig: quote . and .. in test names
The test runner uses "." in its output between the test module and the
test name, so quote the leading '.' in these test names to make them
easier to read.
2024-01-16 13:49:00 -08:00
Purrie
c4a1b54ebe tls client interface consistency fix
Client for tls was using a function that wasn't declared on the
interface for it. The issue wasn't apparent because net stream
implemented that function.

I changed it to keep the interface promise of what's required to be
compatible with the tls client functionality.
2024-01-16 13:02:00 -08:00
Andrew Kelley
195eeed2d8 std: remove deprecated API 2024-01-16 04:20:05 -08:00
xEgoist
194ed30825 child_process: Use security attributes while creating handle.
As suggested by @matu3ba, it can be better to use Security Attributes
directly while creating the handle instead of creating the handle then
setting the handle to inherit. Doing so can prevent potentially leaking
to other parallel spawned processes which would inherit the opened `\Device\Null`
handle.

This change also allows windows.OpenFile to handle when bInheritHandle
is set.

Note that we are using the same `saAttr`, but since it's taken as a
pointer to a const in all calls, it's never mutated, and OpenFile never alters it.

This also saves 1 kernel call for setting the handle to inherit.
2024-01-16 01:25:14 -08:00
xEgoist
41bf816fa6 child_process: Add write access to the null handle
This commit allows write access to the `\\Device\\Null` Handle.
Without a write access, it's not possible for the child process to write
SdOut to Null. As a requirement `SetHandleInformation` was also changed
to mark the handle as iheritable (by adding it to Flags) by the spawned process.
This allows the child to access the NUL device that was opened.

This also makes the Windows part to behave similarly to `spawnPosix`.
2024-01-16 01:25:14 -08:00
Krzysztof Wolicki
7116b02210 Allow multiple options using the same enum type 2024-01-15 23:08:11 -08:00
Andrew Kelley
88ee323cd7
Merge pull request #18570 from gh-fork-dump/linux-6.7
Linux: Update syscall bits for 6.7
2024-01-15 23:04:02 -08:00
Andrew Kelley
d1ce8b8837
Merge pull request #18168 from cipharius/feature/zig-build-fossil-support
Adds support for Fossil SCM source tree archives as zig build dependencies
2024-01-15 23:02:50 -08:00
Andrew Kelley
f2721a4cbc std.ArrayList: pedantic rewordings of documentation and unit tests 2024-01-15 23:44:36 -07:00
notcancername
69461bcae4 std.array_list: Document and reduce illegal behavior in ArrayLists 2024-01-15 23:44:36 -07:00
cipharius
f25c499d12 Permits tar directory path without trailing slash 2024-01-15 18:31:32 +02:00
Stephen Gregoratto
3200fae9c5 Linux: Add syscall bindings, enhance documentation.
- Add syscall bindings/structures for the `futex2` family.
  The documentation is taken from the syscall definitions.
- Add documnentation for the `cachestat` bindings and structures.
  Taken from work I did in Cosmopolitian libc.
- Add binding for `map_shadow_stack`.
  No documentation for this one, since the kernel devs didn't bother to
  do it ¯\_(ツ)_/¯.
2024-01-15 20:05:03 +11:00
Stephen Gregoratto
cca021c211 Linux: Update syscalls for the 6.7 release
This release adds the rest of the futex2[1] syscalls, along with
shadow stack[2] support for more architectures.

[1]: https://lwn.net/Articles/940944/
[2]: https://lwn.net/Articles/926649/
2024-01-15 20:05:03 +11:00
Jakub Konka
3dddb881bf
Merge pull request #18560 from ziglang/elf-report-dupes
elf: report duplicate symbol definitions
2024-01-15 07:37:09 +01:00
Jakub Konka
852e7e24b5
Merge pull request #17917 from Jan200101/PR/each_lib_rpath_frontend
move rpath to frontend and remove native paths from it
2024-01-15 07:35:12 +01:00
Andrew Kelley
a5934edd48 std.os.linux.io_uring: fix compilation errors
Commit f0c42fbba1 was created before the
additional compile error for var used instead of const.
2024-01-14 19:20:41 -07:00
Andrew Kelley
f0c42fbba1
Merge pull request #18025 from ianic/io_uring_send_zc
io_uring: add send_zc and *_direct operations
2024-01-14 18:10:51 -08:00
expikr
ff23efe9fa Update pow.zig 2024-01-14 18:09:26 -08:00
expikr
0c70d9c714 use Peer Type Resolution for standalone complex fn
use peer type resolution

Update complex.zig

Revert "use peer type resolution"

This reverts commit 1bc681ca5b.

Revert "Update pow.zig"

This reverts commit 5487e8d3159f832b5a0bf29a06bd12575182464f.

Update pow.zig

Revert "Update pow.zig"

This reverts commit 521153d1ef.

Update pow.zig
2024-01-14 18:09:17 -08:00
Tristan Ross
9fce1d1ab1
mem: add byteswap array support (#17959)
also make byteswap work with enums
2024-01-14 21:06:31 -05:00
expikr
f9d8176e94
Update atan2.zig (#17840)
Co-authored-by: castholm <carl@astholm.se>
2024-01-14 21:04:30 -05:00
expikr
1a7a711964
std.math: add wrap function (#18154) 2024-01-14 20:45:39 -05:00
Jan200101
e517d5a51e std.zig.system.NativePaths: add NixOS lib dirs to the rpath 2024-01-14 15:57:45 -07:00
Jakub Konka
a8b9f0cf22 std/Build/Step/Compile: do not propagate deps of complex addObject step 2024-01-14 23:07:21 +01:00
Andrew Kelley
4debd4338c
Merge pull request #18547 from ziglang/gh-fork-dump-fchmod-fixes
Add `fchmodat` fallback on Linux when `flags` is nonzero.
2024-01-14 11:26:25 -08:00
Krzysztof Wolicki
78549d1e10 mingw: Add missing misc/mingw-access.c and misc/ucrt-access.c 2024-01-14 11:25:01 -08:00
Andrew Kelley
09074d7cd7 std.os: proper use of inline
Uses `inline` only to forward the comptime-ness of the flags parameter
to function selection.

Also fixes doc comments in std.c.versionCheck.
2024-01-13 23:56:32 -07:00
Stephen Gregoratto
01cc904fc7 Rework fchmodat tests
Based on the Linux kernel fchmodat2 test
2024-01-13 23:52:01 -07:00
Stephen Gregoratto
bc69d62669 Linux: Add fchmodat fallback when flags is nonzero
The check for determining whether to use the fallback code has been
moved into an inline function as per Andrew's comments in #17954.
2024-01-13 23:52:01 -07:00
Stephen Gregoratto
cf6751ae55 Add fchmodat2 bits to os/linux.zig 2024-01-13 23:52:01 -07:00
Stephen Gregoratto
26db31f6f6 Add fchmodat2 to the Linux syscall list
This syscall was added to simplify the the libc implementations of
fchmodat, as the original syscall does not take a `flags` argument.

Another syscall, `map_shadow_stack`, was also added for x86_64.
2024-01-13 23:52:01 -07:00
Andrew Kelley
bd46410419 Revert "Merge pull request #18410 from dweiller/by-length-slice-bug"
This reverts commit d9d840a33a, reversing
changes made to a04d433094.

This is not an adequate implementation of the missing safety check, as
evidenced by the changes to std.json that are reverted in this commit.

Reopens #18382
Closes #18510
2024-01-13 23:21:44 -07:00
Carl Åstholm
0f9345ea9a Expose -f(no-)formatted-panics to the build system (again) 2024-01-13 22:07:34 -08:00
Ryan Liptak
4dd3505e43 std.ArrayList: Clarify that ensureTotalCapacity/ensureTotalCapacityPrecise will never shrink the array
Closes #18499
2024-01-13 19:58:22 -08:00
vinnichase
279607cae5
Fix fmt UTF-8 characters as fill (#18533)
Co-authored-by: Jacob Young <jacobly0@users.noreply.github.com>
2024-01-13 22:47:03 -05:00
Nameless
b723296e1f std.http: add missing documentation and a few examples 2024-01-13 18:51:38 -08:00
Nameless
832f6d8f7f std.Uri: fix implementation of resolve with trailing slashes 2024-01-13 18:50:29 -08:00
Guillaume Wenzek
c5d359e4cd fix #17142, wrong comptime log_int computation 2024-01-13 18:46:16 -08:00
Igor Anić
7d3a31872e tar: improve diagnostic reporting
Using Python testtar file (mentioned in #14310) to test diagnostic
reporting.
Added computing checksum by using both unsigned and signed header bytes
values.
Added skipping gnu exteneded sparse headers while reporting unsupported
header in diagnostic.

Note on testing:

wget https://github.com/python/cpython/raw/3.11/Lib/test/testtar.tar -O
/tmp/testtar.tar

```
test "Python testtar.tar file" {
    const file_name = "testtar.tar";

    var file = try std.fs.cwd().openFile("/tmp/" ++ file_name, .{});
    defer file.close();

    var diag = Options.Diagnostics{ .allocator = std.testing.allocator };
    defer diag.deinit();

    var iter = iterator(file.reader(), &diag);
    while (try iter.next()) |f| {
        std.debug.print("supported: {} {s} {d}\n", .{ f.kind, f.name, f.size });
        try f.skip();
    }
    for (diag.errors.items) |e| {
        switch (e) {
            .unsupported_file_type => |u| {
                std.debug.print("unsupported: {} {s}\n", .{ u.file_type, u.file_name });
            },
            else => unreachable,
        }
    }
}
```
2024-01-13 19:37:33 -07:00
Igor Anić
7923a53996 tar: rename reader to iterator
Itarator has `next` function, iterates over tar files. When using from
outside of module with `tar.` prefix makes more sense.

var iter = tar.iterator(reader, null);
while (try iter.next()) |file| {
...
}
2024-01-13 19:37:33 -07:00
Igor Anić
e21a12e56b tar: use @embedFile in tests
Like in other tests which uses testdata files (compress). That enables
wasi testing also, was failing because file system operations in tests.
2024-01-13 19:37:33 -07:00
Igor Anić
76fe1f53d5 tar: fix tests on 32-bit platforms 2024-01-13 19:37:33 -07:00
Igor Anić
a75fd4ff15 tar: move test cases to std/tar/testdata
Create std/tar/test.zig for test which uses cases from testdata.
2024-01-13 19:37:33 -07:00
Igor Anić
f8e42d6b30 tar: add Go test case files to the project 2024-01-13 19:37:33 -07:00
Igor Anić
c07527abac tar: reorganize file, functions before tests 2024-01-13 19:37:33 -07:00
Igor Anić
c76abe0e18 tar: use file word in less places 2024-01-13 19:37:33 -07:00
Igor Anić
4a6d67ab1a tar: remove stratch from tar reader
Use explicit buffers for name, link_name instead.
It is cleaner that way.
2024-01-13 19:37:33 -07:00
Igor Anić
9f7dd32308 tar: refactor pax attribute
Make it little readable.
2024-01-13 19:37:33 -07:00
Igor Anić
dbab45cfc6 tar: replace custom buffered reader with std.io 2024-01-13 19:37:33 -07:00
Igor Anić
58e0e509c6 tar: add module comment and references 2024-01-13 19:37:33 -07:00
Igor Anić
a3cf8ec71e tar: add pax file reader tests 2024-01-13 19:37:33 -07:00
Igor Anić
7b0bbc680f tar: add file mode to result of tarbal iteration
So we have information to set executable bit on write to file system.
2024-01-13 19:37:33 -07:00
Igor Anić
2a432d3008 tar: prefix test cases with 'tar'
To make it little easier to filter from all stdlib tests.
2024-01-13 19:37:33 -07:00
Igor Anić
2ed9a276a7 tar: use Go test cases path from env variable
Skip tests if env is not set.
2024-01-13 19:37:33 -07:00
Igor Anić
6bfa7bf197 tar: use scratch buffer for file names
That makes names strings stable during the iteration. Otherwise string
buffers can be overwritten while reading file content.
2024-01-13 19:37:33 -07:00
Igor Anić
6e7a39c935 tar: refactor reading pax attributes 2024-01-13 19:37:33 -07:00
Igor Anić
c761dfc176 tar: add gnu path and link extensions handling 2024-01-13 19:37:33 -07:00
Igor Anić
48b160c1bf tar: handle pax null attrs and pax attr ending 2024-01-13 19:37:33 -07:00
Igor Anić
16c40fc471 tar: add header chksum checking 2024-01-13 19:37:33 -07:00
Igor Anić
169f28d3e6 tar: fix import path 2024-01-13 19:37:33 -07:00
Igor Anić
e1424b84b8 tar: add parsing size in gnu extended format
Reference:
https://www.gnu.org/software/tar/manual/html_node/Extensions.html#Extensions

If the leading byte is 0x80 (128), the non-leading bytes of the field
are concatenated in big-endian order, with the result being a positive
number expressed in binary form.
2024-01-13 19:37:33 -07:00
Igor Anić
6d5283e835 tar: refactor reader and iterator
Make it more readable.
2024-01-13 19:37:33 -07:00
Igor Anić
be5d04ab79 tar: add pax linkpath attribute parsing
Name of symbolic link can be also found in pax attribute.
2024-01-13 19:37:33 -07:00
Igor Anić
1817063375 tar: add initial test cases
Just adding tests, without changing functionality.
2024-01-13 19:37:33 -07:00
Igor Anić
4381241237 tar: refactor Buffer
Move reader into Buffer and make it BufferedReader. This doesn't
introduce any new functionality just grouping similar things.
2024-01-13 19:37:33 -07:00
Igor Anić
ff8544daa5 tar: refactor code to be more testable
Split reading/parsing tar file and writing results to the disk in two
separate steps. So we can later test parsing part without need to write
everyting to the disk.
2024-01-13 19:37:33 -07:00
Jacob Young
7916cf6f83 std.io.GenericReader: add missing error annotations 2024-01-13 13:16:51 -08:00
Michael Scott
e5dc9b1d09 Update styles in std docs to correct display glitch 2024-01-12 16:25:55 -08:00
Chris Boesch
d8b5831dc4 Fixed verbatim copy of trailing '%' in unescapeStr 2024-01-12 16:20:44 -08:00
Meghan Denny
f49a8c5431 std: make c.versionCheck() a comptime-known function 2024-01-12 16:17:39 -08:00
Andrew Kelley
45ec851733 zig build: handle stderr more elegantly
* Specifically recognize stderr as a different concept than an error
  message in Step results.
* Display it differently when only stderr occurs but the build proceeds
  successfully.

closes #18473
2024-01-10 17:11:26 -08:00
Andrew Kelley
854b88fda0 tsan: update rtl files to LLVM 17.0.6 2024-01-10 01:00:37 -07:00
Andrew Kelley
e025ad7b46 std.mem: fix simd.suggestVectorLength merge conflict
Commits
2f8e4347b1 and
6a32d58876 had a conflict that was
undetected by source control.
2024-01-09 18:20:53 -07:00
Veikka Tuominen
828d23956d std.heap: add runtime safety for calling stackFallback(N).get multiple times
Closes #16344
2024-01-09 17:18:20 -08:00
Andrew Kelley
6a32d58876
Merge pull request #18318 from castholm/simd-segfault
Rename `simd.suggestVectorSize` to clarify intent and fix related segfault
2024-01-09 17:13:58 -08:00
Matthew Wozniak
aaf1e0b25b
add ability to open dlls with platform-specific flags (#18370) 2024-01-09 20:11:22 -05:00
Bogdan Romanyuk
4a1a5ee47b
AstGen: add error for redundant comptime var in comptime scope (#18242) 2024-01-09 20:09:39 -05:00
Andrew Kelley
157cdaee0e
Merge pull request #18498 from castholm/cpu-cortex-m-optional-deps
Don't enable optional ARM Cortex-M series CPU features by default
2024-01-09 17:08:08 -08:00