shift_to_zero: be even more conservative (avoid false positives)
[smatch.git] / target.h
blob8bbe494f89bb0707a5a08b7aa685af81ef502cbc
1 #ifndef TARGET_H
2 #define TARGET_H
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;
16 * For "__attribute__((aligned))"
18 extern int max_alignment;
21 * Integer data types
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;
31 extern int max_int_alignment;
34 * Floating point data types
36 extern int bits_in_float;
37 extern int bits_in_double;
38 extern int bits_in_longdouble;
40 extern int max_fp_alignment;
43 * Pointer data type
45 extern int bits_in_pointer;
46 extern int pointer_alignment;
49 * Enum data types
51 extern int bits_in_enum;
52 extern int enum_alignment;
55 * Helper functions for converting bits to bytes and vice versa.
58 static inline int bits_to_bytes(int bits)
60 return bits >= 0 ? (bits + bits_in_char - 1) / bits_in_char : -1;
63 static inline int bytes_to_bits(int bytes)
65 return bytes * bits_in_char;
68 static inline unsigned long array_element_offset(unsigned long base_bits, int idx)
70 int fragment = base_bits % bits_in_char;
71 if (fragment)
72 base_bits += bits_in_char - fragment;
73 return base_bits * idx;
76 #endif