aboutsummaryrefslogtreecommitdiff
path: root/android/include/bionic-compat.h
blob: 01b3279e9bca0e3becdcab15ea9de16aed8c8b7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef __BIONIC_COMPAT_H
#define __BIONIC_COMPAT_H

/* These functions and definitions aren't candidates for adding to bionic:
 * they've either been removed from POSIX or are glibc extensions.
 */

#define _GNU_SOURCE
#include <limits.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <sys/resource.h>
#include <sys/sysmacros.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <unistd.h>

#define __GLIBC_PREREQ(a, b) 1

// TODO: remove after https://android-review.git.corp.google.com/c/platform/bionic/+/3034152
#define LINE_MAX _POSIX2_LINE_MAX

#define _UTSNAME_DOMAIN_LENGTH SYS_NMLN
#define _UTSNAME_LENGTH SYS_NMLN

/* Bionic doesn't support extended patterns and
 * as of LTP20180515, this only used by read_all.c
 * which is run from runtest/fs.
 *
 * LTP does not pass the argument that will end up
 * going down the extended pattern match call, so
 * we are safe here. This is for *build* purposes only
 * and we don't alter behavior
 */
#define FNM_EXTMATCH 0

typedef unsigned long ulong;

static inline void *valloc(size_t size)
{
    return memalign(sysconf(_SC_PAGESIZE), size);
}

static inline char *get_current_dir_name(void)
{
    return getcwd(NULL, 0);
}

static inline int getdtablesize(void)
{
    struct rlimit lim;
    int err = getrlimit(RLIMIT_NOFILE, &lim);
    if (err < 0)
        return err;

    return lim.rlim_cur;
}

static inline void pthread_testcancel(void) { }
static inline int pthread_cancel(pthread_t thread) { return 0; }

#endif /* __BIONIC_COMPAT_H */