SCM Repository
Annotation of /sml/trunk/ckit/src/c-util/sizes.c
Parent Directory
|
Revision Log
Revision 597 - (view) (download) (as text)
1 : | dbm | 597 | /* automatically generates Sizes.sml */ |
2 : | |||
3 : | #include <stdio.h> | ||
4 : | |||
5 : | typedef struct { char c; } min_struct; | ||
6 : | typedef union { char c; } min_union; | ||
7 : | typedef long long longlong; | ||
8 : | typedef long double longdouble; | ||
9 : | typedef char* pointer; | ||
10 : | |||
11 : | #define OFFSET(ty) \ | ||
12 : | { \ | ||
13 : | struct { \ | ||
14 : | char a; \ | ||
15 : | ty b; \ | ||
16 : | } x; \ | ||
17 : | printf(" "); \ | ||
18 : | printf(#ty " = {bits = %d, align = %d},\n", \ | ||
19 : | sizeof(ty)*8, \ | ||
20 : | ((unsigned long)&(x.b) - (unsigned long)&(x.a))*8); \ | ||
21 : | } | ||
22 : | |||
23 : | main () | ||
24 : | { | ||
25 : | printf("(* This file was automatically generated using size.c.\n"); | ||
26 : | printf(" * It contains information about c data sizes and layout.\n\n"); | ||
27 : | printf(" * Limitations:\n"); | ||
28 : | printf(" * 1. write proper test for bitFieldAlignment.\n"); | ||
29 : | printf(" * 2. include date and system information in this file?\n"); | ||
30 : | printf(" *)\n\n"); | ||
31 : | printf("val sizes = { (*** all sizes in bits ***)\n"); | ||
32 : | OFFSET(char) | ||
33 : | OFFSET(short) | ||
34 : | OFFSET(int) | ||
35 : | OFFSET(long) | ||
36 : | OFFSET(longlong) | ||
37 : | OFFSET(float) | ||
38 : | OFFSET(double) | ||
39 : | OFFSET(longdouble) | ||
40 : | OFFSET(pointer) | ||
41 : | OFFSET(min_struct) | ||
42 : | OFFSET(min_union) | ||
43 : | printf(" onlyPackBitFields = false,\n"); | ||
44 : | printf(" ignoreUnnamedBitFieldAlignment = true\n}\n"); | ||
45 : | } |
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |