home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / printing / ghostscrip / source / _gs / c / genarch < prev    next >
Encoding:
Text File  |  1991-10-27  |  862 b   |  33 lines

  1. /* genarch.c */
  2. /* Generate a header file (arch.h) with parameters */
  3. /* reflecting the machine architecture. */
  4.  
  5. #include <stdio.h>
  6. #ifdef ARC
  7. /* Modifications for the Archimedes: include stdlib (for exit()),
  8.    and change file names
  9.  */
  10. #include <stdlib.h>
  11. #endif
  12.  
  13. /* We should write the result on stdout, but the Turbo C 'make' */
  14. /* can't handle output redirection (sigh). */
  15.  
  16. main(argc, argv)
  17.     int argc;
  18.     char *argv[];
  19. {    char *fname = argv[1];
  20.     long one = 1;
  21.     int v16 = 1 << 16;
  22.     FILE *f = fopen(fname, "w");
  23.     if ( f == NULL )
  24.        {    fprintf(stderr, "genarch.c: can't open %s for writing\n", fname);
  25.         exit(1);
  26.        }
  27.     fprintf(f, "/* Parameters derived from machine and compiler architecture */\n\n");
  28.     fprintf(f, "#define arch_is_big_endian %d\n", 1 - *(char *)&one);
  29.     fprintf(f, "#define arch_ints_are_short %d\n", v16 == 0);
  30.     fclose(f);
  31.     return 0;
  32. }
  33.