summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-12-17 00:09:33 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-12-17 22:50:28 +0100
commiteadae505b5d1e22fc39e24a3e437afb00f7313f1 (patch)
tree4d3dd3368caf4779f2ec2a1f0fa49971f89c4bb5
parent01bd0384f3a1bcba7a129418af7acb4087dd8904 (diff)
downloadsparse-eadae505b5d1e22fc39e24a3e437afb00f7313f1.tar.gz
add predefine for __CHAR_UNSIGNED__
This macro is needed by <limits.h> to get, among others things, CHAR_MAX from __SCHAR_MAX__. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--lib.c4
-rw-r--r--machine.h6
2 files changed, 9 insertions, 1 deletions
diff --git a/lib.c b/lib.c
index 592fc414..ed2f5e3d 100644
--- a/lib.c
+++ b/lib.c
@@ -302,7 +302,7 @@ unsigned long fdump_ir;
int fmem_report = 0;
unsigned long long fmemcpy_max_count = 100000;
unsigned long fpasses = ~0UL;
-int funsigned_char = 0;
+int funsigned_char = UNSIGNED_CHAR;
int preprocess_only;
@@ -1236,6 +1236,8 @@ static void predefined_macros(void)
}
predefine("__CHAR_BIT__", 1, "%d", bits_in_char);
+ if (funsigned_char)
+ predefine("__CHAR_UNSIGNED__", 1, "1");
predefined_ctype("SHORT", &short_ctype, PTYPE_SIZEOF);
predefined_ctype("SHRT", &short_ctype, PTYPE_MAX|PTYPE_WIDTH);
diff --git a/machine.h b/machine.h
index 522f9ba0..09c1f513 100644
--- a/machine.h
+++ b/machine.h
@@ -74,4 +74,10 @@ enum machine {
#define MACH_NATIVE MACH_UNKNOWN
#endif
+#if defined(__CHAR_UNSIGNED__)
+#define UNSIGNED_CHAR 1
+#else
+#define UNSIGNED_CHAR 0
+#endif
+
#endif