OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [config/] [vms/] [vms-c.c] - Blame information for rev 709

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 709 jeremybenn
/* VMS specific, C compiler specific functions.
2
   Copyright (C) 2011
3
   Free Software Foundation, Inc.
4
   Contributed by Tristan Gingold (gingold@adacore.com).
5
 
6
This file is part of GCC.
7
 
8
GCC is free software; you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation; either version 3, or (at your option)
11
any later version.
12
 
13
GCC is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
GNU General Public License for more details.
17
 
18
You should have received a copy of the GNU General Public License
19
along with GCC; see the file COPYING3.  If not see
20
<http://www.gnu.org/licenses/>.  */
21
 
22
#include "config.h"
23
#include "system.h"
24
#include "coretypes.h"
25
#include "tm.h"
26
#include "cpplib.h"
27
#include "tree.h"
28
#include "c-family/c-pragma.h"
29
#include "c-family/c-common.h"
30
#include "toplev.h"
31
#include "ggc.h"
32
#include "tm_p.h"
33
#include "incpath.h"
34
#include "diagnostic.h"
35
 
36
/* '#pragma __nostandard' is simply ignored.  */
37
 
38
static void
39
vms_pragma_nostandard (cpp_reader *pfile ATTRIBUTE_UNUSED)
40
{
41
  tree x;
42
 
43
  if (pragma_lex (&x) != CPP_EOF)
44
    warning (OPT_Wpragmas, "junk at end of #pragma __nostandard");
45
}
46
 
47
/* '#pragma __standard' is simply ignored.  */
48
 
49
static void
50
vms_pragma_standard (cpp_reader *pfile ATTRIBUTE_UNUSED)
51
{
52
  tree x;
53
 
54
  if (pragma_lex (&x) != CPP_EOF)
55
    warning (OPT_Wpragmas, "junk at end of #pragma __standard");
56
}
57
 
58
/* Saved member alignment.  */
59
static int saved_member_alignment;
60
 
61
/* Handle '#pragma member_alignment'.  */
62
 
63
static void
64
vms_pragma_member_alignment (cpp_reader *pfile ATTRIBUTE_UNUSED)
65
{
66
  tree x;
67
  int tok;
68
  const char *arg;
69
 
70
  tok = pragma_lex (&x);
71
 
72
  if (tok == CPP_EOF)
73
    {
74
      /* Disable packing.  */
75
      maximum_field_alignment = initial_max_fld_align;
76
      return;
77
    }
78
  if (tok != CPP_NAME)
79
    {
80
      warning (OPT_Wpragmas, "malformed '#pragma member_alignment', ignoring");
81
      return;
82
    }
83
 
84
  arg = IDENTIFIER_POINTER (x);
85
  /* Accept '__' prefix.  */
86
  if (arg[0] == '_' && arg[1] == '_')
87
    arg += 2;
88
 
89
  if (strcmp (arg, "save") == 0)
90
    saved_member_alignment = maximum_field_alignment;
91
  else if (strcmp (arg, "restore") == 0)
92
    maximum_field_alignment = saved_member_alignment;
93
  else
94
    {
95
      error ("unknown '#pragma member_alignment' name %s", arg);
96
      return;
97
    }
98
  if (pragma_lex (&x) != CPP_EOF)
99
    {
100
      error ("malformed '#pragma member_alignment'");
101
      return;
102
    }
103
}
104
 
105
/* Handle '#pragma nomember_alignment'.  */
106
 
107
static void
108
vms_pragma_nomember_alignment (cpp_reader *pfile ATTRIBUTE_UNUSED)
109
{
110
  tree x;
111
  int tok;
112
 
113
  tok = pragma_lex (&x);
114
  if (tok == CPP_NAME)
115
    {
116
      const char *arg = IDENTIFIER_POINTER (x);
117
 
118
      /* Accept '__' prefix.  */
119
      if (arg[0] == '_' && arg[1] == '_')
120
        arg += 2;
121
 
122
      if (strcmp (arg, "word") == 0)
123
        maximum_field_alignment = 2 * BITS_PER_UNIT;
124
      else if (strcmp (arg, "longword") == 0)
125
        maximum_field_alignment = 4 * BITS_PER_UNIT;
126
      else if (strcmp (arg, "quadword") == 0)
127
        maximum_field_alignment = 8 * BITS_PER_UNIT;
128
      else
129
        {
130
          error ("unhandled alignment for '#pragma nomember_alignment'");
131
        }
132
 
133
      tok = pragma_lex (&x);
134
    }
135
  else
136
    {
137
      /* Enable packing.  */
138
      maximum_field_alignment = BITS_PER_UNIT;
139
    }
140
 
141
  if (tok != CPP_EOF)
142
    {
143
      error ("garbage at end of '#pragma nomember_alignment'");
144
      return;
145
    }
146
}
147
 
148
/* The 'extern model' for public data.  */
149
 
150
enum extern_model_kind
151
{
152
  /* Create one overlaid section per variable.  */
153
  extern_model_common_block,
154
 
155
  /* Like unix: multiple not-initialized declarations are allowed.  */
156
  extern_model_relaxed_refdef,
157
 
158
  /* Like -fno-common.  */
159
  extern_model_strict_refdef,
160
 
161
  /* Declarations creates symbols without storage.  */
162
  extern_model_globalvalue
163
};
164
 
165
/* Current and saved extern model.  */
166
static enum extern_model_kind current_extern_model;
167
static enum extern_model_kind saved_extern_model;
168
 
169
/* Partial handling of '#pragma extern_model'.  */
170
 
171
static void
172
vms_pragma_extern_model (cpp_reader *pfile ATTRIBUTE_UNUSED)
173
{
174
  tree x;
175
  int tok;
176
  const char *arg;
177
 
178
  tok = pragma_lex (&x);
179
 
180
  if (tok != CPP_NAME)
181
    {
182
      warning (OPT_Wpragmas, "malformed '#pragma extern_model', ignoring");
183
      return;
184
    }
185
 
186
  arg = IDENTIFIER_POINTER (x);
187
  /* Accept "__" prefix.  */
188
  if (arg[0] == '_' && arg[1] == '_')
189
    arg += 2;
190
 
191
  if (strcmp (arg, "save") == 0)
192
    saved_extern_model = current_extern_model;
193
  else if (strcmp (arg, "restore") == 0)
194
    current_extern_model = saved_extern_model;
195
  else if (strcmp (arg, "strict_refdef") == 0)
196
    current_extern_model = extern_model_strict_refdef;
197
  else if (strcmp (arg, "common_block") == 0)
198
    current_extern_model = extern_model_common_block;
199
  else if (strcmp (arg, "globalvalue") == 0)
200
    {
201
      sorry ("extern model globalvalue");
202
      return;
203
    }
204
  else
205
    {
206
      error ("unknown '#pragma extern_model' model '%s'", arg);
207
      return;
208
    }
209
#if 0
210
  if (pragma_lex (&x) != CPP_EOF)
211
    {
212
      permerror (input_location, "junk at end of '#pragma extern_model'");
213
      return;
214
    }
215
#endif
216
}
217
 
218
/* Ignore '#pragma message'.  */
219
 
220
static void
221
vms_pragma_message (cpp_reader *pfile ATTRIBUTE_UNUSED)
222
{
223
  /* Completly ignored.  */
224
#if 0
225
  pedwarn (input_location, OPT_Wpragmas,
226
           "vms '#pragma __message' is ignored");
227
#endif
228
}
229
 
230
/* Handle '#pragma __extern_prefix'  */
231
 
232
static GTY(()) tree saved_extern_prefix;
233
 
234
static void
235
vms_pragma_extern_prefix (cpp_reader * ARG_UNUSED (dummy))
236
{
237
  enum cpp_ttype tok;
238
  tree x;
239
 
240
  tok = pragma_lex (&x);
241
  if (tok == CPP_NAME)
242
    {
243
      const char *op = IDENTIFIER_POINTER (x);
244
 
245
      if (!strcmp (op, "__save"))
246
        saved_extern_prefix = pragma_extern_prefix;
247
      else if (!strcmp (op, "__restore"))
248
        pragma_extern_prefix = saved_extern_prefix;
249
      else
250
        warning (OPT_Wpragmas,
251
                 "malformed '#pragma __extern_prefix', ignoring");
252
      return;
253
    }
254
  else if (tok != CPP_STRING)
255
    {
256
      warning (OPT_Wpragmas,
257
               "malformed '#pragma __extern_prefix', ignoring");
258
    }
259
  else
260
    {
261
      /* Note that the length includes the null terminator.  */
262
      pragma_extern_prefix = (TREE_STRING_LENGTH (x) > 1 ? x : NULL);
263
    }
264
}
265
 
266
/* Add vms-specific pragma.  */
267
 
268
void
269
vms_c_register_pragma (void)
270
{
271
  c_register_pragma (NULL, "__nostandard", vms_pragma_nostandard);
272
  c_register_pragma (NULL, "nostandard", vms_pragma_nostandard);
273
  c_register_pragma (NULL, "__standard", vms_pragma_standard);
274
  c_register_pragma (NULL, "standard", vms_pragma_standard);
275
  c_register_pragma (NULL, "__member_alignment", vms_pragma_member_alignment);
276
  c_register_pragma (NULL, "member_alignment", vms_pragma_member_alignment);
277
  c_register_pragma (NULL, "__nomember_alignment",
278
                     vms_pragma_nomember_alignment);
279
  c_register_pragma (NULL, "nomember_alignment",
280
                     vms_pragma_nomember_alignment);
281
  c_register_pragma (NULL, "__extern_model", vms_pragma_extern_model);
282
  c_register_pragma (NULL, "extern_model", vms_pragma_extern_model);
283
  c_register_pragma (NULL, "__message", vms_pragma_message);
284
  c_register_pragma (NULL, "__extern_prefix", vms_pragma_extern_prefix);
285
}
286
 
287
/* Standard modules list.  */
288
static const char * const vms_std_modules[] = { "rtldef", "starlet_c", NULL };
289
 
290
/* Find include modules in the include path.  */
291
 
292
void
293
vms_c_register_includes (const char *sysroot,
294
                         const char *iprefix ATTRIBUTE_UNUSED, int stdinc)
295
{
296
  static const char dir_separator_str[] = { DIR_SEPARATOR, 0 };
297
  struct cpp_dir *dir;
298
 
299
  /* Add on standard include pathes.  */
300
  if (!stdinc)
301
    return;
302
 
303
  for (dir = get_added_cpp_dirs (SYSTEM); dir != NULL; dir = dir->next)
304
    {
305
      const char * const *lib;
306
      for (lib = vms_std_modules; *lib != NULL; lib++)
307
        {
308
          char *path;
309
          struct stat st;
310
 
311
          if (sysroot != NULL)
312
            path = concat (sysroot, dir->name, dir_separator_str, *lib, NULL);
313
          else
314
            path = concat (dir->name, dir_separator_str, *lib, NULL);
315
 
316
          if (stat (path, &st) == 0 && S_ISDIR (st.st_mode))
317
            {
318
              cpp_dir *p;
319
 
320
              p = XNEW (cpp_dir);
321
              p->next = NULL;
322
              p->name = path;
323
              p->sysp = 1;
324
              p->construct = 0;
325
              p->user_supplied_p = 0;
326
              add_cpp_dir_path (p, SYSTEM);
327
            }
328
          else
329
            free (path);
330
        }
331
    }
332
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.