home *** CD-ROM | disk | FTP | other *** search
- /* genarch.c */
- /* Generate a header file (arch.h) with parameters */
- /* reflecting the machine architecture. */
-
- #include <stdio.h>
- #ifdef ARC
- /* Modifications for the Archimedes: include stdlib (for exit()),
- and change file names
- */
- #include <stdlib.h>
- #endif
-
- /* We should write the result on stdout, but the Turbo C 'make' */
- /* can't handle output redirection (sigh). */
-
- main(argc, argv)
- int argc;
- char *argv[];
- { char *fname = argv[1];
- long one = 1;
- int v16 = 1 << 16;
- FILE *f = fopen(fname, "w");
- if ( f == NULL )
- { fprintf(stderr, "genarch.c: can't open %s for writing\n", fname);
- exit(1);
- }
- fprintf(f, "/* Parameters derived from machine and compiler architecture */\n\n");
- fprintf(f, "#define arch_is_big_endian %d\n", 1 - *(char *)&one);
- fprintf(f, "#define arch_ints_are_short %d\n", v16 == 0);
- fclose(f);
- return 0;
- }
-