diff --git a/mod.zig b/mod.zig index 020b6ae996c24e70f838d9a2f612edd5489133e7..0adf8ccae38f16a2de1d2a14eb15b89788b5e51e 100644 --- a/mod.zig +++ b/mod.zig @@ -2814,6 +2814,21 @@ pub const S = struct { pub const IRWXO = 0o007; }; +pub const CLOCK = struct { + pub const REALTIME = 0; + pub const MONOTONIC = 1; + pub const PROCESS_CPUTIME_ID = 2; + pub const THREAD_CPUTIME_ID = 3; + pub const MONOTONIC_RAW = 4; + pub const REALTIME_COARSE = 5; + pub const MONOTONIC_COARSE = 6; + pub const BOOTTIME = 7; + pub const REALTIME_ALARM = 8; + pub const BOOTTIME_ALARM = 9; + pub const SGI_CYCLE = 10; + pub const TAI = 11; +}; + pub const NAME_MAX = 255; pub const PATH_MAX = 4096; pub const NGROUPS_MAX = 32; @@ -3108,3 +3123,10 @@ pub fn getaddrinfo(noalias nodename: ?[*:0]const u8, noalias servname: ?[*:0]con pub fn freeaddrinfo(ai: *const struct_addrinfo) void { return libc.freeaddrinfo(ai); } +pub fn clock_gettime(clock_id: clockid_t) !struct_timespec { + var tp: struct_timespec = undefined; + const rc = libc.clock_gettime(clock_id, &tp); + if (rc == -1) return errno.fromInt(errno.fromLibC()); + std.debug.assert(rc == 0); + return tp; +} diff --git a/test.zig b/test.zig index b24d22ac335d0202d9536189cced29516f5a30f6..ff8468da0655681e71d891c00452fd87e90015fc 100644 --- a/test.zig +++ b/test.zig @@ -27,4 +27,5 @@ test { _ = &linux.recv; _ = &linux.getaddrinfo; _ = &linux.freeaddrinfo; + _ = &linux.clock_gettime; }