xref: /aosp_15_r20/bionic/libm/freebsd-compat.h (revision 8d67ca893c1523eb926b9080dbe4e2ffd2a27ba1)
1*8d67ca89SAndroid Build Coastguard Worker /*
2*8d67ca89SAndroid Build Coastguard Worker  * Copyright (C) 2013 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 // Since we're implementing all the extensions,
20*8d67ca89SAndroid Build Coastguard Worker // we need to make sure we get all their declarations when we include <math.h>.
21*8d67ca89SAndroid Build Coastguard Worker #define _BSD_SOURCE
22*8d67ca89SAndroid Build Coastguard Worker 
23*8d67ca89SAndroid Build Coastguard Worker // Some FreeBSD source includes <complex.h> and assumes <math.h> from that.
24*8d67ca89SAndroid Build Coastguard Worker #include <math.h>
25*8d67ca89SAndroid Build Coastguard Worker 
26*8d67ca89SAndroid Build Coastguard Worker #define __weak_reference(sym,alias)     \
27*8d67ca89SAndroid Build Coastguard Worker     __asm__(".weak " #alias);           \
28*8d67ca89SAndroid Build Coastguard Worker     __asm__(".equ "  #alias ", " #sym)
29*8d67ca89SAndroid Build Coastguard Worker 
30*8d67ca89SAndroid Build Coastguard Worker #define __strong_reference(sym,aliassym) \
31*8d67ca89SAndroid Build Coastguard Worker     extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)))
32*8d67ca89SAndroid Build Coastguard Worker 
33*8d67ca89SAndroid Build Coastguard Worker // digittoint is in BSD's <ctype.h> but not ours.
34*8d67ca89SAndroid Build Coastguard Worker #include <ctype.h>
digittoint(char ch)35*8d67ca89SAndroid Build Coastguard Worker static inline int digittoint(char ch) {
36*8d67ca89SAndroid Build Coastguard Worker   if (!isxdigit(ch)) return -1;
37*8d67ca89SAndroid Build Coastguard Worker   return isdigit(ch) ? (ch - '0') : (_tolower(ch) - 'a');
38*8d67ca89SAndroid Build Coastguard Worker }
39*8d67ca89SAndroid Build Coastguard Worker 
40*8d67ca89SAndroid Build Coastguard Worker // FreeBSD exports these in <math.h> but we don't.
41*8d67ca89SAndroid Build Coastguard Worker double cospi(double);
42*8d67ca89SAndroid Build Coastguard Worker double sinpi(double);
43