1 #ifndef __BIONIC_COMPAT_H
2 #define __BIONIC_COMPAT_H
3 
4 /* These functions and definitions aren't candidates for adding to bionic:
5  * they've either been removed from POSIX or are glibc extensions.
6  */
7 
8 #define _GNU_SOURCE
9 #include <stddef.h>
10 #include <stdlib.h>
11 #include <string.h>
12 #include <unistd.h>
13 #include <sys/time.h>
14 #include <sys/types.h>
15 #include <sys/utsname.h>
16 #include <sys/resource.h>
17 #include <linux/icmp.h>
18 
19 #define __GLIBC_PREREQ(a, b) 1
20 
21 #define DEV_BSIZE 512
22 #define NGROUPS NGROUPS_MAX
23 #define SHMLBA sysconf(_SC_PAGESIZE)
24 #define SIGCLD SIGCHLD
25 #define S_IREAD S_IRUSR
26 #define S_IWRITE S_IWUSR
27 #define _UTSNAME_DOMAIN_LENGTH SYS_NMLN
28 #define _UTSNAME_LENGTH SYS_NMLN
29 
30 enum __ptrace_request { ENUM_PTRACE_UNUSED };
31 typedef unsigned long ulong;
32 
valloc(size_t size)33 static inline void *valloc(size_t size)
34 {
35     return memalign(sysconf(_SC_PAGESIZE), size);
36 }
37 
get_current_dir_name(void)38 static inline char *get_current_dir_name(void)
39 {
40     return getcwd(NULL, 0);
41 }
42 
getdtablesize(void)43 static inline int getdtablesize(void)
44 {
45     struct rlimit lim;
46     int err = getrlimit(RLIMIT_NOFILE, &lim);
47     if (err < 0)
48         return err;
49 
50     return lim.rlim_cur;
51 }
52 
pthread_testcancel(void)53 static inline void pthread_testcancel(void) { }
pthread_cancel(pthread_t thread)54 static inline int pthread_cancel(pthread_t thread) { return 0; }
pthread_yield(void)55 static inline int pthread_yield(void)
56 {
57     extern int sched_yield(void);
58     return sched_yield();
59 }
60 
61 #endif /* __BIONIC_COMPAT_H */
62