Commit Graph

1528 Commits

Author SHA1 Message Date
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
Alex Rønne Petersen
c2fcdc21c2
std.os.windows.tls: Change type of _tls_start/_tls_end to *anyopaque.
If they're typed as `u8`, they can be aligned to anything. We want at least
pointer size alignment.
2024-08-03 20:47:08 +02:00
Alex Rønne Petersen
8056a85151
std: Move start_windows_tls.zig to os/windows/tls.zig.
Just to be consistent with Linux.
2024-08-03 20:35:08 +02:00
Alex Rønne Petersen
0ad97b4122
std.os.linux: Add VDSO definition for riscv32/riscv64. 2024-08-03 18:49:12 +02:00
Alex Rønne Petersen
64e119124f
std.os.linux: Fix CGT_SYM for mips/mips64. 2024-08-03 18:48:53 +02:00
Alex Rønne Petersen
d71076c982
std.os.linux: Replace @hasDecl() with != void check for VDSO.
If there is a VDSO, it will have clock_gettime(). The main thing we're concerned
about is architectures that don't have a VDSO at all, of which there are a few.
2024-08-03 18:46:04 +02:00
Alex Rønne Petersen
f7d07b44d1
std.os.linux: Fix arm check in fadvise() to also include thumb. 2024-08-01 20:58:08 +02:00
Alex Rønne Petersen
a2868147b1
std.os.linux: Fix require_aligned_register_pair to check isMIPS32().
Only 32-bit architectures need this.
2024-08-01 20:58:08 +02:00
Alex Rønne Petersen
e5c75479c2
std.Target: Rework isPPC()/isPPC64() functions.
* Rename isPPC() -> isPowerPC32().
* Rename isPPC64() -> isPowerPC64().
* Add new isPowerPC() function which covers both.

There was confusion even in the standard library about what isPPC() meant. This
change makes these functions work how I think most people actually expect them
to work, and makes them consistent with isMIPS(), isSPARC(), etc.

I chose to rename from PPC to PowerPC because 1) it's more consistent with the
other functions, and 2) it'll cause loud rather than silent breakage for anyone
who might have been depending on isPPC() while misunderstanding it.
2024-08-01 20:58:05 +02:00
Alex Rønne Petersen
624fa8523a std.os.linux: Unbreak the build
Happened because I wrote #20869 before #20870.
2024-08-01 13:05:26 +02:00
Andrew Kelley
8f7cbaa4c0
Merge pull request #20870 from alexrp/target-cleanup-3
`std.Target`: Remove more dead OS/architecture tags
2024-08-01 01:32:32 -07:00
Andrew Kelley
f17f73b4fa
Merge pull request #20869 from alexrp/linux-syscalls
`std.os.linux`: Add syscall enums for all remaining architectures
2024-08-01 01:21:10 -07:00
Andrew Kelley
91163b44dd
Merge pull request #20857 from alexrp/tls-porting
`std.os.linux.tls`: Refactor, improve documentation, fix a bug, and port to more architectures
2024-08-01 01:15:17 -07:00
Andrew Kelley
16dde6d260
Merge pull request #20772 from alexrp/linux-audit
`std.os.linux.AUDIT`: Rewrite ARCH in terms of std.elf.EM.
2024-08-01 01:09:22 -07:00
Alex Rønne Petersen
2e719f3239
std.os.linux.start_pie: Use a 64-bit displacement for s390x.
Not likely to be necessary ever, but might as well be 100% correct.
2024-07-30 18:02:40 +02:00