mirror of
https://github.com/radareorg/radare2.git
synced 2025-03-04 04:17:25 +00:00
Fixes for <=glibc-2.2 versions
This commit is contained in:
parent
e54b8d0092
commit
14bc6586fc
@ -340,7 +340,13 @@ R_API int r_sys_usleep(int usecs) {
|
||||
rqtp.tv_nsec = (usecs - (rqtp.tv_sec * 1000000)) * 1000;
|
||||
return clock_nanosleep (CLOCK_MONOTONIC, 0, &rqtp, NULL);
|
||||
#elif __UNIX__
|
||||
#if defined(__GLIBC__) && defined(__GLIBC_MINOR__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 2)
|
||||
// Old versions of GNU libc return void for usleep
|
||||
usleep (usecs);
|
||||
return 0;
|
||||
#else
|
||||
return usleep (usecs);
|
||||
#endif
|
||||
#else
|
||||
// w32 api uses milliseconds
|
||||
usecs /= 1000;
|
||||
|
@ -132,6 +132,10 @@ R_API bool r_th_getname(RThread *th, char *name, size_t len) {
|
||||
|
||||
R_API bool r_th_setaffinity(RThread *th, int cpuid) {
|
||||
#if __linux__
|
||||
#if defined(__GLIBC__) && defined (__GLIBC_MINOR__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 2)
|
||||
// Old versions of GNU libc don't have this feature
|
||||
#pragma message("warning r_th_setaffinity not implemented")
|
||||
#else
|
||||
cpu_set_t c;
|
||||
CPU_ZERO(&c);
|
||||
CPU_SET(cpuid, &c);
|
||||
@ -140,6 +144,7 @@ R_API bool r_th_setaffinity(RThread *th, int cpuid) {
|
||||
eprintf ("Failed to set cpu affinity\n");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
#elif __FreeBSD__ || __DragonFly__
|
||||
cpuset_t c;
|
||||
CPU_ZERO(&c);
|
||||
|
@ -72,16 +72,16 @@ R_API char *r_time_stamp_to_str(ut32 timeStamp) {
|
||||
}
|
||||
|
||||
R_API ut32 r_time_dos_time_stamp_to_posix(ut32 timeStamp) {
|
||||
ut16 date = timeStamp >> 16;
|
||||
ut16 date = timeStamp >> 16;
|
||||
ut16 time = timeStamp & 0xFFFF;
|
||||
|
||||
|
||||
/* Date */
|
||||
ut32 year = ((date & 0xfe00) >> 9) + 1980;
|
||||
ut32 month = (date & 0x01e0) >> 5;
|
||||
ut32 day = date & 0x001f;
|
||||
|
||||
|
||||
/* Time */
|
||||
ut32 hour = (time & 0xf800) >> 11;
|
||||
ut32 hour = (time & 0xf800) >> 11;
|
||||
ut32 minutes = (time & 0x07e0) >> 5;
|
||||
ut32 seconds = (time & 0x001f) << 1;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user