1 /* This is a workaround around <stdint.h> not being available
2  * everywhere.
3  */
4 #include <stdio.h>
5 #include <stdlib.h>
6 
gen(const char * tname,const char * prefix,size_t size)7 void gen(const char *tname, const char *prefix, size_t size) {
8   const char *ty;
9   if (size == sizeof(long long)) ty = "long long";
10   else if (size == sizeof(long)) ty = "long";
11   else if (size == sizeof(int)) ty = "int";
12   else if (size == sizeof(short)) ty = "short";
13   else if (size == sizeof(char)) ty = "char";
14   else exit(1);
15   printf("typedef %s %s %s;\n", prefix, ty, tname);
16 }
17 
main()18 int main() {
19   printf("#pragma once\n\n");
20   gen("Word", "unsigned", sizeof(void *));
21   if (sizeof(long long) >= 8)
22     gen("Word64", "unsigned", 8);
23   gen("Word32", "unsigned", 4);
24   gen("Word16", "unsigned", 2);
25   printf("\n");
26   gen("Int", "signed", sizeof(void *));
27   if (sizeof(long long) >= 8)
28     gen("Int64", "signed", 8);
29   gen("Int32", "signed", 4);
30   gen("Int16", "signed", 2);
31   return 0;
32 }
33