1655 Commits

Author SHA1 Message Date
phatchman
ae38fc6a50
Return FileNotFound when CreateProcessW is called with a missing path (#23567) 2025-04-15 21:39:44 +00:00
Ryan King
6c598e8341 std: add os.linux.sysinfo(), use it for process.totalSystemMemory()
Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
2025-04-15 20:08:59 +02:00
Andrew Kelley
2cb69e53b4
Merge pull request #23541 from alexrp/linux-5.10
`std.Target`: Bump minimum Linux kernel and glibc versions according to Debian LTS
2025-04-13 17:25:34 -04:00
Andrew Kelley
08a6c4ca9b
Merge pull request #23272 from squeek502/getenvw-optim
Windows: Faster `getenvW` and a standalone environment variable test
2025-04-11 15:46:34 -04:00
Alex Rønne Petersen
2527c82482
std.os.linux: Use faccessat2 syscall in faccessat().
Only the former has a flags parameter. It's only available in Linux 5.8+.

Closes #16606.
2025-04-11 21:17:35 +02:00
Pat Tullmann
4b63f94b4e Fix sigaddset/sigdelset bit-fiddling math
The code was using u32 and usize interchangably, which doesn't work on
64-bit systems.  This:
  `pub const sigset_t = [1024 / 32]u32;`
is not consistent with this:
  `const shift = @as(u5, @intCast(s & (usize_bits - 1)));`

However, normal signal numbers are less than 31, so the bad math doesn't matter much.  Also, despite support for 1024 signals in the set, only setting signals between 1 and NSIG (which is mostly 65, but sometimes 128) is defined.  The existing tests only exercised signal numbers in the first 31 bits so they didn't trip over this:

The C library `sigaddset` will return `EINVAL` if given an out of bounds signal number.  I made the Zig code just silently ignore any out of bounds signal numbers.

Moved all the `sigset` related declarations next to each in the source, too.

The `filled_sigset` seems non-standard to me.  I think it is meant to be used like `empty_sigset`, but it only contains 31 set signals, which seems wrong (should be 64 or 128, aka `NSIG`).  It's also unused.  The oddly named but similar `all_mask` is used (by posix.zig) but sets all 1024 bits (which I understood to be undefined behavior but seems to work just fine).  For comparison the musl `sigfillset` fills in 65 bits or 128 bits.
2025-04-10 23:49:44 +02:00
Pat Tullmann
991560fb49 linux.zig: epoll_wait: pass kernel sigset size
Linux kernel syscalls expect to be given the number of bits of sigset that
they're built for, not the full 1024-bit sigsets that glibc supports.

I audited the other syscalls in here that use `sigset_t` and they're all
using `NSIG / 8`.

Fixes #12715
2025-04-09 16:37:58 +02:00
Alex Rønne Petersen
2d33cc2e42
Merge pull request #23376 from sweiglbosker/m68k-archbits 2025-04-08 06:04:16 +02:00
Alex Rønne Petersen
1cab57f361
std.os.linux: Add some missing arch bits for loongarch64. 2025-04-07 16:03:22 +02:00
Alex Rønne Petersen
9423712519
std: Disable usage of fstat() and friends on loongarch.
Like riscv32, loongarch exclusively uses statx().
2025-04-07 16:03:22 +02:00
Stefan Weigl-Bosker
bcb4ba9afd
std.os.linux: use heap.pageSize() instead of MMAP2_UNIT 2025-04-07 13:37:01 +02:00
Stefan Weigl-Bosker
6fd358d287
std.os.linux: add arch bits for m68k
fixup
2025-04-07 13:36:45 +02:00
Dacheng Gao
596e0bd47b std.os.linux: add constants for ETH 2025-04-06 02:52:20 +02:00
Carmen
84c9cee502 fix review 2025-04-04 12:42:28 +01:00
Carmen
65c943671e OpenMode is exhaustive 2025-04-04 12:42:28 +01:00
Carmen
a61678b754 dont return tuple, split into 2 functions 2025-04-04 12:42:28 +01:00
Carmen
45afde2036 Payload -> @FieldType and use mem.sliceTo 2025-04-04 12:42:28 +01:00
Carmen
2112167f8c std.os.uefi.protocol.File: fix some typed definitions 2025-04-04 12:42:28 +01:00
Alex Rønne Petersen
8ff104380d
std.os.windows.PF: Add ARM_V83_LRCPC_INSTRUCTIONS_AVAILABLE. 2025-04-03 04:00:30 +02:00
Alex Rønne Petersen
9dfdf35032
Merge pull request #22337 from ruihe774/fix-app-mask
* std.os.linux: remove app_mask
* std.posix: on libc-less linux, block all signals in raise(), not just app_mask
2025-04-02 17:36:59 +02:00
Carmen
9720bade7a
std.start: allow return uefi error union in main (#23425) 2025-04-01 17:10:10 +00:00
Carmen
fa86e09fb3
std.os.uefi.protocol: ziggify function signatures (#23214) 2025-04-01 10:47:51 +00:00
Sean Stasiak
6e8493daa3 check result of mmap() call to handle a large base_addr value correctly 2025-03-27 20:34:41 +01:00
wooster0
263ba34619 linux: don't export getauxval when not required 2025-03-26 20:37:35 +01:00
Alex Rønne Petersen
b350049f51
Merge pull request #23062 from ianic/io_uring_bind
io_uring: Update to kernel changes in 6.11 and 6.12
2025-03-26 11:39:56 +01:00
Jonathan Marler
1408288b95 support more process creation options on Windows
Adds a CreateProcessFlags packed struct for all the possible flags to
CreateProcessW on windows.  In addition, propagates the existing
`start_suspended` option in std.process.Child which was previously only
used on Darwin.  Also adds a `create_no_window` option to std.process.Child
which is a commonly used flag for launching console executables on
windows without causing a new console window to "pop up".
2025-03-25 23:48:27 +01:00
Pat Tullmann
14c046fc07 lib/std: PermissionDenied/AccessDenied cleanup and fallout
This PR consistently maps .ACCES into AccessDenied and .PERM into
PermissionDenied.  AccessDenied is returned if the file mode bit
(user/group/other rwx bits) disallow access (errno was `EACCES`).
PermissionDenied is returned if something else denies access (errno was
`EPERM`) (immutable bit, SELinux, capabilities, etc).  This somewhat
subtle distinction is a POSIX thing.

Most of the change is updating std.posix Error Sets to contain both
errors, and then propagating the pair up through caller Error Sets.

Fixes #16782
2025-03-24 16:20:45 +01:00
Pat Tullmann
f304d8e50a windows: Use AccessDenied for ACCESS_DENIED on Windows
Windows defines an `ACCESS_DENIED` error code.  There is no
PERMISSION_DENIED (or its equivalent) which seems to only exist on POSIX
systems.  Fix a couple Windows calls code to return `error.AccessDenied`
for `ACCESS_DENIED` and to stop mapping AccessDenied into
PermissionDenied.
2025-03-24 16:20:45 +01:00
Ryan Liptak
78ecf3bb3a windows: Document Environment pointer 2025-03-22 15:44:27 -07:00
Carmen
17b40b1d68 lib/std/os/uefi/status.zig: add error to enum conversion fn 2025-03-09 10:54:21 +00:00
Jeremy Hertel
801a95035c std.time.epoch: change getDaysInMonth to accept the year as an argument 2025-03-08 14:25:28 -05:00
Igor Anić
94b36dbe50 io_uring: refactor buf_reg flags
Use packed struct instead of or-ed integers.

Thanks to @linsug for pr comments: https://github.com/ziglang/zig/pull/23062
2025-03-05 13:35:52 +01:00
Igor Anić
c133171567 io_uring: incremental provided buffer consumption
[Incremental provided buffer
consumption](https://github.com/axboe/liburing/wiki/What's-new-with-io_uring-in-6.11-and-6.12#incremental-provided-buffer-consumption)
support is added in kernel 6.12.

IoUring.BufferGroup will now use incremental consumption whenever
kernel supports it.

Before, provided buffers are wholly consumed when picked. Each cqe
points to the different buffer. With this, cqe points to the part of the
buffer. Multiple cqe's can reuse same buffer.
Appropriate sizing of buffers becomes less important.

There are slight changes in BufferGroup interface (it now needs to track
current receive point for each buffer). Init requires allocator
instead of buffers slice, it will allocate buffers slice and head
pointers slice. Get and put now requires cqe becasue there we have
information will the buffer be reused.
2025-03-05 13:35:52 +01:00
Igor Anić
4df039d235 io_uring: add setsockopt/getsockopt
ring.cmd_sock is generic socket operation. Two most common uses are
setsockopt and getsockopt. This provides same interface as posix
versions of this methods.

libring has also [sqe_set_flags](https://man7.org/linux/man-pages/man3/io_uring_sqe_set_flags.3.html)
method. Adding that in our io_uring_sqe. Adding sqe.link_next method for setting most common flag.
2025-03-05 13:35:52 +01:00
Igor Anić
d98c0893b0 io_uring: probe capabilities function
ring.get_probe returns io_uring_probe which can be use to probe
capabilities of the current running kernel.

Ref:
https://unixism.net/loti/ref-liburing/supported_caps.html
e1003e496e/src/setup.c (L454)
2025-03-05 13:35:52 +01:00
Igor Anić
85e2074878 io_uring: fix tests on 5.4.0 kernel
Found it failing in a new way on that kernel.
2025-03-05 13:35:52 +01:00
Igor Anić
2da8eff9d6 io_uring: add bind and listen 2025-03-05 13:35:52 +01:00
ziggoon
5b03e248b7 add FFI & wrappers for NtAllocateVirtualMemory & NtFreeVirtualMemory + add missing alloction constants MEM_RESERVE_PLACEHOLDER / MEM_PRESERVE_PLACEHOLDER 2025-03-04 22:10:49 -06:00
Linus Groh
79460d4a3e Remove uses of deprecated callconv aliases 2025-03-05 03:01:43 +00:00
Linus Groh
1a03b8c899 std.os.uefi: Fix two padding mistakes in the Time struct
```c
//************************************************
//EFI_TIME
//************************************************
// This represents the current time information
typedef struct {
   UINT16    Year;              // 1900 - 9999
   UINT8     Month;             // 1 - 12
   UINT8     Day;               // 1 - 31
   UINT8     Hour;              // 0 - 23
   UINT8     Minute;            // 0 - 59
   UINT8     Second;            // 0 - 59
   UINT8     Pad1;
   UINT32    Nanosecond;        // 0 - 999,999,999
   INT16     TimeZone;          // —1440 to 1440 or 2047
   UINT8     Daylight;
   UINT8     Pad2;
 }   EFI_TIME;
```
2025-03-02 23:16:34 +00:00
Linus Groh
6378295b77 std.os.uefi: Fix integer overflow in Time.toEpoch()
Instead of thinking hard about what the actual supported maximum value
for each sub-calculation is we can simply use an u64 from hours onwards.
2025-03-02 22:58:45 +00:00
Jari Vetoniemi
aa5c6c027c linux: add UDP socket options 2025-02-21 06:05:04 +01:00
Jari Vetoniemi
c41bc20ec7 linux: add IORING_RECVSEND_BUNDLE 2025-02-20 12:09:38 +01:00
Ali Cheraghi
bffbc918ee std.time: more precise nanoTimestamp in windows 2025-02-13 16:55:58 +01:00
nikneym
408c817e1e linux/IoUring: add register_files_sparse 2025-02-11 13:19:05 +03:00
nikneym
6f6b85e298 linux/io_uring_sqe: add prep_files_update 2025-02-11 13:18:27 +03:00
nikneym
ecfd9cef7d linux/io_uring_sqe: add prep_cancel_fd 2025-02-11 13:17:54 +03:00
Pat Tullmann
138d30bb47 wasi: fix wasm-wasi-musl constants
Zig's copy of the `SYMLINK_{NO,}FOLLOW` constants from wasi-musl was
wrong, as were the `IFIFO` and `IFSOCK` file type flags.  Fix these up,
and add comments pointing to exactly where they come from (as the
wasi-musl source has lots of unused, different definitions of these
constants).

Add tests for the Zig convention that WASM preopen 3 is the current
working directory.   This is true for WASM with or without libc.

Enable several fs and posix tests that are now passing (not necessarily
because of this change) on wasm targets.

Fixes #20890.
2025-02-09 09:08:11 +01:00
Linus Groh
0660f5b521 std.os.uefi: Drop 'Efi' prefix from type names
The UEFI spec only does this because C doesn't have namespaces, we don't
have that problem. Most type names were already omitting the prefix.
2025-02-09 02:30:32 +00:00
Linus Groh
0a7502e886 std.os.uefi: Adjust casing of remaining enum fields
Work towards #2101.
2025-02-09 02:23:53 +00:00