diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-06-14 12:54:09 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-06-21 08:14:12 +0200 |
| commit | 233960fb148c581f28d52428fc03e1e02aa81a83 (patch) | |
| tree | 68c1160bbc7deb6902dd7dce45dd53df0d05e04d /lib.c | |
| parent | e97275d8e5c44482b3627c3f303addd0631cfd6d (diff) | |
| download | sparse-dev-233960fb148c581f28d52428fc03e1e02aa81a83.tar.gz | |
add predefines for __INT_WIDTH__ & friends
Recent versions of GCC predefine macros like __INT_WIDTH__ for
the integer types.
Do the same here since some <limits.h> may depends on it.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'lib.c')
| -rw-r--r-- | lib.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -1133,6 +1133,14 @@ static void predefined_sizeof(const char *name, unsigned bits) predefine(buf, 1, "%d", bits/8); } +static void predefined_width(const char *name, unsigned bits) +{ + char buf[32]; + + snprintf(buf, sizeof(buf), "__%s_WIDTH__", name); + predefine(buf, 1, "%d", bits); +} + static void predefined_max(const char *name, const char *suffix, unsigned bits) { unsigned long long max = (1ULL << (bits - 1 )) - 1; @@ -1146,6 +1154,7 @@ static void predefined_type_size(const char *name, const char *suffix, unsigned { predefined_max(name, suffix, bits); predefined_sizeof(name, bits); + predefined_width(name, bits); } static void predefined_macros(void) @@ -1191,8 +1200,12 @@ static void predefined_macros(void) predefined_sizeof("SHORT", bits_in_short); predefined_max("SHRT", "", bits_in_short); + predefined_width("SHRT", bits_in_short); predefined_max("SCHAR", "", bits_in_char); + predefined_width("SCHAR", bits_in_char); + predefined_sizeof("WCHAR_T",bits_in_wchar); predefined_max("WCHAR", "", bits_in_wchar); + predefined_width("WCHAR", bits_in_wchar); predefine("__CHAR_BIT__", 1, "%d", bits_in_char); predefined_type_size("INT", "", bits_in_int); @@ -1202,7 +1215,9 @@ static void predefined_macros(void) predefined_sizeof("INT128", 128); predefined_sizeof("SIZE_T", bits_in_pointer); + predefined_width( "SIZE", bits_in_pointer); predefined_sizeof("PTRDIFF_T", bits_in_pointer); + predefined_width( "PTRDIFF", bits_in_pointer); predefined_sizeof("POINTER", bits_in_pointer); predefined_sizeof("FLOAT", bits_in_float); |
