| 1 |
/* |
| 2 |
* Copyright (c) 2018 Chris Jones <[email protected]> |
| 3 |
* Copyright (c) 2019 Michael Dickens <[email protected]> |
| 4 |
* |
| 5 |
* Permission to use, copy, modify, and distribute this software for any |
| 6 |
* purpose with or without fee is hereby granted, provided that the above |
| 7 |
* copyright notice and this permission notice appear in all copies. |
| 8 |
* |
| 9 |
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 10 |
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 11 |
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 12 |
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 13 |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 14 |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 15 |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 16 |
*/ |
| 17 |
|
| 18 |
#ifndef _MACPORTS_MATH_H_ |
| 19 |
#define _MACPORTS_MATH_H_ |
| 20 |
|
| 21 |
/* MP support header */ |
| 22 |
#include "MacportsLegacySupport.h" |
| 23 |
|
| 24 |
#if __MP_LEGACY_SUPPORT_LLROUND__ |
| 25 |
|
| 26 |
__MP__BEGIN_DECLS |
| 27 |
|
| 28 |
/* |
| 29 |
* These functions are present in the system math library but their |
| 30 |
* prototypes might not be declared under some circumstances. Declare |
| 31 |
* them here anyway. |
| 32 |
*/ |
| 33 |
|
| 34 |
/* |
| 35 |
* this is the same condition that defines the function prototypes in |
| 36 |
* the GCC <math.h>. |
| 37 |
*/ |
| 38 |
#if !(__DARWIN_NO_LONG_LONG) |
| 39 |
extern long long int llrint ( double ); |
| 40 |
extern long long int llrintf ( float ); |
| 41 |
extern long long int llrintl ( long double ); |
| 42 |
|
| 43 |
extern long long int llround ( double ); |
| 44 |
extern long long int llroundf ( float ); |
| 45 |
extern long long int llroundl ( long double ); |
| 46 |
#endif |
| 47 |
|
| 48 |
__MP__END_DECLS |
| 49 |
|
| 50 |
/* |
| 51 |
* If the GCC <math.h> header exists, then tell it: (1) to include the |
| 52 |
* next <math.h>, which should be from the system; and (2) to not use |
| 53 |
* it's <math.h> yet, because it basically wraps <cmath> and we need |
| 54 |
* to keep everything herein focused on just <math.h>. If the user |
| 55 |
* wants <cmath>, they should #include that specific header. |
| 56 |
*/ |
| 57 |
|
| 58 |
#undef L_GLIBCXX_MATH_H |
| 59 |
#ifndef _GLIBCXX_MATH_H |
| 60 |
#define L_GLIBCXX_MATH_H 1 |
| 61 |
#define _GLIBCXX_MATH_H 1 |
| 62 |
#endif |
| 63 |
|
| 64 |
#undef L_GLIBCXX_INCLUDE_NEXT_C_HEADERS |
| 65 |
#ifndef _GLIBCXX_INCLUDE_NEXT_C_HEADERS |
| 66 |
#define L_GLIBCXX_INCLUDE_NEXT_C_HEADERS 1 |
| 67 |
#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS 1 |
| 68 |
#endif |
| 69 |
|
| 70 |
#endif /* __MP_LEGACY_SUPPORT_LLROUND__ */ |
| 71 |
|
| 72 |
/* |
| 73 |
* Include the next math.h, which might be from the primary system or |
| 74 |
* it might be within GCC's c or c++ (yup!) headers |
| 75 |
*/ |
| 76 |
|
| 77 |
#include_next <math.h> |
| 78 |
|
| 79 |
#if __MP_LEGACY_SUPPORT_COSSIN__ |
| 80 |
|
| 81 |
/* Following is borrowed from math.h on macOS 10.9+ */ |
| 82 |
|
| 83 |
/* __sincos and __sincosf were introduced in OSX 10.9 and iOS 7.0. When |
| 84 |
targeting an older system, we simply split them up into discrete calls |
| 85 |
to sin( ) and cos( ). */ |
| 86 |
|
| 87 |
__MP__BEGIN_DECLS |
| 88 |
extern void __sincosf(float __x, float *__sinp, float *__cosp); |
| 89 |
extern void __sincos(double __x, double *__sinp, double *__cosp); |
| 90 |
__MP__END_DECLS |
| 91 |
|
| 92 |
#endif /* __MP_LEGACY_SUPPORT_COSSIN__ */ |
| 93 |
|
| 94 |
#if __MP_LEGACY_SUPPORT_LLROUND__ |
| 95 |
|
| 96 |
#ifdef L_GLIBCXX_MATH_H |
| 97 |
#undef L_GLIBCXX_MATH_H |
| 98 |
#undef _GLIBCXX_MATH_H |
| 99 |
#endif |
| 100 |
|
| 101 |
#ifdef L_GLIBCXX_INCLUDE_NEXT_C_HEADERS |
| 102 |
#undef L_GLIBCXX_INCLUDE_NEXT_C_HEADERS |
| 103 |
#undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS |
| 104 |
#endif |
| 105 |
|
| 106 |
#endif /* __MP_LEGACY_SUPPORT_LLROUND__ */ |
| 107 |
|
| 108 |
#endif /* _MACPORTS_MATH_H_ */ |