• 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 <limits.h>
10 #include <linux/icmp.h>
11 #include <stddef.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include <sys/resource.h>
15 #include <sys/sysmacros.h>
16 #include <sys/time.h>
17 #include <sys/types.h>
18 #include <sys/utsname.h>
19 #include <unistd.h>
20 
21 #define __GLIBC_PREREQ(a, b) 1
22 
23 #define DEV_BSIZE 512
24 #define NGROUPS NGROUPS_MAX
25 #define SHMLBA sysconf(_SC_PAGESIZE)
26 #define SIGCLD SIGCHLD
27 #define S_IREAD S_IRUSR
28 #define S_IWRITE S_IWUSR
29 #define _UTSNAME_DOMAIN_LENGTH SYS_NMLN
30 #define _UTSNAME_LENGTH SYS_NMLN
31 #define LINE_MAX _POSIX2_LINE_MAX
32 /* Bionic doesn't support extended patterns and
33  * as of LTP20180515, this only used by read_all.c
34  * which is run from runtest/fs.
35  *
36  * LTP does not pass the argument that will end up
37  * going down the extended pattern match call, so
38  * we are safe here. This is for *build* purposes only
39  * and we don't alter behavior
40  */
41 #define FNM_EXTMATCH 0
42 
43 enum __ptrace_request { ENUM_PTRACE_UNUSED };
44 typedef unsigned long ulong;
45 
valloc(size_t size)46 static inline void *valloc(size_t size)
47 {
48     return memalign(sysconf(_SC_PAGESIZE), size);
49 }
50 
get_current_dir_name(void)51 static inline char *get_current_dir_name(void)
52 {
53     return getcwd(NULL, 0);
54 }
55 
getdtablesize(void)56 static inline int getdtablesize(void)
57 {
58     struct rlimit lim;
59     int err = getrlimit(RLIMIT_NOFILE, &lim);
60     if (err < 0)
61         return err;
62 
63     return lim.rlim_cur;
64 }
65 
pthread_testcancel(void)66 static inline void pthread_testcancel(void) { }
pthread_cancel(pthread_t thread)67 static inline int pthread_cancel(pthread_t thread) { return 0; }
pthread_yield(void)68 static inline int pthread_yield(void)
69 {
70     extern int sched_yield(void);
71     return sched_yield();
72 }
73 
74 #endif /* __BIONIC_COMPAT_H */
75