]> gcc.gnu.org Git - gcc.git/blame - libgfortran/libgfortran.h
calls.c (initialize_argument_information): Forbid sibcalls if a callee-copied argumen...
[gcc.git] / libgfortran / libgfortran.h
CommitLineData
6de9cd9a
DN
1/* Common declarations for all of libgfor.
2 Copyright 2002, 2003 Free Software Foundation, Inc.
3 Contributed by Paul Brook <paul@nowt.org>, and
4 Andy Vaught <andy@xena.eas.asu.edu>
5
6This file is part of the GNU Fortran 95 runtime library (libgfor).
7
8Libgfor is free software; you can redistribute it and/or
9modify it under the terms of the GNU Lesser General Public
10License as published by the Free Software Foundation; either
11version 2.1 of the License, or (at your option) any later version.
12
13Libgfor is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU Lesser General Public License for more details.
17
18You should have received a copy of the GNU Lesser General Public
19License along with libgfor; see the file COPYING.LIB. If not,
20write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21Boston, MA 02111-1307, USA. */
22
23
24#ifndef LIBGFOR_H
25#define LIBGFOR_H
26
27#include <math.h>
28#include <stddef.h>
29
30#ifndef M_PI
31#define M_PI 3.14159265358979323846264338327
32#endif
33
34#include "config.h"
35
36#if HAVE_COMPLEX_H
37# include <complex.h>
38#else
39#define complex __complex__
40#endif
41
42#if HAVE_STDINT_H
43#include <stdint.h>
44#endif
45
46#if HAVE_INTTYPES_H
47#include <inttypes.h>
48#endif
49
50#if HAVE_SYS_TYPES_H
51#include <sys/types.h>
52#endif
81f4be3c 53typedef off_t gfc_offset;
6de9cd9a
DN
54
55#ifndef NULL
56#define NULL (void *) 0
57#endif
58
59#ifndef __GNUC__
60#define __attribute__(x)
61#endif
62
63/* For a library, a standard prefix is a requirement in order to
64 partition the namespace. It's ugly to look at and a pain to type,
65 so we hide it behind macros. */
66#define prefix(x) _gfortran_ ## x
67
68/* The only reliable way to get the offset of a field in a struct
69 in a system independent way is via this macro. */
70#ifndef offsetof
71#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER)
72#endif
73
74/* TODO: find the C99 version of these an move into above ifdef. */
75#define REALPART(z) (__real__(z))
76#define IMAGPART(z) (__imag__(z))
77#define COMPLEX_ASSIGN(z_, r_, i_) {__real__(z_) = (r_); __imag__(z_) = (i_);}
78
79typedef int32_t GFC_INTEGER_4;
80typedef int64_t GFC_INTEGER_8;
81typedef uint32_t GFC_UINTEGER_4;
82typedef uint64_t GFC_UINTEGER_8;
83typedef GFC_INTEGER_4 GFC_LOGICAL_4;
84typedef GFC_INTEGER_8 GFC_LOGICAL_8;
85typedef float GFC_REAL_4;
86typedef double GFC_REAL_8;
87typedef complex float GFC_COMPLEX_4;
88typedef complex double GFC_COMPLEX_8;
89
90typedef size_t index_type;
91
92/* This will be 0 on little-endian machines and one on big-endian machines. */
93#define l8_to_l4_offset prefix(l8_to_l4_offset)
94extern int l8_to_l4_offset;
95
96#define GFOR_POINTER_L8_TO_L4(p8) \
97 (l8_to_l4_offset + (GFC_LOGICAL_4 *)(p8))
98
99#define GFC_INTEGER_4_HUGE \
100 (GFC_INTEGER_4)((((GFC_UINTEGER_4)1) << 31) - 1)
101#define GFC_INTEGER_8_HUGE \
102 (GFC_INTEGER_8)((((GFC_UINTEGER_8)1) << 63) - 1)
103#define GFC_REAL_4_HUGE FLT_MAX
104#define GFC_REAL_8_HUGE DBL_MAX
105
106#ifndef GFC_MAX_DIMENSIONS
107#define GFC_MAX_DIMENSIONS 7
108#endif
109
110typedef struct descriptor_dimension
111{
112 index_type stride;
113 index_type lbound;
114 index_type ubound;
115}
116descriptor_dimension;
117
118#define GFC_ARRAY_DESCRIPTOR(r, type) \
119struct {\
120 type *data;\
121 type *base;\
122 index_type dtype;\
123 descriptor_dimension dim[r];\
124}
125
126/* Commonly used array descriptor types. */
127typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, void) gfc_array_void;
128typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, char) gfc_array_char;
129typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_4) gfc_array_i4;
130typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_8) gfc_array_i8;
131typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_4) gfc_array_r4;
132typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_8) gfc_array_r8;
133typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_4) gfc_array_c4;
134typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_8) gfc_array_c8;
135typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_4) gfc_array_l4;
136typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_8) gfc_array_l8;
137
138#define GFC_DTYPE_RANK_MASK 0x07
139#define GFC_DTYPE_TYPE_SHIFT 3
140#define GFC_DTYPE_TYPE_MASK 0x38
141#define GFC_DTYPE_SIZE_SHIFT 6
142
143enum
144{
145 GFC_DTYPE_UNKNOWN = 0,
146 GFC_DTYPE_INTEGER,
147 /* TODO: recognize logical types. */
148 GFC_DTYPE_LOGICAL,
149 GFC_DTYPE_REAL,
150 GFC_DTYPE_COMPLEX,
151 GFC_DTYPE_DERIVED,
152 GFC_DTYPE_CHARACTER
153};
154
155#define GFC_DESCRIPTOR_RANK(desc) ((desc)->dtype & GFC_DTYPE_RANK_MASK)
156#define GFC_DESCRIPTOR_TYPE(desc) (((desc)->dtype & GFC_DTYPE_TYPE_MASK) \
157 >> GFC_DTYPE_TYPE_SHIFT)
158#define GFC_DESCRIPTOR_SIZE(desc) ((desc)->dtype >> GFC_DTYPE_SIZE_SHIFT)
159#define GFC_DESCRIPTOR_DATA(desc) ((desc)->data)
160#define GFC_DESCRIPTOR_DTYPE(desc) ((desc)->dtype)
161
162/* Runtime library include. */
163#define stringize(x) expand_macro(x)
164#define expand_macro(x) # x
165
166/* Runtime options structure. */
167
168typedef struct
169{
170 int stdin_unit, stdout_unit, optional_plus;
171 int allocate_init_flag, allocate_init_value;
172 int locus;
173
174 int separator_len;
175 const char *separator;
176
177 int mem_check;
178 int use_stderr, all_unbuffered, default_recl;
179
180 int fpu_round, fpu_precision, fpu_invalid, fpu_denormal, fpu_zerodiv,
181 fpu_overflow, fpu_underflow, fpu_precision_loss;
182
183 int sighup, sigint;
184}
185options_t;
186
187
188#define options prefix(options)
189extern options_t options;
190
191
192/* Structure for statement options. */
193
194typedef struct
195{
196 const char *name;
197 int value;
198}
199st_option;
200
201/* Runtime errors. The EOR and EOF errors are required to be negative. */
202
203typedef enum
204{
205 ERROR_FIRST = -3, /* Marker for the first error. */
206 ERROR_EOR = -2,
207 ERROR_END = -1,
208 ERROR_OK = 0, /* Indicates success, must be zero. */
209 ERROR_OS, /* Operating system error, more info in errno. */
210 ERROR_OPTION_CONFLICT,
211 ERROR_BAD_OPTION,
212 ERROR_MISSING_OPTION,
213 ERROR_ALREADY_OPEN,
214 ERROR_BAD_UNIT,
215 ERROR_FORMAT,
216 ERROR_BAD_ACTION,
217 ERROR_ENDFILE,
218 ERROR_BAD_US,
219 ERROR_READ_VALUE,
220 ERROR_READ_OVERFLOW,
221 ERROR_LAST /* Not a real error, the last error # + 1. */
222}
223error_codes;
224
225
226/* The filename and line number don't go inside the globals structure.
227 They are set by the rest of the program and must be linked to. */
228
229#define line prefix(line)
230extern unsigned line; /* Location of the current libray call (optional). */
231
232#define filename prefix(filename)
233extern char *filename;
234
235
236/* main.c */
237
238#define library_start prefix(library_start)
239void library_start (void);
240
241#define library_end prefix(library_end)
242void library_end (void);
243
244#define set_args prefix(set_args)
245void set_args (int, char **);
246
247#define get_args prefix(get_args)
248void get_args (int *, char ***);
249
250
251/* error.c */
252#define rtoa prefix(rtoa)
253char *rtoa (double f, int length, int oprec);
254
255#define itoa prefix(itoa)
256char *itoa (int64_t);
257
258#define xtoa prefix(xtoa)
259char *xtoa (uint64_t);
260
261#define os_error prefix(os_error)
262void os_error (const char *) __attribute__ ((noreturn));
263
264#define show_locus prefix(show_locus)
265void show_locus (void);
266
267#define runtime_error prefix(runtime_error)
268void runtime_error (const char *) __attribute__ ((noreturn));
269
270#define internal_error prefix(internal_error)
271void internal_error (const char *) __attribute__ ((noreturn));
272
273#define get_oserror prefix(get_oserror)
274const char *get_oserror (void);
275
276#define write_error prefix(write_error)
277void write_error (const char *);
278
279#define sys_exit prefix(sys_exit)
280void sys_exit (int) __attribute__ ((noreturn));
281
282#define st_printf prefix(st_printf)
283int st_printf (const char *, ...) __attribute__ ((format (printf, 1, 2)));
284
285#define st_sprintf prefix(st_sprintf)
286void st_sprintf (char *, const char *, ...) __attribute__ ((format (printf, 2, 3)));
287
288#define translate_error prefix(translate_error)
289const char *translate_error (int);
290
291#define generate_error prefix(generate_error)
292void generate_error (int, const char *);
293
294
295/* memory.c */
296
297#define memory_init prefix(memory_init)
298void memory_init (void);
299
300#define runtime_cleanup prefix(runtime_cleanup)
301void runtime_cleanup (void);
302
303#define get_mem prefix(get_mem)
304void *get_mem (size_t) __attribute__ ((malloc));
305
306#define free_mem prefix(free_mem)
307void free_mem (void *);
308
309#define internal_malloc_size prefix(internal_malloc_size)
310void *internal_malloc_size (size_t);
311
312#define internal_malloc prefix(internal_malloc)
313void *internal_malloc (GFC_INTEGER_4);
314
315#define internal_malloc64 prefix(internal_malloc64)
316void *internal_malloc64 (GFC_INTEGER_8);
317
318#define internal_free prefix(internal_free)
319void internal_free (void *);
320
321#define allocate prefix(allocate)
322void allocate (void **, GFC_INTEGER_4, GFC_INTEGER_4 *);
323
324#define allocate64 prefix(allocate64)
325void allocate64 (void **, GFC_INTEGER_8, GFC_INTEGER_4 *);
326
327#define deallocate prefix(deallocate)
328void deallocate (void **, GFC_INTEGER_4 *);
329
330
331/* environ.c */
332
333#define check_buffered prefix(check_buffered)
334int check_buffered (int);
335
336#define init_variables prefix(init_variables)
337void init_variables (void);
338
339#define show_variables prefix(show_variables)
340void show_variables (void);
341
342
343/* string.c */
344
345#define find_option prefix(find_option)
346int find_option (const char *, int, st_option *, const char *);
347
348#define fstrlen prefix(fstrlen)
349int fstrlen (const char *, int);
350
351#define fstrcpy prefix(fstrcpy)
352void fstrcpy (char *, int, const char *, int);
353
354#define cf_strcpy prefix(cf_strcpy)
355void cf_strcpy (char *, int, const char *);
356
357/* io.c */
358
359#define init_units prefix(init_units)
360void init_units (void);
361
362#define close_units prefix(close_units)
363void close_units (void);
364
365/* stop.c */
366#define stop_numeric prefix(stop_numeric)
367void stop_numeric (GFC_INTEGER_4);
368
369/* reshape_packed.c */
370#define reshape_packed prefix(reshape_packed)
371void reshape_packed (char *, index_type, const char *, index_type,
372 const char *, index_type);
373
374/* Repacking functions. */
375#define internal_pack prefix(internal_pack)
376void *internal_pack (gfc_array_char *);
377
378#define internal_unpack prefix(internal_unpack)
379void internal_unpack (gfc_array_char *, const void *);
380
381#define internal_pack_4 prefix(internal_pack_4)
382GFC_INTEGER_4 *internal_pack_4 (gfc_array_i4 *);
383
384#define internal_pack_8 prefix(internal_pack_8)
385GFC_INTEGER_8 *internal_pack_8 (gfc_array_i8 *);
386
387#define internal_unpack_4 prefix(internal_unpack_4)
388void internal_unpack_4 (gfc_array_i4 *, const GFC_INTEGER_4 *);
389
390#define internal_unpack_8 prefix(internal_unpack_8)
391void internal_unpack_8 (gfc_array_i8 *, const GFC_INTEGER_8 *);
392
393/* string_intrinsics.c */
394
395#define compare_string prefix(compare_string)
396GFC_INTEGER_4 compare_string (GFC_INTEGER_4, const char *,
397 GFC_INTEGER_4, const char *);
398
abdef811
BD
399/* random.c */
400
401#define random_seed prefix(random_seed)
402void random_seed (GFC_INTEGER_4 * size, const gfc_array_i4 * put,
403 const gfc_array_i4 * get);
404
6de9cd9a
DN
405#endif
406
This page took 0.092949 seconds and 5 git commands to generate.