blob: b9768e1856321570e40e24da5deb4de17bb99d88 [file] [log] [blame]
Elliott Hughes01339442014-02-20 18:04:58 -08001/*
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 */
16
17#ifndef _BIONIC_OPENBSD_COMPAT_H_included
18#define _BIONIC_OPENBSD_COMPAT_H_included
19
Elliott Hughesb8104622014-08-19 09:18:03 -070020#define _BSD_SOURCE
21
Dan Albertf79ee062014-07-01 22:41:50 +000022#include <sys/cdefs.h>
Elliott Hughes2b67d7d2014-07-18 15:57:41 -070023#include <stddef.h> // For size_t.
Dan Albertf79ee062014-07-01 22:41:50 +000024
Elliott Hughescc7e5f42014-08-26 17:00:37 -070025/* 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
34
Elliott Hughesf3c73902014-04-18 10:29:16 -070035/* OpenBSD's <ctype.h> uses these names, which conflicted with stlport.
36 * Additionally, we changed the numeric/digit type from N to D for libcxx.
37 */
38#define _U _CTYPE_U
39#define _L _CTYPE_L
40#define _N _CTYPE_D
41#define _S _CTYPE_S
42#define _P _CTYPE_P
43#define _C _CTYPE_C
44#define _X _CTYPE_X
45#define _B _CTYPE_B
46
Elliott Hughesb4e099c2014-05-29 16:04:53 -070047/* OpenBSD has this, but we can't really implement it correctly on Linux. */
48#define issetugid() 0
49
Elliott Hughes2b67d7d2014-07-18 15:57:41 -070050#define explicit_bzero(p, s) memset(p, 0, s)
51
52/* We have OpenBSD's getentropy_linux.c, but we don't mention getentropy in any header. */
53__LIBC_HIDDEN__ extern int getentropy(void*, size_t);
54
Dan Albertf79ee062014-07-01 22:41:50 +000055/* LP32 NDK ctype.h contained references to these. */
Elliott Hughesa167eef2014-07-14 14:41:47 -070056__LIBC64_HIDDEN__ extern const short* _tolower_tab_;
57__LIBC64_HIDDEN__ extern const short* _toupper_tab_;
Dan Albertf79ee062014-07-01 22:41:50 +000058
Elliott Hughesa167eef2014-07-14 14:41:47 -070059__LIBC_HIDDEN__ extern struct atexit* __atexit;
60__LIBC_HIDDEN__ extern const char _C_ctype_[];
61__LIBC_HIDDEN__ extern const short _C_toupper_[];
62__LIBC_HIDDEN__ extern const short _C_tolower_[];
63__LIBC_HIDDEN__ extern char* __findenv(const char*, int, int*);
64__LIBC_HIDDEN__ extern char* _mktemp(char*);
65
66/* TODO: hide this when android_support.a is fixed (http://b/16298580).*/
67/*__LIBC_HIDDEN__*/ extern int __isthreaded;
Dmitriy Ivanov53c3c272014-07-11 12:59:16 -070068
Elliott Hughes01339442014-02-20 18:04:58 -080069#endif