xref: /aosp_15_r20/bionic/libc/upstream-netbsd/android/include/netbsd-compat.h (revision 8d67ca893c1523eb926b9080dbe4e2ffd2a27ba1)
1*8d67ca89SAndroid Build Coastguard Worker /*
2*8d67ca89SAndroid Build Coastguard Worker  * Copyright (C) 2012 The Android Open Source Project
3*8d67ca89SAndroid Build Coastguard Worker  *
4*8d67ca89SAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*8d67ca89SAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*8d67ca89SAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*8d67ca89SAndroid Build Coastguard Worker  *
8*8d67ca89SAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*8d67ca89SAndroid Build Coastguard Worker  *
10*8d67ca89SAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*8d67ca89SAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*8d67ca89SAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*8d67ca89SAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*8d67ca89SAndroid Build Coastguard Worker  * limitations under the License.
15*8d67ca89SAndroid Build Coastguard Worker  */
16*8d67ca89SAndroid Build Coastguard Worker 
17*8d67ca89SAndroid Build Coastguard Worker #pragma once
18*8d67ca89SAndroid Build Coastguard Worker 
19*8d67ca89SAndroid Build Coastguard Worker #define _BSD_SOURCE
20*8d67ca89SAndroid Build Coastguard Worker #define _GNU_SOURCE 1
21*8d67ca89SAndroid Build Coastguard Worker 
22*8d67ca89SAndroid Build Coastguard Worker // NetBSD uses _DIAGASSERT to null-check arguments and the like,
23*8d67ca89SAndroid Build Coastguard Worker // but it's clear from the number of mistakes in their assertions
24*8d67ca89SAndroid Build Coastguard Worker // that they don't actually test or ship with this.
25*8d67ca89SAndroid Build Coastguard Worker #define _DIAGASSERT(e) /* nothing */
26*8d67ca89SAndroid Build Coastguard Worker 
27*8d67ca89SAndroid Build Coastguard Worker /*
28*8d67ca89SAndroid Build Coastguard Worker  * The following macro is used to remove const cast-away warnings
29*8d67ca89SAndroid Build Coastguard Worker  * from gcc -Wcast-qual; it should be used with caution because it
30*8d67ca89SAndroid Build Coastguard Worker  * can hide valid errors; in particular most valid uses are in
31*8d67ca89SAndroid Build Coastguard Worker  * situations where the API requires it, not to cast away string
32*8d67ca89SAndroid Build Coastguard Worker  * constants. We don't use *intptr_t on purpose here and we are
33*8d67ca89SAndroid Build Coastguard Worker  * explicit about unsigned long so that we don't have additional
34*8d67ca89SAndroid Build Coastguard Worker  * dependencies.
35*8d67ca89SAndroid Build Coastguard Worker  */
36*8d67ca89SAndroid Build Coastguard Worker #define __UNCONST(a)    ((void *)(unsigned long)(const void *)(a))
37*8d67ca89SAndroid Build Coastguard Worker 
38*8d67ca89SAndroid Build Coastguard Worker // TODO: we don't yet have thread-safe environment variables.
39*8d67ca89SAndroid Build Coastguard Worker #define __readlockenv() 0
40*8d67ca89SAndroid Build Coastguard Worker #define __unlockenv() 0
41*8d67ca89SAndroid Build Coastguard Worker 
42*8d67ca89SAndroid Build Coastguard Worker #include <sys/cdefs.h>
43*8d67ca89SAndroid Build Coastguard Worker #include <stddef.h>
44*8d67ca89SAndroid Build Coastguard Worker int reallocarr(void*, size_t, size_t);
45*8d67ca89SAndroid Build Coastguard Worker 
46*8d67ca89SAndroid Build Coastguard Worker #define __arraycount(a) (sizeof(a) / sizeof(a[0]))
47*8d67ca89SAndroid Build Coastguard Worker 
48*8d67ca89SAndroid Build Coastguard Worker /* Use appropriate shell depending on process's executable. */
49*8d67ca89SAndroid Build Coastguard Worker __LIBC_HIDDEN__ extern const char* __bionic_get_shell_path();
50*8d67ca89SAndroid Build Coastguard Worker #define _PATH_BSHELL __bionic_get_shell_path()
51