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