blob: afd10770f8ab710080e26d3dde0cc74e3c654bdd [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
Elliott Hughes5c5152b2019-10-29 19:59:28 -070017#pragma once
Elliott Hughes01339442014-02-20 18:04:58 -080018
Elliott Hughesb8104622014-08-19 09:18:03 -070019#define _BSD_SOURCE
Dan Albertf79ee062014-07-01 22:41:50 +000020#include <sys/cdefs.h>
Elliott Hughes8465e962017-09-27 16:33:35 -070021
Elliott Hughes2b67d7d2014-07-18 15:57:41 -070022#include <stddef.h> // For size_t.
Dan Albertf79ee062014-07-01 22:41:50 +000023
Elliott Hughes5c5152b2019-10-29 19:59:28 -070024#include <sys/random.h> // For getentropy.
Elliott Hughes8465e962017-09-27 16:33:35 -070025
Elliott Hughesb3646832017-07-11 12:34:19 -070026#define __BEGIN_HIDDEN_DECLS _Pragma("GCC visibility push(hidden)")
27#define __END_HIDDEN_DECLS _Pragma("GCC visibility pop")
28
29extern const char* __progname;
30
Elliott Hughes506c6de2016-01-15 16:30:18 -080031/* Ignore all DEF_STRONG/DEF_WEAK in OpenBSD. */
32#define DEF_STRONG(sym)
33#define DEF_WEAK(sym)
Elliott Hughesf826a372017-07-13 09:35:15 -070034#define __weak_alias __strong_alias
Chih-Hung Hsiehb6b5cb52014-08-28 11:47:48 -070035
Elliott Hughes998f2d52014-12-19 19:30:11 -080036/* Ignore all __warn_references in OpenBSD. */
37#define __warn_references(sym,msg)
38
Elliott Hughesf3c73902014-04-18 10:29:16 -070039/* OpenBSD's <ctype.h> uses these names, which conflicted with stlport.
40 * Additionally, we changed the numeric/digit type from N to D for libcxx.
41 */
42#define _U _CTYPE_U
43#define _L _CTYPE_L
44#define _N _CTYPE_D
45#define _S _CTYPE_S
46#define _P _CTYPE_P
47#define _C _CTYPE_C
48#define _X _CTYPE_X
49#define _B _CTYPE_B
50
Elliott Hughesb4e099c2014-05-29 16:04:53 -070051/* OpenBSD has this, but we can't really implement it correctly on Linux. */
52#define issetugid() 0
53
Elliott Hughes2b67d7d2014-07-18 15:57:41 -070054#define explicit_bzero(p, s) memset(p, 0, s)
55
Elliott Hughesc08c25b2014-09-24 10:27:09 -070056/* OpenBSD has these in <sys/param.h>, but "ALIGN" isn't something we want to reserve. */
57#define ALIGNBYTES (sizeof(uintptr_t) - 1)
58#define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) &~ ALIGNBYTES)
59
Yabin Cui3471fcb2015-01-07 20:36:20 -080060/* OpenBSD has this in paths.h. But this directory doesn't normally exist.
61 * Even when it does exist, only the 'shell' user has permissions.
62 */
63#define _PATH_TMP "/data/local/tmp/"
64
Sandeep Patil9b1ca562017-08-21 12:17:19 -070065/* Use appropriate shell depending on process's executable. */
66__LIBC_HIDDEN__ extern const char* __bionic_get_shell_path();
67#define _PATH_BSHELL __bionic_get_shell_path()
68
Elliott Hughesa167eef2014-07-14 14:41:47 -070069__LIBC_HIDDEN__ extern char* __findenv(const char*, int, int*);
70__LIBC_HIDDEN__ extern char* _mktemp(char*);