Annotation of GNUtools/cc/c-pragma.c, revision 1.1

1.1     ! root        1: /* Handle #pragma, system V.4 style.  Supports #pragma weak and #pragma pack.
        !             2:    Copyright (C) 1992 Free Software Foundation, Inc.
        !             3: 
        !             4: This file is part of GNU CC.
        !             5: 
        !             6: GNU CC is free software; you can redistribute it and/or modify
        !             7: it under the terms of the GNU General Public License as published by
        !             8: the Free Software Foundation; either version 2, or (at your option)
        !             9: any later version.
        !            10: 
        !            11: GNU CC is distributed in the hope that it will be useful,
        !            12: but WITHOUT ANY WARRANTY; without even the implied warranty of
        !            13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        !            14: GNU General Public License for more details.
        !            15: 
        !            16: You should have received a copy of the GNU General Public License
        !            17: along with GNU CC; see the file COPYING.  If not, write to
        !            18: the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
        !            19: 
        !            20: #include <stdio.h>
        !            21: #include "config.h"
        !            22: #include "tree.h"
        !            23: #include "function.h"
        !            24: 
        !            25: #ifdef HANDLE_SYSV_PRAGMA
        !            26: 
        !            27: /* Support #pragma weak by default if WEAK_ASM_OP is defined.  */
        !            28: #if !defined (HANDLE_PRAGMA_WEAK) && defined (WEAK_ASM_OP) && defined (SET_ASM_OP)
        !            29: #define HANDLE_PRAGMA_WEAK 1
        !            30: #endif
        !            31: 
        !            32: /* See varasm.c for an identical definition.  */
        !            33: enum pragma_state
        !            34: {
        !            35:   ps_start,
        !            36:   ps_done,
        !            37:   ps_bad,
        !            38:   ps_weak,
        !            39:   ps_name,
        !            40:   ps_equals,
        !            41:   ps_value,
        !            42:   ps_pack,
        !            43:   ps_left,
        !            44:   ps_align,
        !            45:   ps_right
        !            46: };
        !            47: 
        !            48: /* When structure field packing is in effect, this variable is the
        !            49:    number of bits to use as the maximum alignment.  When packing is not
        !            50:    in effect, this is zero. */
        !            51: 
        !            52: extern int maximum_field_alignment;
        !            53: 
        !            54: /* File used for outputting assembler code.  */
        !            55: extern FILE *asm_out_file;
        !            56: 
        !            57: /* Handle one token of a pragma directive.  TOKEN is the
        !            58:    current token, and STRING is its printable form.  */
        !            59: 
        !            60: void
        !            61: handle_pragma_token (string, token)
        !            62:      char *string;
        !            63:      tree token;
        !            64: {
        !            65:   static enum pragma_state state = ps_start, type;
        !            66:   static char *name;
        !            67:   static char *value;
        !            68:   static int align;
        !            69: 
        !            70:   if (string == 0)
        !            71:     {
        !            72:       if (type == ps_pack)
        !            73:        {
        !            74:          if (state == ps_right)
        !            75:            maximum_field_alignment = align * 8;
        !            76:          else
        !            77:            warning ("malformed `#pragma pack'");
        !            78:        }
        !            79:       else if (type == ps_weak)
        !            80:        {
        !            81: #ifdef HANDLE_PRAGMA_WEAK
        !            82:          if (HANDLE_PRAGMA_WEAK)
        !            83:            handle_pragma_weak (state, asm_out_file, name, value);
        !            84: 
        !            85: #endif /* HANDLE_PRAMA_WEAK */
        !            86:        }
        !            87: 
        !            88:       type = state = ps_start;
        !            89:       return;
        !            90:     }
        !            91: 
        !            92:   switch (state)
        !            93:     {
        !            94:     case ps_start:
        !            95:       if (token && TREE_CODE (token) == IDENTIFIER_NODE)
        !            96:        {
        !            97:          if (strcmp (IDENTIFIER_POINTER (token), "pack") == 0)
        !            98:            type = state = ps_pack;
        !            99:          else if (strcmp (IDENTIFIER_POINTER (token), "weak") == 0)
        !           100:            type = state = ps_weak;
        !           101:          else
        !           102:            type = state = ps_done;
        !           103:        }
        !           104:       else
        !           105:        type = state = ps_done;
        !           106:       break;
        !           107: 
        !           108:     case ps_weak:
        !           109:       if (token && TREE_CODE (token) == IDENTIFIER_NODE)
        !           110:        {
        !           111:          name = IDENTIFIER_POINTER (token);
        !           112:          state = ps_name;
        !           113:        }
        !           114:       else
        !           115:        state = ps_bad;
        !           116:       break;
        !           117: 
        !           118:     case ps_name:
        !           119:       state = (strcmp (string, "=") ? ps_bad : ps_equals);
        !           120:       break;
        !           121: 
        !           122:     case ps_equals:
        !           123:       if (token && TREE_CODE (token) == IDENTIFIER_NODE)
        !           124:        {
        !           125:          value = IDENTIFIER_POINTER (token);
        !           126:          state = ps_value;
        !           127:        }
        !           128:       else
        !           129:        state = ps_bad;
        !           130:       break;
        !           131: 
        !           132:     case ps_value:
        !           133:       state = ps_bad;
        !           134:       break;
        !           135: 
        !           136:     case ps_pack:
        !           137:       if (strcmp (string, "(") == 0)
        !           138:        state = ps_left;
        !           139:       else
        !           140:        state = ps_bad;
        !           141:       break;
        !           142: 
        !           143:     case ps_left:
        !           144:       if (token && TREE_CODE (token) == INTEGER_CST
        !           145:          && TREE_INT_CST_HIGH (token) == 0)
        !           146:        switch (TREE_INT_CST_LOW (token))
        !           147:          {
        !           148:          case 1:
        !           149:          case 2:
        !           150:          case 4:
        !           151:            align = TREE_INT_CST_LOW (token);
        !           152:            state = ps_align;
        !           153:            break;
        !           154: 
        !           155:          default:
        !           156:            state = ps_bad;
        !           157:          }
        !           158:       else if (! token && strcmp (string, ")") == 0)
        !           159:        {
        !           160:          align = 0;
        !           161:          state = ps_right;
        !           162:        }
        !           163:       else
        !           164:        state = ps_bad;
        !           165:       break;
        !           166: 
        !           167:     case ps_align:
        !           168:       if (strcmp (string, ")") == 0)
        !           169:        state = ps_right;
        !           170:       else
        !           171:        state = ps_bad;
        !           172:       break;
        !           173: 
        !           174:     case ps_right:
        !           175:       state = ps_bad;
        !           176:       break;
        !           177: 
        !           178:     case ps_bad:
        !           179:     case ps_done:
        !           180:       break;
        !           181: 
        !           182:     default:
        !           183:       abort ();
        !           184:     }
        !           185: }
        !           186: #endif /* HANDLE_SYSV_PRAGMA */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.