aboutsummaryrefslogtreecommitdiff
path: root/lib/std/os/linux.zig
AgeCommit message (Collapse)Author
2022-08-22stage2+stage1: remove type parameter from bit builtinsVeikka Tuominen
Closes #12529 Closes #12511 Closes #6835
2022-08-11std: fix definition of SIG_IGN, SIG_DFL, etc.Isaac Freund
POSIX specifies that the sa_handler field of the sigaction struct may be set to SIG_IGN or SIG_DFL. However, the current constants in the standard library use the function pointer signature corresponding to the sa_sigaction field instead. This may not cause issues in practice because the fields usually occupy the same memory in a union, but this isn't required by POSIX and there may be systems we do not yet support that do this differently. Fixing this also makes the Zig interface less confusing to use after reading the man page.
2022-07-31Linux: Add IN_MASK_CREATE and corresponding error handling in inotify_add_watchRyan Liptak
From https://man7.org/linux/man-pages/man7/inotify.7.html > **IN_MASK_CREATE** (since Linux 4.18) > > Watch pathname only if it does not already have a watch associated with it; the error EEXIST results if pathname is already being watched.
2022-07-23io_uring: add new flags and opcodesVincent Rischmann
2022-07-21LLVM: fix lowering of structs with underaligned fieldsAndrew Kelley
When lowering a struct type to an LLVM struct type, keep track of whether there are any underaligned fields. If so, then make it a packed llvm struct. This works because we already insert manual padding bytes regardless. We could unconditionally use an LLVM packed struct; the reason we bother checking for underaligned fields is that it is a conservative choice, in case LLVM handles packed structs less optimally. A future improvement could simplify this code by unconditionally using packed LLVM structs and then make sure measure perf is unaffected. closes #12190
2022-07-05Mark fstype argument to mount as optionalJonathan Marler
The fstype argument to the mount system call can be null. To see an example run "strace -e trace=mount unshare -m": ``` mount("none", "/", NULL, MS_REC|MS_PRIVATE, NULL) = 0 ... ```
2022-07-03std: better definition for std.os.linux.epoll_eventAndrew Kelley
The previous definition depends on a non-lang-spec-compliant memory layout for packed structs, which happens to trigger #11989 in stage2. This commit changes the struct to be an extern struct with an align(4) field. However, stage1 cannot handle this, so conditional compilation logic is used to select different struct definitions depending on stage1 vs stage2. This works around #11989 but does not solve the underlying problem - putting an extern union inside a packed struct will still trigger the assert. After this, both stage1 and stage2 std lib tests run assertion-clean with a debug LLVM 13.
2022-06-28zig fmt: fix idempotency with newlines surrounding doc commentPhilipp Lühmann
Fixes: https://github.com/ziglang/zig/issues/11802
2022-05-26fix semantic error with std.os.linux.all_maskJonathan Marler
all_mask is a value of type sigset_t, which is defined as an array type [N]u32. However, all_mask references sigset_t.len, but, the array type does not have a len field. Fix is to use @typeInfo(sigset_t).Array.len instead.
2022-05-16Generate linux syscalls via. the linux source treeStephen Gregoratto
Previously, updating the `SYS` enum for each architecture required manually looking at the syscall tables and inserting any new additions. This commit adds a tool, `generate_linux_syscalls.zig`, that automates this process using the syscall tables in the Linux source tree. On architectures without a table, it runs `zig cc` as a pre-processor to extract the system-call numbers from the Linux headers.
2022-05-16std.os: Add memfd_create for FreeBSDIsaac Freund
This is minorly breaking as e.g. std.os.linux.MFD_CLOEXEC is now std.os.linux.MFD.CLOEXEC.
2022-05-13target: Rename sparcv9 -> sparc64Koakuma
Rename all references of sparcv9 to sparc64, to make Zig align more with other projects. Also, added new function to convert glibc arch name to Zig arch name, since it refers to the architecture as sparcv9. This is based on the suggestion by @kubkon in PR 11847. (https://github.com/ziglang/zig/pull/11487#pullrequestreview-963761757)
2022-05-13std.os.linux: fix signature of setgroupsJonathan Marler
the list parameter should be a multi-item pointer rather than a single-item pointer. see: https://linux.die.net/man/2/setgroups > setgroups() sets the supplementary group IDs for the calling process... > the size argument specifies the number of supplementary group IDs in the buffer pointed to by list.
2022-05-02Avoid some unnecessary underscores in constant namesr00ster91
2022-04-28Seccomp fixups re: #10717Stephen Gregoratto
- Add type annotation for AUDIT.current. - Make unsupported archs a compile error.
2022-04-28Merge pull request #10717 from gh-fork-dump/seccomp-bitsVeikka Tuominen
Add Seccomp bits for linux
2022-03-21stage2 llvm: fix lowerDeclRefValue for function aliasesVeikka Tuominen
2022-03-19std: enable default panic handler for stage2 LLVM on LinuxVeikka Tuominen
2022-03-09Add bits for the Linux Secure Computing facilityStephen Gregoratto
2022-02-27stage2: fix bitcast to optional ptr in llvm backend; omit safety check for ↵Veikka Tuominen
intToPtr on optional ptr
2022-02-27stage2: use stage1 test runner for stage2Veikka Tuominen
2022-02-23std.os.linux.socketpair: fd is an out parameterFelix Queißner
2022-02-13Merge pull request #10863 from m-radomski/fixAndrew Kelley
std: validate frame-pointer address in stack walking
2022-02-13Fix preadv/pwritev bug on 64bit platformTw
Signed-off-by: Tw <wei.tan@intel.com>
2022-02-11validate in Windows using VirtualQuerym
2022-02-11std: validate frame-pointer address in stack walkingm
2022-01-29Add bits for the Linux Auditing SystemStephen Gregoratto
Also adds the _CSKY and _FRV ELF machines that are defined in `<linux/elf-em.h>`
2022-01-27fchown: use the 32-bit uid/gid variant of the syscall on 32-bit linux targetsVesim
2021-12-19stage1, stage2: rename c_void to anyopaque (#10316)Isaac Freund
zig fmt now replaces c_void with anyopaque to make updating code easy.
2021-12-12os/linux: add more io_uring opcodeVincent Rischmann
2021-12-04Added an explicit type for the termios constants (#10266)Zapolsky Anton
Adds the `tcflag_t` type to the termios constants. This is made to allow bitwise operations on the termios constants without an integer cast, e.g.: ```zig var raw = try std.os.tcgetattr(std.os.STDIN_FILENO); raw.lflag &= std.os.linux.ECHO | std.os.linux.ICANON; ``` instead of ```zig var raw = try std.os.tcgetattr(std.os.STDIN_FILENO); raw.lflag &= ~@intCast(u32, std.os.linux.ECHO | std.os.linux.ICANON); ``` Contributes to #10181
2021-11-16os/linux: fix rlimit_resource for mips/sparcv9Vincent Rischmann
On MIPS and SPARC the RLIMIT kinds have different numbers than the other architectures.
2021-11-15Add `chmod` and `chown`Ominitay
2021-11-10Merge pull request #9853 from koachan/sparc64-unittestsAndrew Kelley
SPARCv9: make more tests pass
2021-11-01std: expose rusage constants under rusage namespaceAndrew Kelley
2021-11-01std: add Linux perf syscall bitsAndrew Kelley
Example usage: ```zig const std = @import("std"); const PERF = std.os.linux.PERF; const assert = std.debug.assert; test "perf" { var attr: std.os.linux.perf_event_attr = .{ .type = PERF.TYPE.HARDWARE, .config = @enumToInt(PERF.COUNT.HW.INSTRUCTIONS), .flags = .{ .disabled = true, .exclude_kernel = true, .exclude_hv = true, }, }; const fd = try std.os.perf_event_open(&attr, 0, -1, -1, PERF.FLAG.FD_CLOEXEC); defer std.os.close(fd); _ = std.os.linux.ioctl(fd, PERF.EVENT_IOC.RESET, 0); _ = std.os.linux.ioctl(fd, PERF.EVENT_IOC.ENABLE, 0); long(); _ = std.os.linux.ioctl(fd, PERF.EVENT_IOC.DISABLE, 0); var result: usize = 0; assert((try std.os.read(fd, std.mem.asBytes(&result))) == @sizeOf(usize)); std.debug.print("instruction count: {d}\n", .{result}); } fn long() void { var i: usize = 0; while (i < 100000) : (i += 1) {} } ```
2021-10-10Linux: fix socket constants for SPARCv9Koakuma
2021-10-04migrate from `std.Target.current` to `@import("builtin").target`Andrew Kelley
closes #9388 closes #9321
2021-09-18Add Linux ioctl creation utilities (#9748)Jens Goldberg
* Add Linux ioctl creation utilities * Apply suggestions from code review Co-authored-by: Veikka Tuominen <git@vexu.eu> * Update lib/std/os/linux.zig Co-authored-by: zigazeljko <ziga.zeljko@gmail.com> Co-authored-by: Veikka Tuominen <git@vexu.eu> Co-authored-by: zigazeljko <ziga.zeljko@gmail.com>
2021-09-16Set the Storage socket sizes to be system definedStephen Gregoratto
Some systems (Solaris, OpenBSD, AIX) change their definitions of sockaddr_storage to be larger than 128 bytes. This comment adds a new constant in the `sockaddr` that defines the size for every system. Fixes #9759
2021-09-12os: usingnamespace fixes for std.x.os.Socket and std.os.TCPKenta Iwasaki
Extract existing constants to do with TCP socket options into a 'TCP' namespace. Export 'MSG' and 'TCP' from std.os.{linux, windows} into std.c. Fix compile errors to do with std.x.os.Socket methods related to setting TCP socket options. Handle errors in the case that an interface could not be resolved in an IPv6 address on Windows. Tested using Wine with the loopback interface disabled. Have all instantiations of std.x.os.Socket on Windows instantiate an overlapped socket descriptor. Fixes the '1ms read timeout' test in std.x.net.tcp.Client. The test would previously deadlock, as read timeouts only apply to overlapped sockets. Windows documentation by default recommends that most instantiations of sockets on Windows be overlapped sockets (s.t. they may operate in both blocking or nonblocking mode when operated with WSA* syscalls). Refer to the documentation for WSASocketA for more info.
2021-09-01fix regression on linux with kernel_timespecAndrew Kelley
I incorrectly assumed that __kernel_timespec was used when not linking libc, however that is not the case. `std.os.timespec` is used both for libc and non-libc cases. `__kernel_timespec` is a special struct that is used only for io_uring.
2021-09-01std.os reorg: regression fixes to stack_t, and std.ThreadAndrew Kelley
2021-09-01re-apply a commit dropped in this branch due to conflictsAndrew Kelley
This commit reapplies 4f0aa7d639e099b18df583cb984412037fbb1dbe.
2021-09-01std.os fixes to get the test suite passing againAndrew Kelley
2021-09-01std: fix regressions from this branchAndrew Kelley
Also move some usingnamespace test cases from compare_output to behavior.
2021-09-01std: reorganization that allows new usingnamespace semanticsAndrew Kelley
The proposal #9629 is now accepted, usingnamespace stays but no longer puts identifiers in scope.
2021-09-01std.os: more reorganization effortsAndrew Kelley
* std lib tests are passing on x86_64-linux with and without -lc * stage2 is building from source on x86_64-linux * down to 38 remaining uses of `usingnamespace`
2021-09-01std.os.linux: remove the "bits" namespace altogetherAndrew Kelley
Now there is only 1 architecture-specific file for Linux kernel bits.
2021-09-01std: reorganize std.c to eliminate `usingnamespace`Andrew Kelley
Behavior tests pass on x86_64-linux with -lc