OSDN Git Service

* incpath.c (remove_duplicates): If name is not a directory, issue
[pf3gnuchains/gcc-fork.git] / libgfortran / libgfortran.h
1 /* Common declarations for all of libgfortran.
2    Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
3    Free Software Foundation, Inc.
4    Contributed by Paul Brook <paul@nowt.org>, and
5    Andy Vaught <andy@xena.eas.asu.edu>
6
7 This file is part of the GNU Fortran runtime library (libgfortran).
8
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.
13
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.
18
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.
22
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/>.  */
27
28 #ifndef LIBGFOR_H
29 #define LIBGFOR_H
30
31 /* Ensure that ANSI conform stdio is used. This needs to be set before
32    any system header file is included.  */
33 #if defined __MINGW32__
34 #  define _POSIX 1
35 #  define gfc_printf gnu_printf
36 #else
37 #  define gfc_printf __printf__
38 #endif
39
40 /* config.h MUST be first because it can affect system headers.  */
41 #include "config.h"
42
43 #include <stdio.h>
44 #include <math.h>
45 #include <stddef.h>
46 #include <float.h>
47 #include <stdarg.h>
48
49 #ifdef __MINGW32__
50 extern float __strtof (const char *, char **);
51 #define gfc_strtof __strtof
52 extern double __strtod (const char *, char **);
53 #define gfc_strtod __strtod
54 extern long double __strtold (const char *, char **);
55 #define gfc_strtold __strtold
56 #else
57 #define gfc_strtof strtof
58 #define gfc_strtod strtod
59 #define gfc_strtold strtold
60 #endif
61
62 #if HAVE_COMPLEX_H
63 # include <complex.h>
64 #else
65 #define complex __complex__
66 #endif
67
68 #include "../gcc/fortran/libgfortran.h"
69
70 #include "c99_protos.h"
71
72 #if HAVE_IEEEFP_H
73 #include <ieeefp.h>
74 #endif
75
76 #include "gstdint.h"
77
78 #if HAVE_SYS_TYPES_H
79 #include <sys/types.h>
80 #endif
81
82 #ifdef __MINGW32__
83 typedef off64_t gfc_offset;
84 #else
85 typedef off_t gfc_offset;
86 #endif
87
88 #ifndef NULL
89 #define NULL (void *) 0
90 #endif
91
92 #ifndef __GNUC__
93 #define __attribute__(x)
94 #define likely(x)       (x)
95 #define unlikely(x)     (x)
96 #else
97 #define likely(x)       __builtin_expect(!!(x), 1)
98 #define unlikely(x)     __builtin_expect(!!(x), 0)
99 #endif
100
101
102 /* We use intptr_t and uintptr_t, which may not be always defined in
103    system headers.  */
104
105 #ifndef HAVE_INTPTR_T
106 #if __SIZEOF_POINTER__ == __SIZEOF_LONG__
107 #define intptr_t long
108 #elif __SIZEOF_POINTER__ == __SIZEOF_LONG_LONG__
109 #define intptr_t long long
110 #elif __SIZEOF_POINTER__ == __SIZEOF_INT__
111 #define intptr_t int
112 #elif __SIZEOF_POINTER__ == __SIZEOF_SHORT__
113 #define intptr_t short
114 #else
115 #error "Pointer type with unexpected size"
116 #endif
117 #endif
118
119 #ifndef HAVE_UINTPTR_T
120 #if __SIZEOF_POINTER__ == __SIZEOF_LONG__
121 #define uintptr_t unsigned long
122 #elif __SIZEOF_POINTER__ == __SIZEOF_LONG_LONG__
123 #define uintptr_t unsigned long long
124 #elif __SIZEOF_POINTER__ == __SIZEOF_INT__
125 #define uintptr_t unsigned int
126 #elif __SIZEOF_POINTER__ == __SIZEOF_SHORT__
127 #define uintptr_t unsigned short
128 #else
129 #error "Pointer type with unexpected size"
130 #endif
131 #endif
132
133
134 /* On mingw, work around the buggy Windows snprintf() by using the one
135    mingw provides, __mingw_snprintf().  We also provide a prototype for
136    __mingw_snprintf(), because the mingw headers currently don't have one.  */
137 #if HAVE_MINGW_SNPRINTF
138 extern int __mingw_snprintf (char *, size_t, const char *, ...)
139      __attribute__ ((format (gnu_printf, 3, 4)));
140 #undef snprintf
141 #define snprintf __mingw_snprintf
142 #endif
143
144
145 /* For a library, a standard prefix is a requirement in order to partition
146    the namespace.  IPREFIX is for symbols intended to be internal to the
147    library.  */
148 #define PREFIX(x)       _gfortran_ ## x
149 #define IPREFIX(x)      _gfortrani_ ## x
150
151 /* Magic to rename a symbol at the compiler level.  You continue to refer
152    to the symbol as OLD in the source, but it'll be named NEW in the asm.  */
153 #define sym_rename(old, new) sym_rename1(old, __USER_LABEL_PREFIX__, new)
154 #define sym_rename1(old, ulp, new) sym_rename2(old, ulp, new)
155 #define sym_rename2(old, ulp, new) extern __typeof(old) old __asm__(#ulp #new)
156
157 /* There are several classifications of routines:
158
159      (1) Symbols used only within the library,
160      (2) Symbols to be exported from the library,
161      (3) Symbols to be exported from the library, but
162          also used inside the library.
163
164    By telling the compiler about these different classifications we can
165    tightly control the interface seen by the user, and get better code
166    from the compiler at the same time.
167
168    One of the following should be used immediately after the declaration
169    of each symbol:
170
171      internal_proto     Marks a symbol used only within the library,
172                         and adds IPREFIX to the assembly-level symbol
173                         name.  The later is important for maintaining
174                         the namespace partition for the static library.
175
176      export_proto       Marks a symbol to be exported, and adds PREFIX
177                         to the assembly-level symbol name.
178
179      export_proto_np    Marks a symbol to be exported without adding PREFIX.
180
181      iexport_proto      Marks a function to be exported, but with the 
182                         understanding that it can be used inside as well.
183
184      iexport_data_proto Similarly, marks a data symbol to be exported.
185                         Unfortunately, some systems can't play the hidden
186                         symbol renaming trick on data symbols, thanks to
187                         the horribleness of COPY relocations.
188
189    If iexport_proto or iexport_data_proto is used, you must also use
190    iexport or iexport_data after the *definition* of the symbol.  */
191
192 #if defined(HAVE_ATTRIBUTE_VISIBILITY)
193 # define internal_proto(x) \
194         sym_rename(x, IPREFIX (x)) __attribute__((__visibility__("hidden")))
195 #else
196 # define internal_proto(x)      sym_rename(x, IPREFIX(x))
197 #endif
198
199 #if defined(HAVE_ATTRIBUTE_VISIBILITY) && defined(HAVE_ATTRIBUTE_ALIAS)
200 # define export_proto(x)        sym_rename(x, PREFIX(x))
201 # define export_proto_np(x)     extern char swallow_semicolon
202 # define iexport_proto(x)       internal_proto(x)
203 # define iexport(x)             iexport1(x, IPREFIX(x))
204 # define iexport1(x,y)          iexport2(x,y)
205 # define iexport2(x,y) \
206         extern __typeof(x) PREFIX(x) __attribute__((__alias__(#y)))
207 #else
208 # define export_proto(x)        sym_rename(x, PREFIX(x))
209 # define export_proto_np(x)     extern char swallow_semicolon
210 # define iexport_proto(x)       export_proto(x)
211 # define iexport(x)             extern char swallow_semicolon
212 #endif
213
214 /* TODO: detect the case when we *can* hide the symbol.  */
215 #define iexport_data_proto(x)   export_proto(x)
216 #define iexport_data(x)         extern char swallow_semicolon
217
218 /* The only reliable way to get the offset of a field in a struct
219    in a system independent way is via this macro.  */
220 #ifndef offsetof
221 #define offsetof(TYPE, MEMBER)  ((size_t) &((TYPE *) 0)->MEMBER)
222 #endif
223
224 /* The C99 classification macros isfinite, isinf, isnan, isnormal
225    and signbit are broken or inconsistent on quite a few targets.
226    So, we use GCC's builtins instead.
227
228    Another advantage for GCC's builtins for these type-generic macros
229    is that it handles floating-point types that the system headers
230    may not support (like __float128).  */
231
232 #undef isnan
233 #define isnan(x) __builtin_isnan(x)
234 #undef isfinite
235 #define isfinite(x) __builtin_isfinite(x)
236 #undef isinf
237 #define isinf(x) __builtin_isinf(x)
238 #undef isnormal
239 #define isnormal(x) __builtin_isnormal(x)
240 #undef signbit
241 #define signbit(x) __builtin_signbit(x)
242
243 /* TODO: find the C99 version of these an move into above ifdef.  */
244 #define REALPART(z) (__real__(z))
245 #define IMAGPART(z) (__imag__(z))
246 #define COMPLEX_ASSIGN(z_, r_, i_) {__real__(z_) = (r_); __imag__(z_) = (i_);}
247
248 #include "kinds.h"
249
250 /* Define the type used for the current record number for large file I/O.
251    The size must be consistent with the size defined on the compiler side.  */
252 #ifdef HAVE_GFC_INTEGER_8
253 typedef GFC_INTEGER_8 GFC_IO_INT;
254 #else
255 #ifdef HAVE_GFC_INTEGER_4
256 typedef GFC_INTEGER_4 GFC_IO_INT;
257 #else
258 #error "GFC_INTEGER_4 should be available for the library to compile".
259 #endif
260 #endif
261
262 /* The following two definitions must be consistent with the types used
263    by the compiler.  */
264 /* The type used of array indices, amongst other things.  */
265 typedef ssize_t index_type;
266
267 /* The type used for the lengths of character variables.  */
268 typedef GFC_INTEGER_4 gfc_charlen_type;
269
270 /* Definitions of CHARACTER data types:
271      - CHARACTER(KIND=1) corresponds to the C char type,
272      - CHARACTER(KIND=4) corresponds to an unsigned 32-bit integer.  */
273 typedef GFC_UINTEGER_4 gfc_char4_t;
274
275 /* Byte size of character kinds.  For the kinds currently supported, it's
276    simply equal to the kind parameter itself.  */
277 #define GFC_SIZE_OF_CHAR_KIND(kind) (kind)
278
279 /* This will be 0 on little-endian machines and one on big-endian machines.  */
280 extern int big_endian;
281 internal_proto(big_endian);
282
283 #define GFOR_POINTER_TO_L1(p, kind) \
284   (big_endian * (kind - 1) + (GFC_LOGICAL_1 *)(p))
285
286 #define GFC_INTEGER_1_HUGE \
287   (GFC_INTEGER_1)((((GFC_UINTEGER_1)1) << 7) - 1)
288 #define GFC_INTEGER_2_HUGE \
289   (GFC_INTEGER_2)((((GFC_UINTEGER_2)1) << 15) - 1)
290 #define GFC_INTEGER_4_HUGE \
291   (GFC_INTEGER_4)((((GFC_UINTEGER_4)1) << 31) - 1)
292 #define GFC_INTEGER_8_HUGE \
293   (GFC_INTEGER_8)((((GFC_UINTEGER_8)1) << 63) - 1)
294 #ifdef HAVE_GFC_INTEGER_16
295 #define GFC_INTEGER_16_HUGE \
296   (GFC_INTEGER_16)((((GFC_UINTEGER_16)1) << 127) - 1)
297 #endif
298
299 /* M{IN,AX}{LOC,VAL} need also infinities and NaNs if supported.  */
300
301 #ifdef __FLT_HAS_INFINITY__
302 # define GFC_REAL_4_INFINITY __builtin_inff ()
303 #endif
304 #ifdef __DBL_HAS_INFINITY__
305 # define GFC_REAL_8_INFINITY __builtin_inf ()
306 #endif
307 #ifdef __LDBL_HAS_INFINITY__
308 # ifdef HAVE_GFC_REAL_10
309 #  define GFC_REAL_10_INFINITY __builtin_infl ()
310 # endif
311 # ifdef HAVE_GFC_REAL_16
312 #  define GFC_REAL_16_INFINITY __builtin_infl ()
313 # endif
314 #endif
315 #ifdef __FLT_HAS_QUIET_NAN__
316 # define GFC_REAL_4_QUIET_NAN __builtin_nanf ("")
317 #endif
318 #ifdef __DBL_HAS_QUIET_NAN__
319 # define GFC_REAL_8_QUIET_NAN __builtin_nan ("")
320 #endif
321 #ifdef __LDBL_HAS_QUIET_NAN__
322 # ifdef HAVE_GFC_REAL_10
323 #  define GFC_REAL_10_QUIET_NAN __builtin_nanl ("")
324 # endif
325 # ifdef HAVE_GFC_REAL_16
326 #  define GFC_REAL_16_QUIET_NAN __builtin_nanl ("")
327 # endif
328 #endif
329
330 typedef struct descriptor_dimension
331 {
332   index_type _stride;
333   index_type _lbound;
334   index_type _ubound;
335 }
336
337 descriptor_dimension;
338
339 #define GFC_ARRAY_DESCRIPTOR(r, type) \
340 struct {\
341   type *data;\
342   size_t offset;\
343   index_type dtype;\
344   descriptor_dimension dim[r];\
345 }
346
347 /* Commonly used array descriptor types.  */
348 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, void) gfc_array_void;
349 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, char) gfc_array_char;
350 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_1) gfc_array_i1;
351 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_2) gfc_array_i2;
352 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_4) gfc_array_i4;
353 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_8) gfc_array_i8;
354 #ifdef HAVE_GFC_INTEGER_16
355 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_16) gfc_array_i16;
356 #endif
357 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_4) gfc_array_r4;
358 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_8) gfc_array_r8;
359 #ifdef HAVE_GFC_REAL_10
360 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_10) gfc_array_r10;
361 #endif
362 #ifdef HAVE_GFC_REAL_16
363 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_16) gfc_array_r16;
364 #endif
365 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_4) gfc_array_c4;
366 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_8) gfc_array_c8;
367 #ifdef HAVE_GFC_COMPLEX_10
368 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_10) gfc_array_c10;
369 #endif
370 #ifdef HAVE_GFC_COMPLEX_16
371 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_16) gfc_array_c16;
372 #endif
373 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_1) gfc_array_l1;
374 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_2) gfc_array_l2;
375 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_4) gfc_array_l4;
376 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_8) gfc_array_l8;
377 #ifdef HAVE_GFC_LOGICAL_16
378 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_16) gfc_array_l16;
379 #endif
380
381
382 #define GFC_DESCRIPTOR_RANK(desc) ((desc)->dtype & GFC_DTYPE_RANK_MASK)
383 #define GFC_DESCRIPTOR_TYPE(desc) (((desc)->dtype & GFC_DTYPE_TYPE_MASK) \
384                                    >> GFC_DTYPE_TYPE_SHIFT)
385 #define GFC_DESCRIPTOR_SIZE(desc) ((desc)->dtype >> GFC_DTYPE_SIZE_SHIFT)
386 #define GFC_DESCRIPTOR_DATA(desc) ((desc)->data)
387 #define GFC_DESCRIPTOR_DTYPE(desc) ((desc)->dtype)
388
389 #define GFC_DIMENSION_LBOUND(dim) ((dim)._lbound)
390 #define GFC_DIMENSION_UBOUND(dim) ((dim)._ubound)
391 #define GFC_DIMENSION_STRIDE(dim) ((dim)._stride)
392 #define GFC_DIMENSION_EXTENT(dim) ((dim)._ubound + 1 - (dim)._lbound)
393 #define GFC_DIMENSION_SET(dim,lb,ub,str) \
394   do \
395     { \
396       (dim)._lbound = lb;                       \
397       (dim)._ubound = ub;                       \
398       (dim)._stride = str;                      \
399     } while (0)
400             
401
402 #define GFC_DESCRIPTOR_LBOUND(desc,i) ((desc)->dim[i]._lbound)
403 #define GFC_DESCRIPTOR_UBOUND(desc,i) ((desc)->dim[i]._ubound)
404 #define GFC_DESCRIPTOR_EXTENT(desc,i) ((desc)->dim[i]._ubound + 1 \
405                                       - (desc)->dim[i]._lbound)
406 #define GFC_DESCRIPTOR_EXTENT_BYTES(desc,i) \
407   (GFC_DESCRIPTOR_EXTENT(desc,i) * GFC_DESCRIPTOR_SIZE(desc))
408
409 #define GFC_DESCRIPTOR_STRIDE(desc,i) ((desc)->dim[i]._stride)
410 #define GFC_DESCRIPTOR_STRIDE_BYTES(desc,i) \
411   (GFC_DESCRIPTOR_STRIDE(desc,i) * GFC_DESCRIPTOR_SIZE(desc))
412
413 /* Macros to get both the size and the type with a single masking operation  */
414
415 #define GFC_DTYPE_SIZE_MASK \
416   ((~((index_type) 0) >> GFC_DTYPE_SIZE_SHIFT) << GFC_DTYPE_SIZE_SHIFT)
417 #define GFC_DTYPE_TYPE_SIZE_MASK (GFC_DTYPE_SIZE_MASK | GFC_DTYPE_TYPE_MASK)
418
419 #define GFC_DTYPE_TYPE_SIZE(desc) ((desc)->dtype & GFC_DTYPE_TYPE_SIZE_MASK)
420
421 #define GFC_DTYPE_INTEGER_1 ((GFC_DTYPE_INTEGER << GFC_DTYPE_TYPE_SHIFT) \
422    | (sizeof(GFC_INTEGER_1) << GFC_DTYPE_SIZE_SHIFT))
423 #define GFC_DTYPE_INTEGER_2 ((GFC_DTYPE_INTEGER << GFC_DTYPE_TYPE_SHIFT) \
424    | (sizeof(GFC_INTEGER_2) << GFC_DTYPE_SIZE_SHIFT))
425 #define GFC_DTYPE_INTEGER_4 ((GFC_DTYPE_INTEGER << GFC_DTYPE_TYPE_SHIFT) \
426    | (sizeof(GFC_INTEGER_4) << GFC_DTYPE_SIZE_SHIFT))
427 #define GFC_DTYPE_INTEGER_8 ((GFC_DTYPE_INTEGER << GFC_DTYPE_TYPE_SHIFT) \
428    | (sizeof(GFC_INTEGER_8) << GFC_DTYPE_SIZE_SHIFT))
429 #ifdef HAVE_GFC_INTEGER_16
430 #define GFC_DTYPE_INTEGER_16 ((GFC_DTYPE_INTEGER << GFC_DTYPE_TYPE_SHIFT) \
431    | (sizeof(GFC_INTEGER_16) << GFC_DTYPE_SIZE_SHIFT))
432 #endif
433
434 #define GFC_DTYPE_LOGICAL_1 ((GFC_DTYPE_LOGICAL << GFC_DTYPE_TYPE_SHIFT) \
435    | (sizeof(GFC_LOGICAL_1) << GFC_DTYPE_SIZE_SHIFT))
436 #define GFC_DTYPE_LOGICAL_2 ((GFC_DTYPE_LOGICAL << GFC_DTYPE_TYPE_SHIFT) \
437    | (sizeof(GFC_LOGICAL_2) << GFC_DTYPE_SIZE_SHIFT))
438 #define GFC_DTYPE_LOGICAL_4 ((GFC_DTYPE_LOGICAL << GFC_DTYPE_TYPE_SHIFT) \
439    | (sizeof(GFC_LOGICAL_4) << GFC_DTYPE_SIZE_SHIFT))
440 #define GFC_DTYPE_LOGICAL_8 ((GFC_DTYPE_LOGICAL << GFC_DTYPE_TYPE_SHIFT) \
441    | (sizeof(GFC_LOGICAL_8) << GFC_DTYPE_SIZE_SHIFT))
442 #ifdef HAVE_GFC_LOGICAL_16
443 #define GFC_DTYPE_LOGICAL_16 ((GFC_DTYPE_LOGICAL << GFC_DTYPE_TYPE_SHIFT) \
444    | (sizeof(GFC_LOGICAL_16) << GFC_DTYPE_SIZE_SHIFT))
445 #endif
446
447 #define GFC_DTYPE_REAL_4 ((GFC_DTYPE_REAL << GFC_DTYPE_TYPE_SHIFT) \
448    | (sizeof(GFC_REAL_4) << GFC_DTYPE_SIZE_SHIFT))
449 #define GFC_DTYPE_REAL_8 ((GFC_DTYPE_REAL << GFC_DTYPE_TYPE_SHIFT) \
450    | (sizeof(GFC_REAL_8) << GFC_DTYPE_SIZE_SHIFT))
451 #ifdef HAVE_GFC_REAL_10
452 #define GFC_DTYPE_REAL_10  ((GFC_DTYPE_REAL << GFC_DTYPE_TYPE_SHIFT) \
453    | (sizeof(GFC_REAL_10) << GFC_DTYPE_SIZE_SHIFT))
454 #endif
455 #ifdef HAVE_GFC_REAL_16
456 #define GFC_DTYPE_REAL_16 ((GFC_DTYPE_REAL << GFC_DTYPE_TYPE_SHIFT) \
457    | (sizeof(GFC_REAL_16) << GFC_DTYPE_SIZE_SHIFT))
458 #endif
459
460 #define GFC_DTYPE_COMPLEX_4 ((GFC_DTYPE_COMPLEX << GFC_DTYPE_TYPE_SHIFT) \
461    | (sizeof(GFC_COMPLEX_4) << GFC_DTYPE_SIZE_SHIFT))
462 #define GFC_DTYPE_COMPLEX_8 ((GFC_DTYPE_COMPLEX << GFC_DTYPE_TYPE_SHIFT) \
463    | (sizeof(GFC_COMPLEX_8) << GFC_DTYPE_SIZE_SHIFT))
464 #ifdef HAVE_GFC_COMPLEX_10
465 #define GFC_DTYPE_COMPLEX_10 ((GFC_DTYPE_COMPLEX << GFC_DTYPE_TYPE_SHIFT) \
466    | (sizeof(GFC_COMPLEX_10) << GFC_DTYPE_SIZE_SHIFT))
467 #endif
468 #ifdef HAVE_GFC_COMPLEX_16
469 #define GFC_DTYPE_COMPLEX_16 ((GFC_DTYPE_COMPLEX << GFC_DTYPE_TYPE_SHIFT) \
470    | (sizeof(GFC_COMPLEX_16) << GFC_DTYPE_SIZE_SHIFT))
471 #endif
472
473 #define GFC_DTYPE_DERIVED_1 ((GFC_DTYPE_DERIVED << GFC_DTYPE_TYPE_SHIFT) \
474    | (sizeof(GFC_INTEGER_1) << GFC_DTYPE_SIZE_SHIFT))
475 #define GFC_DTYPE_DERIVED_2 ((GFC_DTYPE_DERIVED << GFC_DTYPE_TYPE_SHIFT) \
476    | (sizeof(GFC_INTEGER_2) << GFC_DTYPE_SIZE_SHIFT))
477 #define GFC_DTYPE_DERIVED_4 ((GFC_DTYPE_DERIVED << GFC_DTYPE_TYPE_SHIFT) \
478    | (sizeof(GFC_INTEGER_4) << GFC_DTYPE_SIZE_SHIFT))
479 #define GFC_DTYPE_DERIVED_8 ((GFC_DTYPE_DERIVED << GFC_DTYPE_TYPE_SHIFT) \
480    | (sizeof(GFC_INTEGER_8) << GFC_DTYPE_SIZE_SHIFT))
481 #ifdef HAVE_GFC_INTEGER_16
482 #define GFC_DTYPE_DERIVED_16 ((GFC_DTYPE_DERIVED << GFC_DTYPE_TYPE_SHIFT) \
483    | (sizeof(GFC_INTEGER_16) << GFC_DTYPE_SIZE_SHIFT))
484 #endif
485
486 /* Macros to determine the alignment of pointers.  */
487
488 #define GFC_UNALIGNED_2(x) (((uintptr_t)(x)) & \
489                             (__alignof__(GFC_INTEGER_2) - 1))
490 #define GFC_UNALIGNED_4(x) (((uintptr_t)(x)) & \
491                             (__alignof__(GFC_INTEGER_4) - 1))
492 #define GFC_UNALIGNED_8(x) (((uintptr_t)(x)) & \
493                             (__alignof__(GFC_INTEGER_8) - 1))
494 #ifdef HAVE_GFC_INTEGER_16
495 #define GFC_UNALIGNED_16(x) (((uintptr_t)(x)) & \
496                              (__alignof__(GFC_INTEGER_16) - 1))
497 #endif
498
499 #define GFC_UNALIGNED_C4(x) (((uintptr_t)(x)) & \
500                              (__alignof__(GFC_COMPLEX_4) - 1))
501
502 #define GFC_UNALIGNED_C8(x) (((uintptr_t)(x)) & \
503                              (__alignof__(GFC_COMPLEX_8) - 1))
504
505 /* Runtime library include.  */
506 #define stringize(x) expand_macro(x)
507 #define expand_macro(x) # x
508
509 /* Runtime options structure.  */
510
511 typedef struct
512 {
513   int stdin_unit, stdout_unit, stderr_unit, optional_plus;
514   int locus;
515
516   int separator_len;
517   const char *separator;
518
519   int use_stderr, all_unbuffered, unbuffered_preconnected, default_recl;
520   int fpe, dump_core, backtrace;
521 }
522 options_t;
523
524 extern options_t options;
525 internal_proto(options);
526
527 extern void handler (int);
528 internal_proto(handler);
529
530
531 /* Compile-time options that will influence the library.  */
532
533 typedef struct
534 {
535   int warn_std;
536   int allow_std;
537   int pedantic;
538   int convert;
539   int dump_core;
540   int backtrace;
541   int sign_zero;
542   size_t record_marker;
543   int max_subrecord_length;
544   int bounds_check;
545   int range_check;
546 }
547 compile_options_t;
548
549 extern compile_options_t compile_options;
550 internal_proto(compile_options);
551
552 extern void init_compile_options (void);
553 internal_proto(init_compile_options);
554
555 #define GFC_MAX_SUBRECORD_LENGTH 2147483639   /* 2**31 - 9 */
556
557 /* Structure for statement options.  */
558
559 typedef struct
560 {
561   const char *name;
562   int value;
563 }
564 st_option;
565
566
567 /* This is returned by notification_std to know if, given the flags
568    that were given (-std=, -pedantic) we should issue an error, a warning
569    or nothing.  */
570 typedef enum
571 { NOTIFICATION_SILENT, NOTIFICATION_WARNING, NOTIFICATION_ERROR }
572 notification;
573
574 /* This is returned by notify_std and several io functions.  */
575 typedef enum
576 { SUCCESS = 1, FAILURE }
577 try;
578
579 /* The filename and line number don't go inside the globals structure.
580    They are set by the rest of the program and must be linked to.  */
581
582 /* Location of the current library call (optional).  */
583 extern unsigned line;
584 iexport_data_proto(line);
585
586 extern char *filename;
587 iexport_data_proto(filename);
588
589 /* Avoid conflicting prototypes of alloca() in system headers by using 
590    GCC's builtin alloca().  */
591 #define gfc_alloca(x)  __builtin_alloca(x)
592
593
594 /* Directory for creating temporary files.  Only used when none of the
595    following environment variables exist: GFORTRAN_TMPDIR, TMP and TEMP.  */
596 #define DEFAULT_TEMPDIR "/tmp"
597
598 /* The default value of record length for preconnected units is defined
599    here. This value can be overriden by an environment variable.
600    Default value is 1 Gb.  */
601 #define DEFAULT_RECL 1073741824
602
603
604 #define CHARACTER2(name) \
605               gfc_charlen_type name ## _len; \
606               char * name
607
608 typedef struct st_parameter_common
609 {
610   GFC_INTEGER_4 flags;
611   GFC_INTEGER_4 unit;
612   const char *filename;
613   GFC_INTEGER_4 line;
614   CHARACTER2 (iomsg);
615   GFC_INTEGER_4 *iostat;
616 }
617 st_parameter_common;
618
619 #undef CHARACTER2
620
621 #define IOPARM_LIBRETURN_MASK           (3 << 0)
622 #define IOPARM_LIBRETURN_OK             (0 << 0)
623 #define IOPARM_LIBRETURN_ERROR          (1 << 0)
624 #define IOPARM_LIBRETURN_END            (2 << 0)
625 #define IOPARM_LIBRETURN_EOR            (3 << 0)
626 #define IOPARM_ERR                      (1 << 2)
627 #define IOPARM_END                      (1 << 3)
628 #define IOPARM_EOR                      (1 << 4)
629 #define IOPARM_HAS_IOSTAT               (1 << 5)
630 #define IOPARM_HAS_IOMSG                (1 << 6)
631
632 #define IOPARM_COMMON_MASK              ((1 << 7) - 1)
633
634 #define IOPARM_OPEN_HAS_RECL_IN         (1 << 7)
635 #define IOPARM_OPEN_HAS_FILE            (1 << 8)
636 #define IOPARM_OPEN_HAS_STATUS          (1 << 9)
637 #define IOPARM_OPEN_HAS_ACCESS          (1 << 10)
638 #define IOPARM_OPEN_HAS_FORM            (1 << 11)
639 #define IOPARM_OPEN_HAS_BLANK           (1 << 12)
640 #define IOPARM_OPEN_HAS_POSITION        (1 << 13)
641 #define IOPARM_OPEN_HAS_ACTION          (1 << 14)
642 #define IOPARM_OPEN_HAS_DELIM           (1 << 15)
643 #define IOPARM_OPEN_HAS_PAD             (1 << 16)
644 #define IOPARM_OPEN_HAS_CONVERT         (1 << 17)
645 #define IOPARM_OPEN_HAS_DECIMAL         (1 << 18)
646 #define IOPARM_OPEN_HAS_ENCODING        (1 << 19)
647 #define IOPARM_OPEN_HAS_ROUND           (1 << 20)
648 #define IOPARM_OPEN_HAS_SIGN            (1 << 21)
649 #define IOPARM_OPEN_HAS_ASYNCHRONOUS    (1 << 22)
650 #define IOPARM_OPEN_HAS_NEWUNIT         (1 << 23)
651
652 /* library start function and end macro.  These can be expanded if needed
653    in the future.  cmp is st_parameter_common *cmp  */
654
655 extern void library_start (st_parameter_common *);
656 internal_proto(library_start);
657
658 #define library_end()
659
660 /* main.c */
661
662 extern void stupid_function_name_for_static_linking (void);
663 internal_proto(stupid_function_name_for_static_linking);
664
665 extern void set_args (int, char **);
666 iexport_proto(set_args);
667
668 extern void get_args (int *, char ***);
669 internal_proto(get_args);
670
671 extern void store_exe_path (const char *);
672 export_proto(store_exe_path);
673
674 extern char * full_exe_path (void);
675 internal_proto(full_exe_path);
676
677 /* backtrace.c */
678
679 extern void show_backtrace (void);
680 internal_proto(show_backtrace);
681
682 /* error.c */
683
684 #if defined(HAVE_GFC_REAL_16)
685 #define GFC_LARGEST_BUF (sizeof (GFC_REAL_16))
686 #elif defined(HAVE_GFC_INTEGER_16)
687 #define GFC_LARGEST_BUF (sizeof (GFC_INTEGER_LARGEST))
688 #elif defined(HAVE_GFC_REAL_10)
689 #define GFC_LARGEST_BUF (sizeof (GFC_REAL_10))
690 #else
691 #define GFC_LARGEST_BUF (sizeof (GFC_INTEGER_LARGEST))
692 #endif
693
694 #define GFC_ITOA_BUF_SIZE (sizeof (GFC_INTEGER_LARGEST) * 3 + 2)
695 #define GFC_XTOA_BUF_SIZE (GFC_LARGEST_BUF * 2 + 1)
696 #define GFC_OTOA_BUF_SIZE (GFC_LARGEST_BUF * 3 + 1)
697 #define GFC_BTOA_BUF_SIZE (GFC_LARGEST_BUF * 8 + 1)
698
699 extern void sys_exit (int) __attribute__ ((noreturn));
700 internal_proto(sys_exit);
701
702 extern const char *gfc_xtoa (GFC_UINTEGER_LARGEST, char *, size_t);
703 internal_proto(gfc_xtoa);
704
705 extern void os_error (const char *) __attribute__ ((noreturn));
706 iexport_proto(os_error);
707
708 extern void show_locus (st_parameter_common *);
709 internal_proto(show_locus);
710
711 extern void runtime_error (const char *, ...)
712      __attribute__ ((noreturn, format (gfc_printf, 1, 2)));
713 iexport_proto(runtime_error);
714
715 extern void runtime_error_at (const char *, const char *, ...)
716      __attribute__ ((noreturn, format (gfc_printf, 2, 3)));
717 iexport_proto(runtime_error_at);
718
719 extern void runtime_warning_at (const char *, const char *, ...)
720      __attribute__ ((format (gfc_printf, 2, 3)));
721 iexport_proto(runtime_warning_at);
722
723 extern void internal_error (st_parameter_common *, const char *)
724   __attribute__ ((noreturn));
725 internal_proto(internal_error);
726
727 extern const char *get_oserror (void);
728 internal_proto(get_oserror);
729
730 extern const char *translate_error (int);
731 internal_proto(translate_error);
732
733 extern void generate_error (st_parameter_common *, int, const char *);
734 iexport_proto(generate_error);
735
736 extern try notify_std (st_parameter_common *, int, const char *);
737 internal_proto(notify_std);
738
739 extern notification notification_std(int);
740 internal_proto(notification_std);
741
742 /* fpu.c */
743
744 extern void set_fpu (void);
745 internal_proto(set_fpu);
746
747 /* memory.c */
748
749 extern void *get_mem (size_t) __attribute__ ((malloc));
750 internal_proto(get_mem);
751
752 extern void *internal_malloc_size (size_t) __attribute__ ((malloc));
753 internal_proto(internal_malloc_size);
754
755 /* environ.c */
756
757 extern int check_buffered (int);
758 internal_proto(check_buffered);
759
760 extern void init_variables (void);
761 internal_proto(init_variables);
762
763 extern void show_variables (void);
764 internal_proto(show_variables);
765
766 unit_convert get_unformatted_convert (int);
767 internal_proto(get_unformatted_convert);
768
769 /* string.c */
770
771 extern int find_option (st_parameter_common *, const char *, gfc_charlen_type,
772                         const st_option *, const char *);
773 internal_proto(find_option);
774
775 extern gfc_charlen_type fstrlen (const char *, gfc_charlen_type);
776 internal_proto(fstrlen);
777
778 extern gfc_charlen_type fstrcpy (char *, gfc_charlen_type, const char *, gfc_charlen_type);
779 internal_proto(fstrcpy);
780
781 extern gfc_charlen_type cf_strcpy (char *, gfc_charlen_type, const char *);
782 internal_proto(cf_strcpy);
783
784 /* io/intrinsics.c */
785
786 extern void flush_all_units (void);
787 internal_proto(flush_all_units);
788
789 /* io.c */
790
791 extern void init_units (void);
792 internal_proto(init_units);
793
794 extern void close_units (void);
795 internal_proto(close_units);
796
797 extern int unit_to_fd (int);
798 internal_proto(unit_to_fd);
799
800 extern int st_printf (const char *, ...)
801   __attribute__ ((format (gfc_printf, 1, 2)));
802 internal_proto(st_printf);
803
804 extern int st_vprintf (const char *, va_list);
805 internal_proto(st_vprintf);
806
807 extern char * filename_from_unit (int);
808 internal_proto(filename_from_unit);
809
810 /* stop.c */
811
812 extern void stop_string (const char *, GFC_INTEGER_4)
813   __attribute__ ((noreturn));
814 export_proto(stop_string);
815
816 /* reshape_packed.c */
817
818 extern void reshape_packed (char *, index_type, const char *, index_type,
819                             const char *, index_type);
820 internal_proto(reshape_packed);
821
822 /* Repacking functions.  These are called internally by internal_pack
823    and internal_unpack.  */
824
825 GFC_INTEGER_1 *internal_pack_1 (gfc_array_i1 *);
826 internal_proto(internal_pack_1);
827
828 GFC_INTEGER_2 *internal_pack_2 (gfc_array_i2 *);
829 internal_proto(internal_pack_2);
830
831 GFC_INTEGER_4 *internal_pack_4 (gfc_array_i4 *);
832 internal_proto(internal_pack_4);
833
834 GFC_INTEGER_8 *internal_pack_8 (gfc_array_i8 *);
835 internal_proto(internal_pack_8);
836
837 #if defined HAVE_GFC_INTEGER_16
838 GFC_INTEGER_16 *internal_pack_16 (gfc_array_i16 *);
839 internal_proto(internal_pack_16);
840 #endif
841
842 GFC_REAL_4 *internal_pack_r4 (gfc_array_r4 *);
843 internal_proto(internal_pack_r4);
844
845 GFC_REAL_8 *internal_pack_r8 (gfc_array_r8 *);
846 internal_proto(internal_pack_r8);
847
848 #if defined HAVE_GFC_REAL_10
849 GFC_REAL_10 *internal_pack_r10 (gfc_array_r10 *);
850 internal_proto(internal_pack_r10);
851 #endif
852
853 #if defined HAVE_GFC_REAL_16
854 GFC_REAL_16 *internal_pack_r16 (gfc_array_r16 *);
855 internal_proto(internal_pack_r16);
856 #endif
857
858 GFC_COMPLEX_4 *internal_pack_c4 (gfc_array_c4 *);
859 internal_proto(internal_pack_c4);
860
861 GFC_COMPLEX_8 *internal_pack_c8 (gfc_array_c8 *);
862 internal_proto(internal_pack_c8);
863
864 #if defined HAVE_GFC_COMPLEX_10
865 GFC_COMPLEX_10 *internal_pack_c10 (gfc_array_c10 *);
866 internal_proto(internal_pack_c10);
867 #endif
868
869 #if defined HAVE_GFC_COMPLEX_16
870 GFC_COMPLEX_16 *internal_pack_c16 (gfc_array_c16 *);
871 internal_proto(internal_pack_c16);
872 #endif
873
874 extern void internal_unpack_1 (gfc_array_i1 *, const GFC_INTEGER_1 *);
875 internal_proto(internal_unpack_1);
876
877 extern void internal_unpack_2 (gfc_array_i2 *, const GFC_INTEGER_2 *);
878 internal_proto(internal_unpack_2);
879
880 extern void internal_unpack_4 (gfc_array_i4 *, const GFC_INTEGER_4 *);
881 internal_proto(internal_unpack_4);
882
883 extern void internal_unpack_8 (gfc_array_i8 *, const GFC_INTEGER_8 *);
884 internal_proto(internal_unpack_8);
885
886 #if defined HAVE_GFC_INTEGER_16
887 extern void internal_unpack_16 (gfc_array_i16 *, const GFC_INTEGER_16 *);
888 internal_proto(internal_unpack_16);
889 #endif
890
891 extern void internal_unpack_r4 (gfc_array_r4 *, const GFC_REAL_4 *);
892 internal_proto(internal_unpack_r4);
893
894 extern void internal_unpack_r8 (gfc_array_r8 *, const GFC_REAL_8 *);
895 internal_proto(internal_unpack_r8);
896
897 #if defined HAVE_GFC_REAL_10
898 extern void internal_unpack_r10 (gfc_array_r10 *, const GFC_REAL_10 *);
899 internal_proto(internal_unpack_r10);
900 #endif
901
902 #if defined HAVE_GFC_REAL_16
903 extern void internal_unpack_r16 (gfc_array_r16 *, const GFC_REAL_16 *);
904 internal_proto(internal_unpack_r16);
905 #endif
906
907 extern void internal_unpack_c4 (gfc_array_c4 *, const GFC_COMPLEX_4 *);
908 internal_proto(internal_unpack_c4);
909
910 extern void internal_unpack_c8 (gfc_array_c8 *, const GFC_COMPLEX_8 *);
911 internal_proto(internal_unpack_c8);
912
913 #if defined HAVE_GFC_COMPLEX_10
914 extern void internal_unpack_c10 (gfc_array_c10 *, const GFC_COMPLEX_10 *);
915 internal_proto(internal_unpack_c10);
916 #endif
917
918 #if defined HAVE_GFC_COMPLEX_16
919 extern void internal_unpack_c16 (gfc_array_c16 *, const GFC_COMPLEX_16 *);
920 internal_proto(internal_unpack_c16);
921 #endif
922
923 /* Internal auxiliary functions for the pack intrinsic.  */
924
925 extern void pack_i1 (gfc_array_i1 *, const gfc_array_i1 *,
926                      const gfc_array_l1 *, const gfc_array_i1 *);
927 internal_proto(pack_i1);
928
929 extern void pack_i2 (gfc_array_i2 *, const gfc_array_i2 *,
930                      const gfc_array_l1 *, const gfc_array_i2 *);
931 internal_proto(pack_i2);
932
933 extern void pack_i4 (gfc_array_i4 *, const gfc_array_i4 *,
934                      const gfc_array_l1 *, const gfc_array_i4 *);
935 internal_proto(pack_i4);
936
937 extern void pack_i8 (gfc_array_i8 *, const gfc_array_i8 *,
938                      const gfc_array_l1 *, const gfc_array_i8 *);
939 internal_proto(pack_i8);
940
941 #ifdef HAVE_GFC_INTEGER_16
942 extern void pack_i16 (gfc_array_i16 *, const gfc_array_i16 *,
943                      const gfc_array_l1 *, const gfc_array_i16 *);
944 internal_proto(pack_i16);
945 #endif
946
947 extern void pack_r4 (gfc_array_r4 *, const gfc_array_r4 *,
948                      const gfc_array_l1 *, const gfc_array_r4 *);
949 internal_proto(pack_r4);
950
951 extern void pack_r8 (gfc_array_r8 *, const gfc_array_r8 *,
952                      const gfc_array_l1 *, const gfc_array_r8 *);
953 internal_proto(pack_r8);
954
955 #ifdef HAVE_GFC_REAL_10
956 extern void pack_r10 (gfc_array_r10 *, const gfc_array_r10 *,
957                      const gfc_array_l1 *, const gfc_array_r10 *);
958 internal_proto(pack_r10);
959 #endif
960
961 #ifdef HAVE_GFC_REAL_16
962 extern void pack_r16 (gfc_array_r16 *, const gfc_array_r16 *,
963                      const gfc_array_l1 *, const gfc_array_r16 *);
964 internal_proto(pack_r16);
965 #endif
966
967 extern void pack_c4 (gfc_array_c4 *, const gfc_array_c4 *,
968                      const gfc_array_l1 *, const gfc_array_c4 *);
969 internal_proto(pack_c4);
970
971 extern void pack_c8 (gfc_array_c8 *, const gfc_array_c8 *,
972                      const gfc_array_l1 *, const gfc_array_c8 *);
973 internal_proto(pack_c8);
974
975 #ifdef HAVE_GFC_REAL_10
976 extern void pack_c10 (gfc_array_c10 *, const gfc_array_c10 *,
977                      const gfc_array_l1 *, const gfc_array_c10 *);
978 internal_proto(pack_c10);
979 #endif
980
981 #ifdef HAVE_GFC_REAL_16
982 extern void pack_c16 (gfc_array_c16 *, const gfc_array_c16 *,
983                      const gfc_array_l1 *, const gfc_array_c16 *);
984 internal_proto(pack_c16);
985 #endif
986
987 /* Internal auxiliary functions for the unpack intrinsic.  */
988
989 extern void unpack0_i1 (gfc_array_i1 *, const gfc_array_i1 *,
990                         const gfc_array_l1 *, const GFC_INTEGER_1 *);
991 internal_proto(unpack0_i1);
992
993 extern void unpack0_i2 (gfc_array_i2 *, const gfc_array_i2 *,
994                         const gfc_array_l1 *, const GFC_INTEGER_2 *);
995 internal_proto(unpack0_i2);
996
997 extern void unpack0_i4 (gfc_array_i4 *, const gfc_array_i4 *,
998                         const gfc_array_l1 *, const GFC_INTEGER_4 *);
999 internal_proto(unpack0_i4);
1000
1001 extern void unpack0_i8 (gfc_array_i8 *, const gfc_array_i8 *,
1002                         const gfc_array_l1 *, const GFC_INTEGER_8 *);
1003 internal_proto(unpack0_i8);
1004
1005 #ifdef HAVE_GFC_INTEGER_16
1006
1007 extern void unpack0_i16 (gfc_array_i16 *, const gfc_array_i16 *,
1008                          const gfc_array_l1 *, const GFC_INTEGER_16 *);
1009 internal_proto(unpack0_i16);
1010
1011 #endif
1012
1013 extern void unpack0_r4 (gfc_array_r4 *, const gfc_array_r4 *,
1014                         const gfc_array_l1 *, const GFC_REAL_4 *);
1015 internal_proto(unpack0_r4);
1016
1017 extern void unpack0_r8 (gfc_array_r8 *, const gfc_array_r8 *,
1018                         const gfc_array_l1 *, const GFC_REAL_8 *);
1019 internal_proto(unpack0_r8);
1020
1021 #ifdef HAVE_GFC_REAL_10
1022
1023 extern void unpack0_r10 (gfc_array_r10 *, const gfc_array_r10 *,
1024                          const gfc_array_l1 *, const GFC_REAL_10 *);
1025 internal_proto(unpack0_r10);
1026
1027 #endif
1028
1029 #ifdef HAVE_GFC_REAL_16
1030
1031 extern void unpack0_r16 (gfc_array_r16 *, const gfc_array_r16 *,
1032                          const gfc_array_l1 *, const GFC_REAL_16 *);
1033 internal_proto(unpack0_r16);
1034
1035 #endif
1036
1037 extern void unpack0_c4 (gfc_array_c4 *, const gfc_array_c4 *,
1038                         const gfc_array_l1 *, const GFC_COMPLEX_4 *);
1039 internal_proto(unpack0_c4);
1040
1041 extern void unpack0_c8 (gfc_array_c8 *, const gfc_array_c8 *,
1042                         const gfc_array_l1 *, const GFC_COMPLEX_8 *);
1043 internal_proto(unpack0_c8);
1044
1045 #ifdef HAVE_GFC_COMPLEX_10
1046
1047 extern void unpack0_c10 (gfc_array_c10 *, const gfc_array_c10 *,
1048                          const gfc_array_l1 *mask, const GFC_COMPLEX_10 *);
1049 internal_proto(unpack0_c10);
1050
1051 #endif
1052
1053 #ifdef HAVE_GFC_COMPLEX_16
1054
1055 extern void unpack0_c16 (gfc_array_c16 *, const gfc_array_c16 *,
1056                          const gfc_array_l1 *, const GFC_COMPLEX_16 *);
1057 internal_proto(unpack0_c16);
1058
1059 #endif
1060
1061 extern void unpack1_i1 (gfc_array_i1 *, const gfc_array_i1 *,
1062                         const gfc_array_l1 *, const gfc_array_i1 *);
1063 internal_proto(unpack1_i1);
1064
1065 extern void unpack1_i2 (gfc_array_i2 *, const gfc_array_i2 *,
1066                         const gfc_array_l1 *, const gfc_array_i2 *);
1067 internal_proto(unpack1_i2);
1068
1069 extern void unpack1_i4 (gfc_array_i4 *, const gfc_array_i4 *,
1070                         const gfc_array_l1 *, const gfc_array_i4 *);
1071 internal_proto(unpack1_i4);
1072
1073 extern void unpack1_i8 (gfc_array_i8 *, const gfc_array_i8 *,
1074                         const gfc_array_l1 *, const gfc_array_i8 *);
1075 internal_proto(unpack1_i8);
1076
1077 #ifdef HAVE_GFC_INTEGER_16
1078 extern void unpack1_i16 (gfc_array_i16 *, const gfc_array_i16 *,
1079                          const gfc_array_l1 *, const gfc_array_i16 *);
1080 internal_proto(unpack1_i16);
1081 #endif
1082
1083 extern void unpack1_r4 (gfc_array_r4 *, const gfc_array_r4 *,
1084                         const gfc_array_l1 *, const gfc_array_r4 *);
1085 internal_proto(unpack1_r4);
1086
1087 extern void unpack1_r8 (gfc_array_r8 *, const gfc_array_r8 *,
1088                         const gfc_array_l1 *, const gfc_array_r8 *);
1089 internal_proto(unpack1_r8);
1090
1091 #ifdef HAVE_GFC_REAL_10
1092 extern void unpack1_r10 (gfc_array_r10 *, const gfc_array_r10 *,
1093                          const gfc_array_l1 *, const gfc_array_r10 *);
1094 internal_proto(unpack1_r10);
1095 #endif
1096
1097 #ifdef HAVE_GFC_REAL_16
1098 extern void unpack1_r16 (gfc_array_r16 *, const gfc_array_r16 *,
1099                          const gfc_array_l1 *, const gfc_array_r16 *);
1100 internal_proto(unpack1_r16);
1101 #endif
1102
1103 extern void unpack1_c4 (gfc_array_c4 *, const gfc_array_c4 *,
1104                         const gfc_array_l1 *, const gfc_array_c4 *);
1105 internal_proto(unpack1_c4);
1106
1107 extern void unpack1_c8 (gfc_array_c8 *, const gfc_array_c8 *,
1108                         const gfc_array_l1 *, const gfc_array_c8 *);
1109 internal_proto(unpack1_c8);
1110
1111 #ifdef HAVE_GFC_COMPLEX_10
1112 extern void unpack1_c10 (gfc_array_c10 *, const gfc_array_c10 *,
1113                          const gfc_array_l1 *, const gfc_array_c10 *);
1114 internal_proto(unpack1_c10);
1115 #endif
1116
1117 #ifdef HAVE_GFC_COMPLEX_16
1118 extern void unpack1_c16 (gfc_array_c16 *, const gfc_array_c16 *,
1119                          const gfc_array_l1 *, const gfc_array_c16 *);
1120 internal_proto(unpack1_c16);
1121 #endif
1122
1123 /* Helper functions for spread.  */
1124
1125 extern void spread_i1 (gfc_array_i1 *, const gfc_array_i1 *,
1126                        const index_type, const index_type);
1127 internal_proto(spread_i1);
1128
1129 extern void spread_i2 (gfc_array_i2 *, const gfc_array_i2 *,
1130                        const index_type, const index_type);
1131 internal_proto(spread_i2);
1132
1133 extern void spread_i4 (gfc_array_i4 *, const gfc_array_i4 *,
1134                        const index_type, const index_type);
1135 internal_proto(spread_i4);
1136
1137 extern void spread_i8 (gfc_array_i8 *, const gfc_array_i8 *,
1138                        const index_type, const index_type);
1139 internal_proto(spread_i8);
1140
1141 #ifdef HAVE_GFC_INTEGER_16
1142 extern void spread_i16 (gfc_array_i16 *, const gfc_array_i16 *,
1143                        const index_type, const index_type);
1144 internal_proto(spread_i16);
1145
1146 #endif
1147
1148 extern void spread_r4 (gfc_array_r4 *, const gfc_array_r4 *,
1149                        const index_type, const index_type);
1150 internal_proto(spread_r4);
1151
1152 extern void spread_r8 (gfc_array_r8 *, const gfc_array_r8 *,
1153                        const index_type, const index_type);
1154 internal_proto(spread_r8);
1155
1156 #ifdef HAVE_GFC_REAL_10
1157 extern void spread_r10 (gfc_array_r10 *, const gfc_array_r10 *,
1158                        const index_type, const index_type);
1159 internal_proto(spread_r10);
1160
1161 #endif
1162
1163 #ifdef HAVE_GFC_REAL_16
1164 extern void spread_r16 (gfc_array_r16 *, const gfc_array_r16 *,
1165                        const index_type, const index_type);
1166 internal_proto(spread_r16);
1167
1168 #endif
1169
1170 extern void spread_c4 (gfc_array_c4 *, const gfc_array_c4 *,
1171                        const index_type, const index_type);
1172 internal_proto(spread_c4);
1173
1174 extern void spread_c8 (gfc_array_c8 *, const gfc_array_c8 *,
1175                        const index_type, const index_type);
1176 internal_proto(spread_c8);
1177
1178 #ifdef HAVE_GFC_COMPLEX_10
1179 extern void spread_c10 (gfc_array_c10 *, const gfc_array_c10 *,
1180                        const index_type, const index_type);
1181 internal_proto(spread_c10);
1182
1183 #endif
1184
1185 #ifdef HAVE_GFC_COMPLEX_16
1186 extern void spread_c16 (gfc_array_c16 *, const gfc_array_c16 *,
1187                        const index_type, const index_type);
1188 internal_proto(spread_c16);
1189
1190 #endif
1191
1192 extern void spread_scalar_i1 (gfc_array_i1 *, const GFC_INTEGER_1 *,
1193                               const index_type, const index_type);
1194 internal_proto(spread_scalar_i1);
1195
1196 extern void spread_scalar_i2 (gfc_array_i2 *, const GFC_INTEGER_2 *,
1197                               const index_type, const index_type);
1198 internal_proto(spread_scalar_i2);
1199
1200 extern void spread_scalar_i4 (gfc_array_i4 *, const GFC_INTEGER_4 *,
1201                               const index_type, const index_type);
1202 internal_proto(spread_scalar_i4);
1203
1204 extern void spread_scalar_i8 (gfc_array_i8 *, const GFC_INTEGER_8 *,
1205                               const index_type, const index_type);
1206 internal_proto(spread_scalar_i8);
1207
1208 #ifdef HAVE_GFC_INTEGER_16
1209 extern void spread_scalar_i16 (gfc_array_i16 *, const GFC_INTEGER_16 *,
1210                                const index_type, const index_type);
1211 internal_proto(spread_scalar_i16);
1212
1213 #endif
1214
1215 extern void spread_scalar_r4 (gfc_array_r4 *, const GFC_REAL_4 *,
1216                               const index_type, const index_type);
1217 internal_proto(spread_scalar_r4);
1218
1219 extern void spread_scalar_r8 (gfc_array_r8 *, const GFC_REAL_8 *,
1220                               const index_type, const index_type);
1221 internal_proto(spread_scalar_r8);
1222
1223 #ifdef HAVE_GFC_REAL_10
1224 extern void spread_scalar_r10 (gfc_array_r10 *, const GFC_REAL_10 *,
1225                                const index_type, const index_type);
1226 internal_proto(spread_scalar_r10);
1227
1228 #endif
1229
1230 #ifdef HAVE_GFC_REAL_16
1231 extern void spread_scalar_r16 (gfc_array_r16 *, const GFC_REAL_16 *,
1232                                const index_type, const index_type);
1233 internal_proto(spread_scalar_r16);
1234
1235 #endif
1236
1237 extern void spread_scalar_c4 (gfc_array_c4 *, const GFC_COMPLEX_4 *,
1238                               const index_type, const index_type);
1239 internal_proto(spread_scalar_c4);
1240
1241 extern void spread_scalar_c8 (gfc_array_c8 *, const GFC_COMPLEX_8 *,
1242                               const index_type, const index_type);
1243 internal_proto(spread_scalar_c8);
1244
1245 #ifdef HAVE_GFC_COMPLEX_10
1246 extern void spread_scalar_c10 (gfc_array_c10 *, const GFC_COMPLEX_10 *,
1247                                const index_type, const index_type);
1248 internal_proto(spread_scalar_c10);
1249
1250 #endif
1251
1252 #ifdef HAVE_GFC_COMPLEX_16
1253 extern void spread_scalar_c16 (gfc_array_c16 *, const GFC_COMPLEX_16 *,
1254                                const index_type, const index_type);
1255 internal_proto(spread_scalar_c16);
1256
1257 #endif
1258
1259 /* string_intrinsics.c */
1260
1261 extern int compare_string (gfc_charlen_type, const char *,
1262                            gfc_charlen_type, const char *);
1263 iexport_proto(compare_string);
1264
1265 extern int compare_string_char4 (gfc_charlen_type, const gfc_char4_t *,
1266                                  gfc_charlen_type, const gfc_char4_t *);
1267 iexport_proto(compare_string_char4);
1268
1269 /* random.c */
1270
1271 extern void random_seed_i4 (GFC_INTEGER_4 * size, gfc_array_i4 * put,
1272                             gfc_array_i4 * get);
1273 iexport_proto(random_seed_i4);
1274 extern void random_seed_i8 (GFC_INTEGER_8 * size, gfc_array_i8 * put,
1275                             gfc_array_i8 * get);
1276 iexport_proto(random_seed_i8);
1277
1278 /* size.c */
1279
1280 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, void) array_t;
1281
1282 extern index_type size0 (const array_t * array); 
1283 iexport_proto(size0);
1284
1285 /* bounds.c */
1286
1287 extern void bounds_equal_extents (array_t *, array_t *, const char *,
1288                                   const char *);
1289 internal_proto(bounds_equal_extents);
1290
1291 extern void bounds_reduced_extents (array_t *, array_t *, int, const char *,
1292                              const char *intrinsic);
1293 internal_proto(bounds_reduced_extents);
1294
1295 extern void bounds_iforeach_return (array_t *, array_t *, const char *);
1296 internal_proto(bounds_iforeach_return);
1297
1298 extern void bounds_ifunction_return (array_t *, const index_type *,
1299                                      const char *, const char *);
1300 internal_proto(bounds_ifunction_return);
1301
1302 extern index_type count_0 (const gfc_array_l1 *);
1303
1304 internal_proto(count_0);
1305
1306 /* Internal auxiliary functions for cshift */
1307
1308 void cshift0_i1 (gfc_array_i1 *, const gfc_array_i1 *, ssize_t, int);
1309 internal_proto(cshift0_i1);
1310
1311 void cshift0_i2 (gfc_array_i2 *, const gfc_array_i2 *, ssize_t, int);
1312 internal_proto(cshift0_i2);
1313
1314 void cshift0_i4 (gfc_array_i4 *, const gfc_array_i4 *, ssize_t, int);
1315 internal_proto(cshift0_i4);
1316
1317 void cshift0_i8 (gfc_array_i8 *, const gfc_array_i8 *, ssize_t, int);
1318 internal_proto(cshift0_i8);
1319
1320 #ifdef HAVE_GFC_INTEGER_16
1321 void cshift0_i16 (gfc_array_i16 *, const gfc_array_i16 *, ssize_t, int);
1322 internal_proto(cshift0_i16);
1323 #endif
1324
1325 void cshift0_r4 (gfc_array_r4 *, const gfc_array_r4 *, ssize_t, int);
1326 internal_proto(cshift0_r4);
1327
1328 void cshift0_r8 (gfc_array_r8 *, const gfc_array_r8 *, ssize_t, int);
1329 internal_proto(cshift0_r8);
1330
1331 #ifdef HAVE_GFC_REAL_10
1332 void cshift0_r10 (gfc_array_r10 *, const gfc_array_r10 *, ssize_t, int);
1333 internal_proto(cshift0_r10);
1334 #endif
1335
1336 #ifdef HAVE_GFC_REAL_16
1337 void cshift0_r16 (gfc_array_r16 *, const gfc_array_r16 *, ssize_t, int);
1338 internal_proto(cshift0_r16);
1339 #endif
1340
1341 void cshift0_c4 (gfc_array_c4 *, const gfc_array_c4 *, ssize_t, int);
1342 internal_proto(cshift0_c4);
1343
1344 void cshift0_c8 (gfc_array_c8 *, const gfc_array_c8 *, ssize_t, int);
1345 internal_proto(cshift0_c8);
1346
1347 #ifdef HAVE_GFC_COMPLEX_10
1348 void cshift0_c10 (gfc_array_c10 *, const gfc_array_c10 *, ssize_t, int);
1349 internal_proto(cshift0_c10);
1350 #endif
1351
1352 #ifdef HAVE_GFC_COMPLEX_16
1353 void cshift0_c16 (gfc_array_c16 *, const gfc_array_c16 *, ssize_t, int);
1354 internal_proto(cshift0_c16);
1355 #endif
1356
1357 #endif  /* LIBGFOR_H  */