1425bb815Sopenharmony_ci/* Copyright JS Foundation and other contributors, http://js.foundation 2425bb815Sopenharmony_ci * 3425bb815Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4425bb815Sopenharmony_ci * you may not use this file except in compliance with the License. 5425bb815Sopenharmony_ci * You may obtain a copy of the License at 6425bb815Sopenharmony_ci * 7425bb815Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8425bb815Sopenharmony_ci * 9425bb815Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10425bb815Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS 11425bb815Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12425bb815Sopenharmony_ci * See the License for the specific language governing permissions and 13425bb815Sopenharmony_ci * limitations under the License. 14425bb815Sopenharmony_ci * 15425bb815Sopenharmony_ci * This file is based on work under the following copyright and permission 16425bb815Sopenharmony_ci * notice: 17425bb815Sopenharmony_ci * 18425bb815Sopenharmony_ci * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved. 19425bb815Sopenharmony_ci * 20425bb815Sopenharmony_ci * Permission to use, copy, modify, and distribute this 21425bb815Sopenharmony_ci * software is freely granted, provided that this notice 22425bb815Sopenharmony_ci * is preserved. 23425bb815Sopenharmony_ci * 24425bb815Sopenharmony_ci * @(#)fdlibm.h 1.5 04/04/22 25425bb815Sopenharmony_ci */ 26425bb815Sopenharmony_ci 27425bb815Sopenharmony_ci#ifndef JERRY_LIBM_INTERNAL_H 28425bb815Sopenharmony_ci#define JERRY_LIBM_INTERNAL_H 29425bb815Sopenharmony_ci 30425bb815Sopenharmony_ci/* Sometimes it's necessary to define __LITTLE_ENDIAN explicitly 31425bb815Sopenharmony_ci but these catch some common cases. */ 32425bb815Sopenharmony_ci 33425bb815Sopenharmony_ci#ifndef __LITTLE_ENDIAN 34425bb815Sopenharmony_ci/* Check if compiler has byte order macro. Some older versions do not. 35425bb815Sopenharmony_ci * If byte order is supported and set to little or target is among common 36425bb815Sopenharmony_ci * cases checked define __LITTLE_ENDIAN. 37425bb815Sopenharmony_ci */ 38425bb815Sopenharmony_ci#if (defined (i386) || defined (__i386) || defined (__i386__) || \ 39425bb815Sopenharmony_ci defined (i486) || defined (__i486) || defined (__i486__) || \ 40425bb815Sopenharmony_ci defined (intel) || defined (x86) || defined (i86pc) || \ 41425bb815Sopenharmony_ci defined (__alpha) || defined (__osf__) || \ 42425bb815Sopenharmony_ci defined (__x86_64__) || defined (__arm__) || defined (__aarch64__) || \ 43425bb815Sopenharmony_ci defined (__xtensa__) || defined (__MIPSEL)) || \ 44425bb815Sopenharmony_ci(defined (__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) 45425bb815Sopenharmony_ci#define __LITTLE_ENDIAN 46425bb815Sopenharmony_ci#endif 47425bb815Sopenharmony_ci#endif /* !__LITTLE_ENDIAN */ 48425bb815Sopenharmony_ci 49425bb815Sopenharmony_ci#ifdef __LITTLE_ENDIAN 50425bb815Sopenharmony_ci#define __HI(x) *(1 + (const int *) &x) 51425bb815Sopenharmony_ci#define __LO(x) *(const int *) &x 52425bb815Sopenharmony_citypedef union 53425bb815Sopenharmony_ci{ 54425bb815Sopenharmony_ci double dbl; 55425bb815Sopenharmony_ci struct 56425bb815Sopenharmony_ci { 57425bb815Sopenharmony_ci int lo; 58425bb815Sopenharmony_ci int hi; 59425bb815Sopenharmony_ci } as_int; 60425bb815Sopenharmony_ci} double_accessor; 61425bb815Sopenharmony_ci#else /* !__LITTLE_ENDIAN */ 62425bb815Sopenharmony_ci#define __HI(x) *(const int *) &x 63425bb815Sopenharmony_ci#define __LO(x) *(1 + (const int *) &x) 64425bb815Sopenharmony_ci 65425bb815Sopenharmony_citypedef union 66425bb815Sopenharmony_ci{ 67425bb815Sopenharmony_ci double dbl; 68425bb815Sopenharmony_ci struct 69425bb815Sopenharmony_ci { 70425bb815Sopenharmony_ci int hi; 71425bb815Sopenharmony_ci int lo; 72425bb815Sopenharmony_ci } as_int; 73425bb815Sopenharmony_ci} double_accessor; 74425bb815Sopenharmony_ci#endif /* __LITTLE_ENDIAN */ 75425bb815Sopenharmony_ci 76425bb815Sopenharmony_ci#ifndef NAN 77425bb815Sopenharmony_ci#define NAN (0.0/0.0) 78425bb815Sopenharmony_ci#endif 79425bb815Sopenharmony_ci 80425bb815Sopenharmony_ci/* 81425bb815Sopenharmony_ci * ANSI/POSIX 82425bb815Sopenharmony_ci */ 83425bb815Sopenharmony_cidouble acos (double x); 84425bb815Sopenharmony_cidouble asin (double x); 85425bb815Sopenharmony_cidouble atan (double x); 86425bb815Sopenharmony_cidouble atan2 (double y, double x); 87425bb815Sopenharmony_cidouble cos (double x); 88425bb815Sopenharmony_cidouble sin (double x); 89425bb815Sopenharmony_cidouble tan (double x); 90425bb815Sopenharmony_ci 91425bb815Sopenharmony_cidouble cosh (double x); 92425bb815Sopenharmony_cidouble sinh (double x); 93425bb815Sopenharmony_cidouble tanh (double x); 94425bb815Sopenharmony_ci 95425bb815Sopenharmony_cidouble acosh (double x); 96425bb815Sopenharmony_cidouble asinh (double x); 97425bb815Sopenharmony_cidouble atanh (double x); 98425bb815Sopenharmony_ci 99425bb815Sopenharmony_cidouble exp (double x); 100425bb815Sopenharmony_cidouble expm1 (double x); 101425bb815Sopenharmony_cidouble log (double x); 102425bb815Sopenharmony_cidouble log1p (double x); 103425bb815Sopenharmony_cidouble log2 (double x); 104425bb815Sopenharmony_cidouble log10 (double); 105425bb815Sopenharmony_ci 106425bb815Sopenharmony_cidouble pow (double x, double y); 107425bb815Sopenharmony_cidouble sqrt (double x); 108425bb815Sopenharmony_cidouble cbrt (double); 109425bb815Sopenharmony_ci 110425bb815Sopenharmony_cidouble ceil (double x); 111425bb815Sopenharmony_cidouble fabs (double x); 112425bb815Sopenharmony_cidouble floor (double x); 113425bb815Sopenharmony_cidouble fmod (double x, double y); 114425bb815Sopenharmony_ci 115425bb815Sopenharmony_ciint isnan (double x); 116425bb815Sopenharmony_ciint finite (double x); 117425bb815Sopenharmony_ci 118425bb815Sopenharmony_cidouble nextafter (double x, double y); 119425bb815Sopenharmony_ci 120425bb815Sopenharmony_ci/* 121425bb815Sopenharmony_ci * Functions callable from C, intended to support IEEE arithmetic. 122425bb815Sopenharmony_ci */ 123425bb815Sopenharmony_cidouble copysign (double x, double y); 124425bb815Sopenharmony_cidouble scalbn (double x, int n); 125425bb815Sopenharmony_ci 126425bb815Sopenharmony_ci#endif /* !JERRY_LIBM_INTERNAL_H */ 127