From 664956aaa0a952f5f83efdbd4a265dd420989368 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Sun, 11 Aug 2024 14:51:26 +0200 Subject: [PATCH] Fixed some issue when build OS is _time64 aware (should help #987 #983 #976 #975, maybe some other) --- CMakeLists.txt | 1 + src/emu/x86syscall.c | 6 +- src/include/myalign.h | 48 ++++++++++--- src/libtools/myalign.c | 84 +++++++++++++++++++++++ src/libtools/myalign64.c | 41 ++++++++--- src/libtools/myalignsys64.c | 47 +++++++++++++ src/libtools/threads.c | 32 +++++++-- src/libtools/vkalign.c | 3 - src/wrapped/generated/functions_list.txt | 1 + src/wrapped/generated/wrappedlibrttypes.h | 1 + src/wrapped/wrappedlibc.c | 56 +++++++-------- src/wrapped/wrappedlibc_private.h | 4 +- src/wrapped/wrappedlibrt.c | 40 ++++++++++- src/wrapped/wrappedlibrt_private.h | 6 +- 14 files changed, 306 insertions(+), 64 deletions(-) create mode 100644 src/libtools/myalignsys64.c diff --git a/CMakeLists.txt b/CMakeLists.txt index b5a75b051..af7f768fb 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -350,6 +350,7 @@ set(ELFLOADER_SRC "${BOX86_ROOT}/src/libtools/auxval.c" "${BOX86_ROOT}/src/libtools/myalign.c" "${BOX86_ROOT}/src/libtools/myalign64.c" + "${BOX86_ROOT}/src/libtools/myalignsys64.c" "${BOX86_ROOT}/src/libtools/stat64_helper.c" "${BOX86_ROOT}/src/libtools/myfts.c" "${BOX86_ROOT}/src/libtools/sdl1rwops.c" diff --git a/src/emu/x86syscall.c b/src/emu/x86syscall.c index 9d59b452f..9b28e09e1 100755 --- a/src/emu/x86syscall.c +++ b/src/emu/x86syscall.c @@ -685,7 +685,7 @@ void EXPORT x86Syscall(x86emu_t *emu) { struct stat64 st; unsigned int r = syscall(__NR_stat64, R_EBX, &st); - UnalignStat64(&st, (void*)R_ECX); + UnalignSysStat64(&st, (void*)R_ECX); R_EAX = r; } @@ -696,7 +696,7 @@ void EXPORT x86Syscall(x86emu_t *emu) { struct stat64 st; unsigned int r = syscall(__NR_lstat64, R_EBX, &st); - UnalignStat64(&st, (void*)R_ECX); + UnalignSysStat64(&st, (void*)R_ECX); R_EAX = r; } @@ -707,7 +707,7 @@ void EXPORT x86Syscall(x86emu_t *emu) { struct stat64 st; unsigned int r = syscall(__NR_fstat64, R_EBX, &st); - UnalignStat64(&st, (void*)R_ECX); + UnalignSysStat64(&st, (void*)R_ECX); R_EAX = r; } diff --git a/src/include/myalign.h b/src/include/myalign.h index 47c96ea5d..d27b1ff45 100755 --- a/src/include/myalign.h +++ b/src/include/myalign.h @@ -25,8 +25,11 @@ void myStackAlignW(const char* fmt, uint32_t* st, uint32_t* mystack); void AlignStat64(const void* source, void* dest); void UnalignStat64(const void* source, void* dest); +void UnalignSysStat64(const void* source, void* dest); +void UnalignStat(const void* source, void* dest); void UnalignStatFS64(const void* source, void* dest); +void UnalignStatFS(const void* source, void* dest); void UnalignOggVorbis(void* dest, void* source); // Arm -> x86 void AlignOggVorbis(void* dest, void* source); // x86 -> Arm @@ -43,6 +46,9 @@ void AlignEpollEvent(void* dest, void* source, int nbr); // x86 -> Arm void UnalignSmpegInfo(void* dest, void* source); // Arm -> x86 void AlignSmpegInfo(void* dest, void* source); // x86 -> Arm +void Timespec2Timespec64(void* dest, const void* source); +void Timespec642Timespec(void* dest, const void* source); + // stat64 is packed on i386, not on arm (and possibly other structures) #undef st_atime #undef st_atime_nsec @@ -50,19 +56,43 @@ void AlignSmpegInfo(void* dest, void* source); // x86 -> Arm #undef st_mtime_nsec #undef st_ctime #undef st_ctime_nsec + +struct i386_stat { + uint64_t st_dev; + uint32_t __pad1; + uint32_t st_ino; + uint32_t st_mode; + uint32_t st_nlink; + uint32_t st_uid; + uint32_t st_gid; + uint64_t st_rdev; + uint32_t __pad2; + int32_t st_size; + int32_t st_blksize; + int32_t st_blocks; + int32_t st_atime_sec; + uint32_t st_atime_nsec; + int32_t st_mtime_sec; + uint32_t st_mtime_nsec; + int32_t st_ctime_sec; + uint32_t st_ctime_nsec; + uint32_t __unused4; + uint32_t __unused5; +} __attribute__((packed)); + struct i386_stat64 { uint64_t st_dev; - uint8_t __pad0[4]; - uint32_t __st_ino; - uint32_t st_mode; - uint32_t st_nlink; - uint32_t st_uid; - uint32_t st_gid; + uint32_t __pad0; + uint32_t __st_ino; + uint32_t st_mode; + uint32_t st_nlink; + uint32_t st_uid; + uint32_t st_gid; uint64_t st_rdev; - uint8_t __pad3[4]; + uint32_t __pad3; int64_t st_size; - uint32_t st_blksize; - uint64_t st_blocks; + uint32_t st_blksize; + uint64_t st_blocks; uint32_t st_atime; uint32_t st_atime_nsec; uint32_t st_mtime; diff --git a/src/libtools/myalign.c b/src/libtools/myalign.c index f931279b8..9fe1eeece 100755 --- a/src/libtools/myalign.c +++ b/src/libtools/myalign.c @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include "x86emu.h" #include "emu/x86emu_private.h" @@ -918,3 +920,85 @@ void unalignNGValue(void* value, my_GValue_t* v, int n) --n; } } + +void UnalignStat(const void* source, void* dest) +{ + struct i386_stat *i386st = (struct i386_stat*)dest; + struct stat *st = (struct stat*) source; + + i386st->__pad1 = 0; + i386st->__pad2 = 0; + i386st->st_dev = st->st_dev; + i386st->st_ino = st->st_ino; + i386st->st_mode = st->st_mode; + i386st->st_nlink = st->st_nlink; + i386st->st_uid = st->st_uid; + i386st->st_gid = st->st_gid; + i386st->st_rdev = st->st_rdev; + i386st->st_size = st->st_size; + i386st->st_blksize = st->st_blksize; + i386st->st_blocks = st->st_blocks; + # ifdef __USE_XOPEN2K8 + i386st->st_atime_sec = st->st_atim.tv_sec; + i386st->st_atime_nsec = st->st_atim.tv_nsec; + i386st->st_mtime_sec = st->st_mtim.tv_sec; + i386st->st_mtime_nsec = st->st_mtim.tv_nsec; + i386st->st_ctime_sec = st->st_ctim.tv_sec; + i386st->st_ctime_nsec = st->st_ctim.tv_nsec; + #else + i386st->st_atime_sec = st->st_atime; + i386st->st_atime_nsec = st->st_atimensec; + i386st->st_mtime_sec = st->st_mtime; + i386st->st_mtime_nsec = st->st_mtimensec; + i386st->st_ctime_sec = st->st_ctime; + i386st->st_ctime_nsec = st->st_ctimensec; + #endif +} + +void UnalignStatFS(const void* source, void* dest) +{ + struct i386_statfs *i386st = (struct i386_statfs*)dest; + struct statfs *st = (struct statfs*) source; + + i386st->f_type = st->f_type; + i386st->f_bsize = st->f_bsize; + i386st->f_blocks = st->f_blocks; + i386st->f_bfree = st->f_bfree; + i386st->f_bavail = st->f_bavail; + i386st->f_files = st->f_files; + i386st->f_ffree = st->f_ffree; + memcpy(&i386st->f_fsid, &st->f_fsid, sizeof(i386st->f_fsid)); + i386st->f_namelen = st->f_namelen; + i386st->f_frsize = st->f_frsize; + i386st->f_flags = st->f_flags; + i386st->f_spare[0] = st->f_spare[0]; + i386st->f_spare[1] = st->f_spare[1]; + i386st->f_spare[2] = st->f_spare[2]; + i386st->f_spare[3] = st->f_spare[3]; +} + +typedef struct my_timespec_s { + int tv_sec; + int tv_nsec; +} my_timespec_t; + +typedef struct my_timespec64_s { + int64_t tv_sec; + int tv_nsec; + int :32; +} my_timespec64_t; + +void Timespec2Timespec64(void* dest, const void* source) +{ + my_timespec64_t* dst = (my_timespec64_t*)dest; + my_timespec_t* src = (my_timespec_t*)source; + dst->tv_sec = src->tv_sec; + dst->tv_nsec = src->tv_nsec; +} +void Timespec642Timespec(void* dest, const void* source) +{ + my_timespec_t* dst = (my_timespec_t*)dest; + my_timespec64_t* src = (my_timespec64_t*)source; + dst->tv_sec = src->tv_sec; + dst->tv_nsec = src->tv_nsec; +} diff --git a/src/libtools/myalign64.c b/src/libtools/myalign64.c index 86e6a95e1..666b3184c 100755 --- a/src/libtools/myalign64.c +++ b/src/libtools/myalign64.c @@ -5,27 +5,31 @@ #include #include #include -#include +#include #include #include +#include #include "x86emu.h" #include "emu/x86emu_private.h" #include "myalign.h" +#include "debug.h" void UnalignStat64(const void* source, void* dest) { struct i386_stat64 *i386st = (struct i386_stat64*)dest; struct stat64 *st = (struct stat64*) source; - memset(i386st->__pad0, 0, sizeof(i386st->__pad0)); - memset(i386st->__pad3, 0, sizeof(i386st->__pad3)); + i386st->__pad0 = 0; + i386st->__pad3 = 0; i386st->st_dev = st->st_dev; -#ifndef POWERPCLE - i386st->__st_ino = st->__st_ino; -#else +#ifdef __USE_TIME64_REDIRECTS + i386st->__st_ino = st->st_ino; +#elif defined(POWERPCLE) i386st->__st_ino = st->st_ino; // Separate __st_ino doesn't // exist on powerpc +#else + i386st->__st_ino = st->__st_ino; #endif i386st->st_mode = st->st_mode; i386st->st_nlink = st->st_nlink; @@ -35,12 +39,21 @@ void UnalignStat64(const void* source, void* dest) i386st->st_size = st->st_size; i386st->st_blksize = st->st_blksize; i386st->st_blocks = st->st_blocks; +# ifdef __USE_XOPEN2K8 + i386st->st_atime = st->st_atim.tv_sec; + i386st->st_atime_nsec = st->st_atim.tv_nsec; + i386st->st_mtime = st->st_mtim.tv_sec; + i386st->st_mtime_nsec = st->st_mtim.tv_nsec; + i386st->st_ctime = st->st_ctim.tv_sec; + i386st->st_ctime_nsec = st->st_ctim.tv_nsec; +#else i386st->st_atime = st->st_atime; i386st->st_atime_nsec = st->st_atime_nsec; i386st->st_mtime = st->st_mtime; i386st->st_mtime_nsec = st->st_mtime_nsec; i386st->st_ctime = st->st_ctime; i386st->st_ctime_nsec = st->st_ctime_nsec; +#endif i386st->st_ino = st->st_ino; } @@ -50,11 +63,10 @@ void AlignStat64(const void* source, void* dest) struct i386_stat64 *i386st = (struct i386_stat64*)source; st->st_dev = i386st->st_dev; -#ifndef POWERPCLE - st->__st_ino = i386st->__st_ino; +#if defined(__USE_TIME64_REDIRECTS) || defined(POWERPCLE) + // Separate __st_ino doesn't exist #else - st->st_ino = i386st->__st_ino; // Separate __st_ino doesn't - // exist on powerpc + st->__st_ino = i386st->__st_ino; #endif st->st_mode = i386st->st_mode; st->st_nlink = i386st->st_nlink; @@ -64,12 +76,21 @@ void AlignStat64(const void* source, void* dest) st->st_size = i386st->st_size; st->st_blksize = i386st->st_blksize; st->st_blocks = i386st->st_blocks; +#ifdef __USE_XOPEN2K8 + st->st_atim.tv_sec = i386st->st_atime; + st->st_atim.tv_nsec = i386st->st_atime_nsec; + st->st_mtim.tv_sec = i386st->st_mtime; + st->st_mtim.tv_nsec = i386st->st_mtime_nsec; + st->st_ctim.tv_sec = i386st->st_ctime; + st->st_ctim.tv_nsec = i386st->st_ctime_nsec; +#else st->st_atime = i386st->st_atime; st->st_atime_nsec = i386st->st_atime_nsec; st->st_mtime = i386st->st_mtime; st->st_mtime_nsec = i386st->st_mtime_nsec; st->st_ctime = i386st->st_ctime; st->st_ctime_nsec = i386st->st_ctime_nsec; +#endif st->st_ino = i386st->st_ino; } diff --git a/src/libtools/myalignsys64.c b/src/libtools/myalignsys64.c new file mode 100644 index 000000000..0e6e2d12e --- /dev/null +++ b/src/libtools/myalignsys64.c @@ -0,0 +1,47 @@ +#define _LARGEFILE_SOURCE 1 +#define _FILE_OFFSET_BITS 64 +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include + +#include "x86emu.h" +#include "emu/x86emu_private.h" +#include "myalign.h" +#include "debug.h" + +void UnalignSysStat64(const void* source, void* dest) +{ + struct i386_stat64 *i386st = (struct i386_stat64*)dest; + struct stat64 *st = (struct stat64*) source; + + i386st->__pad0 = 0; + i386st->__pad3 = 0; + i386st->st_dev = st->st_dev; +#ifndef POWERPCLE + i386st->__st_ino = st->__st_ino; +#else + i386st->__st_ino = st->st_ino; // Separate __st_ino doesn't + // exist on powerpc +#endif + i386st->st_mode = st->st_mode; + i386st->st_nlink = st->st_nlink; + i386st->st_uid = st->st_uid; + i386st->st_gid = st->st_gid; + i386st->st_rdev = st->st_rdev; + i386st->st_size = st->st_size; + i386st->st_blksize = st->st_blksize; + i386st->st_blocks = st->st_blocks; + i386st->st_atime = st->st_atime; + i386st->st_atime_nsec = st->st_atime_nsec; + i386st->st_mtime = st->st_mtime; + i386st->st_mtime_nsec = st->st_mtime_nsec; + i386st->st_ctime = st->st_ctime; + i386st->st_ctime_nsec = st->st_ctime_nsec; + i386st->st_ino = st->st_ino; +} diff --git a/src/libtools/threads.c b/src/libtools/threads.c index 07a16e659..207ed4616 100755 --- a/src/libtools/threads.c +++ b/src/libtools/threads.c @@ -569,7 +569,15 @@ EXPORT int my_pthread_cond_timedwait_old(x86emu_t* emu, void* cond, void* mutex, { (void)emu; pthread_cond_t * c = get_cond(cond); - return pthread_cond_timedwait(c, getAlignedMutex((pthread_mutex_t*)mutex), (const struct timespec*)abstime); + #ifdef __USE_TIME64_REDIRECTS + struct timespec t1; + Timespec2Timespec64(&t1, abstime); + #define T abstime?(&t1):NULL + #else + #define T (const struct timespec*)abstime + #endif + return pthread_cond_timedwait(c, getAlignedMutex((pthread_mutex_t*)mutex), T); + #undef T } EXPORT int my_pthread_cond_wait_old(x86emu_t* emu, void* cond, void* mutex) { @@ -581,7 +589,15 @@ EXPORT int my_pthread_cond_wait_old(x86emu_t* emu, void* cond, void* mutex) EXPORT int my_pthread_cond_timedwait(x86emu_t* emu, void* cond, void* mutex, void* abstime) { (void)emu; - return pthread_cond_timedwait((pthread_cond_t*)cond, getAlignedMutex((pthread_mutex_t*)mutex), (const struct timespec*)abstime); + #ifdef __USE_TIME64_REDIRECTS + struct timespec t1; + Timespec2Timespec64(&t1, abstime); + #define T abstime?(&t1):NULL + #else + #define T (const struct timespec*)abstime + #endif + return pthread_cond_timedwait((pthread_cond_t*)cond, getAlignedMutex((pthread_mutex_t*)mutex), T); + #undef T } EXPORT int my_pthread_cond_wait(x86emu_t* emu, void* cond, void* mutex) { @@ -914,9 +930,17 @@ EXPORT int my_pthread_mutex_lock(pthread_mutex_t *m) } EXPORT int my___pthread_mutex_lock(pthread_mutex_t *m) __attribute__((alias("my_pthread_mutex_lock"))); -EXPORT int my_pthread_mutex_timedlock(pthread_mutex_t *m, const struct timespec * t) +EXPORT int my_pthread_mutex_timedlock(pthread_mutex_t *m, void* abstime) { - return pthread_mutex_timedlock(getAlignedMutex(m), t); + #ifdef __USE_TIME64_REDIRECTS + struct timespec t1; + Timespec2Timespec64(&t1, abstime); + #define T abstime?(&t1):NULL + #else + #define T (const struct timespec*)abstime + #endif + return pthread_mutex_timedlock(getAlignedMutex(m), T); + #undef T } EXPORT int my_pthread_mutex_trylock(pthread_mutex_t *m) diff --git a/src/libtools/vkalign.c b/src/libtools/vkalign.c index 7cbae81e9..fef3b3228 100644 --- a/src/libtools/vkalign.c +++ b/src/libtools/vkalign.c @@ -1,6 +1,3 @@ -#undef _LARGEFILE_SOURCE -#undef _FILE_OFFSET_BITS -#undef _TIME_BITS #include #include #include diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt index ffd8de52f..443d61587 100644 --- a/src/wrapped/generated/functions_list.txt +++ b/src/wrapped/generated/functions_list.txt @@ -3694,6 +3694,7 @@ wrappedlibrt: - aio_cancel - iFupp: - timer_create +- iFiipp: - iFipip: - lio_listio wrappedlibsm: diff --git a/src/wrapped/generated/wrappedlibrttypes.h b/src/wrapped/generated/wrappedlibrttypes.h index b9b52f9da..47d8e851e 100644 --- a/src/wrapped/generated/wrappedlibrttypes.h +++ b/src/wrapped/generated/wrappedlibrttypes.h @@ -14,6 +14,7 @@ typedef int32_t (*iFp_t)(void*); typedef int32_t (*iFip_t)(int32_t, void*); typedef int32_t (*iFupp_t)(uint32_t, void*, void*); +typedef int32_t (*iFiipp_t)(int32_t, int32_t, void*, void*); typedef int32_t (*iFipip_t)(int32_t, void*, int32_t, void*); #define SUPER() ADDED_FUNCTIONS() \ diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c index e42f9f4e8..b5d8db870 100755 --- a/src/wrapped/wrappedlibc.c +++ b/src/wrapped/wrappedlibc.c @@ -1197,29 +1197,6 @@ EXPORT void my__ITM_registerTMCloneTable(x86emu_t* emu, void* p, uint32_t s) { ( EXPORT void my__ITM_deregisterTMCloneTable(x86emu_t* emu, void* p) { (void)emu; (void)p; } -struct i386_stat { - uint64_t st_dev; - uint32_t __pad1; - uint32_t st_ino; - uint32_t st_mode; - uint32_t st_nlink; - uint32_t st_uid; - uint32_t st_gid; - uint64_t st_rdev; - uint32_t __pad2; - int32_t st_size; - int32_t st_blksize; - int32_t st_blocks; - int32_t st_atime_sec; - uint32_t st_atime_nsec; - int32_t st_mtime_sec; - uint32_t st_mtime_nsec; - int32_t st_ctime_sec; - uint32_t st_ctime_nsec; - uint32_t __unused4; - uint32_t __unused5; -} __attribute__((packed)); - static int FillStatFromStat64(int vers, const struct stat64 *st64, void *st32) { struct i386_stat *i386st = (struct i386_stat *)st32; @@ -1264,14 +1241,13 @@ static int FillStatFromStat64(int vers, const struct stat64 *st64, void *st32) errno = EOVERFLOW; return -1; } - i386st->st_atime_sec = st64->st_atim.tv_sec; + i386st->st_atime_sec = st64->st_atim.tv_sec; i386st->st_atime_nsec = st64->st_atim.tv_nsec; - i386st->st_mtime_sec = st64->st_mtim.tv_sec; + i386st->st_mtime_sec = st64->st_mtim.tv_sec; i386st->st_mtime_nsec = st64->st_mtim.tv_nsec; - i386st->st_ctime_sec = st64->st_ctim.tv_sec; + i386st->st_ctime_sec = st64->st_ctim.tv_sec; i386st->st_ctime_nsec = st64->st_ctim.tv_nsec; - i386st->__unused4 = 0; - i386st->__unused5 = 0; + i386st->st_ino = 0; return 0; } @@ -1486,6 +1462,21 @@ EXPORT int my_statfs64(const char* path, void* buf) return r; } +EXPORT int my_fstatfs(int fd, void* buf) +{ + struct statfs st; + int r = fstatfs(fd, &st); + UnalignStatFS(&st, buf); + return r; +} + +EXPORT int my_statfs(const char* path, void* buf) +{ + struct statfs st; + int r = statfs(path, &st); + UnalignStatFS(&st, buf); + return r; +} #ifdef ANDROID typedef int (*__compar_d_fn_t)(const void*, const void*, void*); @@ -3385,7 +3376,16 @@ EXPORT int my_nanosleep(const struct timespec *req, struct timespec *rem) { if(!req) return 0; // workaround for some strange calls + #ifdef __USE_TIME64_REDIRECTS + struct timespec t1, t2; + Timespec2Timespec64(&t1, req); + int ret = nanosleep(&t1, rem?(&t2):NULL); + if(rem) + Timespec642Timespec(rem, &t2); + return ret; + #else return nanosleep(req, rem); + #endif } #ifndef NOALIGN diff --git a/src/wrapped/wrappedlibc_private.h b/src/wrapped/wrappedlibc_private.h index 5e63f19ea..e6eb27d8d 100755 --- a/src/wrapped/wrappedlibc_private.h +++ b/src/wrapped/wrappedlibc_private.h @@ -417,7 +417,7 @@ GO(__fsetlocking, iFpi) GO(fsetpos, iFpp) GO(fsetpos64, iFpp) GO(fsetxattr, iFippui) -GOW(fstatfs, iFip) +GOWM(fstatfs, iFip) //%%,noE GOWM(fstatfs64, iFip) //%%,noE GO(fstatvfs, iFip) GOW(fstatvfs64, iFip) // alignment? @@ -1645,7 +1645,7 @@ GO2(sscanf, iFppV, vsscanf) // sscanf va_list is only pointer, no realign to GOM(__stack_chk_fail, vFEv) //%% GOM(lstat64, iFEpp) GOM(stat64, iFEpp) -GOW(statfs, iFpp) +GOWM(statfs, iFpp) //%%,noE // __statfs GOWM(statfs64, iFpp) //%%,noE GO(statvfs, iFpp) diff --git a/src/wrapped/wrappedlibrt.c b/src/wrapped/wrappedlibrt.c index 09861a334..f13b0797c 100755 --- a/src/wrapped/wrappedlibrt.c +++ b/src/wrapped/wrappedlibrt.c @@ -22,6 +22,7 @@ #include "librarian.h" #include "box86context.h" #include "emu/x86emu_private.h" +#include "myalign.h" #undef aio_suspend #undef aio_return @@ -29,8 +30,6 @@ #undef aio_read #undef aio_error -#undef clock_gettime - const char* librtName = "librt.so.1"; #define LIBNAME librt @@ -155,6 +154,43 @@ EXPORT int mylio_listio(x86emu_t* emu, int mode, void* list[], int nent, struct } #endif +EXPORT int my_clock_gettime(int clock, void* buf) +{ + #ifdef __USE_TIME64_REDIRECTS + struct timespec spec; + int ret = clock_gettime(clock, &spec); + Timespec642Timespec(buf, &spec); + return ret; + #else + return clock_gettime(clock, buf); + #endif +} +EXPORT int my_clock_settime(int clock, void* buf) +{ + #ifdef __USE_TIME64_REDIRECTS + struct timespec spec; + Timespec2Timespec64(&spec, buf); + return clock_settime(clock, &spec); + #else + return clock_settime(clock, buf); + #endif +} + +EXPORT int my_clock_nanosleep(int clock, int flags, void* _t1, void* _t2) +{ + #ifdef __USE_TIME64_REDIRECTS + struct timespec t1, t2; + if(_t1) + Timespec2Timespec64(&t1, _t1); + int ret = clock_nanosleep(clock, flags, _t1?(&t1):NULL, _t2?(&t2):NULL); + if(_t2) + Timespec642Timespec(_t2, &t2); + return ret; + #else + return clock_nanosleep(clock, flags, _t1, _t2); + #endif +} + #define CUSTOM_INIT \ getMy(lib); diff --git a/src/wrapped/wrappedlibrt_private.h b/src/wrapped/wrappedlibrt_private.h index df74dc2ff..a7cc3df84 100755 --- a/src/wrapped/wrappedlibrt_private.h +++ b/src/wrapped/wrappedlibrt_private.h @@ -23,9 +23,9 @@ GOM(aio_write, iFEp) GOM(aio_write64, iFEp) GO(clock_getcpuclockid, iFup) GO(clock_getres, iFup) -GO(clock_gettime, iFup) -GO(clock_nanosleep, iFuipp) -GO(clock_settime, iFup) +GOM(clock_gettime, iFip) //%%,noE +GOM(clock_nanosleep, iFiipp) //%%,noE +GOM(clock_settime, iFip) //%%,noE GOM(lio_listio, iFEipip) // lio_listio64 // mq_close