OSDN Git Service

2009-07-10 Steven G. Kargl <kargl@gcc.gnu.org>
[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
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 95 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 /* config.h MUST be first because it can affect system headers.  */
32 #include "config.h"
33
34 #include <stdio.h>
35 #include <math.h>
36 #include <stddef.h>
37 #include <float.h>
38 #include <stdarg.h>
39
40 #if HAVE_COMPLEX_H
41 # include <complex.h>
42 #else
43 #define complex __complex__
44 #endif
45
46 #include "../gcc/fortran/libgfortran.h"
47
48 #include "c99_protos.h"
49
50 #if HAVE_IEEEFP_H
51 #include <ieeefp.h>
52 #endif
53
54 #include "gstdint.h"
55
56 #if HAVE_SYS_TYPES_H
57 #include <sys/types.h>
58 #endif
59 typedef off_t gfc_offset;
60
61 #ifndef NULL
62 #define NULL (void *) 0
63 #endif
64
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
73
74
75 /* We use intptr_t and uintptr_t, which may not be always defined in
76    system headers.  */
77
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
91
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
105
106
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
116
117
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
123
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)
129
130 /* There are several classifications of routines:
131
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.
136
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.
140
141    One of the following should be used immediately after the declaration
142    of each symbol:
143
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.
148
149      export_proto       Marks a symbol to be exported, and adds PREFIX
150                         to the assembly-level symbol name.
151
152      export_proto_np    Marks a symbol to be exported without adding PREFIX.
153
154      iexport_proto      Marks a function to be exported, but with the 
155                         understanding that it can be used inside as well.
156
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.
161
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.  */
164
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
171
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
193
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
197
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
203
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.
207
208    Also, isfinite is broken on Cygwin.
209
210    When isfinite is not available, try to use one of the
211    alternatives, or bail out.  */
212
213 #if defined(HAVE_BROKEN_ISFINITE) || defined(__CYGWIN__)
214 #undef isfinite
215 #endif
216
217 #if defined(HAVE_BROKEN_ISNAN)
218 #undef isnan
219 #endif
220
221 #if defined(HAVE_BROKEN_FPCLASSIFY)
222 #undef fpclassify
223 #endif
224
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)  */
232
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)  */
240
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_);}
245
246 #include "kinds.h"
247
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
259
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;
264
265 /* The type used for the lengths of character variables.  */
266 typedef GFC_INTEGER_4 gfc_charlen_type;
267
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;
272
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)
276
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);
280
281 #define GFOR_POINTER_TO_L1(p, kind) \
282   (big_endian * (kind - 1) + (GFC_LOGICAL_1 *)(p))
283
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
296
297
298 typedef struct descriptor_dimension
299 {
300   index_type _stride;
301   index_type _lbound;
302   index_type _ubound;
303 }
304
305 descriptor_dimension;
306
307 #define GFC_ARRAY_DESCRIPTOR(r, type) \
308 struct {\
309   type *data;\
310   size_t offset;\
311   index_type dtype;\
312   descriptor_dimension dim[r];\
313 }
314
315 /* Commonly used array descriptor types.  */
316 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, void) gfc_array_void;
317 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, char) gfc_array_char;
318 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_1) gfc_array_i1;
319 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_2) gfc_array_i2;
320 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_4) gfc_array_i4;
321 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_8) gfc_array_i8;
322 #ifdef HAVE_GFC_INTEGER_16
323 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_16) gfc_array_i16;
324 #endif
325 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_4) gfc_array_r4;
326 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_8) gfc_array_r8;
327 #ifdef HAVE_GFC_REAL_10
328 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_10) gfc_array_r10;
329 #endif
330 #ifdef HAVE_GFC_REAL_16
331 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_16) gfc_array_r16;
332 #endif
333 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_4) gfc_array_c4;
334 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_8) gfc_array_c8;
335 #ifdef HAVE_GFC_COMPLEX_10
336 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_10) gfc_array_c10;
337 #endif
338 #ifdef HAVE_GFC_COMPLEX_16
339 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_16) gfc_array_c16;
340 #endif
341 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_1) gfc_array_l1;
342 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_2) gfc_array_l2;
343 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_4) gfc_array_l4;
344 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_8) gfc_array_l8;
345 #ifdef HAVE_GFC_LOGICAL_16
346 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_16) gfc_array_l16;
347 #endif
348
349
350 #define GFC_DESCRIPTOR_RANK(desc) ((desc)->dtype & GFC_DTYPE_RANK_MASK)
351 #define GFC_DESCRIPTOR_TYPE(desc) (((desc)->dtype & GFC_DTYPE_TYPE_MASK) \
352                                    >> GFC_DTYPE_TYPE_SHIFT)
353 #define GFC_DESCRIPTOR_SIZE(desc) ((desc)->dtype >> GFC_DTYPE_SIZE_SHIFT)
354 #define GFC_DESCRIPTOR_DATA(desc) ((desc)->data)
355 #define GFC_DESCRIPTOR_DTYPE(desc) ((desc)->dtype)
356
357 #define GFC_DIMENSION_LBOUND(dim) ((dim)._lbound)
358 #define GFC_DIMENSION_UBOUND(dim) ((dim)._ubound)
359 #define GFC_DIMENSION_STRIDE(dim) ((dim)._stride)
360 #define GFC_DIMENSION_EXTENT(dim) ((dim)._ubound + 1 - (dim)._lbound)
361 #define GFC_DIMENSION_SET(dim,lb,ub,str) \
362   do \
363     { \
364       (dim)._lbound = lb;                       \
365       (dim)._ubound = ub;                       \
366       (dim)._stride = str;                      \
367     } while (0)
368             
369
370 #define GFC_DESCRIPTOR_LBOUND(desc,i) ((desc)->dim[i]._lbound)
371 #define GFC_DESCRIPTOR_UBOUND(desc,i) ((desc)->dim[i]._ubound)
372 #define GFC_DESCRIPTOR_EXTENT(desc,i) ((desc)->dim[i]._ubound + 1 \
373                                       - (desc)->dim[i]._lbound)
374 #define GFC_DESCRIPTOR_EXTENT_BYTES(desc,i) \
375   (GFC_DESCRIPTOR_EXTENT(desc,i) * GFC_DESCRIPTOR_SIZE(desc))
376
377 #define GFC_DESCRIPTOR_STRIDE(desc,i) ((desc)->dim[i]._stride)
378 #define GFC_DESCRIPTOR_STRIDE_BYTES(desc,i) \
379   (GFC_DESCRIPTOR_STRIDE(desc,i) * GFC_DESCRIPTOR_SIZE(desc))
380
381 /* Macros to get both the size and the type with a single masking operation  */
382
383 #define GFC_DTYPE_SIZE_MASK \
384   ((~((index_type) 0) >> GFC_DTYPE_SIZE_SHIFT) << GFC_DTYPE_SIZE_SHIFT)
385 #define GFC_DTYPE_TYPE_SIZE_MASK (GFC_DTYPE_SIZE_MASK | GFC_DTYPE_TYPE_MASK)
386
387 #define GFC_DTYPE_TYPE_SIZE(desc) ((desc)->dtype & GFC_DTYPE_TYPE_SIZE_MASK)
388
389 #define GFC_DTYPE_INTEGER_1 ((GFC_DTYPE_INTEGER << GFC_DTYPE_TYPE_SHIFT) \
390    | (sizeof(GFC_INTEGER_1) << GFC_DTYPE_SIZE_SHIFT))
391 #define GFC_DTYPE_INTEGER_2 ((GFC_DTYPE_INTEGER << GFC_DTYPE_TYPE_SHIFT) \
392    | (sizeof(GFC_INTEGER_2) << GFC_DTYPE_SIZE_SHIFT))
393 #define GFC_DTYPE_INTEGER_4 ((GFC_DTYPE_INTEGER << GFC_DTYPE_TYPE_SHIFT) \
394    | (sizeof(GFC_INTEGER_4) << GFC_DTYPE_SIZE_SHIFT))
395 #define GFC_DTYPE_INTEGER_8 ((GFC_DTYPE_INTEGER << GFC_DTYPE_TYPE_SHIFT) \
396    | (sizeof(GFC_INTEGER_8) << GFC_DTYPE_SIZE_SHIFT))
397 #ifdef HAVE_GFC_INTEGER_16
398 #define GFC_DTYPE_INTEGER_16 ((GFC_DTYPE_INTEGER << GFC_DTYPE_TYPE_SHIFT) \
399    | (sizeof(GFC_INTEGER_16) << GFC_DTYPE_SIZE_SHIFT))
400 #endif
401
402 #define GFC_DTYPE_LOGICAL_1 ((GFC_DTYPE_LOGICAL << GFC_DTYPE_TYPE_SHIFT) \
403    | (sizeof(GFC_LOGICAL_1) << GFC_DTYPE_SIZE_SHIFT))
404 #define GFC_DTYPE_LOGICAL_2 ((GFC_DTYPE_LOGICAL << GFC_DTYPE_TYPE_SHIFT) \
405    | (sizeof(GFC_LOGICAL_2) << GFC_DTYPE_SIZE_SHIFT))
406 #define GFC_DTYPE_LOGICAL_4 ((GFC_DTYPE_LOGICAL << GFC_DTYPE_TYPE_SHIFT) \
407    | (sizeof(GFC_LOGICAL_4) << GFC_DTYPE_SIZE_SHIFT))
408 #define GFC_DTYPE_LOGICAL_8 ((GFC_DTYPE_LOGICAL << GFC_DTYPE_TYPE_SHIFT) \
409    | (sizeof(GFC_LOGICAL_8) << GFC_DTYPE_SIZE_SHIFT))
410 #ifdef HAVE_GFC_LOGICAL_16
411 #define GFC_DTYPE_LOGICAL_16 ((GFC_DTYPE_LOGICAL << GFC_DTYPE_TYPE_SHIFT) \
412    | (sizeof(GFC_LOGICAL_16) << GFC_DTYPE_SIZE_SHIFT))
413 #endif
414
415 #define GFC_DTYPE_REAL_4 ((GFC_DTYPE_REAL << GFC_DTYPE_TYPE_SHIFT) \
416    | (sizeof(GFC_REAL_4) << GFC_DTYPE_SIZE_SHIFT))
417 #define GFC_DTYPE_REAL_8 ((GFC_DTYPE_REAL << GFC_DTYPE_TYPE_SHIFT) \
418    | (sizeof(GFC_REAL_8) << GFC_DTYPE_SIZE_SHIFT))
419 #ifdef HAVE_GFC_REAL_10
420 #define GFC_DTYPE_REAL_10  ((GFC_DTYPE_REAL << GFC_DTYPE_TYPE_SHIFT) \
421    | (sizeof(GFC_REAL_10) << GFC_DTYPE_SIZE_SHIFT))
422 #endif
423 #ifdef HAVE_GFC_REAL_16
424 #define GFC_DTYPE_REAL_16 ((GFC_DTYPE_REAL << GFC_DTYPE_TYPE_SHIFT) \
425    | (sizeof(GFC_REAL_16) << GFC_DTYPE_SIZE_SHIFT))
426 #endif
427
428 #define GFC_DTYPE_COMPLEX_4 ((GFC_DTYPE_COMPLEX << GFC_DTYPE_TYPE_SHIFT) \
429    | (sizeof(GFC_COMPLEX_4) << GFC_DTYPE_SIZE_SHIFT))
430 #define GFC_DTYPE_COMPLEX_8 ((GFC_DTYPE_COMPLEX << GFC_DTYPE_TYPE_SHIFT) \
431    | (sizeof(GFC_COMPLEX_8) << GFC_DTYPE_SIZE_SHIFT))
432 #ifdef HAVE_GFC_COMPLEX_10
433 #define GFC_DTYPE_COMPLEX_10 ((GFC_DTYPE_COMPLEX << GFC_DTYPE_TYPE_SHIFT) \
434    | (sizeof(GFC_COMPLEX_10) << GFC_DTYPE_SIZE_SHIFT))
435 #endif
436 #ifdef HAVE_GFC_COMPLEX_16
437 #define GFC_DTYPE_COMPLEX_16 ((GFC_DTYPE_COMPLEX << GFC_DTYPE_TYPE_SHIFT) \
438    | (sizeof(GFC_COMPLEX_16) << GFC_DTYPE_SIZE_SHIFT))
439 #endif
440
441 #define GFC_DTYPE_DERIVED_1 ((GFC_DTYPE_DERIVED << GFC_DTYPE_TYPE_SHIFT) \
442    | (sizeof(GFC_INTEGER_1) << GFC_DTYPE_SIZE_SHIFT))
443 #define GFC_DTYPE_DERIVED_2 ((GFC_DTYPE_DERIVED << GFC_DTYPE_TYPE_SHIFT) \
444    | (sizeof(GFC_INTEGER_2) << GFC_DTYPE_SIZE_SHIFT))
445 #define GFC_DTYPE_DERIVED_4 ((GFC_DTYPE_DERIVED << GFC_DTYPE_TYPE_SHIFT) \
446    | (sizeof(GFC_INTEGER_4) << GFC_DTYPE_SIZE_SHIFT))
447 #define GFC_DTYPE_DERIVED_8 ((GFC_DTYPE_DERIVED << GFC_DTYPE_TYPE_SHIFT) \
448    | (sizeof(GFC_INTEGER_8) << GFC_DTYPE_SIZE_SHIFT))
449 #ifdef HAVE_GFC_INTEGER_16
450 #define GFC_DTYPE_DERIVED_16 ((GFC_DTYPE_DERIVED << GFC_DTYPE_TYPE_SHIFT) \
451    | (sizeof(GFC_INTEGER_16) << GFC_DTYPE_SIZE_SHIFT))
452 #endif
453
454 /* Macros to determine the alignment of pointers.  */
455
456 #define GFC_UNALIGNED_2(x) (((uintptr_t)(x)) & \
457                             (__alignof__(GFC_INTEGER_2) - 1))
458 #define GFC_UNALIGNED_4(x) (((uintptr_t)(x)) & \
459                             (__alignof__(GFC_INTEGER_4) - 1))
460 #define GFC_UNALIGNED_8(x) (((uintptr_t)(x)) & \
461                             (__alignof__(GFC_INTEGER_8) - 1))
462 #ifdef HAVE_GFC_INTEGER_16
463 #define GFC_UNALIGNED_16(x) (((uintptr_t)(x)) & \
464                              (__alignof__(GFC_INTEGER_16) - 1))
465 #endif
466
467 #define GFC_UNALIGNED_C4(x) (((uintptr_t)(x)) & \
468                              (__alignof__(GFC_COMPLEX_4) - 1))
469
470 #define GFC_UNALIGNED_C8(x) (((uintptr_t)(x)) & \
471                              (__alignof__(GFC_COMPLEX_8) - 1))
472
473 /* Runtime library include.  */
474 #define stringize(x) expand_macro(x)
475 #define expand_macro(x) # x
476
477 /* Runtime options structure.  */
478
479 typedef struct
480 {
481   int stdin_unit, stdout_unit, stderr_unit, optional_plus;
482   int locus;
483
484   int separator_len;
485   const char *separator;
486
487   int use_stderr, all_unbuffered, unbuffered_preconnected, default_recl;
488   int fpe, dump_core, backtrace;
489 }
490 options_t;
491
492 extern options_t options;
493 internal_proto(options);
494
495 extern void handler (int);
496 internal_proto(handler);
497
498
499 /* Compile-time options that will influence the library.  */
500
501 typedef struct
502 {
503   int warn_std;
504   int allow_std;
505   int pedantic;
506   int convert;
507   int dump_core;
508   int backtrace;
509   int sign_zero;
510   size_t record_marker;
511   int max_subrecord_length;
512   int bounds_check;
513   int range_check;
514 }
515 compile_options_t;
516
517 extern compile_options_t compile_options;
518 internal_proto(compile_options);
519
520 extern void init_compile_options (void);
521 internal_proto(init_compile_options);
522
523 #define GFC_MAX_SUBRECORD_LENGTH 2147483639   /* 2**31 - 9 */
524
525 /* Structure for statement options.  */
526
527 typedef struct
528 {
529   const char *name;
530   int value;
531 }
532 st_option;
533
534
535 /* This is returned by notification_std to know if, given the flags
536    that were given (-std=, -pedantic) we should issue an error, a warning
537    or nothing.  */
538 typedef enum
539 { SILENT, WARNING, ERROR }
540 notification;
541
542 /* This is returned by notify_std and several io functions.  */
543 typedef enum
544 { SUCCESS = 1, FAILURE }
545 try;
546
547 /* The filename and line number don't go inside the globals structure.
548    They are set by the rest of the program and must be linked to.  */
549
550 /* Location of the current library call (optional).  */
551 extern unsigned line;
552 iexport_data_proto(line);
553
554 extern char *filename;
555 iexport_data_proto(filename);
556
557 /* Avoid conflicting prototypes of alloca() in system headers by using 
558    GCC's builtin alloca().  */
559 #define gfc_alloca(x)  __builtin_alloca(x)
560
561
562 /* Directory for creating temporary files.  Only used when none of the
563    following environment variables exist: GFORTRAN_TMPDIR, TMP and TEMP.  */
564 #define DEFAULT_TEMPDIR "/tmp"
565
566 /* The default value of record length for preconnected units is defined
567    here. This value can be overriden by an environment variable.
568    Default value is 1 Gb.  */
569 #define DEFAULT_RECL 1073741824
570
571
572 #define CHARACTER2(name) \
573               gfc_charlen_type name ## _len; \
574               char * name
575
576 typedef struct st_parameter_common
577 {
578   GFC_INTEGER_4 flags;
579   GFC_INTEGER_4 unit;
580   const char *filename;
581   GFC_INTEGER_4 line;
582   CHARACTER2 (iomsg);
583   GFC_INTEGER_4 *iostat;
584 }
585 st_parameter_common;
586
587 #undef CHARACTER2
588
589 #define IOPARM_LIBRETURN_MASK           (3 << 0)
590 #define IOPARM_LIBRETURN_OK             (0 << 0)
591 #define IOPARM_LIBRETURN_ERROR          (1 << 0)
592 #define IOPARM_LIBRETURN_END            (2 << 0)
593 #define IOPARM_LIBRETURN_EOR            (3 << 0)
594 #define IOPARM_ERR                      (1 << 2)
595 #define IOPARM_END                      (1 << 3)
596 #define IOPARM_EOR                      (1 << 4)
597 #define IOPARM_HAS_IOSTAT               (1 << 5)
598 #define IOPARM_HAS_IOMSG                (1 << 6)
599
600 #define IOPARM_COMMON_MASK              ((1 << 7) - 1)
601
602 #define IOPARM_OPEN_HAS_RECL_IN         (1 << 7)
603 #define IOPARM_OPEN_HAS_FILE            (1 << 8)
604 #define IOPARM_OPEN_HAS_STATUS          (1 << 9)
605 #define IOPARM_OPEN_HAS_ACCESS          (1 << 10)
606 #define IOPARM_OPEN_HAS_FORM            (1 << 11)
607 #define IOPARM_OPEN_HAS_BLANK           (1 << 12)
608 #define IOPARM_OPEN_HAS_POSITION        (1 << 13)
609 #define IOPARM_OPEN_HAS_ACTION          (1 << 14)
610 #define IOPARM_OPEN_HAS_DELIM           (1 << 15)
611 #define IOPARM_OPEN_HAS_PAD             (1 << 16)
612 #define IOPARM_OPEN_HAS_CONVERT         (1 << 17)
613 #define IOPARM_OPEN_HAS_DECIMAL         (1 << 18)
614 #define IOPARM_OPEN_HAS_ENCODING        (1 << 19)
615 #define IOPARM_OPEN_HAS_ROUND           (1 << 20)
616 #define IOPARM_OPEN_HAS_SIGN            (1 << 21)
617 #define IOPARM_OPEN_HAS_ASYNCHRONOUS    (1 << 22)
618 #define IOPARM_OPEN_HAS_NEWUNIT         (1 << 23)
619
620 /* library start function and end macro.  These can be expanded if needed
621    in the future.  cmp is st_parameter_common *cmp  */
622
623 extern void library_start (st_parameter_common *);
624 internal_proto(library_start);
625
626 #define library_end()
627
628 /* main.c */
629
630 extern void stupid_function_name_for_static_linking (void);
631 internal_proto(stupid_function_name_for_static_linking);
632
633 extern void set_args (int, char **);
634 iexport_proto(set_args);
635
636 extern void get_args (int *, char ***);
637 internal_proto(get_args);
638
639 extern void store_exe_path (const char *);
640 export_proto(store_exe_path);
641
642 extern char * full_exe_path (void);
643 internal_proto(full_exe_path);
644
645 /* backtrace.c */
646
647 extern void show_backtrace (void);
648 internal_proto(show_backtrace);
649
650 /* error.c */
651
652 #define GFC_ITOA_BUF_SIZE (sizeof (GFC_INTEGER_LARGEST) * 3 + 2)
653 #define GFC_XTOA_BUF_SIZE (sizeof (GFC_UINTEGER_LARGEST) * 2 + 1)
654 #define GFC_OTOA_BUF_SIZE (sizeof (GFC_INTEGER_LARGEST) * 3 + 1)
655 #define GFC_BTOA_BUF_SIZE (sizeof (GFC_INTEGER_LARGEST) * 8 + 1)
656
657 extern void sys_exit (int) __attribute__ ((noreturn));
658 internal_proto(sys_exit);
659
660 extern const char *gfc_xtoa (GFC_UINTEGER_LARGEST, char *, size_t);
661 internal_proto(gfc_xtoa);
662
663 extern void os_error (const char *) __attribute__ ((noreturn));
664 iexport_proto(os_error);
665
666 extern void show_locus (st_parameter_common *);
667 internal_proto(show_locus);
668
669 extern void runtime_error (const char *, ...)
670      __attribute__ ((noreturn, format (printf, 1, 2)));
671 iexport_proto(runtime_error);
672
673 extern void runtime_error_at (const char *, const char *, ...)
674      __attribute__ ((noreturn, format (printf, 2, 3)));
675 iexport_proto(runtime_error_at);
676
677 extern void runtime_warning_at (const char *, const char *, ...)
678      __attribute__ ((format (printf, 2, 3)));
679 iexport_proto(runtime_warning_at);
680
681 extern void internal_error (st_parameter_common *, const char *)
682   __attribute__ ((noreturn));
683 internal_proto(internal_error);
684
685 extern const char *get_oserror (void);
686 internal_proto(get_oserror);
687
688 extern const char *translate_error (int);
689 internal_proto(translate_error);
690
691 extern void generate_error (st_parameter_common *, int, const char *);
692 iexport_proto(generate_error);
693
694 extern try notify_std (st_parameter_common *, int, const char *);
695 internal_proto(notify_std);
696
697 extern notification notification_std(int);
698 internal_proto(notification_std);
699
700 /* fpu.c */
701
702 extern void set_fpu (void);
703 internal_proto(set_fpu);
704
705 /* memory.c */
706
707 extern void *get_mem (size_t) __attribute__ ((malloc));
708 internal_proto(get_mem);
709
710 extern void free_mem (void *);
711 internal_proto(free_mem);
712
713 extern void *internal_malloc_size (size_t) __attribute__ ((malloc));
714 internal_proto(internal_malloc_size);
715
716 /* environ.c */
717
718 extern int check_buffered (int);
719 internal_proto(check_buffered);
720
721 extern void init_variables (void);
722 internal_proto(init_variables);
723
724 extern void show_variables (void);
725 internal_proto(show_variables);
726
727 unit_convert get_unformatted_convert (int);
728 internal_proto(get_unformatted_convert);
729
730 /* string.c */
731
732 extern int find_option (st_parameter_common *, const char *, gfc_charlen_type,
733                         const st_option *, const char *);
734 internal_proto(find_option);
735
736 extern gfc_charlen_type fstrlen (const char *, gfc_charlen_type);
737 internal_proto(fstrlen);
738
739 extern gfc_charlen_type fstrcpy (char *, gfc_charlen_type, const char *, gfc_charlen_type);
740 internal_proto(fstrcpy);
741
742 extern gfc_charlen_type cf_strcpy (char *, gfc_charlen_type, const char *);
743 internal_proto(cf_strcpy);
744
745 /* io/intrinsics.c */
746
747 extern void flush_all_units (void);
748 internal_proto(flush_all_units);
749
750 /* io.c */
751
752 extern void init_units (void);
753 internal_proto(init_units);
754
755 extern void close_units (void);
756 internal_proto(close_units);
757
758 extern int unit_to_fd (int);
759 internal_proto(unit_to_fd);
760
761 extern int st_printf (const char *, ...)
762   __attribute__ ((format (printf, 1, 2)));
763 internal_proto(st_printf);
764
765 extern int st_vprintf (const char *, va_list);
766 internal_proto(st_vprintf);
767
768 extern char * filename_from_unit (int);
769 internal_proto(filename_from_unit);
770
771 /* stop.c */
772
773 extern void stop_numeric (GFC_INTEGER_4) __attribute__ ((noreturn));
774 iexport_proto(stop_numeric);
775
776 /* reshape_packed.c */
777
778 extern void reshape_packed (char *, index_type, const char *, index_type,
779                             const char *, index_type);
780 internal_proto(reshape_packed);
781
782 /* Repacking functions.  These are called internally by internal_pack
783    and internal_unpack.  */
784
785 GFC_INTEGER_1 *internal_pack_1 (gfc_array_i1 *);
786 internal_proto(internal_pack_1);
787
788 GFC_INTEGER_2 *internal_pack_2 (gfc_array_i2 *);
789 internal_proto(internal_pack_2);
790
791 GFC_INTEGER_4 *internal_pack_4 (gfc_array_i4 *);
792 internal_proto(internal_pack_4);
793
794 GFC_INTEGER_8 *internal_pack_8 (gfc_array_i8 *);
795 internal_proto(internal_pack_8);
796
797 #if defined HAVE_GFC_INTEGER_16
798 GFC_INTEGER_16 *internal_pack_16 (gfc_array_i16 *);
799 internal_proto(internal_pack_16);
800 #endif
801
802 GFC_REAL_4 *internal_pack_r4 (gfc_array_r4 *);
803 internal_proto(internal_pack_r4);
804
805 GFC_REAL_8 *internal_pack_r8 (gfc_array_r8 *);
806 internal_proto(internal_pack_r8);
807
808 #if defined HAVE_GFC_REAL_10
809 GFC_REAL_10 *internal_pack_r10 (gfc_array_r10 *);
810 internal_proto(internal_pack_r10);
811 #endif
812
813 #if defined HAVE_GFC_REAL_16
814 GFC_REAL_16 *internal_pack_r16 (gfc_array_r16 *);
815 internal_proto(internal_pack_r16);
816 #endif
817
818 GFC_COMPLEX_4 *internal_pack_c4 (gfc_array_c4 *);
819 internal_proto(internal_pack_c4);
820
821 GFC_COMPLEX_8 *internal_pack_c8 (gfc_array_c8 *);
822 internal_proto(internal_pack_c8);
823
824 #if defined HAVE_GFC_COMPLEX_10
825 GFC_COMPLEX_10 *internal_pack_c10 (gfc_array_c10 *);
826 internal_proto(internal_pack_c10);
827 #endif
828
829 #if defined HAVE_GFC_COMPLEX_16
830 GFC_COMPLEX_16 *internal_pack_c16 (gfc_array_c16 *);
831 internal_proto(internal_pack_c16);
832 #endif
833
834 extern void internal_unpack_1 (gfc_array_i1 *, const GFC_INTEGER_1 *);
835 internal_proto(internal_unpack_1);
836
837 extern void internal_unpack_2 (gfc_array_i2 *, const GFC_INTEGER_2 *);
838 internal_proto(internal_unpack_2);
839
840 extern void internal_unpack_4 (gfc_array_i4 *, const GFC_INTEGER_4 *);
841 internal_proto(internal_unpack_4);
842
843 extern void internal_unpack_8 (gfc_array_i8 *, const GFC_INTEGER_8 *);
844 internal_proto(internal_unpack_8);
845
846 #if defined HAVE_GFC_INTEGER_16
847 extern void internal_unpack_16 (gfc_array_i16 *, const GFC_INTEGER_16 *);
848 internal_proto(internal_unpack_16);
849 #endif
850
851 extern void internal_unpack_r4 (gfc_array_r4 *, const GFC_REAL_4 *);
852 internal_proto(internal_unpack_r4);
853
854 extern void internal_unpack_r8 (gfc_array_r8 *, const GFC_REAL_8 *);
855 internal_proto(internal_unpack_r8);
856
857 #if defined HAVE_GFC_REAL_10
858 extern void internal_unpack_r10 (gfc_array_r10 *, const GFC_REAL_10 *);
859 internal_proto(internal_unpack_r10);
860 #endif
861
862 #if defined HAVE_GFC_REAL_16
863 extern void internal_unpack_r16 (gfc_array_r16 *, const GFC_REAL_16 *);
864 internal_proto(internal_unpack_r16);
865 #endif
866
867 extern void internal_unpack_c4 (gfc_array_c4 *, const GFC_COMPLEX_4 *);
868 internal_proto(internal_unpack_c4);
869
870 extern void internal_unpack_c8 (gfc_array_c8 *, const GFC_COMPLEX_8 *);
871 internal_proto(internal_unpack_c8);
872
873 #if defined HAVE_GFC_COMPLEX_10
874 extern void internal_unpack_c10 (gfc_array_c10 *, const GFC_COMPLEX_10 *);
875 internal_proto(internal_unpack_c10);
876 #endif
877
878 #if defined HAVE_GFC_COMPLEX_16
879 extern void internal_unpack_c16 (gfc_array_c16 *, const GFC_COMPLEX_16 *);
880 internal_proto(internal_unpack_c16);
881 #endif
882
883 /* Internal auxiliary functions for the pack intrinsic.  */
884
885 extern void pack_i1 (gfc_array_i1 *, const gfc_array_i1 *,
886                      const gfc_array_l1 *, const gfc_array_i1 *);
887 internal_proto(pack_i1);
888
889 extern void pack_i2 (gfc_array_i2 *, const gfc_array_i2 *,
890                      const gfc_array_l1 *, const gfc_array_i2 *);
891 internal_proto(pack_i2);
892
893 extern void pack_i4 (gfc_array_i4 *, const gfc_array_i4 *,
894                      const gfc_array_l1 *, const gfc_array_i4 *);
895 internal_proto(pack_i4);
896
897 extern void pack_i8 (gfc_array_i8 *, const gfc_array_i8 *,
898                      const gfc_array_l1 *, const gfc_array_i8 *);
899 internal_proto(pack_i8);
900
901 #ifdef HAVE_GFC_INTEGER_16
902 extern void pack_i16 (gfc_array_i16 *, const gfc_array_i16 *,
903                      const gfc_array_l1 *, const gfc_array_i16 *);
904 internal_proto(pack_i16);
905 #endif
906
907 extern void pack_r4 (gfc_array_r4 *, const gfc_array_r4 *,
908                      const gfc_array_l1 *, const gfc_array_r4 *);
909 internal_proto(pack_r4);
910
911 extern void pack_r8 (gfc_array_r8 *, const gfc_array_r8 *,
912                      const gfc_array_l1 *, const gfc_array_r8 *);
913 internal_proto(pack_r8);
914
915 #ifdef HAVE_GFC_REAL_10
916 extern void pack_r10 (gfc_array_r10 *, const gfc_array_r10 *,
917                      const gfc_array_l1 *, const gfc_array_r10 *);
918 internal_proto(pack_r10);
919 #endif
920
921 #ifdef HAVE_GFC_REAL_16
922 extern void pack_r16 (gfc_array_r16 *, const gfc_array_r16 *,
923                      const gfc_array_l1 *, const gfc_array_r16 *);
924 internal_proto(pack_r16);
925 #endif
926
927 extern void pack_c4 (gfc_array_c4 *, const gfc_array_c4 *,
928                      const gfc_array_l1 *, const gfc_array_c4 *);
929 internal_proto(pack_c4);
930
931 extern void pack_c8 (gfc_array_c8 *, const gfc_array_c8 *,
932                      const gfc_array_l1 *, const gfc_array_c8 *);
933 internal_proto(pack_c8);
934
935 #ifdef HAVE_GFC_REAL_10
936 extern void pack_c10 (gfc_array_c10 *, const gfc_array_c10 *,
937                      const gfc_array_l1 *, const gfc_array_c10 *);
938 internal_proto(pack_c10);
939 #endif
940
941 #ifdef HAVE_GFC_REAL_16
942 extern void pack_c16 (gfc_array_c16 *, const gfc_array_c16 *,
943                      const gfc_array_l1 *, const gfc_array_c16 *);
944 internal_proto(pack_c16);
945 #endif
946
947 /* Internal auxiliary functions for the unpack intrinsic.  */
948
949 extern void unpack0_i1 (gfc_array_i1 *, const gfc_array_i1 *,
950                         const gfc_array_l1 *, const GFC_INTEGER_1 *);
951 internal_proto(unpack0_i1);
952
953 extern void unpack0_i2 (gfc_array_i2 *, const gfc_array_i2 *,
954                         const gfc_array_l1 *, const GFC_INTEGER_2 *);
955 internal_proto(unpack0_i2);
956
957 extern void unpack0_i4 (gfc_array_i4 *, const gfc_array_i4 *,
958                         const gfc_array_l1 *, const GFC_INTEGER_4 *);
959 internal_proto(unpack0_i4);
960
961 extern void unpack0_i8 (gfc_array_i8 *, const gfc_array_i8 *,
962                         const gfc_array_l1 *, const GFC_INTEGER_8 *);
963 internal_proto(unpack0_i8);
964
965 #ifdef HAVE_GFC_INTEGER_16
966
967 extern void unpack0_i16 (gfc_array_i16 *, const gfc_array_i16 *,
968                          const gfc_array_l1 *, const GFC_INTEGER_16 *);
969 internal_proto(unpack0_i16);
970
971 #endif
972
973 extern void unpack0_r4 (gfc_array_r4 *, const gfc_array_r4 *,
974                         const gfc_array_l1 *, const GFC_REAL_4 *);
975 internal_proto(unpack0_r4);
976
977 extern void unpack0_r8 (gfc_array_r8 *, const gfc_array_r8 *,
978                         const gfc_array_l1 *, const GFC_REAL_8 *);
979 internal_proto(unpack0_r8);
980
981 #ifdef HAVE_GFC_REAL_10
982
983 extern void unpack0_r10 (gfc_array_r10 *, const gfc_array_r10 *,
984                          const gfc_array_l1 *, const GFC_REAL_10 *);
985 internal_proto(unpack0_r10);
986
987 #endif
988
989 #ifdef HAVE_GFC_REAL_16
990
991 extern void unpack0_r16 (gfc_array_r16 *, const gfc_array_r16 *,
992                          const gfc_array_l1 *, const GFC_REAL_16 *);
993 internal_proto(unpack0_r16);
994
995 #endif
996
997 extern void unpack0_c4 (gfc_array_c4 *, const gfc_array_c4 *,
998                         const gfc_array_l1 *, const GFC_COMPLEX_4 *);
999 internal_proto(unpack0_c4);
1000
1001 extern void unpack0_c8 (gfc_array_c8 *, const gfc_array_c8 *,
1002                         const gfc_array_l1 *, const GFC_COMPLEX_8 *);
1003 internal_proto(unpack0_c8);
1004
1005 #ifdef HAVE_GFC_COMPLEX_10
1006
1007 extern void unpack0_c10 (gfc_array_c10 *, const gfc_array_c10 *,
1008                          const gfc_array_l1 *mask, const GFC_COMPLEX_10 *);
1009 internal_proto(unpack0_c10);
1010
1011 #endif
1012
1013 #ifdef HAVE_GFC_COMPLEX_16
1014
1015 extern void unpack0_c16 (gfc_array_c16 *, const gfc_array_c16 *,
1016                          const gfc_array_l1 *, const GFC_COMPLEX_16 *);
1017 internal_proto(unpack0_c16);
1018
1019 #endif
1020
1021 extern void unpack1_i1 (gfc_array_i1 *, const gfc_array_i1 *,
1022                         const gfc_array_l1 *, const gfc_array_i1 *);
1023 internal_proto(unpack1_i1);
1024
1025 extern void unpack1_i2 (gfc_array_i2 *, const gfc_array_i2 *,
1026                         const gfc_array_l1 *, const gfc_array_i2 *);
1027 internal_proto(unpack1_i2);
1028
1029 extern void unpack1_i4 (gfc_array_i4 *, const gfc_array_i4 *,
1030                         const gfc_array_l1 *, const gfc_array_i4 *);
1031 internal_proto(unpack1_i4);
1032
1033 extern void unpack1_i8 (gfc_array_i8 *, const gfc_array_i8 *,
1034                         const gfc_array_l1 *, const gfc_array_i8 *);
1035 internal_proto(unpack1_i8);
1036
1037 #ifdef HAVE_GFC_INTEGER_16
1038 extern void unpack1_i16 (gfc_array_i16 *, const gfc_array_i16 *,
1039                          const gfc_array_l1 *, const gfc_array_i16 *);
1040 internal_proto(unpack1_i16);
1041 #endif
1042
1043 extern void unpack1_r4 (gfc_array_r4 *, const gfc_array_r4 *,
1044                         const gfc_array_l1 *, const gfc_array_r4 *);
1045 internal_proto(unpack1_r4);
1046
1047 extern void unpack1_r8 (gfc_array_r8 *, const gfc_array_r8 *,
1048                         const gfc_array_l1 *, const gfc_array_r8 *);
1049 internal_proto(unpack1_r8);
1050
1051 #ifdef HAVE_GFC_REAL_10
1052 extern void unpack1_r10 (gfc_array_r10 *, const gfc_array_r10 *,
1053                          const gfc_array_l1 *, const gfc_array_r10 *);
1054 internal_proto(unpack1_r10);
1055 #endif
1056
1057 #ifdef HAVE_GFC_REAL_16
1058 extern void unpack1_r16 (gfc_array_r16 *, const gfc_array_r16 *,
1059                          const gfc_array_l1 *, const gfc_array_r16 *);
1060 internal_proto(unpack1_r16);
1061 #endif
1062
1063 extern void unpack1_c4 (gfc_array_c4 *, const gfc_array_c4 *,
1064                         const gfc_array_l1 *, const gfc_array_c4 *);
1065 internal_proto(unpack1_c4);
1066
1067 extern void unpack1_c8 (gfc_array_c8 *, const gfc_array_c8 *,
1068                         const gfc_array_l1 *, const gfc_array_c8 *);
1069 internal_proto(unpack1_c8);
1070
1071 #ifdef HAVE_GFC_COMPLEX_10
1072 extern void unpack1_c10 (gfc_array_c10 *, const gfc_array_c10 *,
1073                          const gfc_array_l1 *, const gfc_array_c10 *);
1074 internal_proto(unpack1_c10);
1075 #endif
1076
1077 #ifdef HAVE_GFC_COMPLEX_16
1078 extern void unpack1_c16 (gfc_array_c16 *, const gfc_array_c16 *,
1079                          const gfc_array_l1 *, const gfc_array_c16 *);
1080 internal_proto(unpack1_c16);
1081 #endif
1082
1083 /* Helper functions for spread.  */
1084
1085 extern void spread_i1 (gfc_array_i1 *, const gfc_array_i1 *,
1086                        const index_type, const index_type);
1087 internal_proto(spread_i1);
1088
1089 extern void spread_i2 (gfc_array_i2 *, const gfc_array_i2 *,
1090                        const index_type, const index_type);
1091 internal_proto(spread_i2);
1092
1093 extern void spread_i4 (gfc_array_i4 *, const gfc_array_i4 *,
1094                        const index_type, const index_type);
1095 internal_proto(spread_i4);
1096
1097 extern void spread_i8 (gfc_array_i8 *, const gfc_array_i8 *,
1098                        const index_type, const index_type);
1099 internal_proto(spread_i8);
1100
1101 #ifdef HAVE_GFC_INTEGER_16
1102 extern void spread_i16 (gfc_array_i16 *, const gfc_array_i16 *,
1103                        const index_type, const index_type);
1104 internal_proto(spread_i16);
1105
1106 #endif
1107
1108 extern void spread_r4 (gfc_array_r4 *, const gfc_array_r4 *,
1109                        const index_type, const index_type);
1110 internal_proto(spread_r4);
1111
1112 extern void spread_r8 (gfc_array_r8 *, const gfc_array_r8 *,
1113                        const index_type, const index_type);
1114 internal_proto(spread_r8);
1115
1116 #ifdef HAVE_GFC_REAL_10
1117 extern void spread_r10 (gfc_array_r10 *, const gfc_array_r10 *,
1118                        const index_type, const index_type);
1119 internal_proto(spread_r10);
1120
1121 #endif
1122
1123 #ifdef HAVE_GFC_REAL_16
1124 extern void spread_r16 (gfc_array_r16 *, const gfc_array_r16 *,
1125                        const index_type, const index_type);
1126 internal_proto(spread_r16);
1127
1128 #endif
1129
1130 extern void spread_c4 (gfc_array_c4 *, const gfc_array_c4 *,
1131                        const index_type, const index_type);
1132 internal_proto(spread_c4);
1133
1134 extern void spread_c8 (gfc_array_c8 *, const gfc_array_c8 *,
1135                        const index_type, const index_type);
1136 internal_proto(spread_c8);
1137
1138 #ifdef HAVE_GFC_COMPLEX_10
1139 extern void spread_c10 (gfc_array_c10 *, const gfc_array_c10 *,
1140                        const index_type, const index_type);
1141 internal_proto(spread_c10);
1142
1143 #endif
1144
1145 #ifdef HAVE_GFC_COMPLEX_16
1146 extern void spread_c16 (gfc_array_c16 *, const gfc_array_c16 *,
1147                        const index_type, const index_type);
1148 internal_proto(spread_c16);
1149
1150 #endif
1151
1152 extern void spread_scalar_i1 (gfc_array_i1 *, const GFC_INTEGER_1 *,
1153                               const index_type, const index_type);
1154 internal_proto(spread_scalar_i1);
1155
1156 extern void spread_scalar_i2 (gfc_array_i2 *, const GFC_INTEGER_2 *,
1157                               const index_type, const index_type);
1158 internal_proto(spread_scalar_i2);
1159
1160 extern void spread_scalar_i4 (gfc_array_i4 *, const GFC_INTEGER_4 *,
1161                               const index_type, const index_type);
1162 internal_proto(spread_scalar_i4);
1163
1164 extern void spread_scalar_i8 (gfc_array_i8 *, const GFC_INTEGER_8 *,
1165                               const index_type, const index_type);
1166 internal_proto(spread_scalar_i8);
1167
1168 #ifdef HAVE_GFC_INTEGER_16
1169 extern void spread_scalar_i16 (gfc_array_i16 *, const GFC_INTEGER_16 *,
1170                                const index_type, const index_type);
1171 internal_proto(spread_scalar_i16);
1172
1173 #endif
1174
1175 extern void spread_scalar_r4 (gfc_array_r4 *, const GFC_REAL_4 *,
1176                               const index_type, const index_type);
1177 internal_proto(spread_scalar_r4);
1178
1179 extern void spread_scalar_r8 (gfc_array_r8 *, const GFC_REAL_8 *,
1180                               const index_type, const index_type);
1181 internal_proto(spread_scalar_r8);
1182
1183 #ifdef HAVE_GFC_REAL_10
1184 extern void spread_scalar_r10 (gfc_array_r10 *, const GFC_REAL_10 *,
1185                                const index_type, const index_type);
1186 internal_proto(spread_scalar_r10);
1187
1188 #endif
1189
1190 #ifdef HAVE_GFC_REAL_16
1191 extern void spread_scalar_r16 (gfc_array_r16 *, const GFC_REAL_16 *,
1192                                const index_type, const index_type);
1193 internal_proto(spread_scalar_r16);
1194
1195 #endif
1196
1197 extern void spread_scalar_c4 (gfc_array_c4 *, const GFC_COMPLEX_4 *,
1198                               const index_type, const index_type);
1199 internal_proto(spread_scalar_c4);
1200
1201 extern void spread_scalar_c8 (gfc_array_c8 *, const GFC_COMPLEX_8 *,
1202                               const index_type, const index_type);
1203 internal_proto(spread_scalar_c8);
1204
1205 #ifdef HAVE_GFC_COMPLEX_10
1206 extern void spread_scalar_c10 (gfc_array_c10 *, const GFC_COMPLEX_10 *,
1207                                const index_type, const index_type);
1208 internal_proto(spread_scalar_c10);
1209
1210 #endif
1211
1212 #ifdef HAVE_GFC_COMPLEX_16
1213 extern void spread_scalar_c16 (gfc_array_c16 *, const GFC_COMPLEX_16 *,
1214                                const index_type, const index_type);
1215 internal_proto(spread_scalar_c16);
1216
1217 #endif
1218
1219 /* string_intrinsics.c */
1220
1221 extern int compare_string (gfc_charlen_type, const char *,
1222                            gfc_charlen_type, const char *);
1223 iexport_proto(compare_string);
1224
1225 extern int compare_string_char4 (gfc_charlen_type, const gfc_char4_t *,
1226                                  gfc_charlen_type, const gfc_char4_t *);
1227 iexport_proto(compare_string_char4);
1228
1229 /* random.c */
1230
1231 extern void random_seed_i4 (GFC_INTEGER_4 * size, gfc_array_i4 * put,
1232                             gfc_array_i4 * get);
1233 iexport_proto(random_seed_i4);
1234 extern void random_seed_i8 (GFC_INTEGER_8 * size, gfc_array_i8 * put,
1235                             gfc_array_i8 * get);
1236 iexport_proto(random_seed_i8);
1237
1238 /* size.c */
1239
1240 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, void) array_t;
1241
1242 extern index_type size0 (const array_t * array); 
1243 iexport_proto(size0);
1244
1245 /* Internal auxiliary functions for cshift */
1246
1247 void cshift0_i1 (gfc_array_i1 *, const gfc_array_i1 *, ssize_t, int);
1248 internal_proto(cshift0_i1);
1249
1250 void cshift0_i2 (gfc_array_i2 *, const gfc_array_i2 *, ssize_t, int);
1251 internal_proto(cshift0_i2);
1252
1253 void cshift0_i4 (gfc_array_i4 *, const gfc_array_i4 *, ssize_t, int);
1254 internal_proto(cshift0_i4);
1255
1256 void cshift0_i8 (gfc_array_i8 *, const gfc_array_i8 *, ssize_t, int);
1257 internal_proto(cshift0_i8);
1258
1259 #ifdef HAVE_GFC_INTEGER_16
1260 void cshift0_i16 (gfc_array_i16 *, const gfc_array_i16 *, ssize_t, int);
1261 internal_proto(cshift0_i16);
1262 #endif
1263
1264 void cshift0_r4 (gfc_array_r4 *, const gfc_array_r4 *, ssize_t, int);
1265 internal_proto(cshift0_r4);
1266
1267 void cshift0_r8 (gfc_array_r8 *, const gfc_array_r8 *, ssize_t, int);
1268 internal_proto(cshift0_r8);
1269
1270 #ifdef HAVE_GFC_REAL_10
1271 void cshift0_r10 (gfc_array_r10 *, const gfc_array_r10 *, ssize_t, int);
1272 internal_proto(cshift0_r10);
1273 #endif
1274
1275 #ifdef HAVE_GFC_REAL_16
1276 void cshift0_r16 (gfc_array_r16 *, const gfc_array_r16 *, ssize_t, int);
1277 internal_proto(cshift0_r16);
1278 #endif
1279
1280 void cshift0_c4 (gfc_array_c4 *, const gfc_array_c4 *, ssize_t, int);
1281 internal_proto(cshift0_c4);
1282
1283 void cshift0_c8 (gfc_array_c8 *, const gfc_array_c8 *, ssize_t, int);
1284 internal_proto(cshift0_c8);
1285
1286 #ifdef HAVE_GFC_COMPLEX_10
1287 void cshift0_c10 (gfc_array_c10 *, const gfc_array_c10 *, ssize_t, int);
1288 internal_proto(cshift0_c10);
1289 #endif
1290
1291 #ifdef HAVE_GFC_COMPLEX_16
1292 void cshift0_c16 (gfc_array_c16 *, const gfc_array_c16 *, ssize_t, int);
1293 internal_proto(cshift0_c16);
1294 #endif
1295
1296 #endif  /* LIBGFOR_H  */