aboutsummaryrefslogtreecommitdiffstats
path: root/src/generate-macros.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/generate-macros.c')
-rw-r--r--src/generate-macros.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/generate-macros.c b/src/generate-macros.c
new file mode 100644
index 0000000..ef87ad5
--- /dev/null
+++ b/src/generate-macros.c
@@ -0,0 +1,22 @@
+#include <stdint.h>
+#include <stdio.h>
+
+int
+main(void)
+{
+ if (sizeof(float) == 4) {
+ unsigned long int a, b;
+ a = (unsigned long int)*(uint32_t *)&(float){ (float)(1. / 12.) };
+ b = (unsigned long int)*(uint32_t *)&(float){ -(float)(1. / 12.) };
+ printf("#define USING_BINARY32 %i\n",
+ a == 0x3daaaaabUL && b == 0xbdaaaaabUL);
+ }
+ if (sizeof(double) == 8) {
+ unsigned long long int a, b;
+ a = (unsigned long long int)*(uint64_t *)&(double){ 1. / 12. };
+ b = (unsigned long long int)*(uint64_t *)&(double){ -1. / 12. };
+ printf("#define USING_BINARY64 %i\n",
+ a == 0x3fb5555555555555ULL && b == 0xbfb5555555555555ULL);
+ }
+ return 0;
+}