OSDN Git Service

* optabs.c (expand_ffs): Initialize val and defined_at_zero
[pf3gnuchains/gcc-fork.git] / libgfortran / libgfortran.h
1 /* Common declarations for all of libgfortran.
2    Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
3    Contributed by Paul Brook <paul@nowt.org>, and
4    Andy Vaught <andy@xena.eas.asu.edu>
5
6 This file is part of the GNU Fortran 95 runtime library (libgfortran).
7
8 Libgfortran is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 Libgfortran is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with libgfor; see the file COPYING.LIB.  If not,
20 write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA.  */
22
23 /* As a special exception, if you link this library with other files,
24    some of which are compiled with GCC, to produce an executable,
25    this library does not by itself cause the resulting executable
26    to be covered by the GNU General Public License.
27    This exception does not however invalidate any other reasons why
28    the executable file might be covered by the GNU General Public License.  */
29
30
31 #ifndef LIBGFOR_H
32 #define LIBGFOR_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 "config.h"
49 #include "c99_protos.h"
50
51 #if HAVE_IEEEFP_H
52 #include <ieeefp.h>
53 #endif
54
55 #include "gstdint.h"
56
57 #if HAVE_SYS_TYPES_H
58 #include <sys/types.h>
59 #endif
60 typedef off_t gfc_offset;
61
62 #ifndef NULL
63 #define NULL (void *) 0
64 #endif
65
66 #ifndef __GNUC__
67 #define __attribute__(x)
68 #endif
69
70
71 /* On mingw, work around the buggy Windows snprintf() by using the one
72    mingw provides, __mingw_snprintf().  We also provide a prototype for
73    __mingw_snprintf(), because the mingw headers currently don't have one.  */
74 #if HAVE_MINGW_SNPRINTF
75 extern int __mingw_snprintf (char *, size_t, const char *, ...);
76 #undef snprintf
77 #define snprintf __mingw_snprintf
78 #endif
79
80
81 /* For a library, a standard prefix is a requirement in order to partition
82    the namespace.  IPREFIX is for symbols intended to be internal to the
83    library.  */
84 #define PREFIX(x)       _gfortran_ ## x
85 #define IPREFIX(x)      _gfortrani_ ## x
86
87 /* Magic to rename a symbol at the compiler level.  You continue to refer
88    to the symbol as OLD in the source, but it'll be named NEW in the asm.  */
89 #define sym_rename(old, new) sym_rename1(old, __USER_LABEL_PREFIX__, new)
90 #define sym_rename1(old, ulp, new) sym_rename2(old, ulp, new)
91 #define sym_rename2(old, ulp, new) extern __typeof(old) old __asm__(#ulp #new)
92
93 /* There are several classifications of routines:
94
95      (1) Symbols used only within the library,
96      (2) Symbols to be exported from the library,
97      (3) Symbols to be exported from the library, but
98          also used inside the library.
99
100    By telling the compiler about these different classifications we can
101    tightly control the interface seen by the user, and get better code
102    from the compiler at the same time.
103
104    One of the following should be used immediately after the declaration
105    of each symbol:
106
107      internal_proto     Marks a symbol used only within the library,
108                         and adds IPREFIX to the assembly-level symbol
109                         name.  The later is important for maintaining
110                         the namespace partition for the static library.
111
112      export_proto       Marks a symbol to be exported, and adds PREFIX
113                         to the assembly-level symbol name.
114
115      export_proto_np    Marks a symbol to be exported without adding PREFIX.
116
117      iexport_proto      Marks a function to be exported, but with the 
118                         understanding that it can be used inside as well.
119
120      iexport_data_proto Similarly, marks a data symbol to be exported.
121                         Unfortunately, some systems can't play the hidden
122                         symbol renaming trick on data symbols, thanks to
123                         the horribleness of COPY relocations.
124
125    If iexport_proto or iexport_data_proto is used, you must also use
126    iexport or iexport_data after the *definition* of the symbol.  */
127
128 #if defined(HAVE_ATTRIBUTE_VISIBILITY)
129 # define internal_proto(x) \
130         sym_rename(x, IPREFIX (x)) __attribute__((__visibility__("hidden")))
131 #else
132 # define internal_proto(x)      sym_rename(x, IPREFIX(x))
133 #endif
134
135 #if defined(HAVE_ATTRIBUTE_VISIBILITY) && defined(HAVE_ATTRIBUTE_ALIAS)
136 # define export_proto(x)        sym_rename(x, PREFIX(x))
137 # define export_proto_np(x)     extern char swallow_semicolon
138 # define iexport_proto(x)       internal_proto(x)
139 # define iexport(x)             iexport1(x, IPREFIX(x))
140 # define iexport1(x,y)          iexport2(x,y)
141 # define iexport2(x,y) \
142         extern __typeof(x) PREFIX(x) __attribute__((__alias__(#y)))
143 /* ??? We're not currently building a dll, and it's wrong to add dllexport
144    to objects going into a static library archive.  */
145 #elif 0 && defined(HAVE_ATTRIBUTE_DLLEXPORT)
146 # define export_proto_np(x)     extern __typeof(x) x __attribute__((dllexport))
147 # define export_proto(x)    sym_rename(x, PREFIX(x)) __attribute__((dllexport))
148 # define iexport_proto(x)       export_proto(x)
149 # define iexport(x)             extern char swallow_semicolon
150 #else
151 # define export_proto(x)        sym_rename(x, PREFIX(x))
152 # define export_proto_np(x)     extern char swallow_semicolon
153 # define iexport_proto(x)       export_proto(x)
154 # define iexport(x)             extern char swallow_semicolon
155 #endif
156
157 /* TODO: detect the case when we *can* hide the symbol.  */
158 #define iexport_data_proto(x)   export_proto(x)
159 #define iexport_data(x)         extern char swallow_semicolon
160
161 /* The only reliable way to get the offset of a field in a struct
162    in a system independent way is via this macro.  */
163 #ifndef offsetof
164 #define offsetof(TYPE, MEMBER)  ((size_t) &((TYPE *) 0)->MEMBER)
165 #endif
166
167 /* The isfinite macro is only available with C99, but some non-C99
168    systems still provide fpclassify, and there is a `finite' function
169    in BSD.
170
171    Also, isfinite is broken on Cygwin.
172
173    When isfinite is not available, try to use one of the
174    alternatives, or bail out.  */
175
176 #if defined(HAVE_BROKEN_ISFINITE) || defined(__CYGWIN__)
177 #undef isfinite
178 #endif
179
180 #if defined(HAVE_BROKEN_ISNAN)
181 #undef isnan
182 #endif
183
184 #if defined(HAVE_BROKEN_FPCLASSIFY)
185 #undef fpclassify
186 #endif
187
188 #if !defined(isfinite)
189 #if !defined(fpclassify)
190 #define isfinite(x) ((x) - (x) == 0)
191 #else
192 #define isfinite(x) (fpclassify(x) != FP_NAN && fpclassify(x) != FP_INFINITE)
193 #endif /* !defined(fpclassify) */
194 #endif /* !defined(isfinite)  */
195
196 #if !defined(isnan)
197 #if !defined(fpclassify)
198 #define isnan(x) ((x) != (x))
199 #else
200 #define isnan(x) (fpclassify(x) == FP_NAN)
201 #endif /* !defined(fpclassify) */
202 #endif /* !defined(isfinite)  */
203
204 /* TODO: find the C99 version of these an move into above ifdef.  */
205 #define REALPART(z) (__real__(z))
206 #define IMAGPART(z) (__imag__(z))
207 #define COMPLEX_ASSIGN(z_, r_, i_) {__real__(z_) = (r_); __imag__(z_) = (i_);}
208
209 #include "kinds.h"
210
211 /* Define the type used for the current record number for large file I/O.
212    The size must be consistent with the size defined on the compiler side.  */
213 #ifdef HAVE_GFC_INTEGER_8
214 typedef GFC_INTEGER_8 GFC_IO_INT;
215 #else
216 #ifdef HAVE_GFC_INTEGER_4
217 typedef GFC_INTEGER_4 GFC_IO_INT;
218 #else
219 #error "GFC_INTEGER_4 should be available for the library to compile".
220 #endif
221 #endif
222
223 /* The following two definitions must be consistent with the types used
224    by the compiler.  */
225 /* The type used of array indices, amongst other things.  */
226 typedef ssize_t index_type;
227 /* The type used for the lengths of character variables.  */
228 typedef GFC_INTEGER_4 gfc_charlen_type;
229
230 /* This will be 0 on little-endian machines and one on big-endian machines.  */
231 extern int l8_to_l4_offset;
232 internal_proto(l8_to_l4_offset);
233
234 #define GFOR_POINTER_TO_L1(p, kind) \
235   (l8_to_l4_offset * (kind - 1) + (GFC_LOGICAL_1 *)(p))
236
237 #define GFC_INTEGER_1_HUGE \
238   (GFC_INTEGER_1)((((GFC_UINTEGER_1)1) << 7) - 1)
239 #define GFC_INTEGER_2_HUGE \
240   (GFC_INTEGER_2)((((GFC_UINTEGER_2)1) << 15) - 1)
241 #define GFC_INTEGER_4_HUGE \
242   (GFC_INTEGER_4)((((GFC_UINTEGER_4)1) << 31) - 1)
243 #define GFC_INTEGER_8_HUGE \
244   (GFC_INTEGER_8)((((GFC_UINTEGER_8)1) << 63) - 1)
245 #ifdef HAVE_GFC_INTEGER_16
246 #define GFC_INTEGER_16_HUGE \
247   (GFC_INTEGER_16)((((GFC_UINTEGER_16)1) << 127) - 1)
248 #endif
249
250 #define GFC_REAL_4_HUGE FLT_MAX
251 #define GFC_REAL_8_HUGE DBL_MAX
252 #ifdef HAVE_GFC_REAL_10
253 #define GFC_REAL_10_HUGE LDBL_MAX
254 #endif
255 #ifdef HAVE_GFC_REAL_16
256 #define GFC_REAL_16_HUGE LDBL_MAX
257 #endif
258
259 #define GFC_REAL_4_DIGITS FLT_MANT_DIG
260 #define GFC_REAL_8_DIGITS DBL_MANT_DIG
261 #ifdef HAVE_GFC_REAL_10
262 #define GFC_REAL_10_DIGITS LDBL_MANT_DIG
263 #endif
264 #ifdef HAVE_GFC_REAL_16
265 #define GFC_REAL_16_DIGITS LDBL_MANT_DIG
266 #endif
267
268 #define GFC_REAL_4_RADIX FLT_RADIX
269 #define GFC_REAL_8_RADIX FLT_RADIX
270 #ifdef HAVE_GFC_REAL_10
271 #define GFC_REAL_10_RADIX FLT_RADIX
272 #endif
273 #ifdef HAVE_GFC_REAL_16
274 #define GFC_REAL_16_RADIX FLT_RADIX
275 #endif
276
277
278 typedef struct descriptor_dimension
279 {
280   index_type stride;
281   index_type lbound;
282   index_type ubound;
283 }
284 descriptor_dimension;
285
286 #define GFC_ARRAY_DESCRIPTOR(r, type) \
287 struct {\
288   type *data;\
289   size_t offset;\
290   index_type dtype;\
291   descriptor_dimension dim[r];\
292 }
293
294 /* Commonly used array descriptor types.  */
295 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, void) gfc_array_void;
296 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, char) gfc_array_char;
297 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_1) gfc_array_i1;
298 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_2) gfc_array_i2;
299 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_4) gfc_array_i4;
300 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_8) gfc_array_i8;
301 #ifdef HAVE_GFC_INTEGER_16
302 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_16) gfc_array_i16;
303 #endif
304 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_4) gfc_array_r4;
305 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_8) gfc_array_r8;
306 #ifdef HAVE_GFC_REAL_10
307 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_10) gfc_array_r10;
308 #endif
309 #ifdef HAVE_GFC_REAL_16
310 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_16) gfc_array_r16;
311 #endif
312 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_4) gfc_array_c4;
313 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_8) gfc_array_c8;
314 #ifdef HAVE_GFC_COMPLEX_10
315 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_10) gfc_array_c10;
316 #endif
317 #ifdef HAVE_GFC_COMPLEX_16
318 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_16) gfc_array_c16;
319 #endif
320 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_1) gfc_array_l1;
321 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_2) gfc_array_l2;
322 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_4) gfc_array_l4;
323 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_8) gfc_array_l8;
324 #ifdef HAVE_GFC_LOGICAL_16
325 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_16) gfc_array_l16;
326 #endif
327
328
329 #define GFC_DESCRIPTOR_RANK(desc) ((desc)->dtype & GFC_DTYPE_RANK_MASK)
330 #define GFC_DESCRIPTOR_TYPE(desc) (((desc)->dtype & GFC_DTYPE_TYPE_MASK) \
331                                    >> GFC_DTYPE_TYPE_SHIFT)
332 #define GFC_DESCRIPTOR_SIZE(desc) ((desc)->dtype >> GFC_DTYPE_SIZE_SHIFT)
333 #define GFC_DESCRIPTOR_DATA(desc) ((desc)->data)
334 #define GFC_DESCRIPTOR_DTYPE(desc) ((desc)->dtype)
335
336 /* Runtime library include.  */
337 #define stringize(x) expand_macro(x)
338 #define expand_macro(x) # x
339
340 /* Runtime options structure.  */
341
342 typedef struct
343 {
344   int stdin_unit, stdout_unit, stderr_unit, optional_plus;
345   int allocate_init_flag, allocate_init_value;
346   int locus;
347
348   int separator_len;
349   const char *separator;
350
351   int mem_check;
352   int use_stderr, all_unbuffered, default_recl;
353
354   int fpu_round, fpu_precision, fpe;
355
356   int sighup, sigint;
357   int dump_core, backtrace;
358 }
359 options_t;
360
361 extern options_t options;
362 internal_proto(options);
363
364 extern void handler (int);
365 internal_proto(handler);
366
367
368 /* Compile-time options that will influence the library.  */
369
370 typedef struct
371 {
372   int warn_std;
373   int allow_std;
374   int pedantic;
375   int convert;
376   int dump_core;
377   int backtrace;
378   int sign_zero;
379   size_t record_marker;
380   int max_subrecord_length;
381   int bounds_check;
382 }
383 compile_options_t;
384
385 extern compile_options_t compile_options;
386 internal_proto(compile_options);
387
388 extern void init_compile_options (void);
389 internal_proto(init_compile_options);
390
391 #define GFC_MAX_SUBRECORD_LENGTH 2147483639   /* 2**31 - 9 */
392
393 /* Structure for statement options.  */
394
395 typedef struct
396 {
397   const char *name;
398   int value;
399 }
400 st_option;
401
402
403 /* This is returned by notification_std to know if, given the flags
404    that were given (-std=, -pedantic) we should issue an error, a warning
405    or nothing.  */
406 typedef enum
407 { SILENT, WARNING, ERROR }
408 notification;
409
410 /* This is returned by notify_std and several io functions.  */
411 typedef enum
412 { SUCCESS = 1, FAILURE }
413 try;
414
415 /* The filename and line number don't go inside the globals structure.
416    They are set by the rest of the program and must be linked to.  */
417
418 /* Location of the current library call (optional).  */
419 extern unsigned line;
420 iexport_data_proto(line);
421
422 extern char *filename;
423 iexport_data_proto(filename);
424
425 /* Avoid conflicting prototypes of alloca() in system headers by using 
426    GCC's builtin alloca().  */
427 #define gfc_alloca(x)  __builtin_alloca(x)
428
429
430 /* Directory for creating temporary files.  Only used when none of the
431    following environment variables exist: GFORTRAN_TMPDIR, TMP and TEMP.  */
432 #define DEFAULT_TEMPDIR "/tmp"
433
434 /* The default value of record length for preconnected units is defined
435    here. This value can be overriden by an environment variable.
436    Default value is 1 Gb.  */
437 #define DEFAULT_RECL 1073741824
438
439
440 #define CHARACTER2(name) \
441               gfc_charlen_type name ## _len; \
442               char * name
443
444 typedef struct st_parameter_common
445 {
446   GFC_INTEGER_4 flags;
447   GFC_INTEGER_4 unit;
448   const char *filename;
449   GFC_INTEGER_4 line;
450   CHARACTER2 (iomsg);
451   GFC_INTEGER_4 *iostat;
452 }
453 st_parameter_common;
454
455 #undef CHARACTER2
456
457 #define IOPARM_LIBRETURN_MASK           (3 << 0)
458 #define IOPARM_LIBRETURN_OK             (0 << 0)
459 #define IOPARM_LIBRETURN_ERROR          (1 << 0)
460 #define IOPARM_LIBRETURN_END            (2 << 0)
461 #define IOPARM_LIBRETURN_EOR            (3 << 0)
462 #define IOPARM_ERR                      (1 << 2)
463 #define IOPARM_END                      (1 << 3)
464 #define IOPARM_EOR                      (1 << 4)
465 #define IOPARM_HAS_IOSTAT               (1 << 5)
466 #define IOPARM_HAS_IOMSG                (1 << 6)
467
468 #define IOPARM_COMMON_MASK              ((1 << 7) - 1)
469
470 #define IOPARM_OPEN_HAS_RECL_IN         (1 << 7)
471 #define IOPARM_OPEN_HAS_FILE            (1 << 8)
472 #define IOPARM_OPEN_HAS_STATUS          (1 << 9)
473 #define IOPARM_OPEN_HAS_ACCESS          (1 << 10)
474 #define IOPARM_OPEN_HAS_FORM            (1 << 11)
475 #define IOPARM_OPEN_HAS_BLANK           (1 << 12)
476 #define IOPARM_OPEN_HAS_POSITION        (1 << 13)
477 #define IOPARM_OPEN_HAS_ACTION          (1 << 14)
478 #define IOPARM_OPEN_HAS_DELIM           (1 << 15)
479 #define IOPARM_OPEN_HAS_PAD             (1 << 16)
480 #define IOPARM_OPEN_HAS_CONVERT         (1 << 17)
481
482 /* library start function and end macro.  These can be expanded if needed
483    in the future.  cmp is st_parameter_common *cmp  */
484
485 extern void library_start (st_parameter_common *);
486 internal_proto(library_start);
487
488 #define library_end()
489
490 /* main.c */
491
492 extern void stupid_function_name_for_static_linking (void);
493 internal_proto(stupid_function_name_for_static_linking);
494
495 extern void set_args (int, char **);
496 export_proto(set_args);
497
498 extern void get_args (int *, char ***);
499 internal_proto(get_args);
500
501 extern void store_exe_path (const char *);
502 export_proto(store_exe_path);
503
504 extern char * full_exe_path (void);
505 internal_proto(full_exe_path);
506
507 /* backtrace.c */
508
509 extern void show_backtrace (void);
510 internal_proto(show_backtrace);
511
512 /* error.c */
513
514 #define GFC_ITOA_BUF_SIZE (sizeof (GFC_INTEGER_LARGEST) * 3 + 2)
515 #define GFC_XTOA_BUF_SIZE (sizeof (GFC_UINTEGER_LARGEST) * 2 + 1)
516 #define GFC_OTOA_BUF_SIZE (sizeof (GFC_INTEGER_LARGEST) * 3 + 1)
517 #define GFC_BTOA_BUF_SIZE (sizeof (GFC_INTEGER_LARGEST) * 8 + 1)
518
519 extern void sys_exit (int) __attribute__ ((noreturn));
520 internal_proto(sys_exit);
521
522 extern const char *gfc_itoa (GFC_INTEGER_LARGEST, char *, size_t);
523 internal_proto(gfc_itoa);
524
525 extern const char *xtoa (GFC_UINTEGER_LARGEST, char *, size_t);
526 internal_proto(xtoa);
527
528 extern void os_error (const char *) __attribute__ ((noreturn));
529 iexport_proto(os_error);
530
531 extern void show_locus (st_parameter_common *);
532 internal_proto(show_locus);
533
534 extern void runtime_error (const char *, ...)
535      __attribute__ ((noreturn, format (printf, 1, 2)));
536 iexport_proto(runtime_error);
537
538 extern void runtime_error_at (const char *, const char *, ...)
539      __attribute__ ((noreturn, format (printf, 2, 3)));
540 iexport_proto(runtime_error_at);
541
542 extern void internal_error (st_parameter_common *, const char *)
543   __attribute__ ((noreturn));
544 internal_proto(internal_error);
545
546 extern const char *get_oserror (void);
547 internal_proto(get_oserror);
548
549 extern const char *translate_error (int);
550 internal_proto(translate_error);
551
552 extern void generate_error (st_parameter_common *, int, const char *);
553 iexport_proto(generate_error);
554
555 extern try notify_std (st_parameter_common *, int, const char *);
556 internal_proto(notify_std);
557
558 extern notification notification_std(int);
559 internal_proto(notification_std);
560
561 /* fpu.c */
562
563 extern void set_fpu (void);
564 internal_proto(set_fpu);
565
566 /* memory.c */
567
568 extern void *get_mem (size_t) __attribute__ ((malloc));
569 internal_proto(get_mem);
570
571 extern void free_mem (void *);
572 internal_proto(free_mem);
573
574 extern void *internal_malloc_size (size_t) __attribute__ ((malloc));
575 internal_proto(internal_malloc_size);
576
577 /* environ.c */
578
579 extern int check_buffered (int);
580 internal_proto(check_buffered);
581
582 extern void init_variables (void);
583 internal_proto(init_variables);
584
585 extern void show_variables (void);
586 internal_proto(show_variables);
587
588 unit_convert get_unformatted_convert (int);
589 internal_proto(get_unformatted_convert);
590
591 /* string.c */
592
593 extern int find_option (st_parameter_common *, const char *, gfc_charlen_type,
594                         const st_option *, const char *);
595 internal_proto(find_option);
596
597 extern gfc_charlen_type fstrlen (const char *, gfc_charlen_type);
598 internal_proto(fstrlen);
599
600 extern gfc_charlen_type fstrcpy (char *, gfc_charlen_type, const char *, gfc_charlen_type);
601 internal_proto(fstrcpy);
602
603 extern gfc_charlen_type cf_strcpy (char *, gfc_charlen_type, const char *);
604 internal_proto(cf_strcpy);
605
606 /* io/intrinsics.c */
607
608 extern void flush_all_units (void);
609 internal_proto(flush_all_units);
610
611 /* io.c */
612
613 extern void init_units (void);
614 internal_proto(init_units);
615
616 extern void close_units (void);
617 internal_proto(close_units);
618
619 extern int unit_to_fd (int);
620 internal_proto(unit_to_fd);
621
622 extern int st_printf (const char *, ...)
623   __attribute__ ((format (printf, 1, 2)));
624 internal_proto(st_printf);
625
626 extern int st_vprintf (const char *, va_list);
627 internal_proto(st_vprintf);
628
629 extern char * filename_from_unit (int);
630 internal_proto(filename_from_unit);
631
632 /* stop.c */
633
634 extern void stop_numeric (GFC_INTEGER_4) __attribute__ ((noreturn));
635 iexport_proto(stop_numeric);
636
637 /* reshape_packed.c */
638
639 extern void reshape_packed (char *, index_type, const char *, index_type,
640                             const char *, index_type);
641 internal_proto(reshape_packed);
642
643 /* Repacking functions.  */
644
645 /* ??? These aren't currently used by the compiler, though we
646    certainly could do so.  */
647 GFC_INTEGER_4 *internal_pack_4 (gfc_array_i4 *);
648 internal_proto(internal_pack_4);
649
650 GFC_INTEGER_8 *internal_pack_8 (gfc_array_i8 *);
651 internal_proto(internal_pack_8);
652
653 #if defined HAVE_GFC_INTEGER_16
654 GFC_INTEGER_16 *internal_pack_16 (gfc_array_i16 *);
655 internal_proto(internal_pack_16);
656 #endif
657
658 GFC_COMPLEX_4 *internal_pack_c4 (gfc_array_c4 *);
659 internal_proto(internal_pack_c4);
660
661 GFC_COMPLEX_8 *internal_pack_c8 (gfc_array_c8 *);
662 internal_proto(internal_pack_c8);
663
664 #if defined HAVE_GFC_COMPLEX_10
665 GFC_COMPLEX_10 *internal_pack_c10 (gfc_array_c10 *);
666 internal_proto(internal_pack_c10);
667 #endif
668
669 extern void internal_unpack_4 (gfc_array_i4 *, const GFC_INTEGER_4 *);
670 internal_proto(internal_unpack_4);
671
672 extern void internal_unpack_8 (gfc_array_i8 *, const GFC_INTEGER_8 *);
673 internal_proto(internal_unpack_8);
674
675 #if defined HAVE_GFC_INTEGER_16
676 extern void internal_unpack_16 (gfc_array_i16 *, const GFC_INTEGER_16 *);
677 internal_proto(internal_unpack_16);
678 #endif
679
680 extern void internal_unpack_c4 (gfc_array_c4 *, const GFC_COMPLEX_4 *);
681 internal_proto(internal_unpack_c4);
682
683 extern void internal_unpack_c8 (gfc_array_c8 *, const GFC_COMPLEX_8 *);
684 internal_proto(internal_unpack_c8);
685
686 #if defined HAVE_GFC_COMPLEX_10
687 extern void internal_unpack_c10 (gfc_array_c10 *, const GFC_COMPLEX_10 *);
688 internal_proto(internal_unpack_c10);
689 #endif
690
691 #if defined HAVE_GFC_COMPLEX_16
692 extern void internal_unpack_c16 (gfc_array_c16 *, const GFC_COMPLEX_16 *);
693 internal_proto(internal_unpack_c16);
694 #endif
695
696 /* string_intrinsics.c */
697
698 extern int compare_string (GFC_INTEGER_4, const char *,
699                            GFC_INTEGER_4, const char *);
700 iexport_proto(compare_string);
701
702 /* random.c */
703
704 extern void random_seed_i4 (GFC_INTEGER_4 * size, gfc_array_i4 * put,
705                             gfc_array_i4 * get);
706 iexport_proto(random_seed_i4);
707 extern void random_seed_i8 (GFC_INTEGER_8 * size, gfc_array_i8 * put,
708                             gfc_array_i8 * get);
709 iexport_proto(random_seed_i8);
710
711 /* size.c */
712
713 typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, void) array_t;
714
715 extern index_type size0 (const array_t * array); 
716 iexport_proto(size0);
717
718 #endif  /* LIBGFOR_H  */