source: git/ppcc/cnf/genconfig.c @ 54b24c

spielwiese
Last change on this file since 54b24c was 54b24c, checked in by Reimer Behrends <behrends@…>, 5 years ago
Finalizing thread support.
  • Property mode set to 100644
File size: 911 bytes
Line 
1/* This is a workaround around <stdint.h> not being available
2 * everywhere.
3 */
4#include <stdio.h>
5#include <stdlib.h>
6
7void 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
18int 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}
Note: See TracBrowser for help on using the repository browser.