Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions rules/cstring/src.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,15 @@ void *f24(const void *a0, int a1, size_t a2) { return memrchr(a0, a1, a2); }
#endif

int f27(const char *a0, const char *a1) { return strcasecmp(a0, a1); }

#if defined(__linux__)
char *f28(int errnum, char *buf, size_t buflen) {
return strerror_r(errnum, buf, buflen);
}
#elif defined(__APPLE__)
int f28(int errnum, char *buf, size_t buflen) {
return strerror_r(errnum, buf, buflen);
}
#else
#error "Unsupported platform for strerror_r"
#endif
18 changes: 18 additions & 0 deletions rules/cstring/tgt_unsafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,21 @@ unsafe fn f26(a0: *mut u8, a1: i32, a2: usize) -> *mut ::libc::c_void {
unsafe fn f27(a0: *const u8, a1: *const u8) -> i32 {
libc::strcasecmp(a0 as *const i8, a1 as *const i8)
}

// From the man page:
//
// The GNU-specific strerror_r() returns a pointer to a string containing the error message. This
// may be either a pointer to a string that the function stores in buf, or a pointer to some
// (immutable) static string (in which case buf is unused)
//
// So it's not 100% correct to always return a1. But the Rust libc version only returns int.
#[cfg(target_os = "linux")]
unsafe fn f28(a0: i32, a1: *mut u8, a2: usize) -> *mut u8 {
libc::strerror_r(a0, a1 as *mut i8, a2 as usize);
a1
}

#[cfg(target_os = "macos")]
unsafe fn f28(a0: i32, a1: *mut u8, a2: usize) -> i32 {
libc::strerror_r(a0, a1 as *mut i8, a2 as usize)
}
12 changes: 12 additions & 0 deletions rules/time/src.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,15 @@ size_t f6(char *s, size_t maxsize, const char *format, const struct tm *tp) {
int f7(const char *file, const struct timeval tvp[2]) {
return utimes(file, tvp);
}

#if defined(__linux__)
int f8(struct timeval *tv, struct timezone *tz) {
return gettimeofday(tv, tz);
}
#elif defined(__APPLE__)
int f8(struct timeval *tv, void *tz) {
return gettimeofday(tv, tz);
}
#else
#error "Unsupported platform for gettimeofday"
#endif
10 changes: 10 additions & 0 deletions rules/time/tgt_unsafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,13 @@ unsafe fn f6(a0: *mut u8, a1: u64, a2: *const u8, a3: *const ::libc::tm) -> u64
unsafe fn f7(a0: *const u8, a1: *const ::libc::timeval) -> i32 {
libc::utimes(a0 as *const i8, a1)
}

#[cfg(target_os = "linux")]
unsafe fn f8(a0: *mut libc::timeval, a1: *mut libc::timezone) -> i32 {
libc::gettimeofday(a0, a1 as *mut libc::timezone)
}

#[cfg(target_os = "macos")]
unsafe fn f8(a0: *mut libc::timeval, a1: *mut libc::c_void) -> i32 {
libc::gettimeofday(a0, a1)
}
Loading