You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Adds support for `gettid` and `statx` syscalls.
4
+
///
5
+
/// This module provides a minimal implementation of the `gettid` and `statx` syscalls for Linux.
6
+
/// It uses the `syscall` function to make the system calls directly.
7
+
///
8
+
/// Note: This does NOT introduce GLIBC_2.28/2.30 by itself. On the contrary, it is designed so that zigbuild is able to build our binaries while only requiring GLIBC_2.25.
9
+
///
10
+
use core::ffi::{c_int, c_long, c_void};
11
+
use std::ffi::c_char;
12
+
13
+
// Minimal C-ish types without the libc crate
14
+
typepid_t = i32;
15
+
16
+
// Pull in syscall + errno location from the C runtime (glibc),
17
+
// but note: this does NOT introduce GLIBC_2.28/2.30 by itself.
18
+
extern"C"{
19
+
fnsyscall(num:c_long, ...) -> c_long;
20
+
fn__errno_location() -> *mutc_int;
21
+
}
22
+
23
+
// x86_64 syscall numbers
24
+
#[cfg(target_arch = "x86_64")]
25
+
constSYS_GETTID:c_long = 186;
26
+
#[cfg(target_arch = "x86_64")]
27
+
constSYS_STATX:c_long = 332;
28
+
29
+
// aarch64 syscall numbers
30
+
#[cfg(target_arch = "aarch64")]
31
+
constSYS_GETTID:c_long = 178;
32
+
#[cfg(target_arch = "aarch64")]
33
+
constSYS_STATX:c_long = 291;
34
+
35
+
#[no_mangle]
36
+
pubunsafeextern"C"fngettid() -> pid_t{
37
+
syscall(SYS_GETTID)aspid_t
38
+
}
39
+
40
+
#[repr(C)]
41
+
pubstructstatx_timestamp{
42
+
pubtv_sec:i64,
43
+
pubtv_nsec:u32,
44
+
pub__reserved:i32,
45
+
}
46
+
47
+
#[repr(C)]
48
+
pubstructstatx{
49
+
pubstx_mask:u32,
50
+
pubstx_blksize:u32,
51
+
pubstx_attributes:u64,
52
+
pubstx_nlink:u32,
53
+
pubstx_uid:u32,
54
+
pubstx_gid:u32,
55
+
pubstx_mode:u16,
56
+
pub__spare0:u16,
57
+
pubstx_ino:u64,
58
+
pubstx_size:u64,
59
+
pubstx_blocks:u64,
60
+
pubstx_attributes_mask:u64,
61
+
pubstx_atime:statx_timestamp,
62
+
pubstx_btime:statx_timestamp,
63
+
pubstx_ctime:statx_timestamp,
64
+
pubstx_mtime:statx_timestamp,
65
+
pubstx_rdev_major:u32,
66
+
pubstx_rdev_minor:u32,
67
+
pubstx_dev_major:u32,
68
+
pubstx_dev_minor:u32,
69
+
pubstx_mnt_id:u64,
70
+
pubstx_dio_mem_align:u32,
71
+
pubstx_dio_offset_align:u32,
72
+
pub__spare3:[u64;12],
73
+
}
74
+
75
+
#[no_mangle]
76
+
pubunsafeextern"C"fnstatx(
77
+
dirfd:c_int,
78
+
pathname:*constc_char,
79
+
flags:c_int,
80
+
mask:u32,
81
+
buf:*mutstatx,
82
+
) -> c_int{
83
+
let ret = syscall(SYS_STATX, dirfd, pathname, flags, mask, buf as*mutc_void);
0 commit comments