blob: baf5057238e882a1789541ca4392e756fddd5ea7 [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 Hughesb3646832017-07-11 12:34:19 -070025#define __BEGIN_HIDDEN_DECLS _Pragma("GCC visibility push(hidden)")
26#define __END_HIDDEN_DECLS _Pragma("GCC visibility pop")
27
28extern const char* __progname;
29
Elliott Hughescc7e5f42014-08-26 17:00:37 -070030/* Redirect internal C library calls to the public function. */
31#define _err err
32#define _errx errx
33#define _verr verr
34#define _verrx verrx
35#define _vwarn vwarn
36#define _vwarnx vwarnx
37#define _warn warn
38#define _warnx warnx
39
Elliott Hughes506c6de2016-01-15 16:30:18 -080040/* Ignore all DEF_STRONG/DEF_WEAK in OpenBSD. */
41#define DEF_STRONG(sym)
42#define DEF_WEAK(sym)
Elliott Hughesf826a372017-07-13 09:35:15 -070043#define __weak_alias __strong_alias
Chih-Hung Hsiehb6b5cb52014-08-28 11:47:48 -070044
Elliott Hughes998f2d52014-12-19 19:30:11 -080045/* Ignore all __warn_references in OpenBSD. */
46#define __warn_references(sym,msg)
47
Elliott Hughesf3c73902014-04-18 10:29:16 -070048/* OpenBSD's <ctype.h> uses these names, which conflicted with stlport.
49 * Additionally, we changed the numeric/digit type from N to D for libcxx.
50 */
51#define _U _CTYPE_U
52#define _L _CTYPE_L
53#define _N _CTYPE_D
54#define _S _CTYPE_S
55#define _P _CTYPE_P
56#define _C _CTYPE_C
57#define _X _CTYPE_X
58#define _B _CTYPE_B
59
Elliott Hughesb4e099c2014-05-29 16:04:53 -070060/* OpenBSD has this, but we can't really implement it correctly on Linux. */
61#define issetugid() 0
62
Elliott Hughes2b67d7d2014-07-18 15:57:41 -070063#define explicit_bzero(p, s) memset(p, 0, s)
64
Elliott Hughesc08c25b2014-09-24 10:27:09 -070065/* OpenBSD has these in <sys/param.h>, but "ALIGN" isn't something we want to reserve. */
66#define ALIGNBYTES (sizeof(uintptr_t) - 1)
67#define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) &~ ALIGNBYTES)
68
Yabin Cui3471fcb2015-01-07 20:36:20 -080069/* OpenBSD has this in paths.h. But this directory doesn't normally exist.
70 * Even when it does exist, only the 'shell' user has permissions.
71 */
72#define _PATH_TMP "/data/local/tmp/"
73
Elliott Hughes2b67d7d2014-07-18 15:57:41 -070074/* We have OpenBSD's getentropy_linux.c, but we don't mention getentropy in any header. */
75__LIBC_HIDDEN__ extern int getentropy(void*, size_t);
76
Elliott Hughes28182792014-11-21 19:25:27 -080077/* OpenBSD has this as API, but we just use it internally. */
78__LIBC_HIDDEN__ void* reallocarray(void*, size_t, size_t);
79
Dan Albertf79ee062014-07-01 22:41:50 +000080/* LP32 NDK ctype.h contained references to these. */
Christopher Ferrisa8184452015-10-23 12:32:52 -070081__LIBC32_LEGACY_PUBLIC__ extern const short* _tolower_tab_;
82__LIBC32_LEGACY_PUBLIC__ extern const short* _toupper_tab_;
Dan Albertf79ee062014-07-01 22:41:50 +000083
Elliott Hughesa167eef2014-07-14 14:41:47 -070084__LIBC_HIDDEN__ extern const char _C_ctype_[];
85__LIBC_HIDDEN__ extern const short _C_toupper_[];
86__LIBC_HIDDEN__ extern const short _C_tolower_[];
87__LIBC_HIDDEN__ extern char* __findenv(const char*, int, int*);
88__LIBC_HIDDEN__ extern char* _mktemp(char*);
89
Elliott Hughes01339442014-02-20 18:04:58 -080090#endif