1 #ifndef TARGET_H 2 #define TARGET_H 3 4 extern struct symbol *size_t_ctype; 5 extern struct symbol *ssize_t_ctype; 6 extern struct symbol *intmax_ctype; 7 extern struct symbol *uintmax_ctype; 8 extern struct symbol *int64_ctype; 9 extern struct symbol *uint64_ctype; 10 extern struct symbol *int32_ctype; 11 extern struct symbol *uint32_ctype; 12 extern struct symbol *wchar_ctype; 13 extern struct symbol *wint_ctype; 14 15 /* 16 * For "__attribute__((aligned))" 17 */ 18 extern int max_alignment; 19 20 /* 21 * Integer data types 22 */ 23 extern int bits_in_bool; 24 extern int bits_in_char; 25 extern int bits_in_short; 26 extern int bits_in_int; 27 extern int bits_in_long; 28 extern int bits_in_longlong; 29 extern int bits_in_longlonglong; 30 31 extern int max_int_alignment; 32 33 /* 34 * Floating point data types 35 */ 36 extern int bits_in_float; 37 extern int bits_in_double; 38 extern int bits_in_longdouble; 39 40 extern int max_fp_alignment; 41 42 /* 43 * Pointer data type 44 */ 45 extern int bits_in_pointer; 46 extern int pointer_alignment; 47 48 /* 49 * Enum data types 50 */ 51 extern int bits_in_enum; 52 extern int enum_alignment; 53 54 /* 55 * Helper functions for converting bits to bytes and vice versa. 56 */ 57 58 static inline int bits_to_bytes(int bits) 59 { 60 return bits >= 0 ? (bits + bits_in_char - 1) / bits_in_char : -1; 61 } 62 63 static inline int bytes_to_bits(int bytes) 64 { 65 return bytes * bits_in_char; 66 } 67 68 static inline unsigned long array_element_offset(unsigned long base_bits, int idx) 69 { 70 int fragment = base_bits % bits_in_char; 71 if (fragment) 72 base_bits += bits_in_char - fragment; 73 return base_bits * idx; 74 } 75 76 #endif