2009-10-28 01:48:46 +08:00
|
|
|
/* ===-- int_lib.h - configuration header for compiler-rt -----------------===
|
2009-08-05 09:47:29 +08:00
|
|
|
*
|
|
|
|
* The LLVM Compiler Infrastructure
|
|
|
|
*
|
2010-11-17 06:13:33 +08:00
|
|
|
* This file is dual licensed under the MIT and the University of Illinois Open
|
|
|
|
* Source Licenses. See LICENSE.TXT for details.
|
2009-08-05 09:47:29 +08:00
|
|
|
*
|
|
|
|
* ===----------------------------------------------------------------------===
|
|
|
|
*
|
2009-10-28 01:48:46 +08:00
|
|
|
* This file is a configuration header for compiler-rt.
|
2009-08-05 09:47:29 +08:00
|
|
|
* This file is not part of the interface of this library.
|
|
|
|
*
|
|
|
|
* ===----------------------------------------------------------------------===
|
|
|
|
*/
|
2009-06-27 00:47:03 +08:00
|
|
|
|
|
|
|
#ifndef INT_LIB_H
|
|
|
|
#define INT_LIB_H
|
|
|
|
|
2009-08-05 09:47:29 +08:00
|
|
|
/* Assumption: signed integral is 2's complement */
|
|
|
|
/* Assumption: right shift of signed negative is arithmetic shift */
|
2009-06-27 00:47:03 +08:00
|
|
|
|
|
|
|
#include <limits.h>
|
2011-01-08 03:09:06 +08:00
|
|
|
#include <stdint.h>
|
2009-08-06 03:06:50 +08:00
|
|
|
#include "endianness.h"
|
2009-08-04 11:30:10 +08:00
|
|
|
#include <math.h>
|
|
|
|
|
2010-04-01 01:00:48 +08:00
|
|
|
/* If compiling for kernel use, call panic() instead of abort(). */
|
|
|
|
#ifdef KERNEL_USE
|
|
|
|
extern void panic (const char *, ...);
|
|
|
|
#define compilerrt_abort() \
|
|
|
|
panic("%s:%d: abort in %s", __FILE__, __LINE__, __FUNCTION__)
|
|
|
|
#else
|
2010-04-01 01:00:45 +08:00
|
|
|
#define compilerrt_abort() abort()
|
2010-04-01 01:00:48 +08:00
|
|
|
#endif
|
2010-04-01 01:00:45 +08:00
|
|
|
|
2009-08-04 11:30:10 +08:00
|
|
|
#if !defined(INFINITY) && defined(HUGE_VAL)
|
|
|
|
#define INFINITY HUGE_VAL
|
2009-08-06 03:57:20 +08:00
|
|
|
#endif /* INFINITY */
|
2009-06-27 00:47:03 +08:00
|
|
|
|
|
|
|
typedef int si_int;
|
|
|
|
typedef unsigned su_int;
|
|
|
|
|
|
|
|
typedef long long di_int;
|
|
|
|
typedef unsigned long long du_int;
|
|
|
|
|
|
|
|
typedef union
|
|
|
|
{
|
|
|
|
di_int all;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
#if _YUGA_LITTLE_ENDIAN
|
|
|
|
su_int low;
|
|
|
|
si_int high;
|
|
|
|
#else
|
|
|
|
si_int high;
|
|
|
|
su_int low;
|
2009-08-06 03:57:20 +08:00
|
|
|
#endif /* _YUGA_LITTLE_ENDIAN */
|
2009-08-10 02:41:02 +08:00
|
|
|
}s;
|
2009-06-27 00:47:03 +08:00
|
|
|
} dwords;
|
|
|
|
|
|
|
|
typedef union
|
|
|
|
{
|
|
|
|
du_int all;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
#if _YUGA_LITTLE_ENDIAN
|
|
|
|
su_int low;
|
|
|
|
su_int high;
|
|
|
|
#else
|
|
|
|
su_int high;
|
|
|
|
su_int low;
|
2009-08-06 03:57:20 +08:00
|
|
|
#endif /* _YUGA_LITTLE_ENDIAN */
|
2009-08-10 02:41:02 +08:00
|
|
|
}s;
|
2009-06-27 00:47:03 +08:00
|
|
|
} udwords;
|
|
|
|
|
|
|
|
#if __x86_64
|
|
|
|
|
|
|
|
typedef int ti_int __attribute__ ((mode (TI)));
|
|
|
|
typedef unsigned tu_int __attribute__ ((mode (TI)));
|
|
|
|
|
|
|
|
typedef union
|
|
|
|
{
|
|
|
|
ti_int all;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
#if _YUGA_LITTLE_ENDIAN
|
|
|
|
du_int low;
|
|
|
|
di_int high;
|
|
|
|
#else
|
|
|
|
di_int high;
|
|
|
|
du_int low;
|
2009-08-06 03:57:20 +08:00
|
|
|
#endif /* _YUGA_LITTLE_ENDIAN */
|
2009-08-10 02:41:02 +08:00
|
|
|
}s;
|
2009-06-27 00:47:03 +08:00
|
|
|
} twords;
|
|
|
|
|
|
|
|
typedef union
|
|
|
|
{
|
|
|
|
tu_int all;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
#if _YUGA_LITTLE_ENDIAN
|
|
|
|
du_int low;
|
|
|
|
du_int high;
|
|
|
|
#else
|
|
|
|
du_int high;
|
|
|
|
du_int low;
|
2009-08-06 03:57:20 +08:00
|
|
|
#endif /* _YUGA_LITTLE_ENDIAN */
|
2009-08-10 02:41:02 +08:00
|
|
|
}s;
|
2009-06-27 00:47:03 +08:00
|
|
|
} utwords;
|
|
|
|
|
2009-10-28 01:48:46 +08:00
|
|
|
static inline ti_int make_ti(di_int h, di_int l) {
|
|
|
|
twords r;
|
|
|
|
r.s.high = h;
|
|
|
|
r.s.low = l;
|
|
|
|
return r.all;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline tu_int make_tu(du_int h, du_int l) {
|
|
|
|
utwords r;
|
|
|
|
r.s.high = h;
|
|
|
|
r.s.low = l;
|
|
|
|
return r.all;
|
|
|
|
}
|
|
|
|
|
2009-08-06 03:57:20 +08:00
|
|
|
#endif /* __x86_64 */
|
2009-06-27 00:47:03 +08:00
|
|
|
|
|
|
|
typedef union
|
|
|
|
{
|
|
|
|
su_int u;
|
|
|
|
float f;
|
|
|
|
} float_bits;
|
|
|
|
|
|
|
|
typedef union
|
|
|
|
{
|
|
|
|
udwords u;
|
|
|
|
double f;
|
|
|
|
} double_bits;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
#if _YUGA_LITTLE_ENDIAN
|
|
|
|
udwords low;
|
|
|
|
udwords high;
|
|
|
|
#else
|
|
|
|
udwords high;
|
|
|
|
udwords low;
|
2009-08-06 03:57:20 +08:00
|
|
|
#endif /* _YUGA_LITTLE_ENDIAN */
|
2009-06-27 00:47:03 +08:00
|
|
|
} uqwords;
|
|
|
|
|
|
|
|
typedef union
|
|
|
|
{
|
|
|
|
uqwords u;
|
|
|
|
long double f;
|
|
|
|
} long_double_bits;
|
|
|
|
|
2009-08-06 03:57:20 +08:00
|
|
|
#endif /* INT_LIB_H */
|