jerryscript/jerry-libm/jerry-libm-internal.h
lidija-b e944cdaa8b Add endian set for default toolchain (#2808)
When default toolchain is used and architecture not listed in
"#if" in jerry-libm-internal.h on little endian around 90
test-suite tests, 4 unittests and 30 jerry-tests fails depending
on setup tested.
This change checks endians in case no toolchain is found and
sets __LITTLE_ENDIAN macro if it is little endian. This way
it will be set for any future arhitectures using little endian
and architecture that can have both big and little endian not
listed in jerry-libm-internal.h check.

JerryScript-DCO-1.0-Signed-off-by: Lidija Besker lidija.besker@rt-rk.com
2019-04-12 16:32:58 +02:00

92 lines
2.7 KiB
C

/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is based on work under the following copyright and permission
* notice:
*
* Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
*
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
*
* @(#)fdlibm.h 1.5 04/04/22
*/
#ifndef JERRY_LIBM_INTERNAL_H
#define JERRY_LIBM_INTERNAL_H
/* Sometimes it's necessary to define __LITTLE_ENDIAN explicitly
but these catch some common cases. */
#ifndef __LITTLE_ENDIAN
/* Check if compiler has byte order macro. Some older versions do not.
* If byte order is supported and set to little or target is among common
* cases checked define __LITTLE_ENDIAN.
*/
#if (defined (i386) || defined (__i386) || defined (__i386__) || \
defined (i486) || defined (__i486) || defined (__i486__) || \
defined (intel) || defined (x86) || defined (i86pc) || \
defined (__alpha) || defined (__osf__) || \
defined (__x86_64__) || defined (__arm__) || defined (__aarch64__) || \
defined (__xtensa__) || defined (__MIPSEL)) || \
(defined (__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
#define __LITTLE_ENDIAN
#endif
#endif /* !__LITTLE_ENDIAN */
#ifdef __LITTLE_ENDIAN
#define __HI(x) *(1 + (int *) &x)
#define __LO(x) *(int *) &x
#else /* !__LITTLE_ENDIAN */
#define __HI(x) *(int *) &x
#define __LO(x) *(1 + (int *) &x)
#endif /* __LITTLE_ENDIAN */
/*
* ANSI/POSIX
*/
double acos (double x);
double asin (double x);
double atan (double x);
double atan2 (double y, double x);
double cos (double x);
double sin (double x);
double tan (double x);
double exp (double x);
double log (double x);
double pow (double x, double y);
double sqrt (double x);
double ceil (double x);
double fabs (double x);
double floor (double x);
double fmod (double x, double y);
int isnan (double x);
int finite (double x);
double nextafter (double x, double y);
/*
* Functions callable from C, intended to support IEEE arithmetic.
*/
double copysign (double x, double y);
double scalbn (double x, int n);
#endif /* !JERRY_LIBM_INTERNAL_H */