| Elliott Hughes | 0133944 | 2014-02-20 18:04:58 -0800 | [diff] [blame] | 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 | */ | 
|  | 16 |  | 
| Elliott Hughes | 5c5152b | 2019-10-29 19:59:28 -0700 | [diff] [blame] | 17 | #pragma once | 
| Elliott Hughes | 0133944 | 2014-02-20 18:04:58 -0800 | [diff] [blame] | 18 |  | 
| Elliott Hughes | b810462 | 2014-08-19 09:18:03 -0700 | [diff] [blame] | 19 | #define _BSD_SOURCE | 
| Dan Albert | f79ee06 | 2014-07-01 22:41:50 +0000 | [diff] [blame] | 20 | #include <sys/cdefs.h> | 
| Elliott Hughes | 8465e96 | 2017-09-27 16:33:35 -0700 | [diff] [blame] | 21 |  | 
| Elliott Hughes | 9a4b68e | 2019-11-20 14:56:22 -0800 | [diff] [blame] | 22 | #include <unistd.h> // For environ. | 
|  | 23 |  | 
| Elliott Hughes | 2b67d7d | 2014-07-18 15:57:41 -0700 | [diff] [blame] | 24 | #include <stddef.h> // For size_t. | 
| Dan Albert | f79ee06 | 2014-07-01 22:41:50 +0000 | [diff] [blame] | 25 |  | 
| Elliott Hughes | 5c5152b | 2019-10-29 19:59:28 -0700 | [diff] [blame] | 26 | #include <sys/random.h> // For getentropy. | 
| Elliott Hughes | 8465e96 | 2017-09-27 16:33:35 -0700 | [diff] [blame] | 27 |  | 
| Elliott Hughes | e1dc4f6 | 2021-01-11 11:51:29 -0800 | [diff] [blame] | 28 | #include "private/bsd_sys_param.h" | 
|  | 29 |  | 
| Elliott Hughes | b364683 | 2017-07-11 12:34:19 -0700 | [diff] [blame] | 30 | #define __BEGIN_HIDDEN_DECLS _Pragma("GCC visibility push(hidden)") | 
|  | 31 | #define __END_HIDDEN_DECLS _Pragma("GCC visibility pop") | 
|  | 32 |  | 
|  | 33 | extern const char* __progname; | 
|  | 34 |  | 
| Elliott Hughes | 506c6de | 2016-01-15 16:30:18 -0800 | [diff] [blame] | 35 | /* Ignore all DEF_STRONG/DEF_WEAK in OpenBSD. */ | 
|  | 36 | #define DEF_STRONG(sym) | 
|  | 37 | #define DEF_WEAK(sym) | 
| Elliott Hughes | f826a37 | 2017-07-13 09:35:15 -0700 | [diff] [blame] | 38 | #define __weak_alias __strong_alias | 
| Chih-Hung Hsieh | b6b5cb5 | 2014-08-28 11:47:48 -0700 | [diff] [blame] | 39 |  | 
| Elliott Hughes | 998f2d5 | 2014-12-19 19:30:11 -0800 | [diff] [blame] | 40 | /* Ignore all __warn_references in OpenBSD. */ | 
|  | 41 | #define __warn_references(sym,msg) | 
|  | 42 |  | 
| Elliott Hughes | cdb4a26 | 2020-06-05 16:56:53 -0700 | [diff] [blame] | 43 | #define PROTO_NORMAL(x) | 
|  | 44 |  | 
| Colin Cross | 048f24e | 2021-09-01 17:26:00 -0700 | [diff] [blame] | 45 | #if !defined(ANDROID_HOST_MUSL) | 
| Elliott Hughes | 81c54c7 | 2024-04-29 23:41:39 +0000 | [diff] [blame] | 46 | #define explicit_bzero(p, s) memset_explicit(p, 0, s) | 
| Colin Cross | 048f24e | 2021-09-01 17:26:00 -0700 | [diff] [blame] | 47 | #endif | 
|  | 48 |  | 
|  | 49 | #if defined(ANDROID_HOST_MUSL) | 
|  | 50 | #define __LIBC_HIDDEN__ __attribute__((visibility("hidden"))) | 
|  | 51 | #endif | 
| Elliott Hughes | 2b67d7d | 2014-07-18 15:57:41 -0700 | [diff] [blame] | 52 |  | 
| Yabin Cui | 3471fcb | 2015-01-07 20:36:20 -0800 | [diff] [blame] | 53 | /* OpenBSD has this in paths.h. But this directory doesn't normally exist. | 
|  | 54 | * Even when it does exist, only the 'shell' user has permissions. | 
|  | 55 | */ | 
|  | 56 | #define _PATH_TMP "/data/local/tmp/" | 
|  | 57 |  | 
| Sandeep Patil | 9b1ca56 | 2017-08-21 12:17:19 -0700 | [diff] [blame] | 58 | /* Use appropriate shell depending on process's executable. */ | 
|  | 59 | __LIBC_HIDDEN__ extern const char* __bionic_get_shell_path(); | 
|  | 60 | #define _PATH_BSHELL __bionic_get_shell_path() | 
|  | 61 |  | 
| Elliott Hughes | a167eef | 2014-07-14 14:41:47 -0700 | [diff] [blame] | 62 | __LIBC_HIDDEN__ extern char* __findenv(const char*, int, int*); | 
|  | 63 | __LIBC_HIDDEN__ extern char* _mktemp(char*); | 
| Elliott Hughes | 26b0607 | 2020-07-31 11:00:10 -0700 | [diff] [blame] | 64 |  | 
|  | 65 | // Only OpenBSD has this at the moment, and we're more likely to just say | 
|  | 66 | // "malloc is always calloc", so we don't expose this as libc API. | 
|  | 67 | __LIBC_HIDDEN__ void* recallocarray(void*, size_t, size_t, size_t); |