10133944b09d1c0a35041f7a41eb6bfb660144f4fElliott Hughes/* 20133944b09d1c0a35041f7a41eb6bfb660144f4fElliott Hughes * Copyright (C) 2014 The Android Open Source Project 30133944b09d1c0a35041f7a41eb6bfb660144f4fElliott Hughes * 40133944b09d1c0a35041f7a41eb6bfb660144f4fElliott Hughes * Licensed under the Apache License, Version 2.0 (the "License"); 50133944b09d1c0a35041f7a41eb6bfb660144f4fElliott Hughes * you may not use this file except in compliance with the License. 60133944b09d1c0a35041f7a41eb6bfb660144f4fElliott Hughes * You may obtain a copy of the License at 70133944b09d1c0a35041f7a41eb6bfb660144f4fElliott Hughes * 80133944b09d1c0a35041f7a41eb6bfb660144f4fElliott Hughes * http://www.apache.org/licenses/LICENSE-2.0 90133944b09d1c0a35041f7a41eb6bfb660144f4fElliott Hughes * 100133944b09d1c0a35041f7a41eb6bfb660144f4fElliott Hughes * Unless required by applicable law or agreed to in writing, software 110133944b09d1c0a35041f7a41eb6bfb660144f4fElliott Hughes * distributed under the License is distributed on an "AS IS" BASIS, 120133944b09d1c0a35041f7a41eb6bfb660144f4fElliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 130133944b09d1c0a35041f7a41eb6bfb660144f4fElliott Hughes * See the License for the specific language governing permissions and 140133944b09d1c0a35041f7a41eb6bfb660144f4fElliott Hughes * limitations under the License. 150133944b09d1c0a35041f7a41eb6bfb660144f4fElliott Hughes */ 160133944b09d1c0a35041f7a41eb6bfb660144f4fElliott Hughes 170133944b09d1c0a35041f7a41eb6bfb660144f4fElliott Hughes#ifndef _BIONIC_OPENBSD_COMPAT_H_included 180133944b09d1c0a35041f7a41eb6bfb660144f4fElliott Hughes#define _BIONIC_OPENBSD_COMPAT_H_included 190133944b09d1c0a35041f7a41eb6bfb660144f4fElliott Hughes 20b81046202842427a7e894a6bcb357971332997b0Elliott Hughes#define _BSD_SOURCE 21b81046202842427a7e894a6bcb357971332997b0Elliott Hughes 22f79ee064b64af54bce6d3931f4112761edb7d3a9Dan Albert#include <sys/cdefs.h> 232b67d7dee09852789d9ac7d8972ed6cdb2c18430Elliott Hughes#include <stddef.h> // For size_t. 24f79ee064b64af54bce6d3931f4112761edb7d3a9Dan Albert 25cc7e5f489f02ceee46e315af4f78559d3ad6c962Elliott Hughes/* Redirect internal C library calls to the public function. */ 26cc7e5f489f02ceee46e315af4f78559d3ad6c962Elliott Hughes#define _err err 27cc7e5f489f02ceee46e315af4f78559d3ad6c962Elliott Hughes#define _errx errx 28cc7e5f489f02ceee46e315af4f78559d3ad6c962Elliott Hughes#define _verr verr 29cc7e5f489f02ceee46e315af4f78559d3ad6c962Elliott Hughes#define _verrx verrx 30cc7e5f489f02ceee46e315af4f78559d3ad6c962Elliott Hughes#define _vwarn vwarn 31cc7e5f489f02ceee46e315af4f78559d3ad6c962Elliott Hughes#define _vwarnx vwarnx 32cc7e5f489f02ceee46e315af4f78559d3ad6c962Elliott Hughes#define _warn warn 33cc7e5f489f02ceee46e315af4f78559d3ad6c962Elliott Hughes#define _warnx warnx 34cc7e5f489f02ceee46e315af4f78559d3ad6c962Elliott Hughes 35506c6deff726c8c052ff5abb0cef57e63707bd1cElliott Hughes/* Ignore all DEF_STRONG/DEF_WEAK in OpenBSD. */ 36506c6deff726c8c052ff5abb0cef57e63707bd1cElliott Hughes#define DEF_STRONG(sym) 37506c6deff726c8c052ff5abb0cef57e63707bd1cElliott Hughes#define DEF_WEAK(sym) 38b6b5cb53895a2d5e94368f14a25ccfaf807eacadChih-Hung Hsieh 39998f2d5a50adffcc0447912fb6a7af2dac7accf1Elliott Hughes/* Ignore all __warn_references in OpenBSD. */ 40998f2d5a50adffcc0447912fb6a7af2dac7accf1Elliott Hughes#define __warn_references(sym,msg) 41998f2d5a50adffcc0447912fb6a7af2dac7accf1Elliott Hughes 42f3c73901cb5ca4de2651151cf2c65b31a729466eElliott Hughes/* OpenBSD's <ctype.h> uses these names, which conflicted with stlport. 43f3c73901cb5ca4de2651151cf2c65b31a729466eElliott Hughes * Additionally, we changed the numeric/digit type from N to D for libcxx. 44f3c73901cb5ca4de2651151cf2c65b31a729466eElliott Hughes */ 45f3c73901cb5ca4de2651151cf2c65b31a729466eElliott Hughes#define _U _CTYPE_U 46f3c73901cb5ca4de2651151cf2c65b31a729466eElliott Hughes#define _L _CTYPE_L 47f3c73901cb5ca4de2651151cf2c65b31a729466eElliott Hughes#define _N _CTYPE_D 48f3c73901cb5ca4de2651151cf2c65b31a729466eElliott Hughes#define _S _CTYPE_S 49f3c73901cb5ca4de2651151cf2c65b31a729466eElliott Hughes#define _P _CTYPE_P 50f3c73901cb5ca4de2651151cf2c65b31a729466eElliott Hughes#define _C _CTYPE_C 51f3c73901cb5ca4de2651151cf2c65b31a729466eElliott Hughes#define _X _CTYPE_X 52f3c73901cb5ca4de2651151cf2c65b31a729466eElliott Hughes#define _B _CTYPE_B 53f3c73901cb5ca4de2651151cf2c65b31a729466eElliott Hughes 54b4e099c6f741835b11ecb6f8fd0861b1892ff182Elliott Hughes/* OpenBSD has this, but we can't really implement it correctly on Linux. */ 55b4e099c6f741835b11ecb6f8fd0861b1892ff182Elliott Hughes#define issetugid() 0 56b4e099c6f741835b11ecb6f8fd0861b1892ff182Elliott Hughes 572b67d7dee09852789d9ac7d8972ed6cdb2c18430Elliott Hughes#define explicit_bzero(p, s) memset(p, 0, s) 582b67d7dee09852789d9ac7d8972ed6cdb2c18430Elliott Hughes 59c08c25b4c9bdd95bfbda56a8c21f51b88c8a692eElliott Hughes/* OpenBSD has these in <sys/param.h>, but "ALIGN" isn't something we want to reserve. */ 60c08c25b4c9bdd95bfbda56a8c21f51b88c8a692eElliott Hughes#define ALIGNBYTES (sizeof(uintptr_t) - 1) 61c08c25b4c9bdd95bfbda56a8c21f51b88c8a692eElliott Hughes#define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) &~ ALIGNBYTES) 62c08c25b4c9bdd95bfbda56a8c21f51b88c8a692eElliott Hughes 633471fcbb6a7b13f8f06163f16ef52ceafa5d84a2Yabin Cui/* OpenBSD has this in paths.h. But this directory doesn't normally exist. 643471fcbb6a7b13f8f06163f16ef52ceafa5d84a2Yabin Cui * Even when it does exist, only the 'shell' user has permissions. 653471fcbb6a7b13f8f06163f16ef52ceafa5d84a2Yabin Cui */ 663471fcbb6a7b13f8f06163f16ef52ceafa5d84a2Yabin Cui#define _PATH_TMP "/data/local/tmp/" 673471fcbb6a7b13f8f06163f16ef52ceafa5d84a2Yabin Cui 682b67d7dee09852789d9ac7d8972ed6cdb2c18430Elliott Hughes/* We have OpenBSD's getentropy_linux.c, but we don't mention getentropy in any header. */ 692b67d7dee09852789d9ac7d8972ed6cdb2c18430Elliott Hughes__LIBC_HIDDEN__ extern int getentropy(void*, size_t); 702b67d7dee09852789d9ac7d8972ed6cdb2c18430Elliott Hughes 712818279ace22fb854b00e668c224492c4dd072a4Elliott Hughes/* OpenBSD has this as API, but we just use it internally. */ 722818279ace22fb854b00e668c224492c4dd072a4Elliott Hughes__LIBC_HIDDEN__ void* reallocarray(void*, size_t, size_t); 732818279ace22fb854b00e668c224492c4dd072a4Elliott Hughes 74f79ee064b64af54bce6d3931f4112761edb7d3a9Dan Albert/* LP32 NDK ctype.h contained references to these. */ 75a8184456229ace2b0255468e6b15aeb6509e27f7Christopher Ferris__LIBC32_LEGACY_PUBLIC__ extern const short* _tolower_tab_; 76a8184456229ace2b0255468e6b15aeb6509e27f7Christopher Ferris__LIBC32_LEGACY_PUBLIC__ extern const short* _toupper_tab_; 77a167eef5482d4a89d4277ec74f57adbe38052813Elliott Hughes 78a167eef5482d4a89d4277ec74f57adbe38052813Elliott Hughes__LIBC_HIDDEN__ extern const char _C_ctype_[]; 79a167eef5482d4a89d4277ec74f57adbe38052813Elliott Hughes__LIBC_HIDDEN__ extern const short _C_toupper_[]; 80a167eef5482d4a89d4277ec74f57adbe38052813Elliott Hughes__LIBC_HIDDEN__ extern const short _C_tolower_[]; 81a167eef5482d4a89d4277ec74f57adbe38052813Elliott Hughes__LIBC_HIDDEN__ extern char* __findenv(const char*, int, int*); 82a167eef5482d4a89d4277ec74f57adbe38052813Elliott Hughes__LIBC_HIDDEN__ extern char* _mktemp(char*); 83a167eef5482d4a89d4277ec74f57adbe38052813Elliott Hughes 84a167eef5482d4a89d4277ec74f57adbe38052813Elliott Hughes/* TODO: hide this when android_support.a is fixed (http://b/16298580).*/ 85a167eef5482d4a89d4277ec74f57adbe38052813Elliott Hughes/*__LIBC_HIDDEN__*/ extern int __isthreaded; 8653c3c271dc9927dd280981fc23409af60f460007Dmitriy Ivanov 870133944b09d1c0a35041f7a41eb6bfb660144f4fElliott Hughes#endif 88