aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux/sizeof
diff options
context:
space:
mode:
authorDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2020-03-03 08:17:40 +0100
committerDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2020-03-03 08:17:40 +0100
commit1ab7b51c30e1b10ac45b0bd64cefdc01da0f7f68 (patch)
tree210ffc156c83f04fb0c61a40b4f9037d7ba8a7e1 /test/monniaux/sizeof
parent222c9047d61961db9c6b19fed5ca49829223fd33 (diff)
parent12be46d59a2483a10d77fa8ee67f7e0ca1bd702f (diff)
downloadcompcert-kvx-1ab7b51c30e1b10ac45b0bd64cefdc01da0f7f68.tar.gz
compcert-kvx-1ab7b51c30e1b10ac45b0bd64cefdc01da0f7f68.zip
Merge branch 'mppa-cse2' of gricad-gitlab.univ-grenoble-alpes.fr:sixcy/CompCert into mppa-work
Diffstat (limited to 'test/monniaux/sizeof')
-rw-r--r--test/monniaux/sizeof/sizeof.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/monniaux/sizeof/sizeof.c b/test/monniaux/sizeof/sizeof.c
new file mode 100644
index 00000000..9f283376
--- /dev/null
+++ b/test/monniaux/sizeof/sizeof.c
@@ -0,0 +1,46 @@
+#include <stdio.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <inttypes.h>
+
+#define PRINT_SIZE(t) printf("%s\t%zd\n", #t, sizeof(t))
+#define PRINT_SIZES_INTN(n) \
+ PRINT_SIZE(int##n##_t); \
+ PRINT_SIZE(uint##n##_t); \
+ PRINT_SIZE(int_least##n##_t); \
+ PRINT_SIZE(uint_least##n##_t); \
+ PRINT_SIZE(int_fast##n##_t); \
+ PRINT_SIZE(uint_fast##n##_t)
+
+typedef void fun(void);
+
+int main() {
+ PRINT_SIZE(bool);
+ PRINT_SIZE(char);
+ PRINT_SIZE(short);
+ PRINT_SIZE(int);
+ PRINT_SIZE(long);
+ PRINT_SIZE(long long);
+
+ PRINT_SIZE(void*);
+ PRINT_SIZE(fun*);
+
+ PRINT_SIZE(float);
+ PRINT_SIZE(double);
+ PRINT_SIZE(long double);
+
+ PRINT_SIZE(ptrdiff_t);
+ PRINT_SIZE(size_t);
+ PRINT_SIZE(wchar_t);
+ PRINT_SIZE(intptr_t);
+ PRINT_SIZE(uintptr_t);
+ PRINT_SIZE(intmax_t);
+ PRINT_SIZE(uintmax_t);
+
+ PRINT_SIZES_INTN(8);
+ PRINT_SIZES_INTN(16);
+ PRINT_SIZES_INTN(32);
+ PRINT_SIZES_INTN(64);
+
+ return 0;
+}