Home | History | Annotate | Download | only in lib
      1 /* ===-- int_lib.h - configuration header for compiler-rt  -----------------===
      2  *
      3  *                     The LLVM Compiler Infrastructure
      4  *
      5  * This file is distributed under the University of Illinois Open Source
      6  * License. See LICENSE.TXT for details.
      7  *
      8  * ===----------------------------------------------------------------------===
      9  *
     10  * This file is a configuration header for compiler-rt.
     11  * This file is not part of the interface of this library.
     12  *
     13  * ===----------------------------------------------------------------------===
     14  */
     15 
     16 #ifndef INT_LIB_H
     17 #define INT_LIB_H
     18 
     19 /* Assumption:  signed integral is 2's complement */
     20 /* Assumption:  right shift of signed negative is arithmetic shift */
     21 
     22 #include <limits.h>
     23 #include "endianness.h"
     24 #include <math.h>
     25 
     26 #if !defined(INFINITY) && defined(HUGE_VAL)
     27 #define INFINITY HUGE_VAL
     28 #endif /* INFINITY */
     29 
     30 typedef      int si_int;
     31 typedef unsigned su_int;
     32 
     33 typedef          long long di_int;
     34 typedef unsigned long long du_int;
     35 
     36 typedef union
     37 {
     38     di_int all;
     39     struct
     40     {
     41 #if _YUGA_LITTLE_ENDIAN
     42         su_int low;
     43         si_int high;
     44 #else
     45         si_int high;
     46         su_int low;
     47 #endif /* _YUGA_LITTLE_ENDIAN */
     48     }s;
     49 } dwords;
     50 
     51 typedef union
     52 {
     53     du_int all;
     54     struct
     55     {
     56 #if _YUGA_LITTLE_ENDIAN
     57         su_int low;
     58         su_int high;
     59 #else
     60         su_int high;
     61         su_int low;
     62 #endif /* _YUGA_LITTLE_ENDIAN */
     63     }s;
     64 } udwords;
     65 
     66 #if __x86_64
     67 
     68 typedef int      ti_int __attribute__ ((mode (TI)));
     69 typedef unsigned tu_int __attribute__ ((mode (TI)));
     70 
     71 typedef union
     72 {
     73     ti_int all;
     74     struct
     75     {
     76 #if _YUGA_LITTLE_ENDIAN
     77         du_int low;
     78         di_int high;
     79 #else
     80         di_int high;
     81         du_int low;
     82 #endif /* _YUGA_LITTLE_ENDIAN */
     83     }s;
     84 } twords;
     85 
     86 typedef union
     87 {
     88     tu_int all;
     89     struct
     90     {
     91 #if _YUGA_LITTLE_ENDIAN
     92         du_int low;
     93         du_int high;
     94 #else
     95         du_int high;
     96         du_int low;
     97 #endif /* _YUGA_LITTLE_ENDIAN */
     98     }s;
     99 } utwords;
    100 
    101 static inline ti_int make_ti(di_int h, di_int l) {
    102     twords r;
    103     r.s.high = h;
    104     r.s.low = l;
    105     return r.all;
    106 }
    107 
    108 static inline tu_int make_tu(du_int h, du_int l) {
    109     utwords r;
    110     r.s.high = h;
    111     r.s.low = l;
    112     return r.all;
    113 }
    114 
    115 #endif /* __x86_64 */
    116 
    117 typedef union
    118 {
    119     su_int u;
    120     float f;
    121 } float_bits;
    122 
    123 typedef union
    124 {
    125     udwords u;
    126     double  f;
    127 } double_bits;
    128 
    129 typedef struct
    130 {
    131 #if _YUGA_LITTLE_ENDIAN
    132     udwords low;
    133     udwords high;
    134 #else
    135     udwords high;
    136     udwords low;
    137 #endif /* _YUGA_LITTLE_ENDIAN */
    138 } uqwords;
    139 
    140 typedef union
    141 {
    142     uqwords     u;
    143     long double f;
    144 } long_double_bits;
    145 
    146 #endif /* INT_LIB_H */
    147