| 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 |  | 
|  | 17 | #ifndef _BIONIC_OPENBSD_COMPAT_H_included | 
|  | 18 | #define _BIONIC_OPENBSD_COMPAT_H_included | 
|  | 19 |  | 
| Elliott Hughes | b810462 | 2014-08-19 09:18:03 -0700 | [diff] [blame] | 20 | #define _BSD_SOURCE | 
|  | 21 |  | 
| Dan Albert | f79ee06 | 2014-07-01 22:41:50 +0000 | [diff] [blame] | 22 | #include <sys/cdefs.h> | 
| Elliott Hughes | 2b67d7d | 2014-07-18 15:57:41 -0700 | [diff] [blame] | 23 | #include <stddef.h> // For size_t. | 
| Dan Albert | f79ee06 | 2014-07-01 22:41:50 +0000 | [diff] [blame] | 24 |  | 
| Elliott Hughes | cc7e5f4 | 2014-08-26 17:00:37 -0700 | [diff] [blame] | 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 | 
|  | 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) | 
| Chih-Hung Hsieh | b6b5cb5 | 2014-08-28 11:47:48 -0700 | [diff] [blame] | 38 |  | 
| Elliott Hughes | 998f2d5 | 2014-12-19 19:30:11 -0800 | [diff] [blame] | 39 | /* Ignore all __warn_references in OpenBSD. */ | 
|  | 40 | #define __warn_references(sym,msg) | 
|  | 41 |  | 
| Elliott Hughes | f3c7390 | 2014-04-18 10:29:16 -0700 | [diff] [blame] | 42 | /* OpenBSD's <ctype.h> uses these names, which conflicted with stlport. | 
|  | 43 | * Additionally, we changed the numeric/digit type from N to D for libcxx. | 
|  | 44 | */ | 
|  | 45 | #define _U _CTYPE_U | 
|  | 46 | #define _L _CTYPE_L | 
|  | 47 | #define _N _CTYPE_D | 
|  | 48 | #define _S _CTYPE_S | 
|  | 49 | #define _P _CTYPE_P | 
|  | 50 | #define _C _CTYPE_C | 
|  | 51 | #define _X _CTYPE_X | 
|  | 52 | #define _B _CTYPE_B | 
|  | 53 |  | 
| Elliott Hughes | b4e099c | 2014-05-29 16:04:53 -0700 | [diff] [blame] | 54 | /* OpenBSD has this, but we can't really implement it correctly on Linux. */ | 
|  | 55 | #define issetugid() 0 | 
|  | 56 |  | 
| Elliott Hughes | 2b67d7d | 2014-07-18 15:57:41 -0700 | [diff] [blame] | 57 | #define explicit_bzero(p, s) memset(p, 0, s) | 
|  | 58 |  | 
| Elliott Hughes | c08c25b | 2014-09-24 10:27:09 -0700 | [diff] [blame] | 59 | /* OpenBSD has these in <sys/param.h>, but "ALIGN" isn't something we want to reserve. */ | 
|  | 60 | #define ALIGNBYTES (sizeof(uintptr_t) - 1) | 
|  | 61 | #define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) &~ ALIGNBYTES) | 
|  | 62 |  | 
| Yabin Cui | 3471fcb | 2015-01-07 20:36:20 -0800 | [diff] [blame] | 63 | /* OpenBSD has this in paths.h. But this directory doesn't normally exist. | 
|  | 64 | * Even when it does exist, only the 'shell' user has permissions. | 
|  | 65 | */ | 
|  | 66 | #define _PATH_TMP "/data/local/tmp/" | 
|  | 67 |  | 
| Elliott Hughes | 2b67d7d | 2014-07-18 15:57:41 -0700 | [diff] [blame] | 68 | /* We have OpenBSD's getentropy_linux.c, but we don't mention getentropy in any header. */ | 
|  | 69 | __LIBC_HIDDEN__ extern int getentropy(void*, size_t); | 
|  | 70 |  | 
| Elliott Hughes | 2818279 | 2014-11-21 19:25:27 -0800 | [diff] [blame] | 71 | /* OpenBSD has this as API, but we just use it internally. */ | 
|  | 72 | __LIBC_HIDDEN__ void* reallocarray(void*, size_t, size_t); | 
|  | 73 |  | 
| Dan Albert | f79ee06 | 2014-07-01 22:41:50 +0000 | [diff] [blame] | 74 | /* LP32 NDK ctype.h contained references to these. */ | 
| Christopher Ferris | a818445 | 2015-10-23 12:32:52 -0700 | [diff] [blame] | 75 | __LIBC32_LEGACY_PUBLIC__ extern const short* _tolower_tab_; | 
|  | 76 | __LIBC32_LEGACY_PUBLIC__ extern const short* _toupper_tab_; | 
| Dan Albert | f79ee06 | 2014-07-01 22:41:50 +0000 | [diff] [blame] | 77 |  | 
| Elliott Hughes | a167eef | 2014-07-14 14:41:47 -0700 | [diff] [blame] | 78 | __LIBC_HIDDEN__ extern const char _C_ctype_[]; | 
|  | 79 | __LIBC_HIDDEN__ extern const short _C_toupper_[]; | 
|  | 80 | __LIBC_HIDDEN__ extern const short _C_tolower_[]; | 
|  | 81 | __LIBC_HIDDEN__ extern char* __findenv(const char*, int, int*); | 
|  | 82 | __LIBC_HIDDEN__ extern char* _mktemp(char*); | 
|  | 83 |  | 
|  | 84 | /* TODO: hide this when android_support.a is fixed (http://b/16298580).*/ | 
|  | 85 | /*__LIBC_HIDDEN__*/ extern int __isthreaded; | 
| Dmitriy Ivanov | 53c3c27 | 2014-07-11 12:59:16 -0700 | [diff] [blame] | 86 |  | 
| Elliott Hughes | 0133944 | 2014-02-20 18:04:58 -0800 | [diff] [blame] | 87 | #endif |