| 1 |
/* -*- c++ -*- */ |
| 2 |
/* |
| 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_CMATH_ |
| 19 |
#define _MACPORTS_CMATH_ |
| 20 |
|
| 21 |
/* include MP support header to see if c++11 cmath support is needed */ |
| 22 |
#include "MacportsLegacySupport.h" |
| 23 |
|
| 24 |
#if __MP_LEGACY_SUPPORT_CXX11_CMATH__ |
| 25 |
|
| 26 |
/* |
| 27 |
* NOTE: This has to come -before- the include_next, so that the |
| 28 |
* setting is valid for any subsequently included header. |
| 29 |
*/ |
| 30 |
|
| 31 |
#undef L_GLIBCXX_USE_C99_MATH_TR1 |
| 32 |
#ifndef _GLIBCXX_USE_C99_MATH_TR1 |
| 33 |
#define L_GLIBCXX_USE_C99_MATH_TR1 1 |
| 34 |
|
| 35 |
/* |
| 36 |
* this macro enables c++11 math support in g++. It just needs to be |
| 37 |
* defined; not to any particular value; use 1 just because. |
| 38 |
*/ |
| 39 |
#define _GLIBCXX_USE_C99_MATH_TR1 1 |
| 40 |
#endif |
| 41 |
|
| 42 |
/* |
| 43 |
* Include our local math.h. NOTE: This has to come -before- the |
| 44 |
* include_next for <cmath>, so that the top-level functions are |
| 45 |
* all declared before they are referenced. |
| 46 |
*/ |
| 47 |
#include <math.h> |
| 48 |
#endif /* __MP_LEGACY_SUPPORT_CXX11_CMATH__ */ |
| 49 |
|
| 50 |
/* |
| 51 |
* Include the next cmath, which might be from the primary system or |
| 52 |
* it might be within GCC's c++ headers; either is OK here. |
| 53 |
*/ |
| 54 |
#include_next <cmath> |
| 55 |
|
| 56 |
#if __MP_LEGACY_SUPPORT_CXX11_CMATH__ |
| 57 |
|
| 58 |
#ifdef L_GLIBCXX_USE_C99_MATH_TR1 |
| 59 |
#undef _GLIBCXX_USE_C99_MATH_TR1 |
| 60 |
#undef L_GLIBCXX_USE_C99_MATH_TR1 |
| 61 |
#endif |
| 62 |
|
| 63 |
/* |
| 64 |
* this is the same condition that defines the function prototypes in |
| 65 |
* the system <math.h>. |
| 66 |
*/ |
| 67 |
#if ( defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L ) || ! defined( __STRICT_ANSI__ ) || ! defined( __GNUC__ ) |
| 68 |
#else |
| 69 |
#ifdef _GLIBCXX_NO_C99_ROUNDING_FUNCS |
| 70 |
/* have to define these ourselves because GCC doesn't properly */ |
| 71 |
#if __cplusplus >= 201103L |
| 72 |
|
| 73 |
#undef llrint |
| 74 |
#undef llrintf |
| 75 |
#undef llrintl |
| 76 |
#undef llround |
| 77 |
#undef llroundf |
| 78 |
#undef llroundl |
| 79 |
|
| 80 |
namespace std _GLIBCXX_VISIBILITY(default) |
| 81 |
{ |
| 82 |
_GLIBCXX_BEGIN_NAMESPACE_VERSION |
| 83 |
using ::llrint; |
| 84 |
using ::llrintf; |
| 85 |
using ::llrintl; |
| 86 |
using ::llround; |
| 87 |
using ::llroundf; |
| 88 |
using ::llroundl; |
| 89 |
_GLIBCXX_END_NAMESPACE_VERSION |
| 90 |
} // namespace |
| 91 |
|
| 92 |
#endif /* __cplusplus >= 201103L */ |
| 93 |
#endif /* _GLIBCXX_NO_C99_ROUNDING_FUNCS */ |
| 94 |
#endif /* various */ |
| 95 |
#endif /* __MP_LEGACY_SUPPORT_CXX11_CMATH__ */ |
| 96 |
#endif /* _MACPORTS_CMATH_ */ |