Skip to content

Commit 949608a

Browse files
committed
Add target-dependent rule for gettimeofday
1 parent 943b97c commit 949608a

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

rules/time/src.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,15 @@ size_t f6(char *s, size_t maxsize, const char *format, const struct tm *tp) {
2525
int f7(const char *file, const struct timeval tvp[2]) {
2626
return utimes(file, tvp);
2727
}
28+
29+
#if defined(__linux__)
30+
int f8(struct timeval *tv, struct timezone *tz) {
31+
return gettimeofday(tv, tz);
32+
}
33+
#elif defined(__APPLE__)
34+
int f8(struct timeval *tv, void *tz) {
35+
return gettimeofday(tv, tz);
36+
}
37+
#else
38+
#error "Unsupported platform for gettimeofday"
39+
#endif

rules/time/tgt_unsafe.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,13 @@ unsafe fn f6(a0: *mut u8, a1: u64, a2: *const u8, a3: *const ::libc::tm) -> u64
2424
unsafe fn f7(a0: *const u8, a1: *const ::libc::timeval) -> i32 {
2525
libc::utimes(a0 as *const i8, a1)
2626
}
27+
28+
#[cfg(target_os = "linux")]
29+
unsafe fn f8(a0: *mut libc::timeval, a1: *mut libc::timezone) -> i32 {
30+
libc::gettimeofday(a0, a1)
31+
}
32+
33+
#[cfg(target_os = "macos")]
34+
unsafe fn f8(a0: *mut libc::timeval, a1: *mut libc::c_void) -> i32 {
35+
libc::gettimeofday(a0, a1)
36+
}

0 commit comments

Comments
 (0)