home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / NeXT / GnuSource / cplusplus-8 / config / out-next.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-24  |  2.9 KB  |  112 lines

  1. /* out-next.c:  Functions for NeXT as target machine for GNU C compiler.
  2.  
  3. This file is part of GNU CC.
  4.  
  5. GNU CC is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9.  
  10. GNU CC is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with GNU CC; see the file COPYING.  If not, write to
  17. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  18.  
  19. /* Make everything that used to go in the text section really go there.  */
  20.  
  21. int flag_no_mach_text_sections = 0;
  22.  
  23. #define INIT_PRAGMA_BUF_SIZE    80
  24. #define PRAGMA_BUF_SIZE_INCR    40
  25. #define OPT_STRCMP(opt) (!strncmp (opt, p, sizeof (opt)-1))
  26.  
  27. /* 1 if handle_pragma has been called yet.  */
  28.  
  29. static int pragma_initialized;
  30.  
  31. /* Initial setting of `optimize'.  */
  32.  
  33. static int initial_optimize_flag;
  34.  
  35. /* Called from check_newline via the macro HANDLE_PRAGMA.
  36.    FINPUT is the source file input stream.  */
  37.  
  38. void
  39. handle_pragma (finput)
  40.      FILE *finput;
  41. {
  42.   char c;
  43.   char *pragma_buf;
  44.   int pragma_buf_size, i;
  45.   char *p;
  46.   extern int optimize, obey_regdecls, flag_writable_strings;
  47.  
  48.   /* Record initial setting of optimize flag, so we can restore it.  */
  49.   if (!pragma_initialized)
  50.     {
  51.       pragma_initialized = 1;
  52.       initial_optimize_flag = optimize;
  53.     }
  54.  
  55.   /* Read the input line */
  56.   pragma_buf_size = INIT_PRAGMA_BUF_SIZE;
  57.   pragma_buf = (char *)xmalloc (pragma_buf_size);
  58.   i = 0;
  59.   while (c = getc (finput))
  60.     {
  61.       if (i == pragma_buf_size)
  62.     {
  63.       pragma_buf_size += PRAGMA_BUF_SIZE_INCR;
  64.       pragma_buf = (char *)xrealloc (pragma_buf, pragma_buf_size);
  65.     }
  66.       if (c == '\n')
  67.     {
  68.       ungetc (c, finput);
  69.       pragma_buf[i] = 0;
  70.       break;
  71.     }
  72.       pragma_buf[i] = c;
  73.       i++;
  74.     }
  75.   p = pragma_buf;
  76.   /* Skip white space */
  77.   while ((*p == ' ') || (*p == '\t')) p++;
  78.  
  79.   if (OPT_STRCMP ("CC_OPT_ON"))
  80.     {
  81.       optimize = 1, obey_regdecls = 0;
  82.       warning ("optimization turned on");
  83.     }
  84.   else if (OPT_STRCMP ("CC_OPT_OFF"))
  85.     {
  86.       optimize = 0, obey_regdecls = 1;
  87.       warning ("optimization turned off");
  88.     }
  89.   else if (OPT_STRCMP ("CC_OPT_RESTORE"))
  90.     {
  91.       extern int initial_optimize_flag;
  92.  
  93.       if (optimize != initial_optimize_flag)
  94.     {
  95.       if (initial_optimize_flag)
  96.         obey_regdecls = 0;
  97.       else
  98.         obey_regdecls = 1;
  99.       optimize = initial_optimize_flag;
  100.     }
  101.       warning ("optimization level restored");
  102.     }
  103.   else if (OPT_STRCMP ("CC_WRITABLE_STRINGS"))
  104.     flag_writable_strings = 1;
  105.   else if (OPT_STRCMP ("CC_NON_WRITABLE_STRINGS"))
  106.     flag_writable_strings = 0;
  107.   else if (OPT_STRCMP("CC_NO_MACH_TEXT_SECTIONS"))
  108.     flag_no_mach_text_sections = 1;
  109.   /* Ignore the rest of the line. */
  110.   free (pragma_buf);
  111. }
  112.