1 /* Copyright JS Foundation and other contributors, http://js.foundation 2 * 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 * 15 * This file is based on work under the following copyright and permission 16 * notice: 17 * 18 * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved. 19 * 20 * Permission to use, copy, modify, and distribute this 21 * software is freely granted, provided that this notice 22 * is preserved. 23 * 24 * @(#)fdlibm.h 1.5 04/04/22 25 */ 26 27 #ifndef JERRY_LIBM_INTERNAL_H 28 #define JERRY_LIBM_INTERNAL_H 29 30 /* Sometimes it's necessary to define __LITTLE_ENDIAN explicitly 31 but these catch some common cases. */ 32 33 #ifndef __LITTLE_ENDIAN 34 /* Check if compiler has byte order macro. Some older versions do not. 35 * If byte order is supported and set to little or target is among common 36 * cases checked define __LITTLE_ENDIAN. 37 */ 38 #if (defined (i386) || defined (__i386) || defined (__i386__) || \ 39 defined (i486) || defined (__i486) || defined (__i486__) || \ 40 defined (intel) || defined (x86) || defined (i86pc) || \ 41 defined (__alpha) || defined (__osf__) || \ 42 defined (__x86_64__) || defined (__arm__) || defined (__aarch64__) || \ 43 defined (__xtensa__) || defined (__MIPSEL)) || \ 44 (defined (__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) 45 #define __LITTLE_ENDIAN 46 #endif 47 #endif /* !__LITTLE_ENDIAN */ 48 49 #ifdef __LITTLE_ENDIAN 50 #define __HI(x) *(1 + (const int *) &x) 51 #define __LO(x) *(const int *) &x 52 typedef union 53 { 54 double dbl; 55 struct 56 { 57 int lo; 58 int hi; 59 } as_int; 60 } double_accessor; 61 #else /* !__LITTLE_ENDIAN */ 62 #define __HI(x) *(const int *) &x 63 #define __LO(x) *(1 + (const int *) &x) 64 65 typedef union 66 { 67 double dbl; 68 struct 69 { 70 int hi; 71 int lo; 72 } as_int; 73 } double_accessor; 74 #endif /* __LITTLE_ENDIAN */ 75 76 #ifndef NAN 77 #define NAN (0.0/0.0) 78 #endif 79 80 /* 81 * ANSI/POSIX 82 */ 83 double acos (double x); 84 double asin (double x); 85 double atan (double x); 86 double atan2 (double y, double x); 87 double cos (double x); 88 double sin (double x); 89 double tan (double x); 90 91 double cosh (double x); 92 double sinh (double x); 93 double tanh (double x); 94 95 double acosh (double x); 96 double asinh (double x); 97 double atanh (double x); 98 99 double exp (double x); 100 double expm1 (double x); 101 double log (double x); 102 double log1p (double x); 103 double log2 (double x); 104 double log10 (double); 105 106 double pow (double x, double y); 107 double sqrt (double x); 108 double cbrt (double); 109 110 double ceil (double x); 111 double fabs (double x); 112 double floor (double x); 113 double fmod (double x, double y); 114 115 int isnan (double x); 116 int finite (double x); 117 118 double nextafter (double x, double y); 119 120 /* 121 * Functions callable from C, intended to support IEEE arithmetic. 122 */ 123 double copysign (double x, double y); 124 double scalbn (double x, int n); 125 126 #endif /* !JERRY_LIBM_INTERNAL_H */ 127