* config/sh/linux-atomic.asm (ATOMIC_BOOL_COMPARE_AND_SWAP,
[official-gcc.git] / libgfortran / libgfortran.h
bloba2e200274f5bc2c15af48d6ea730ee0363352c8e
1 /* Common declarations for all of libgfortran.
2 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
3 Free Software Foundation, Inc.
4 Contributed by Paul Brook <paul@nowt.org>, and
5 Andy Vaught <andy@xena.eas.asu.edu>
7 This file is part of the GNU Fortran 95 runtime library (libgfortran).
9 Libgfortran is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3, or (at your option)
12 any later version.
14 Libgfortran is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 Under Section 7 of GPL version 3, you are granted additional
20 permissions described in the GCC Runtime Library Exception, version
21 3.1, as published by the Free Software Foundation.
23 You should have received a copy of the GNU General Public License and
24 a copy of the GCC Runtime Library Exception along with this program;
25 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
26 <http://www.gnu.org/licenses/>. */
28 #ifndef LIBGFOR_H
29 #define LIBGFOR_H
31 /* config.h MUST be first because it can affect system headers. */
32 #include "config.h"
34 #include <stdio.h>
35 #include <math.h>
36 #include <stddef.h>
37 #include <float.h>
38 #include <stdarg.h>
40 #if HAVE_COMPLEX_H
41 # include <complex.h>
42 #else
43 #define complex __complex__
44 #endif
46 #include "../gcc/fortran/libgfortran.h"
48 #include "c99_protos.h"
50 #if HAVE_IEEEFP_H
51 #include <ieeefp.h>
52 #endif
54 #include "gstdint.h"
56 #if HAVE_SYS_TYPES_H
57 #include <sys/types.h>
58 #endif
59 typedef off_t gfc_offset;
61 #ifndef NULL
62 #define NULL (void *) 0
63 #endif
65 #ifndef __GNUC__
66 #define __attribute__(x)
67 #define likely(x) (x)
68 #define unlikely(x) (x)
69 #else
70 #define likely(x) __builtin_expect(!!(x), 1)
71 #define unlikely(x) __builtin_expect(!!(x), 0)
72 #endif
75 /* We use intptr_t and uintptr_t, which may not be always defined in
76 system headers. */
78 #ifndef HAVE_INTPTR_T
79 #if __SIZEOF_POINTER__ == __SIZEOF_LONG__
80 #define intptr_t long
81 #elif __SIZEOF_POINTER__ == __SIZEOF_LONG_LONG__
82 #define intptr_t long long
83 #elif __SIZEOF_POINTER__ == __SIZEOF_INT__
84 #define intptr_t int
85 #elif __SIZEOF_POINTER__ == __SIZEOF_SHORT__
86 #define intptr_t short
87 #else
88 #error "Pointer type with unexpected size"
89 #endif
90 #endif
92 #ifndef HAVE_UINTPTR_T
93 #if __SIZEOF_POINTER__ == __SIZEOF_LONG__
94 #define uintptr_t unsigned long
95 #elif __SIZEOF_POINTER__ == __SIZEOF_LONG_LONG__
96 #define uintptr_t unsigned long long
97 #elif __SIZEOF_POINTER__ == __SIZEOF_INT__
98 #define uintptr_t unsigned int
99 #elif __SIZEOF_POINTER__ == __SIZEOF_SHORT__
100 #define uintptr_t unsigned short
101 #else
102 #error "Pointer type with unexpected size"
103 #endif
104 #endif
107 /* On mingw, work around the buggy Windows snprintf() by using the one
108 mingw provides, __mingw_snprintf(). We also provide a prototype for
109 __mingw_snprintf(), because the mingw headers currently don't have one. */
110 #if HAVE_MINGW_SNPRINTF
111 extern int __mingw_snprintf (char *, size_t, const char *, ...)
112 __attribute__ ((format (gnu_printf, 3, 4)));
113 #undef snprintf
114 #define snprintf __mingw_snprintf
115 #endif
118 /* For a library, a standard prefix is a requirement in order to partition
119 the namespace. IPREFIX is for symbols intended to be internal to the
120 library. */
121 #define PREFIX(x) _gfortran_ ## x
122 #define IPREFIX(x) _gfortrani_ ## x
124 /* Magic to rename a symbol at the compiler level. You continue to refer
125 to the symbol as OLD in the source, but it'll be named NEW in the asm. */
126 #define sym_rename(old, new) sym_rename1(old, __USER_LABEL_PREFIX__, new)
127 #define sym_rename1(old, ulp, new) sym_rename2(old, ulp, new)
128 #define sym_rename2(old, ulp, new) extern __typeof(old) old __asm__(#ulp #new)
130 /* There are several classifications of routines:
132 (1) Symbols used only within the library,
133 (2) Symbols to be exported from the library,
134 (3) Symbols to be exported from the library, but
135 also used inside the library.
137 By telling the compiler about these different classifications we can
138 tightly control the interface seen by the user, and get better code
139 from the compiler at the same time.
141 One of the following should be used immediately after the declaration
142 of each symbol:
144 internal_proto Marks a symbol used only within the library,
145 and adds IPREFIX to the assembly-level symbol
146 name. The later is important for maintaining
147 the namespace partition for the static library.
149 export_proto Marks a symbol to be exported, and adds PREFIX
150 to the assembly-level symbol name.
152 export_proto_np Marks a symbol to be exported without adding PREFIX.
154 iexport_proto Marks a function to be exported, but with the
155 understanding that it can be used inside as well.
157 iexport_data_proto Similarly, marks a data symbol to be exported.
158 Unfortunately, some systems can't play the hidden
159 symbol renaming trick on data symbols, thanks to
160 the horribleness of COPY relocations.
162 If iexport_proto or iexport_data_proto is used, you must also use
163 iexport or iexport_data after the *definition* of the symbol. */
165 #if defined(HAVE_ATTRIBUTE_VISIBILITY)
166 # define internal_proto(x) \
167 sym_rename(x, IPREFIX (x)) __attribute__((__visibility__("hidden")))
168 #else
169 # define internal_proto(x) sym_rename(x, IPREFIX(x))
170 #endif
172 #if defined(HAVE_ATTRIBUTE_VISIBILITY) && defined(HAVE_ATTRIBUTE_ALIAS)
173 # define export_proto(x) sym_rename(x, PREFIX(x))
174 # define export_proto_np(x) extern char swallow_semicolon
175 # define iexport_proto(x) internal_proto(x)
176 # define iexport(x) iexport1(x, IPREFIX(x))
177 # define iexport1(x,y) iexport2(x,y)
178 # define iexport2(x,y) \
179 extern __typeof(x) PREFIX(x) __attribute__((__alias__(#y)))
180 /* ??? We're not currently building a dll, and it's wrong to add dllexport
181 to objects going into a static library archive. */
182 #elif 0 && defined(HAVE_ATTRIBUTE_DLLEXPORT)
183 # define export_proto_np(x) extern __typeof(x) x __attribute__((dllexport))
184 # define export_proto(x) sym_rename(x, PREFIX(x)) __attribute__((dllexport))
185 # define iexport_proto(x) export_proto(x)
186 # define iexport(x) extern char swallow_semicolon
187 #else
188 # define export_proto(x) sym_rename(x, PREFIX(x))
189 # define export_proto_np(x) extern char swallow_semicolon
190 # define iexport_proto(x) export_proto(x)
191 # define iexport(x) extern char swallow_semicolon
192 #endif
194 /* TODO: detect the case when we *can* hide the symbol. */
195 #define iexport_data_proto(x) export_proto(x)
196 #define iexport_data(x) extern char swallow_semicolon
198 /* The only reliable way to get the offset of a field in a struct
199 in a system independent way is via this macro. */
200 #ifndef offsetof
201 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER)
202 #endif
204 /* The isfinite macro is only available with C99, but some non-C99
205 systems still provide fpclassify, and there is a `finite' function
206 in BSD.
208 Also, isfinite is broken on Cygwin.
210 When isfinite is not available, try to use one of the
211 alternatives, or bail out. */
213 #if defined(HAVE_BROKEN_ISFINITE) || defined(__CYGWIN__)
214 #undef isfinite
215 #endif
217 #if defined(HAVE_BROKEN_ISNAN)
218 #undef isnan
219 #endif
221 #if defined(HAVE_BROKEN_FPCLASSIFY)
222 #undef fpclassify
223 #endif
225 #if !defined(isfinite)
226 #if !defined(fpclassify)
227 #define isfinite(x) ((x) - (x) == 0)
228 #else
229 #define isfinite(x) (fpclassify(x) != FP_NAN && fpclassify(x) != FP_INFINITE)
230 #endif /* !defined(fpclassify) */
231 #endif /* !defined(isfinite) */
233 #if !defined(isnan)
234 #if !defined(fpclassify)
235 #define isnan(x) ((x) != (x))
236 #else
237 #define isnan(x) (fpclassify(x) == FP_NAN)
238 #endif /* !defined(fpclassify) */
239 #endif /* !defined(isfinite) */
241 /* TODO: find the C99 version of these an move into above ifdef. */
242 #define REALPART(z) (__real__(z))
243 #define IMAGPART(z) (__imag__(z))
244 #define COMPLEX_ASSIGN(z_, r_, i_) {__real__(z_) = (r_); __imag__(z_) = (i_);}
246 #include "kinds.h"
248 /* Define the type used for the current record number for large file I/O.
249 The size must be consistent with the size defined on the compiler side. */
250 #ifdef HAVE_GFC_INTEGER_8
251 typedef GFC_INTEGER_8 GFC_IO_INT;
252 #else
253 #ifdef HAVE_GFC_INTEGER_4
254 typedef GFC_INTEGER_4 GFC_IO_INT;
255 #else
256 #error "GFC_INTEGER_4 should be available for the library to compile".
257 #endif
258 #endif
260 /* The following two definitions must be consistent with the types used
261 by the compiler. */
262 /* The type used of array indices, amongst other things. */
263 typedef ssize_t index_type;
265 /* The type used for the lengths of character variables. */
266 typedef GFC_INTEGER_4 gfc_charlen_type;
268 /* Definitions of CHARACTER data types:
269 - CHARACTER(KIND=1) corresponds to the C char type,
270 - CHARACTER(KIND=4) corresponds to an unsigned 32-bit integer. */
271 typedef GFC_UINTEGER_4 gfc_char4_t;
273 /* Byte size of character kinds. For the kinds currently supported, it's
274 simply equal to the kind parameter itself. */
275 #define GFC_SIZE_OF_CHAR_KIND(kind) (kind)
277 /* This will be 0 on little-endian machines and one on big-endian machines. */
278 extern int big_endian;
279 internal_proto(big_endian);
281 #define GFOR_POINTER_TO_L1(p, kind) \
282 (big_endian * (kind - 1) + (GFC_LOGICAL_1 *)(p))
284 #define GFC_INTEGER_1_HUGE \
285 (GFC_INTEGER_1)((((GFC_UINTEGER_1)1) << 7) - 1)
286 #define GFC_INTEGER_2_HUGE \
287 (GFC_INTEGER_2)((((GFC_UINTEGER_2)1) << 15) - 1)
288 #define GFC_INTEGER_4_HUGE \
289 (GFC_INTEGER_4)((((GFC_UINTEGER_4)1) << 31) - 1)
290 #define GFC_INTEGER_8_HUGE \
291 (GFC_INTEGER_8)((((GFC_UINTEGER_8)1) << 63) - 1)
292 #ifdef HAVE_GFC_INTEGER_16
293 #define GFC_INTEGER_16_HUGE \
294 (GFC_INTEGER_16)((((GFC_UINTEGER_16)1) << 127) - 1)
295 #endif
297 /* M{IN,AX}{LOC,VAL} need also infinities and NaNs if supported. */
299 #ifdef __FLT_HAS_INFINITY__
300 # define GFC_REAL_4_INFINITY __builtin_inff ()
301 #endif
302 #ifdef __DBL_HAS_INFINITY__
303 # define GFC_REAL_8_INFINITY __builtin_inf ()
304 #endif
305 #ifdef __LDBL_HAS_INFINITY__
306 # ifdef HAVE_GFC_REAL_10
307 # define GFC_REAL_10_INFINITY __builtin_infl ()
308 # endif
309 # ifdef HAVE_GFC_REAL_16
310 # define GFC_REAL_16_INFINITY __builtin_infl ()
311 # endif
312 #endif
313 #ifdef __FLT_HAS_QUIET_NAN__
314 # define GFC_REAL_4_QUIET_NAN __builtin_nanf ("")
315 #endif
316 #ifdef __DBL_HAS_QUIET_NAN__
317 # define GFC_REAL_8_QUIET_NAN __builtin_nan ("")
318 #endif
319 #ifdef __LDBL_HAS_QUIET_NAN__
320 # ifdef HAVE_GFC_REAL_10
321 # define GFC_REAL_10_QUIET_NAN __builtin_nanl ("")
322 # endif
323 # ifdef HAVE_GFC_REAL_16
324 # define GFC_REAL_16_QUIET_NAN __builtin_nanl ("")
325 # endif
326 #endif
328 typedef struct descriptor_dimension
330 index_type _stride;
331 index_type _lbound;
332 index_type _ubound;
335 descriptor_dimension;
337 #define GFC_ARRAY_DESCRIPTOR(r, type) \
338 struct {\
339 type *data;\
340 size_t offset;\
341 index_type dtype;\
342 descriptor_dimension dim[r];\
345 /* Commonly used array descriptor types. */
346 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, void) gfc_array_void;
347 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, char) gfc_array_char;
348 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_1) gfc_array_i1;
349 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_2) gfc_array_i2;
350 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_4) gfc_array_i4;
351 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_8) gfc_array_i8;
352 #ifdef HAVE_GFC_INTEGER_16
353 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_16) gfc_array_i16;
354 #endif
355 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_4) gfc_array_r4;
356 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_8) gfc_array_r8;
357 #ifdef HAVE_GFC_REAL_10
358 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_10) gfc_array_r10;
359 #endif
360 #ifdef HAVE_GFC_REAL_16
361 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_16) gfc_array_r16;
362 #endif
363 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_4) gfc_array_c4;
364 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_8) gfc_array_c8;
365 #ifdef HAVE_GFC_COMPLEX_10
366 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_10) gfc_array_c10;
367 #endif
368 #ifdef HAVE_GFC_COMPLEX_16
369 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_16) gfc_array_c16;
370 #endif
371 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_1) gfc_array_l1;
372 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_2) gfc_array_l2;
373 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_4) gfc_array_l4;
374 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_8) gfc_array_l8;
375 #ifdef HAVE_GFC_LOGICAL_16
376 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_16) gfc_array_l16;
377 #endif
380 #define GFC_DESCRIPTOR_RANK(desc) ((desc)->dtype & GFC_DTYPE_RANK_MASK)
381 #define GFC_DESCRIPTOR_TYPE(desc) (((desc)->dtype & GFC_DTYPE_TYPE_MASK) \
382 >> GFC_DTYPE_TYPE_SHIFT)
383 #define GFC_DESCRIPTOR_SIZE(desc) ((desc)->dtype >> GFC_DTYPE_SIZE_SHIFT)
384 #define GFC_DESCRIPTOR_DATA(desc) ((desc)->data)
385 #define GFC_DESCRIPTOR_DTYPE(desc) ((desc)->dtype)
387 #define GFC_DIMENSION_LBOUND(dim) ((dim)._lbound)
388 #define GFC_DIMENSION_UBOUND(dim) ((dim)._ubound)
389 #define GFC_DIMENSION_STRIDE(dim) ((dim)._stride)
390 #define GFC_DIMENSION_EXTENT(dim) ((dim)._ubound + 1 - (dim)._lbound)
391 #define GFC_DIMENSION_SET(dim,lb,ub,str) \
392 do \
394 (dim)._lbound = lb; \
395 (dim)._ubound = ub; \
396 (dim)._stride = str; \
397 } while (0)
400 #define GFC_DESCRIPTOR_LBOUND(desc,i) ((desc)->dim[i]._lbound)
401 #define GFC_DESCRIPTOR_UBOUND(desc,i) ((desc)->dim[i]._ubound)
402 #define GFC_DESCRIPTOR_EXTENT(desc,i) ((desc)->dim[i]._ubound + 1 \
403 - (desc)->dim[i]._lbound)
404 #define GFC_DESCRIPTOR_EXTENT_BYTES(desc,i) \
405 (GFC_DESCRIPTOR_EXTENT(desc,i) * GFC_DESCRIPTOR_SIZE(desc))
407 #define GFC_DESCRIPTOR_STRIDE(desc,i) ((desc)->dim[i]._stride)
408 #define GFC_DESCRIPTOR_STRIDE_BYTES(desc,i) \
409 (GFC_DESCRIPTOR_STRIDE(desc,i) * GFC_DESCRIPTOR_SIZE(desc))
411 /* Macros to get both the size and the type with a single masking operation */
413 #define GFC_DTYPE_SIZE_MASK \
414 ((~((index_type) 0) >> GFC_DTYPE_SIZE_SHIFT) << GFC_DTYPE_SIZE_SHIFT)
415 #define GFC_DTYPE_TYPE_SIZE_MASK (GFC_DTYPE_SIZE_MASK | GFC_DTYPE_TYPE_MASK)
417 #define GFC_DTYPE_TYPE_SIZE(desc) ((desc)->dtype & GFC_DTYPE_TYPE_SIZE_MASK)
419 #define GFC_DTYPE_INTEGER_1 ((GFC_DTYPE_INTEGER << GFC_DTYPE_TYPE_SHIFT) \
420 | (sizeof(GFC_INTEGER_1) << GFC_DTYPE_SIZE_SHIFT))
421 #define GFC_DTYPE_INTEGER_2 ((GFC_DTYPE_INTEGER << GFC_DTYPE_TYPE_SHIFT) \
422 | (sizeof(GFC_INTEGER_2) << GFC_DTYPE_SIZE_SHIFT))
423 #define GFC_DTYPE_INTEGER_4 ((GFC_DTYPE_INTEGER << GFC_DTYPE_TYPE_SHIFT) \
424 | (sizeof(GFC_INTEGER_4) << GFC_DTYPE_SIZE_SHIFT))
425 #define GFC_DTYPE_INTEGER_8 ((GFC_DTYPE_INTEGER << GFC_DTYPE_TYPE_SHIFT) \
426 | (sizeof(GFC_INTEGER_8) << GFC_DTYPE_SIZE_SHIFT))
427 #ifdef HAVE_GFC_INTEGER_16
428 #define GFC_DTYPE_INTEGER_16 ((GFC_DTYPE_INTEGER << GFC_DTYPE_TYPE_SHIFT) \
429 | (sizeof(GFC_INTEGER_16) << GFC_DTYPE_SIZE_SHIFT))
430 #endif
432 #define GFC_DTYPE_LOGICAL_1 ((GFC_DTYPE_LOGICAL << GFC_DTYPE_TYPE_SHIFT) \
433 | (sizeof(GFC_LOGICAL_1) << GFC_DTYPE_SIZE_SHIFT))
434 #define GFC_DTYPE_LOGICAL_2 ((GFC_DTYPE_LOGICAL << GFC_DTYPE_TYPE_SHIFT) \
435 | (sizeof(GFC_LOGICAL_2) << GFC_DTYPE_SIZE_SHIFT))
436 #define GFC_DTYPE_LOGICAL_4 ((GFC_DTYPE_LOGICAL << GFC_DTYPE_TYPE_SHIFT) \
437 | (sizeof(GFC_LOGICAL_4) << GFC_DTYPE_SIZE_SHIFT))
438 #define GFC_DTYPE_LOGICAL_8 ((GFC_DTYPE_LOGICAL << GFC_DTYPE_TYPE_SHIFT) \
439 | (sizeof(GFC_LOGICAL_8) << GFC_DTYPE_SIZE_SHIFT))
440 #ifdef HAVE_GFC_LOGICAL_16
441 #define GFC_DTYPE_LOGICAL_16 ((GFC_DTYPE_LOGICAL << GFC_DTYPE_TYPE_SHIFT) \
442 | (sizeof(GFC_LOGICAL_16) << GFC_DTYPE_SIZE_SHIFT))
443 #endif
445 #define GFC_DTYPE_REAL_4 ((GFC_DTYPE_REAL << GFC_DTYPE_TYPE_SHIFT) \
446 | (sizeof(GFC_REAL_4) << GFC_DTYPE_SIZE_SHIFT))
447 #define GFC_DTYPE_REAL_8 ((GFC_DTYPE_REAL << GFC_DTYPE_TYPE_SHIFT) \
448 | (sizeof(GFC_REAL_8) << GFC_DTYPE_SIZE_SHIFT))
449 #ifdef HAVE_GFC_REAL_10
450 #define GFC_DTYPE_REAL_10 ((GFC_DTYPE_REAL << GFC_DTYPE_TYPE_SHIFT) \
451 | (sizeof(GFC_REAL_10) << GFC_DTYPE_SIZE_SHIFT))
452 #endif
453 #ifdef HAVE_GFC_REAL_16
454 #define GFC_DTYPE_REAL_16 ((GFC_DTYPE_REAL << GFC_DTYPE_TYPE_SHIFT) \
455 | (sizeof(GFC_REAL_16) << GFC_DTYPE_SIZE_SHIFT))
456 #endif
458 #define GFC_DTYPE_COMPLEX_4 ((GFC_DTYPE_COMPLEX << GFC_DTYPE_TYPE_SHIFT) \
459 | (sizeof(GFC_COMPLEX_4) << GFC_DTYPE_SIZE_SHIFT))
460 #define GFC_DTYPE_COMPLEX_8 ((GFC_DTYPE_COMPLEX << GFC_DTYPE_TYPE_SHIFT) \
461 | (sizeof(GFC_COMPLEX_8) << GFC_DTYPE_SIZE_SHIFT))
462 #ifdef HAVE_GFC_COMPLEX_10
463 #define GFC_DTYPE_COMPLEX_10 ((GFC_DTYPE_COMPLEX << GFC_DTYPE_TYPE_SHIFT) \
464 | (sizeof(GFC_COMPLEX_10) << GFC_DTYPE_SIZE_SHIFT))
465 #endif
466 #ifdef HAVE_GFC_COMPLEX_16
467 #define GFC_DTYPE_COMPLEX_16 ((GFC_DTYPE_COMPLEX << GFC_DTYPE_TYPE_SHIFT) \
468 | (sizeof(GFC_COMPLEX_16) << GFC_DTYPE_SIZE_SHIFT))
469 #endif
471 #define GFC_DTYPE_DERIVED_1 ((GFC_DTYPE_DERIVED << GFC_DTYPE_TYPE_SHIFT) \
472 | (sizeof(GFC_INTEGER_1) << GFC_DTYPE_SIZE_SHIFT))
473 #define GFC_DTYPE_DERIVED_2 ((GFC_DTYPE_DERIVED << GFC_DTYPE_TYPE_SHIFT) \
474 | (sizeof(GFC_INTEGER_2) << GFC_DTYPE_SIZE_SHIFT))
475 #define GFC_DTYPE_DERIVED_4 ((GFC_DTYPE_DERIVED << GFC_DTYPE_TYPE_SHIFT) \
476 | (sizeof(GFC_INTEGER_4) << GFC_DTYPE_SIZE_SHIFT))
477 #define GFC_DTYPE_DERIVED_8 ((GFC_DTYPE_DERIVED << GFC_DTYPE_TYPE_SHIFT) \
478 | (sizeof(GFC_INTEGER_8) << GFC_DTYPE_SIZE_SHIFT))
479 #ifdef HAVE_GFC_INTEGER_16
480 #define GFC_DTYPE_DERIVED_16 ((GFC_DTYPE_DERIVED << GFC_DTYPE_TYPE_SHIFT) \
481 | (sizeof(GFC_INTEGER_16) << GFC_DTYPE_SIZE_SHIFT))
482 #endif
484 /* Macros to determine the alignment of pointers. */
486 #define GFC_UNALIGNED_2(x) (((uintptr_t)(x)) & \
487 (__alignof__(GFC_INTEGER_2) - 1))
488 #define GFC_UNALIGNED_4(x) (((uintptr_t)(x)) & \
489 (__alignof__(GFC_INTEGER_4) - 1))
490 #define GFC_UNALIGNED_8(x) (((uintptr_t)(x)) & \
491 (__alignof__(GFC_INTEGER_8) - 1))
492 #ifdef HAVE_GFC_INTEGER_16
493 #define GFC_UNALIGNED_16(x) (((uintptr_t)(x)) & \
494 (__alignof__(GFC_INTEGER_16) - 1))
495 #endif
497 #define GFC_UNALIGNED_C4(x) (((uintptr_t)(x)) & \
498 (__alignof__(GFC_COMPLEX_4) - 1))
500 #define GFC_UNALIGNED_C8(x) (((uintptr_t)(x)) & \
501 (__alignof__(GFC_COMPLEX_8) - 1))
503 /* Runtime library include. */
504 #define stringize(x) expand_macro(x)
505 #define expand_macro(x) # x
507 /* Runtime options structure. */
509 typedef struct
511 int stdin_unit, stdout_unit, stderr_unit, optional_plus;
512 int locus;
514 int separator_len;
515 const char *separator;
517 int use_stderr, all_unbuffered, unbuffered_preconnected, default_recl;
518 int fpe, dump_core, backtrace;
520 options_t;
522 extern options_t options;
523 internal_proto(options);
525 extern void handler (int);
526 internal_proto(handler);
529 /* Compile-time options that will influence the library. */
531 typedef struct
533 int warn_std;
534 int allow_std;
535 int pedantic;
536 int convert;
537 int dump_core;
538 int backtrace;
539 int sign_zero;
540 size_t record_marker;
541 int max_subrecord_length;
542 int bounds_check;
543 int range_check;
545 compile_options_t;
547 extern compile_options_t compile_options;
548 internal_proto(compile_options);
550 extern void init_compile_options (void);
551 internal_proto(init_compile_options);
553 #define GFC_MAX_SUBRECORD_LENGTH 2147483639 /* 2**31 - 9 */
555 /* Structure for statement options. */
557 typedef struct
559 const char *name;
560 int value;
562 st_option;
565 /* This is returned by notification_std to know if, given the flags
566 that were given (-std=, -pedantic) we should issue an error, a warning
567 or nothing. */
568 typedef enum
569 { SILENT, WARNING, ERROR }
570 notification;
572 /* This is returned by notify_std and several io functions. */
573 typedef enum
574 { SUCCESS = 1, FAILURE }
575 try;
577 /* The filename and line number don't go inside the globals structure.
578 They are set by the rest of the program and must be linked to. */
580 /* Location of the current library call (optional). */
581 extern unsigned line;
582 iexport_data_proto(line);
584 extern char *filename;
585 iexport_data_proto(filename);
587 /* Avoid conflicting prototypes of alloca() in system headers by using
588 GCC's builtin alloca(). */
589 #define gfc_alloca(x) __builtin_alloca(x)
592 /* Directory for creating temporary files. Only used when none of the
593 following environment variables exist: GFORTRAN_TMPDIR, TMP and TEMP. */
594 #define DEFAULT_TEMPDIR "/tmp"
596 /* The default value of record length for preconnected units is defined
597 here. This value can be overriden by an environment variable.
598 Default value is 1 Gb. */
599 #define DEFAULT_RECL 1073741824
602 #define CHARACTER2(name) \
603 gfc_charlen_type name ## _len; \
604 char * name
606 typedef struct st_parameter_common
608 GFC_INTEGER_4 flags;
609 GFC_INTEGER_4 unit;
610 const char *filename;
611 GFC_INTEGER_4 line;
612 CHARACTER2 (iomsg);
613 GFC_INTEGER_4 *iostat;
615 st_parameter_common;
617 #undef CHARACTER2
619 #define IOPARM_LIBRETURN_MASK (3 << 0)
620 #define IOPARM_LIBRETURN_OK (0 << 0)
621 #define IOPARM_LIBRETURN_ERROR (1 << 0)
622 #define IOPARM_LIBRETURN_END (2 << 0)
623 #define IOPARM_LIBRETURN_EOR (3 << 0)
624 #define IOPARM_ERR (1 << 2)
625 #define IOPARM_END (1 << 3)
626 #define IOPARM_EOR (1 << 4)
627 #define IOPARM_HAS_IOSTAT (1 << 5)
628 #define IOPARM_HAS_IOMSG (1 << 6)
630 #define IOPARM_COMMON_MASK ((1 << 7) - 1)
632 #define IOPARM_OPEN_HAS_RECL_IN (1 << 7)
633 #define IOPARM_OPEN_HAS_FILE (1 << 8)
634 #define IOPARM_OPEN_HAS_STATUS (1 << 9)
635 #define IOPARM_OPEN_HAS_ACCESS (1 << 10)
636 #define IOPARM_OPEN_HAS_FORM (1 << 11)
637 #define IOPARM_OPEN_HAS_BLANK (1 << 12)
638 #define IOPARM_OPEN_HAS_POSITION (1 << 13)
639 #define IOPARM_OPEN_HAS_ACTION (1 << 14)
640 #define IOPARM_OPEN_HAS_DELIM (1 << 15)
641 #define IOPARM_OPEN_HAS_PAD (1 << 16)
642 #define IOPARM_OPEN_HAS_CONVERT (1 << 17)
643 #define IOPARM_OPEN_HAS_DECIMAL (1 << 18)
644 #define IOPARM_OPEN_HAS_ENCODING (1 << 19)
645 #define IOPARM_OPEN_HAS_ROUND (1 << 20)
646 #define IOPARM_OPEN_HAS_SIGN (1 << 21)
647 #define IOPARM_OPEN_HAS_ASYNCHRONOUS (1 << 22)
648 #define IOPARM_OPEN_HAS_NEWUNIT (1 << 23)
650 /* library start function and end macro. These can be expanded if needed
651 in the future. cmp is st_parameter_common *cmp */
653 extern void library_start (st_parameter_common *);
654 internal_proto(library_start);
656 #define library_end()
658 /* main.c */
660 extern void stupid_function_name_for_static_linking (void);
661 internal_proto(stupid_function_name_for_static_linking);
663 extern void set_args (int, char **);
664 iexport_proto(set_args);
666 extern void get_args (int *, char ***);
667 internal_proto(get_args);
669 extern void store_exe_path (const char *);
670 export_proto(store_exe_path);
672 extern char * full_exe_path (void);
673 internal_proto(full_exe_path);
675 /* backtrace.c */
677 extern void show_backtrace (void);
678 internal_proto(show_backtrace);
680 /* error.c */
682 #define GFC_ITOA_BUF_SIZE (sizeof (GFC_INTEGER_LARGEST) * 3 + 2)
683 #define GFC_XTOA_BUF_SIZE (sizeof (GFC_UINTEGER_LARGEST) * 2 + 1)
684 #define GFC_OTOA_BUF_SIZE (sizeof (GFC_INTEGER_LARGEST) * 3 + 1)
685 #define GFC_BTOA_BUF_SIZE (sizeof (GFC_INTEGER_LARGEST) * 8 + 1)
687 extern void sys_exit (int) __attribute__ ((noreturn));
688 internal_proto(sys_exit);
690 extern const char *gfc_xtoa (GFC_UINTEGER_LARGEST, char *, size_t);
691 internal_proto(gfc_xtoa);
693 extern void os_error (const char *) __attribute__ ((noreturn));
694 iexport_proto(os_error);
696 extern void show_locus (st_parameter_common *);
697 internal_proto(show_locus);
699 extern void runtime_error (const char *, ...)
700 __attribute__ ((noreturn, format (printf, 1, 2)));
701 iexport_proto(runtime_error);
703 extern void runtime_error_at (const char *, const char *, ...)
704 __attribute__ ((noreturn, format (printf, 2, 3)));
705 iexport_proto(runtime_error_at);
707 extern void runtime_warning_at (const char *, const char *, ...)
708 __attribute__ ((format (printf, 2, 3)));
709 iexport_proto(runtime_warning_at);
711 extern void internal_error (st_parameter_common *, const char *)
712 __attribute__ ((noreturn));
713 internal_proto(internal_error);
715 extern const char *get_oserror (void);
716 internal_proto(get_oserror);
718 extern const char *translate_error (int);
719 internal_proto(translate_error);
721 extern void generate_error (st_parameter_common *, int, const char *);
722 iexport_proto(generate_error);
724 extern try notify_std (st_parameter_common *, int, const char *);
725 internal_proto(notify_std);
727 extern notification notification_std(int);
728 internal_proto(notification_std);
730 /* fpu.c */
732 extern void set_fpu (void);
733 internal_proto(set_fpu);
735 /* memory.c */
737 extern void *get_mem (size_t) __attribute__ ((malloc));
738 internal_proto(get_mem);
740 extern void free_mem (void *);
741 internal_proto(free_mem);
743 extern void *internal_malloc_size (size_t) __attribute__ ((malloc));
744 internal_proto(internal_malloc_size);
746 /* environ.c */
748 extern int check_buffered (int);
749 internal_proto(check_buffered);
751 extern void init_variables (void);
752 internal_proto(init_variables);
754 extern void show_variables (void);
755 internal_proto(show_variables);
757 unit_convert get_unformatted_convert (int);
758 internal_proto(get_unformatted_convert);
760 /* string.c */
762 extern int find_option (st_parameter_common *, const char *, gfc_charlen_type,
763 const st_option *, const char *);
764 internal_proto(find_option);
766 extern gfc_charlen_type fstrlen (const char *, gfc_charlen_type);
767 internal_proto(fstrlen);
769 extern gfc_charlen_type fstrcpy (char *, gfc_charlen_type, const char *, gfc_charlen_type);
770 internal_proto(fstrcpy);
772 extern gfc_charlen_type cf_strcpy (char *, gfc_charlen_type, const char *);
773 internal_proto(cf_strcpy);
775 /* io/intrinsics.c */
777 extern void flush_all_units (void);
778 internal_proto(flush_all_units);
780 /* io.c */
782 extern void init_units (void);
783 internal_proto(init_units);
785 extern void close_units (void);
786 internal_proto(close_units);
788 extern int unit_to_fd (int);
789 internal_proto(unit_to_fd);
791 extern int st_printf (const char *, ...)
792 __attribute__ ((format (printf, 1, 2)));
793 internal_proto(st_printf);
795 extern int st_vprintf (const char *, va_list);
796 internal_proto(st_vprintf);
798 extern char * filename_from_unit (int);
799 internal_proto(filename_from_unit);
801 /* stop.c */
803 extern void stop_numeric (GFC_INTEGER_4) __attribute__ ((noreturn));
804 iexport_proto(stop_numeric);
806 /* reshape_packed.c */
808 extern void reshape_packed (char *, index_type, const char *, index_type,
809 const char *, index_type);
810 internal_proto(reshape_packed);
812 /* Repacking functions. These are called internally by internal_pack
813 and internal_unpack. */
815 GFC_INTEGER_1 *internal_pack_1 (gfc_array_i1 *);
816 internal_proto(internal_pack_1);
818 GFC_INTEGER_2 *internal_pack_2 (gfc_array_i2 *);
819 internal_proto(internal_pack_2);
821 GFC_INTEGER_4 *internal_pack_4 (gfc_array_i4 *);
822 internal_proto(internal_pack_4);
824 GFC_INTEGER_8 *internal_pack_8 (gfc_array_i8 *);
825 internal_proto(internal_pack_8);
827 #if defined HAVE_GFC_INTEGER_16
828 GFC_INTEGER_16 *internal_pack_16 (gfc_array_i16 *);
829 internal_proto(internal_pack_16);
830 #endif
832 GFC_REAL_4 *internal_pack_r4 (gfc_array_r4 *);
833 internal_proto(internal_pack_r4);
835 GFC_REAL_8 *internal_pack_r8 (gfc_array_r8 *);
836 internal_proto(internal_pack_r8);
838 #if defined HAVE_GFC_REAL_10
839 GFC_REAL_10 *internal_pack_r10 (gfc_array_r10 *);
840 internal_proto(internal_pack_r10);
841 #endif
843 #if defined HAVE_GFC_REAL_16
844 GFC_REAL_16 *internal_pack_r16 (gfc_array_r16 *);
845 internal_proto(internal_pack_r16);
846 #endif
848 GFC_COMPLEX_4 *internal_pack_c4 (gfc_array_c4 *);
849 internal_proto(internal_pack_c4);
851 GFC_COMPLEX_8 *internal_pack_c8 (gfc_array_c8 *);
852 internal_proto(internal_pack_c8);
854 #if defined HAVE_GFC_COMPLEX_10
855 GFC_COMPLEX_10 *internal_pack_c10 (gfc_array_c10 *);
856 internal_proto(internal_pack_c10);
857 #endif
859 #if defined HAVE_GFC_COMPLEX_16
860 GFC_COMPLEX_16 *internal_pack_c16 (gfc_array_c16 *);
861 internal_proto(internal_pack_c16);
862 #endif
864 extern void internal_unpack_1 (gfc_array_i1 *, const GFC_INTEGER_1 *);
865 internal_proto(internal_unpack_1);
867 extern void internal_unpack_2 (gfc_array_i2 *, const GFC_INTEGER_2 *);
868 internal_proto(internal_unpack_2);
870 extern void internal_unpack_4 (gfc_array_i4 *, const GFC_INTEGER_4 *);
871 internal_proto(internal_unpack_4);
873 extern void internal_unpack_8 (gfc_array_i8 *, const GFC_INTEGER_8 *);
874 internal_proto(internal_unpack_8);
876 #if defined HAVE_GFC_INTEGER_16
877 extern void internal_unpack_16 (gfc_array_i16 *, const GFC_INTEGER_16 *);
878 internal_proto(internal_unpack_16);
879 #endif
881 extern void internal_unpack_r4 (gfc_array_r4 *, const GFC_REAL_4 *);
882 internal_proto(internal_unpack_r4);
884 extern void internal_unpack_r8 (gfc_array_r8 *, const GFC_REAL_8 *);
885 internal_proto(internal_unpack_r8);
887 #if defined HAVE_GFC_REAL_10
888 extern void internal_unpack_r10 (gfc_array_r10 *, const GFC_REAL_10 *);
889 internal_proto(internal_unpack_r10);
890 #endif
892 #if defined HAVE_GFC_REAL_16
893 extern void internal_unpack_r16 (gfc_array_r16 *, const GFC_REAL_16 *);
894 internal_proto(internal_unpack_r16);
895 #endif
897 extern void internal_unpack_c4 (gfc_array_c4 *, const GFC_COMPLEX_4 *);
898 internal_proto(internal_unpack_c4);
900 extern void internal_unpack_c8 (gfc_array_c8 *, const GFC_COMPLEX_8 *);
901 internal_proto(internal_unpack_c8);
903 #if defined HAVE_GFC_COMPLEX_10
904 extern void internal_unpack_c10 (gfc_array_c10 *, const GFC_COMPLEX_10 *);
905 internal_proto(internal_unpack_c10);
906 #endif
908 #if defined HAVE_GFC_COMPLEX_16
909 extern void internal_unpack_c16 (gfc_array_c16 *, const GFC_COMPLEX_16 *);
910 internal_proto(internal_unpack_c16);
911 #endif
913 /* Internal auxiliary functions for the pack intrinsic. */
915 extern void pack_i1 (gfc_array_i1 *, const gfc_array_i1 *,
916 const gfc_array_l1 *, const gfc_array_i1 *);
917 internal_proto(pack_i1);
919 extern void pack_i2 (gfc_array_i2 *, const gfc_array_i2 *,
920 const gfc_array_l1 *, const gfc_array_i2 *);
921 internal_proto(pack_i2);
923 extern void pack_i4 (gfc_array_i4 *, const gfc_array_i4 *,
924 const gfc_array_l1 *, const gfc_array_i4 *);
925 internal_proto(pack_i4);
927 extern void pack_i8 (gfc_array_i8 *, const gfc_array_i8 *,
928 const gfc_array_l1 *, const gfc_array_i8 *);
929 internal_proto(pack_i8);
931 #ifdef HAVE_GFC_INTEGER_16
932 extern void pack_i16 (gfc_array_i16 *, const gfc_array_i16 *,
933 const gfc_array_l1 *, const gfc_array_i16 *);
934 internal_proto(pack_i16);
935 #endif
937 extern void pack_r4 (gfc_array_r4 *, const gfc_array_r4 *,
938 const gfc_array_l1 *, const gfc_array_r4 *);
939 internal_proto(pack_r4);
941 extern void pack_r8 (gfc_array_r8 *, const gfc_array_r8 *,
942 const gfc_array_l1 *, const gfc_array_r8 *);
943 internal_proto(pack_r8);
945 #ifdef HAVE_GFC_REAL_10
946 extern void pack_r10 (gfc_array_r10 *, const gfc_array_r10 *,
947 const gfc_array_l1 *, const gfc_array_r10 *);
948 internal_proto(pack_r10);
949 #endif
951 #ifdef HAVE_GFC_REAL_16
952 extern void pack_r16 (gfc_array_r16 *, const gfc_array_r16 *,
953 const gfc_array_l1 *, const gfc_array_r16 *);
954 internal_proto(pack_r16);
955 #endif
957 extern void pack_c4 (gfc_array_c4 *, const gfc_array_c4 *,
958 const gfc_array_l1 *, const gfc_array_c4 *);
959 internal_proto(pack_c4);
961 extern void pack_c8 (gfc_array_c8 *, const gfc_array_c8 *,
962 const gfc_array_l1 *, const gfc_array_c8 *);
963 internal_proto(pack_c8);
965 #ifdef HAVE_GFC_REAL_10
966 extern void pack_c10 (gfc_array_c10 *, const gfc_array_c10 *,
967 const gfc_array_l1 *, const gfc_array_c10 *);
968 internal_proto(pack_c10);
969 #endif
971 #ifdef HAVE_GFC_REAL_16
972 extern void pack_c16 (gfc_array_c16 *, const gfc_array_c16 *,
973 const gfc_array_l1 *, const gfc_array_c16 *);
974 internal_proto(pack_c16);
975 #endif
977 /* Internal auxiliary functions for the unpack intrinsic. */
979 extern void unpack0_i1 (gfc_array_i1 *, const gfc_array_i1 *,
980 const gfc_array_l1 *, const GFC_INTEGER_1 *);
981 internal_proto(unpack0_i1);
983 extern void unpack0_i2 (gfc_array_i2 *, const gfc_array_i2 *,
984 const gfc_array_l1 *, const GFC_INTEGER_2 *);
985 internal_proto(unpack0_i2);
987 extern void unpack0_i4 (gfc_array_i4 *, const gfc_array_i4 *,
988 const gfc_array_l1 *, const GFC_INTEGER_4 *);
989 internal_proto(unpack0_i4);
991 extern void unpack0_i8 (gfc_array_i8 *, const gfc_array_i8 *,
992 const gfc_array_l1 *, const GFC_INTEGER_8 *);
993 internal_proto(unpack0_i8);
995 #ifdef HAVE_GFC_INTEGER_16
997 extern void unpack0_i16 (gfc_array_i16 *, const gfc_array_i16 *,
998 const gfc_array_l1 *, const GFC_INTEGER_16 *);
999 internal_proto(unpack0_i16);
1001 #endif
1003 extern void unpack0_r4 (gfc_array_r4 *, const gfc_array_r4 *,
1004 const gfc_array_l1 *, const GFC_REAL_4 *);
1005 internal_proto(unpack0_r4);
1007 extern void unpack0_r8 (gfc_array_r8 *, const gfc_array_r8 *,
1008 const gfc_array_l1 *, const GFC_REAL_8 *);
1009 internal_proto(unpack0_r8);
1011 #ifdef HAVE_GFC_REAL_10
1013 extern void unpack0_r10 (gfc_array_r10 *, const gfc_array_r10 *,
1014 const gfc_array_l1 *, const GFC_REAL_10 *);
1015 internal_proto(unpack0_r10);
1017 #endif
1019 #ifdef HAVE_GFC_REAL_16
1021 extern void unpack0_r16 (gfc_array_r16 *, const gfc_array_r16 *,
1022 const gfc_array_l1 *, const GFC_REAL_16 *);
1023 internal_proto(unpack0_r16);
1025 #endif
1027 extern void unpack0_c4 (gfc_array_c4 *, const gfc_array_c4 *,
1028 const gfc_array_l1 *, const GFC_COMPLEX_4 *);
1029 internal_proto(unpack0_c4);
1031 extern void unpack0_c8 (gfc_array_c8 *, const gfc_array_c8 *,
1032 const gfc_array_l1 *, const GFC_COMPLEX_8 *);
1033 internal_proto(unpack0_c8);
1035 #ifdef HAVE_GFC_COMPLEX_10
1037 extern void unpack0_c10 (gfc_array_c10 *, const gfc_array_c10 *,
1038 const gfc_array_l1 *mask, const GFC_COMPLEX_10 *);
1039 internal_proto(unpack0_c10);
1041 #endif
1043 #ifdef HAVE_GFC_COMPLEX_16
1045 extern void unpack0_c16 (gfc_array_c16 *, const gfc_array_c16 *,
1046 const gfc_array_l1 *, const GFC_COMPLEX_16 *);
1047 internal_proto(unpack0_c16);
1049 #endif
1051 extern void unpack1_i1 (gfc_array_i1 *, const gfc_array_i1 *,
1052 const gfc_array_l1 *, const gfc_array_i1 *);
1053 internal_proto(unpack1_i1);
1055 extern void unpack1_i2 (gfc_array_i2 *, const gfc_array_i2 *,
1056 const gfc_array_l1 *, const gfc_array_i2 *);
1057 internal_proto(unpack1_i2);
1059 extern void unpack1_i4 (gfc_array_i4 *, const gfc_array_i4 *,
1060 const gfc_array_l1 *, const gfc_array_i4 *);
1061 internal_proto(unpack1_i4);
1063 extern void unpack1_i8 (gfc_array_i8 *, const gfc_array_i8 *,
1064 const gfc_array_l1 *, const gfc_array_i8 *);
1065 internal_proto(unpack1_i8);
1067 #ifdef HAVE_GFC_INTEGER_16
1068 extern void unpack1_i16 (gfc_array_i16 *, const gfc_array_i16 *,
1069 const gfc_array_l1 *, const gfc_array_i16 *);
1070 internal_proto(unpack1_i16);
1071 #endif
1073 extern void unpack1_r4 (gfc_array_r4 *, const gfc_array_r4 *,
1074 const gfc_array_l1 *, const gfc_array_r4 *);
1075 internal_proto(unpack1_r4);
1077 extern void unpack1_r8 (gfc_array_r8 *, const gfc_array_r8 *,
1078 const gfc_array_l1 *, const gfc_array_r8 *);
1079 internal_proto(unpack1_r8);
1081 #ifdef HAVE_GFC_REAL_10
1082 extern void unpack1_r10 (gfc_array_r10 *, const gfc_array_r10 *,
1083 const gfc_array_l1 *, const gfc_array_r10 *);
1084 internal_proto(unpack1_r10);
1085 #endif
1087 #ifdef HAVE_GFC_REAL_16
1088 extern void unpack1_r16 (gfc_array_r16 *, const gfc_array_r16 *,
1089 const gfc_array_l1 *, const gfc_array_r16 *);
1090 internal_proto(unpack1_r16);
1091 #endif
1093 extern void unpack1_c4 (gfc_array_c4 *, const gfc_array_c4 *,
1094 const gfc_array_l1 *, const gfc_array_c4 *);
1095 internal_proto(unpack1_c4);
1097 extern void unpack1_c8 (gfc_array_c8 *, const gfc_array_c8 *,
1098 const gfc_array_l1 *, const gfc_array_c8 *);
1099 internal_proto(unpack1_c8);
1101 #ifdef HAVE_GFC_COMPLEX_10
1102 extern void unpack1_c10 (gfc_array_c10 *, const gfc_array_c10 *,
1103 const gfc_array_l1 *, const gfc_array_c10 *);
1104 internal_proto(unpack1_c10);
1105 #endif
1107 #ifdef HAVE_GFC_COMPLEX_16
1108 extern void unpack1_c16 (gfc_array_c16 *, const gfc_array_c16 *,
1109 const gfc_array_l1 *, const gfc_array_c16 *);
1110 internal_proto(unpack1_c16);
1111 #endif
1113 /* Helper functions for spread. */
1115 extern void spread_i1 (gfc_array_i1 *, const gfc_array_i1 *,
1116 const index_type, const index_type);
1117 internal_proto(spread_i1);
1119 extern void spread_i2 (gfc_array_i2 *, const gfc_array_i2 *,
1120 const index_type, const index_type);
1121 internal_proto(spread_i2);
1123 extern void spread_i4 (gfc_array_i4 *, const gfc_array_i4 *,
1124 const index_type, const index_type);
1125 internal_proto(spread_i4);
1127 extern void spread_i8 (gfc_array_i8 *, const gfc_array_i8 *,
1128 const index_type, const index_type);
1129 internal_proto(spread_i8);
1131 #ifdef HAVE_GFC_INTEGER_16
1132 extern void spread_i16 (gfc_array_i16 *, const gfc_array_i16 *,
1133 const index_type, const index_type);
1134 internal_proto(spread_i16);
1136 #endif
1138 extern void spread_r4 (gfc_array_r4 *, const gfc_array_r4 *,
1139 const index_type, const index_type);
1140 internal_proto(spread_r4);
1142 extern void spread_r8 (gfc_array_r8 *, const gfc_array_r8 *,
1143 const index_type, const index_type);
1144 internal_proto(spread_r8);
1146 #ifdef HAVE_GFC_REAL_10
1147 extern void spread_r10 (gfc_array_r10 *, const gfc_array_r10 *,
1148 const index_type, const index_type);
1149 internal_proto(spread_r10);
1151 #endif
1153 #ifdef HAVE_GFC_REAL_16
1154 extern void spread_r16 (gfc_array_r16 *, const gfc_array_r16 *,
1155 const index_type, const index_type);
1156 internal_proto(spread_r16);
1158 #endif
1160 extern void spread_c4 (gfc_array_c4 *, const gfc_array_c4 *,
1161 const index_type, const index_type);
1162 internal_proto(spread_c4);
1164 extern void spread_c8 (gfc_array_c8 *, const gfc_array_c8 *,
1165 const index_type, const index_type);
1166 internal_proto(spread_c8);
1168 #ifdef HAVE_GFC_COMPLEX_10
1169 extern void spread_c10 (gfc_array_c10 *, const gfc_array_c10 *,
1170 const index_type, const index_type);
1171 internal_proto(spread_c10);
1173 #endif
1175 #ifdef HAVE_GFC_COMPLEX_16
1176 extern void spread_c16 (gfc_array_c16 *, const gfc_array_c16 *,
1177 const index_type, const index_type);
1178 internal_proto(spread_c16);
1180 #endif
1182 extern void spread_scalar_i1 (gfc_array_i1 *, const GFC_INTEGER_1 *,
1183 const index_type, const index_type);
1184 internal_proto(spread_scalar_i1);
1186 extern void spread_scalar_i2 (gfc_array_i2 *, const GFC_INTEGER_2 *,
1187 const index_type, const index_type);
1188 internal_proto(spread_scalar_i2);
1190 extern void spread_scalar_i4 (gfc_array_i4 *, const GFC_INTEGER_4 *,
1191 const index_type, const index_type);
1192 internal_proto(spread_scalar_i4);
1194 extern void spread_scalar_i8 (gfc_array_i8 *, const GFC_INTEGER_8 *,
1195 const index_type, const index_type);
1196 internal_proto(spread_scalar_i8);
1198 #ifdef HAVE_GFC_INTEGER_16
1199 extern void spread_scalar_i16 (gfc_array_i16 *, const GFC_INTEGER_16 *,
1200 const index_type, const index_type);
1201 internal_proto(spread_scalar_i16);
1203 #endif
1205 extern void spread_scalar_r4 (gfc_array_r4 *, const GFC_REAL_4 *,
1206 const index_type, const index_type);
1207 internal_proto(spread_scalar_r4);
1209 extern void spread_scalar_r8 (gfc_array_r8 *, const GFC_REAL_8 *,
1210 const index_type, const index_type);
1211 internal_proto(spread_scalar_r8);
1213 #ifdef HAVE_GFC_REAL_10
1214 extern void spread_scalar_r10 (gfc_array_r10 *, const GFC_REAL_10 *,
1215 const index_type, const index_type);
1216 internal_proto(spread_scalar_r10);
1218 #endif
1220 #ifdef HAVE_GFC_REAL_16
1221 extern void spread_scalar_r16 (gfc_array_r16 *, const GFC_REAL_16 *,
1222 const index_type, const index_type);
1223 internal_proto(spread_scalar_r16);
1225 #endif
1227 extern void spread_scalar_c4 (gfc_array_c4 *, const GFC_COMPLEX_4 *,
1228 const index_type, const index_type);
1229 internal_proto(spread_scalar_c4);
1231 extern void spread_scalar_c8 (gfc_array_c8 *, const GFC_COMPLEX_8 *,
1232 const index_type, const index_type);
1233 internal_proto(spread_scalar_c8);
1235 #ifdef HAVE_GFC_COMPLEX_10
1236 extern void spread_scalar_c10 (gfc_array_c10 *, const GFC_COMPLEX_10 *,
1237 const index_type, const index_type);
1238 internal_proto(spread_scalar_c10);
1240 #endif
1242 #ifdef HAVE_GFC_COMPLEX_16
1243 extern void spread_scalar_c16 (gfc_array_c16 *, const GFC_COMPLEX_16 *,
1244 const index_type, const index_type);
1245 internal_proto(spread_scalar_c16);
1247 #endif
1249 /* string_intrinsics.c */
1251 extern int compare_string (gfc_charlen_type, const char *,
1252 gfc_charlen_type, const char *);
1253 iexport_proto(compare_string);
1255 extern int compare_string_char4 (gfc_charlen_type, const gfc_char4_t *,
1256 gfc_charlen_type, const gfc_char4_t *);
1257 iexport_proto(compare_string_char4);
1259 /* random.c */
1261 extern void random_seed_i4 (GFC_INTEGER_4 * size, gfc_array_i4 * put,
1262 gfc_array_i4 * get);
1263 iexport_proto(random_seed_i4);
1264 extern void random_seed_i8 (GFC_INTEGER_8 * size, gfc_array_i8 * put,
1265 gfc_array_i8 * get);
1266 iexport_proto(random_seed_i8);
1268 /* size.c */
1270 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, void) array_t;
1272 extern index_type size0 (const array_t * array);
1273 iexport_proto(size0);
1275 /* bounds.c */
1277 extern void bounds_equal_extents (array_t *, array_t *, const char *,
1278 const char *);
1279 internal_proto(bounds_equal_extents);
1281 extern void bounds_reduced_extents (array_t *, array_t *, int, const char *,
1282 const char *intrinsic);
1283 internal_proto(bounds_reduced_extents);
1285 extern void bounds_iforeach_return (array_t *, array_t *, const char *);
1286 internal_proto(bounds_iforeach_return);
1288 extern void bounds_ifunction_return (array_t *, const index_type *,
1289 const char *, const char *);
1290 internal_proto(bounds_ifunction_return);
1292 /* Internal auxiliary functions for cshift */
1294 void cshift0_i1 (gfc_array_i1 *, const gfc_array_i1 *, ssize_t, int);
1295 internal_proto(cshift0_i1);
1297 void cshift0_i2 (gfc_array_i2 *, const gfc_array_i2 *, ssize_t, int);
1298 internal_proto(cshift0_i2);
1300 void cshift0_i4 (gfc_array_i4 *, const gfc_array_i4 *, ssize_t, int);
1301 internal_proto(cshift0_i4);
1303 void cshift0_i8 (gfc_array_i8 *, const gfc_array_i8 *, ssize_t, int);
1304 internal_proto(cshift0_i8);
1306 #ifdef HAVE_GFC_INTEGER_16
1307 void cshift0_i16 (gfc_array_i16 *, const gfc_array_i16 *, ssize_t, int);
1308 internal_proto(cshift0_i16);
1309 #endif
1311 void cshift0_r4 (gfc_array_r4 *, const gfc_array_r4 *, ssize_t, int);
1312 internal_proto(cshift0_r4);
1314 void cshift0_r8 (gfc_array_r8 *, const gfc_array_r8 *, ssize_t, int);
1315 internal_proto(cshift0_r8);
1317 #ifdef HAVE_GFC_REAL_10
1318 void cshift0_r10 (gfc_array_r10 *, const gfc_array_r10 *, ssize_t, int);
1319 internal_proto(cshift0_r10);
1320 #endif
1322 #ifdef HAVE_GFC_REAL_16
1323 void cshift0_r16 (gfc_array_r16 *, const gfc_array_r16 *, ssize_t, int);
1324 internal_proto(cshift0_r16);
1325 #endif
1327 void cshift0_c4 (gfc_array_c4 *, const gfc_array_c4 *, ssize_t, int);
1328 internal_proto(cshift0_c4);
1330 void cshift0_c8 (gfc_array_c8 *, const gfc_array_c8 *, ssize_t, int);
1331 internal_proto(cshift0_c8);
1333 #ifdef HAVE_GFC_COMPLEX_10
1334 void cshift0_c10 (gfc_array_c10 *, const gfc_array_c10 *, ssize_t, int);
1335 internal_proto(cshift0_c10);
1336 #endif
1338 #ifdef HAVE_GFC_COMPLEX_16
1339 void cshift0_c16 (gfc_array_c16 *, const gfc_array_c16 *, ssize_t, int);
1340 internal_proto(cshift0_c16);
1341 #endif
1343 #endif /* LIBGFOR_H */