| Age | Commit message (Collapse) | Author |
|
Closes #12529
Closes #12511
Closes #6835
|
|
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.
|
|
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.
|
|
|
|
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
|
|
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
...
```
|
|
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.
|
|
Fixes: https://github.com/ziglang/zig/issues/11802
|
|
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.
|
|
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.
|
|
This is minorly breaking as e.g. std.os.linux.MFD_CLOEXEC is now
std.os.linux.MFD.CLOEXEC.
|
|
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)
|
|
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.
|
|
|
|
- Add type annotation for AUDIT.current.
- Make unsupported archs a compile error.
|
|
Add Seccomp bits for linux
|
|
|
|
|
|
|
|
intToPtr on optional ptr
|
|
|
|
|
|
std: validate frame-pointer address in stack walking
|
|
Signed-off-by: Tw <wei.tan@intel.com>
|
|
|
|
|
|
Also adds the _CSKY and _FRV ELF machines that are defined in
`<linux/elf-em.h>`
|
|
|
|
zig fmt now replaces c_void with anyopaque to make updating
code easy.
|
|
|
|
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
|
|
On MIPS and SPARC the RLIMIT kinds have different numbers than the other
architectures.
|
|
|
|
SPARCv9: make more tests pass
|
|
|
|
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) {}
}
```
|
|
|
|
closes #9388
closes #9321
|
|
* 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>
|
|
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
|
|
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.
|
|
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.
|
|
|
|
This commit reapplies 4f0aa7d639e099b18df583cb984412037fbb1dbe.
|
|
|
|
Also move some usingnamespace test cases from compare_output to
behavior.
|
|
The proposal #9629 is now accepted, usingnamespace stays but no longer
puts identifiers in scope.
|
|
* 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`
|
|
Now there is only 1 architecture-specific file for Linux kernel bits.
|
|
Behavior tests pass on x86_64-linux with -lc
|