home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
historic
/
v941.tgz
/
icon.v941src.tar
/
icon.v941src
/
src
/
common
/
infer.c
< prev
next >
Wrap
C/C++ Source or Header
|
2001-12-12
|
816b
|
32 lines
/*
* infer.c -- generate definitions reflecting present hardware architecture
*
* Inspired by mail from Christian Hudon.
*/
#include <assert.h>
#include <stddef.h>
#include <stdio.h>
typedef struct {
char c;
double d;
} tstruct;
static long atdepth(int n) {
return n <= 1 ? (long)&n : atdepth(n - 1);
}
int main(int argc, char *argv[]) {
assert (-1 == (signed char)0xFF); /* chars must be 8 bits */
assert (sizeof(void*) == sizeof(long)); /* these must be the same */
printf("/* generated by infer.c */\n");
printf("#define IntBits %d\n", 8 * sizeof(int));
printf("#define WordBits %d\n", 8 * sizeof(void *));
if (offsetof(tstruct, d) > sizeof(void *))
printf("#define Double\n");
if (atdepth(2) > atdepth(1))
printf("#define UpStack\n");
return 0;
}