aboutsummaryrefslogtreecommitdiffstats
path: root/gen
diff options
context:
space:
mode:
Diffstat (limited to 'gen')
-rw-r--r--gen/bits/intconf.c20
-rw-r--r--gen/bits/intconf.h13
2 files changed, 33 insertions, 0 deletions
diff --git a/gen/bits/intconf.c b/gen/bits/intconf.c
index 2ba2754..8d1311b 100644
--- a/gen/bits/intconf.c
+++ b/gen/bits/intconf.c
@@ -17,10 +17,16 @@
*/
#include <stdio.h>
#include <string.h>
+#include <stddef.h>
#include <time.h>
+volatile char nul = 0;
+volatile wchar_t wnul = 0;
+
+
+
/**
* On my amd64 machine, the usual result is:
* int_fast8_t = int32_t
@@ -109,6 +115,7 @@ int main(int argc, char* argv[])
r |= printf("LONG_BIT %zu\n", 8 * sizeof(long int));
r |= printf("LONG_LONG_BIT %zu\n", 8 * sizeof(long long int));
r |= printf("PTR_BIT %zu\n", 8 * sizeof(void*));
+ r |= printf("WCHAR_BIT %zu\n", 8 * sizeof(L'\0'));
r |= printf("INT%zu %s\n", 8 * sizeof(char), "char");
r |= printf("INT%zu %s\n", 8 * sizeof(short int), "short int");
@@ -123,6 +130,19 @@ int main(int argc, char* argv[])
else if (!strcmp(argv[1], "fast16")) r = fast(16);
else if (!strcmp(argv[1], "fast32")) r = fast(32);
else if (!strcmp(argv[1], "fast64")) r = fast(64);
+ else if (!strcmp(argv[1], "char-signed"))
+ {
+ nul = ~nul;
+ r = !(nul > 0);
+ return printf("%i\n", r) < 0 ? 1 : 0;
+ }
+ else if (!strcmp(argv[1], "wchar-signed"))
+ {
+ wnul = ~wnul;
+ r = !(wnul > 0);
+ return printf("%i\n", r) < 0 ? 1 : 0;
+ }
+
if (r <= 0)
return 1;
return printf("%i\n", r) < 0 ? 1 : 0;
diff --git a/gen/bits/intconf.h b/gen/bits/intconf.h
index eb7b5b5..f9ff861 100644
--- a/gen/bits/intconf.h
+++ b/gen/bits/intconf.h
@@ -25,12 +25,25 @@
//>FAST64=$(bin/gen/bits/intconf fast64)
#define __MAX_TO_MIN(max) (-(max) - 1)
+#if //(bin/gen/bits/intconf char-signed)
+# define __CHAR_SIGNED
+# define __CHAR_SIGNESS signed
+#endif
+# define __CHAR_SIGNESS unsigned
+#endif
+#if //(bin/gen/bits/intconf wchar-signed)
+# define __WCHAR_SIGNED
+# define __WCHAR_SIGNESS signed
+#else
+# define __WCHAR_SIGNESS unsigned
+#endif
#define __CHAR_BIT //(bin/gen/bits/intconf | grep ^CHAR_BIT | sed "s/^[^ ]* //")
#define __SHORT_BIT //(bin/gen/bits/intconf | grep ^SHORT_BIT | sed "s/^[^ ]* //")
#define __INT_BIT //(bin/gen/bits/intconf | grep ^INT_BIT | sed "s/^[^ ]* //")
#define __LONG_BIT //(bin/gen/bits/intconf | grep ^LONG_BIT | sed "s/^[^ ]* //")
#define __LONG_LONG_BIT //(bin/gen/bits/intconf | grep ^LONG_LONG_BIT | sed "s/^[^ ]* //")
#define __PTR_BIT //(bin/gen/bits/intconf | grep ^PTR_BIT | sed "s/^[^ ]* //")
+#define __WCHAR_BIT //(bin/gen/bits/intconf | grep ^WCHAR_BIT | sed "s/^[^ ]* //")
#define __INT8 //(bin/gen/bits/intconf | grep ^INT8 | sed "s/^[^ ]* //" | sed 1q)
#define __INT16 //(bin/gen/bits/intconf | grep ^INT16 | sed "s/^[^ ]* //" | sed 1q)
#define __INT32 //(bin/gen/bits/intconf | grep ^INT32 | sed "s/^[^ ]* //" | sed 1q)