268b3b63a452d589054da7fe42cc58e90b63dc31
1 /*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
17 #ifndef _BIONIC_OPENBSD_COMPAT_H_included
18 #define _BIONIC_OPENBSD_COMPAT_H_included
20 #define _BSD_SOURCE
22 #include <sys/cdefs.h>
23 #include <stddef.h> // For size_t.
25 /* Redirect internal C library calls to the public function. */
26 #define _err err
27 #define _errx errx
28 #define _verr verr
29 #define _verrx verrx
30 #define _vwarn vwarn
31 #define _vwarnx vwarnx
32 #define _warn warn
33 #define _warnx warnx
35 /* Ignore all __weak_alias in OpenBSD. */
36 #define __weak_alias(alias,sym)
38 /* OpenBSD's <ctype.h> uses these names, which conflicted with stlport.
39 * Additionally, we changed the numeric/digit type from N to D for libcxx.
40 */
41 #define _U _CTYPE_U
42 #define _L _CTYPE_L
43 #define _N _CTYPE_D
44 #define _S _CTYPE_S
45 #define _P _CTYPE_P
46 #define _C _CTYPE_C
47 #define _X _CTYPE_X
48 #define _B _CTYPE_B
50 /* OpenBSD has this, but we can't really implement it correctly on Linux. */
51 #define issetugid() 0
53 #define explicit_bzero(p, s) memset(p, 0, s)
55 /* OpenBSD has these in <sys/param.h>, but "ALIGN" isn't something we want to reserve. */
56 #define ALIGNBYTES (sizeof(uintptr_t) - 1)
57 #define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) &~ ALIGNBYTES)
59 /* We have OpenBSD's getentropy_linux.c, but we don't mention getentropy in any header. */
60 __LIBC_HIDDEN__ extern int getentropy(void*, size_t);
62 /* LP32 NDK ctype.h contained references to these. */
63 __LIBC64_HIDDEN__ extern const short* _tolower_tab_;
64 __LIBC64_HIDDEN__ extern const short* _toupper_tab_;
66 __LIBC_HIDDEN__ extern struct atexit* __atexit;
67 __LIBC_HIDDEN__ extern const char _C_ctype_[];
68 __LIBC_HIDDEN__ extern const short _C_toupper_[];
69 __LIBC_HIDDEN__ extern const short _C_tolower_[];
70 __LIBC_HIDDEN__ extern char* __findenv(const char*, int, int*);
71 __LIBC_HIDDEN__ extern char* _mktemp(char*);
73 /* TODO: hide this when android_support.a is fixed (http://b/16298580).*/
74 /*__LIBC_HIDDEN__*/ extern int __isthreaded;
76 #endif