• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/resource.h>
14 #include <sys/sysmacros.h>
15 #include <sys/time.h>
16 #include <sys/types.h>
17 #include <sys/utsname.h>
18 #include <linux/icmp.h>
19 
20 #define __GLIBC_PREREQ(a, b) 1
21 
22 #define DEV_BSIZE 512
23 #define NGROUPS NGROUPS_MAX
24 #define SHMLBA sysconf(_SC_PAGESIZE)
25 #define SIGCLD SIGCHLD
26 #define S_IREAD S_IRUSR
27 #define S_IWRITE S_IWUSR
28 #define _UTSNAME_DOMAIN_LENGTH SYS_NMLN
29 #define _UTSNAME_LENGTH SYS_NMLN
30 
31 enum __ptrace_request { ENUM_PTRACE_UNUSED };
32 typedef unsigned long ulong;
33 
valloc(size_t size)34 static inline void *valloc(size_t size)
35 {
36     return memalign(sysconf(_SC_PAGESIZE), size);
37 }
38 
get_current_dir_name(void)39 static inline char *get_current_dir_name(void)
40 {
41     return getcwd(NULL, 0);
42 }
43 
getdtablesize(void)44 static inline int getdtablesize(void)
45 {
46     struct rlimit lim;
47     int err = getrlimit(RLIMIT_NOFILE, &lim);
48     if (err < 0)
49         return err;
50 
51     return lim.rlim_cur;
52 }
53 
pthread_testcancel(void)54 static inline void pthread_testcancel(void) { }
pthread_cancel(pthread_t thread)55 static inline int pthread_cancel(pthread_t thread) { return 0; }
pthread_yield(void)56 static inline int pthread_yield(void)
57 {
58     extern int sched_yield(void);
59     return sched_yield();
60 }
61 
62 #endif /* __BIONIC_COMPAT_H */
63