| author | |
| committer | |
| log | 38ba4127290d860cadcf078eeda7213094f6c3c7 |
| tree | 38cda37cc4a33441618412e68f1de813faaab944 |
| parent | e12eb5e7f6d257323adf949c9c850323b9d4ebba |
| parent | 111e5ed0a24ca7e96d24e0967b6c28226c0f3297 |
| signature |
std: improvements to linux constants5 files changed, 115 insertions(+), 24 deletions(-)
std/c/linux.zig+3| ... | ... | @@ -1,9 +1,12 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | const maxInt = std.math.maxInt; | |
| 2 | 3 | usingnamespace std.c; |
| 3 | 4 | |
| 4 | 5 | extern "c" fn __errno_location() *c_int; |
| 5 | 6 | pub const _errno = __errno_location; |
| 6 | 7 | |
| 8 | pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); | |
| 9 | ||
| 7 | 10 | pub extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) c_int; |
| 8 | 11 | pub extern "c" fn sched_getaffinity(pid: c_int, size: usize, set: *cpu_set_t) c_int; |
| 9 | 12 | pub extern "c" fn eventfd(initval: c_uint, flags: c_uint) c_int; |
std/os.zig+1-1| ... | ... | @@ -1961,7 +1961,7 @@ pub fn mmap( |
| 1961 | 1961 | ) MMapError![]align(mem.page_size) u8 { |
| 1962 | 1962 | const err = if (builtin.link_libc) blk: { |
| 1963 | 1963 | const rc = std.c.mmap(ptr, length, prot, flags, fd, offset); |
| 1964 | if (rc != MAP_FAILED) return @ptrCast([*]align(mem.page_size) u8, @alignCast(mem.page_size, rc))[0..length]; | |
| 1964 | if (rc != std.c.MAP_FAILED) return @ptrCast([*]align(mem.page_size) u8, @alignCast(mem.page_size, rc))[0..length]; | |
| 1965 | 1965 | break :blk @intCast(usize, system._errno().*); |
| 1966 | 1966 | } else blk: { |
| 1967 | 1967 | const rc = system.mmap(ptr, length, prot, flags, fd, offset); |
std/os/bits/linux.zig+50-11| ... | ... | @@ -22,6 +22,36 @@ pub const STDIN_FILENO = 0; |
| 22 | 22 | pub const STDOUT_FILENO = 1; |
| 23 | 23 | pub const STDERR_FILENO = 2; |
| 24 | 24 | |
| 25 | /// Special value used to indicate openat should use the current working directory | |
| 26 | pub const AT_FDCWD = 100; | |
| 27 | ||
| 28 | /// Do not follow symbolic links | |
| 29 | pub const AT_SYMLINK_NOFOLLOW = 0x100; | |
| 30 | ||
| 31 | /// Remove directory instead of unlinking file | |
| 32 | pub const AT_REMOVEDIR = 0x200; | |
| 33 | ||
| 34 | /// Follow symbolic links. | |
| 35 | pub const AT_SYMLINK_FOLLOW = 0x400; | |
| 36 | ||
| 37 | /// Suppress terminal automount traversal | |
| 38 | pub const AT_NO_AUTOMOUNT = 0x800; | |
| 39 | ||
| 40 | /// Allow empty relative pathname | |
| 41 | pub const AT_EMPTY_PATH = 0x1000; | |
| 42 | ||
| 43 | /// Type of synchronisation required from statx() | |
| 44 | pub const AT_STATX_SYNC_TYPE = 0x6000; | |
| 45 | ||
| 46 | /// - Do whatever stat() does | |
| 47 | pub const AT_STATX_SYNC_AS_STAT = 0x0000; | |
| 48 | ||
| 49 | /// - Force the attributes to be sync'd with the server | |
| 50 | pub const AT_STATX_FORCE_SYNC = 0x2000; | |
| 51 | ||
| 52 | /// - Don't sync attributes with the server | |
| 53 | pub const AT_STATX_DONT_SYNC = 0x4000; | |
| 54 | ||
| 25 | 55 | pub const FUTEX_WAIT = 0; |
| 26 | 56 | pub const FUTEX_WAKE = 1; |
| 27 | 57 | pub const FUTEX_FD = 2; |
| ... | ... | @@ -44,22 +74,31 @@ pub const PROT_EXEC = 4; |
| 44 | 74 | pub const PROT_GROWSDOWN = 0x01000000; |
| 45 | 75 | pub const PROT_GROWSUP = 0x02000000; |
| 46 | 76 | |
| 47 | pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); | |
| 77 | /// Share changes | |
| 48 | 78 | pub const MAP_SHARED = 0x01; |
| 79 | ||
| 80 | /// Changes are private | |
| 49 | 81 | pub const MAP_PRIVATE = 0x02; |
| 82 | ||
| 83 | /// share + validate extension flags | |
| 84 | pub const MAP_SHARED_VALIDATE = 0x03; | |
| 85 | ||
| 86 | /// Mask for type of mapping | |
| 50 | 87 | pub const MAP_TYPE = 0x0f; |
| 88 | ||
| 89 | /// Interpret addr exactly | |
| 51 | 90 | pub const MAP_FIXED = 0x10; |
| 91 | ||
| 92 | /// don't use a file | |
| 52 | 93 | pub const MAP_ANONYMOUS = 0x20; |
| 53 | pub const MAP_NORESERVE = 0x4000; | |
| 54 | pub const MAP_GROWSDOWN = 0x0100; | |
| 55 | pub const MAP_DENYWRITE = 0x0800; | |
| 56 | pub const MAP_EXECUTABLE = 0x1000; | |
| 57 | pub const MAP_LOCKED = 0x2000; | |
| 58 | pub const MAP_POPULATE = 0x8000; | |
| 59 | pub const MAP_NONBLOCK = 0x10000; | |
| 60 | pub const MAP_STACK = 0x20000; | |
| 61 | pub const MAP_HUGETLB = 0x40000; | |
| 62 | pub const MAP_FILE = 0; | |
| 94 | ||
| 95 | /// For anonymous mmap, memory could be uninitialized | |
| 96 | pub const MAP_UNINITIALIZED = 0x4000000; | |
| 97 | ||
| 98 | // MAP_ 0x0100 - 0x80000 flags are per architecture | |
| 99 | ||
| 100 | /// MAP_FIXED which doesn't unmap underlying mapping | |
| 101 | pub const MAP_FIXED_NOREPLACE = 0x100000; | |
| 63 | 102 | |
| 64 | 103 | pub const F_OK = 0; |
| 65 | 104 | pub const X_OK = 1; |
std/os/bits/linux/arm64.zig+29-6| ... | ... | @@ -331,12 +331,35 @@ pub const F_GETOWN_EX = 16; |
| 331 | 331 | |
| 332 | 332 | pub const F_GETOWNER_UIDS = 17; |
| 333 | 333 | |
| 334 | pub const AT_FDCWD = -100; | |
| 335 | pub const AT_SYMLINK_NOFOLLOW = 0x100; | |
| 336 | pub const AT_REMOVEDIR = 0x200; | |
| 337 | pub const AT_SYMLINK_FOLLOW = 0x400; | |
| 338 | pub const AT_NO_AUTOMOUNT = 0x800; | |
| 339 | pub const AT_EMPTY_PATH = 0x1000; | |
| 334 | /// stack-like segment | |
| 335 | pub const MAP_GROWSDOWN = 0x0100; | |
| 336 | ||
| 337 | /// ETXTBSY | |
| 338 | pub const MAP_DENYWRITE = 0x0800; | |
| 339 | ||
| 340 | /// mark it as an executable | |
| 341 | pub const MAP_EXECUTABLE = 0x1000; | |
| 342 | ||
| 343 | /// pages are locked | |
| 344 | pub const MAP_LOCKED = 0x2000; | |
| 345 | ||
| 346 | /// don't check for reservations | |
| 347 | pub const MAP_NORESERVE = 0x4000; | |
| 348 | ||
| 349 | /// populate (prefault) pagetables | |
| 350 | pub const MAP_POPULATE = 0x8000; | |
| 351 | ||
| 352 | /// do not block on IO | |
| 353 | pub const MAP_NONBLOCK = 0x10000; | |
| 354 | ||
| 355 | /// give out an address that is best suited for process/thread stacks | |
| 356 | pub const MAP_STACK = 0x20000; | |
| 357 | ||
| 358 | /// create a huge page mapping | |
| 359 | pub const MAP_HUGETLB = 0x40000; | |
| 360 | ||
| 361 | /// perform synchronous page faults for the mapping | |
| 362 | pub const MAP_SYNC = 0x80000; | |
| 340 | 363 | |
| 341 | 364 | pub const VDSO_USEFUL = true; |
| 342 | 365 | pub const VDSO_CGT_SYM = "__kernel_clock_gettime"; |
std/os/bits/linux/x86_64.zig+32-6| ... | ... | @@ -394,12 +394,38 @@ pub const F_GETOWN_EX = 16; |
| 394 | 394 | |
| 395 | 395 | pub const F_GETOWNER_UIDS = 17; |
| 396 | 396 | |
| 397 | pub const AT_FDCWD = -100; | |
| 398 | pub const AT_SYMLINK_NOFOLLOW = 0x100; | |
| 399 | pub const AT_REMOVEDIR = 0x200; | |
| 400 | pub const AT_SYMLINK_FOLLOW = 0x400; | |
| 401 | pub const AT_NO_AUTOMOUNT = 0x800; | |
| 402 | pub const AT_EMPTY_PATH = 0x1000; | |
| 397 | /// only give out 32bit addresses | |
| 398 | pub const MAP_32BIT = 0x40; | |
| 399 | ||
| 400 | /// stack-like segment | |
| 401 | pub const MAP_GROWSDOWN = 0x0100; | |
| 402 | ||
| 403 | /// ETXTBSY | |
| 404 | pub const MAP_DENYWRITE = 0x0800; | |
| 405 | ||
| 406 | /// mark it as an executable | |
| 407 | pub const MAP_EXECUTABLE = 0x1000; | |
| 408 | ||
| 409 | /// pages are locked | |
| 410 | pub const MAP_LOCKED = 0x2000; | |
| 411 | ||
| 412 | /// don't check for reservations | |
| 413 | pub const MAP_NORESERVE = 0x4000; | |
| 414 | ||
| 415 | /// populate (prefault) pagetables | |
| 416 | pub const MAP_POPULATE = 0x8000; | |
| 417 | ||
| 418 | /// do not block on IO | |
| 419 | pub const MAP_NONBLOCK = 0x10000; | |
| 420 | ||
| 421 | /// give out an address that is best suited for process/thread stacks | |
| 422 | pub const MAP_STACK = 0x20000; | |
| 423 | ||
| 424 | /// create a huge page mapping | |
| 425 | pub const MAP_HUGETLB = 0x40000; | |
| 426 | ||
| 427 | /// perform synchronous page faults for the mapping | |
| 428 | pub const MAP_SYNC = 0x80000; | |
| 403 | 429 | |
| 404 | 430 | pub const VDSO_USEFUL = true; |
| 405 | 431 | pub const VDSO_CGT_SYM = "__vdso_clock_gettime"; |