Commit Graph

1542 Commits

Author SHA1 Message Date
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
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
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
Alex Rønne Petersen
af04404b49 std: Fix assembler comment syntax for sparc. 2024-09-07 13:16:22 -07:00
Alex Rønne Petersen
8043197995
std.os.linux: Add clock_nanosleep() syscall wrapper. 2024-09-06 20:03:00 +02:00
Alex Rønne Petersen
68bb788df5
std.os.linux: Make nanosleep() a compile error on riscv32.
This should eventually be converted to the void/{} pattern along with the other
syscalls that are compile errors for riscv32.
2024-08-31 03:31:58 +02:00
Alex Rønne Petersen
6364995d3f
std.os.linux: Also use kernel_timespec for riscv32 when libc is linked.
Both glibc and musl use time64 as the base ABI for riscv32. This fixes the
`sleep` test in `std.time` hanging forever due to the libc functions reading
bogus values.
2024-08-31 03:31:58 +02:00
Alex Rønne Petersen
537cb49eb2
std.os.linux: Define the Stat struct for riscv32.
The kernel does define the struct, it just doesn't use it. Yet both glibc and
musl expose it directly as their public stat struct, and std.c takes it from
std.os.linux. So just define it after all.
2024-08-31 03:31:58 +02:00
Alex Rønne Petersen
cb0e6d8aa6 std.os.linux: Fix syscall6() when building for PIC/PIE.
LLVM would run out of registers due to the edi usage. Just extend what we're
already doing for ebp to edi as well.
2024-08-30 14:48:17 -07:00
Andrew Kelley
a4cc43c42b
Merge pull request #21174 from alexrp/win-arm
Change `arm-windows-gnu` to `thumb-windows-gnu`, plus some initial port work
2024-08-30 14:34:53 -07:00
mlugg
4330c40596
std: avoid field/decl name conflicts
Most of these changes seem like improvements. The PDB thing had a TODO
saying it used to crash; I anticipate it works now, we'll see what CI
does.

The `std.os.uefi` field renames are a notable breaking change.
2024-08-29 20:39:11 +01:00
mlugg
0fe3fd01dd
std: update std.builtin.Type fields to follow naming conventions
The compiler actually doesn't need any functional changes for this: Sema
does reification based on the tag indices of `std.builtin.Type` already!
So, no zig1.wasm update is necessary.

This change is necessary to disallow name clashes between fields and
decls on a type, which is a prerequisite of #9938.
2024-08-28 08:39:59 +01:00
Alex Rønne Petersen
d702a21bbc
std.os.windows: Define CONTEXT, RUNTIME_FUNCTION, and KNONVOLATILE_CONTEXT_POINTERS for thumb. 2024-08-28 03:13:01 +02:00
Alex Rønne Petersen
2e2441a89d
std.os.windows: Implement teb() for thumb.
6e15604c48/include/winnt.h (L2503)

Closes #4645.
2024-08-28 03:13:01 +02:00
Jacob Young
f289b82d0e Dwarf: implement .eh_frame 2024-08-27 03:55:56 -04:00
mlugg
a3a737e9a6
lib,test,tools,doc: update usages of @export 2024-08-27 00:44:35 +01:00
Michał Drozd
206e5e4d7d
std.os.linux: Fix bunch of compilation errors (#21138)
* Correct layout of IntInfo according to https://www.kernel.org/doc/html/latest/bpf/btf.html#btf-kind-int

* Fix VFS errors

* Fix std.os.linux.sendmmsg

* Fix std.os.linux.sigismember. Add tests

* Fix futex2 functions
2024-08-23 14:21:19 +00:00
Andrew Kelley
60011d28d3
Merge pull request #21137 from Aransentin/af_packet
std.os.linux: Add support for AF_PACKET V3
2024-08-23 00:46:18 -07:00
Andrew Kelley
ee84deda98
Merge pull request #21095 from alexrp/mips64-tests
Get `mips64(el)-linux` working and start testing it
2024-08-22 20:09:08 -07:00
Jens Goldberg
c3214bcd96 Inline the variant union 2024-08-21 10:10:19 +02:00
Jens Goldberg
6f24c4485c Add tpacket_hdr and tpacket_block variant unions 2024-08-20 10:10:14 +02:00
Mohanavel S K
82b676ef79
Added Constants Related To Ioctl (sockios.h) 2024-08-19 20:21:26 +03:00
Jens Goldberg
1950e52c6c Remove FASTROUTE; invisible to userspace, and collides with USER 2024-08-19 16:19:05 +02:00
Jens Goldberg
af007ec1ff std.os.linux: Add support for AF_PACKET V3 2024-08-19 15:01:58 +02:00
Alex Rønne Petersen
ea38009f3d std.os.linux: Fix Stat struct for mips/mips64. 2024-08-18 07:27:23 +02:00
Alex Rønne Petersen
ed9a502dff std.os.linux: Fix rlimit_resource for mips64; move out of arch bits.
It is usually generic, so no point having it in arch bits.
2024-08-18 07:27:23 +02:00
Alex Rønne Petersen
d4973c9922 std.os.linux: Fix syscall errno value handling for mips.
The kernel sets r7 to 0 (success) or -1 (error), and stores the result in r2.
When r7 is -1 and the result is positive, it needs to be negated to get the
errno value that higher-level code, such as errnoFromSyscall(), expects to see.

The old code was missing the check that r2 is positive, but was also doing the
r7 check incorrectly; since it can only be set to 0 or -1, the blez instruction
would always branch.

In practice, this fix is necessary for e.g. the ENOSYS error to be interpreted
correctly. This manifested as hitting an unreachable branch when calling
process_vm_readv() in std.debug.MemoryAccessor.
2024-08-18 07:27:23 +02:00
Alex Rønne Petersen
bcf41c8594 std.os.linux: Fix E definition for mips64. 2024-08-18 07:27:23 +02:00
YANG Xudong
8e91c229e1
loongarch: fix asm to set thread pointer (#21086)
Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
2024-08-15 15:40:44 -07:00
reokodoku
20f4be4cf9 std.os.linux: add mseal syscall 2024-08-14 22:48:13 -07:00
YANG Xudong
76f062690c add getcontext 2024-08-13 10:11:17 -07:00
Alex Rønne Petersen
b00f586c3d
std.os.linux: Add clone() implementation for mips64. (#21038)
Only for n64; no handling for n32 yet.

Also remove pointless comment about o32 in mips64 code.
2024-08-12 16:09:52 -07:00
Alex Rønne Petersen
f7fb261efd std.os.linux.tls: Support sparc32. 2024-08-12 14:22:24 -07:00
Linus Groh
9ef16b36ce std.os.linux: Fix definition of tc_lflag_t on MIPS
Regressed in #21000.
2024-08-12 00:46:28 -07:00
Alex Rønne Petersen
8161e61548 std.os.linux.start_pie: Add support for the new RELR relocation format. 2024-08-11 20:27:09 -07:00
Alex Rønne Petersen
ae5bf2faab std.os.linux: Retranslate and port some ioctl-related types and values. 2024-08-09 13:10:51 -07:00
Andrew Kelley
71a27ebd84
Merge pull request #21004 from alexrp/linux-6.10
Linux 6.10 headers/syscalls
2024-08-09 13:08:39 -07:00
YANG Xudong
a9b65b6fd4
std: add loongarch64 support (#20915)
Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
2024-08-09 00:30:57 +00:00
Alex Rønne Petersen
3a1d4dd19e
Update Linux syscalls to 6.10. 2024-08-09 00:34:52 +02:00
YANG Xudong
b8705ed652
loongarch: various architecture specific fixes (#20912) 2024-08-07 13:06:29 -07:00
Pat Tullmann
4d6429fc4f POSIX link() syscall only takes two arguments (no flags)
The signature is documented as:

   int link(const char *, const char *);

(see https://man7.org/linux/man-pages/man2/link.2.html or https://man.netbsd.org/link.2)

And its not some Linux extension, the [syscall
implementation](21b136cc63/fs/namei.c (L4794-L4797))
only expects two arguments too.

It probably *should* have a flags parameter, but its too late now.

I am a bit surprised that linking glibc or musl against code that invokes
a 'link' with three parameters doesn't fail (at least, I couldn't get any
local test cases to trigger a compile or link error).

The test case in std/posix/test.zig is currently disabled, but if I
manually enable it, it works with this change.
2024-08-07 13:05:42 -07:00
Jeffrey C. Ollie
979fd12be9 Add getppid to std.c and std.os.linux.
The std lib is missing getppid, this patch adds it.
2024-08-07 13:03:21 -07:00
Alex Rønne Petersen
f9f8942008 std.os.linux: Move clone() here and stop exporting it. 2024-08-07 01:19:51 -07:00
Andrew Kelley
75f78bfb77
Merge pull request #20922 from alexrp/vdso
`std.os.linux`: Fix VDSO for mips, add VDSO for riscv
2024-08-07 01:18:35 -07:00
Andrew Kelley
8184912a98
Merge pull request #20925 from alexrp/windows-tls
`std`: Some Windows TLS cleanup and fixes
2024-08-07 01:12:11 -07:00
Alex Rønne Petersen
8cbf091a9a std.os.linux.start_pie: Add sparc/sparc64 support. 2024-08-07 01:09:06 -07:00
Alex Rønne Petersen
cb1fffb29e
std.os.windows.tls: Set AddressOfCallBacks to &__xl_a + 1.
`__xl_a` is just a global variable containing a null function pointer. There's
nothing magical about it or its name at all.

The section names used on `__xl_a` and `__xl_b` (`.CRT$XLA` and `.CRT$XLZ`) are
the real magic here. The compiler emits TLS variables into `.CRT$XL<x>`
sections, where `x` is an uppercase letter between A and Z (exclusive). The
linker then sorts those sections alphabetically (due to the `$`), and the result
is a neat array of TLS initialization callbacks between `__xl_a` and `__xl_z`.

That array is null-terminated, though! Normally, `__xl_z` serves as the null
terminator; however, by pointing `AddressesOfCallBacks` to `__xl_a`, which just
contains a null function pointer, we've effectively made it so that the PE
loader will just immediately stop invoking TLS callbacks. Fix that by pointing
to the first actual TLS callback instead (or `__xl_z` if there are none).
2024-08-03 20:55:00 +02:00
Alex Rønne Petersen
1d8fca0060
std.os.windows.tls: Only define _tls_array when targeting MSVC.
LLVM does not use it when emitting code for the MinGW ABI.
2024-08-03 20:48:48 +02:00
Alex Rønne Petersen
0f1db90198
std.os.windows.tls: Slightly improve type safety. 2024-08-03 20:48:48 +02:00