| 1 |
#include "dependency.h" |
| 2 |
#include <errno.h> |
| 3 |
#include <malloc.h> |
| 4 |
#include <math.h> |
| 5 |
#include <pthread.h> |
| 6 |
#include <stdint.h> |
| 7 |
#include <stdlib.h> |
| 8 |
#include <time.h> |
| 9 |
#include <unistd.h> |
| 10 |
#if defined(__GLIBC_PREREQ) |
| 11 |
#if __GLIBC_PREREQ(2, 39) |
| 12 |
#include <sys/pidfd.h> |
| 13 |
#endif |
| 14 |
#if __GLIBC_PREREQ(2, 35) |
| 15 |
#include <sys/epoll.h> |
| 16 |
#endif |
| 17 |
#if __GLIBC_PREREQ(2, 28) |
| 18 |
#include <threads.h> |
| 19 |
#endif |
| 20 |
#endif |
| 21 |
|
| 22 |
int dep_run() |
| 23 |
{ |
| 24 |
#if defined(__GLIBC_PREREQ) |
| 25 |
#if __GLIBC_PREREQ(2, 39) |
| 26 |
return (pidfd_getpid(0) == pidfd_getpid(0)) ? 0 : 1; |
| 27 |
#elif __GLIBC_PREREQ(2, 35) |
| 28 |
return (epoll_pwait2(0, NULL, 0, NULL, NULL) == epoll_pwait2(0, NULL, 0, NULL, NULL)) ? 0 : 1; |
| 29 |
#elif __GLIBC_PREREQ(2, 34) |
| 30 |
// pthread_mutexattr_init was moved to libc.so.6 in manylinux_2_34+ |
| 31 |
pthread_mutexattr_t attr; |
| 32 |
int sts = pthread_mutexattr_init(&attr); |
| 33 |
if (sts == 0) { |
| 34 |
pthread_mutexattr_destroy(&attr); |
| 35 |
} |
| 36 |
return sts; |
| 37 |
#elif __GLIBC_PREREQ(2, 30) |
| 38 |
return gettid() == getpid() ? 0 : 1; |
| 39 |
#elif __GLIBC_PREREQ(2, 28) |
| 40 |
return thrd_equal(thrd_current(), thrd_current()) ? 0 : 1; |
| 41 |
#elif __GLIBC_PREREQ(2, 24) |
| 42 |
return (int)nextupf(0.0F); |
| 43 |
#elif __GLIBC_PREREQ(2, 17) |
| 44 |
return (int)(intptr_t)secure_getenv("NON_EXISTING_ENV_VARIABLE"); |
| 45 |
#elif __GLIBC_PREREQ(2, 10) |
| 46 |
return malloc_info(0, stdout); |
| 47 |
#else |
| 48 |
return 0; |
| 49 |
#endif |
| 50 |
#else // !defined(__GLIBC_PREREQ) |
| 51 |
return 0; |
| 52 |
#endif |
| 53 |
} |