* config/xtensa/xtensa.c (xtensa_expand_builtin): Use CALL_EXPR_FN.
[official-gcc.git] / libgfortran / io / io.h
blobdf006693b28233e83e0ac89ed307247a3480f38e
1 /* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007
2 Free Software Foundation, Inc.
3 Contributed by Andy Vaught
5 This file is part of the GNU Fortran 95 runtime library (libgfortran).
7 Libgfortran is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 Libgfortran is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Libgfortran; see the file COPYING. If not, write to
19 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
22 /* As a special exception, if you link this library with other files,
23 some of which are compiled with GCC, to produce an executable,
24 this library does not by itself cause the resulting executable
25 to be covered by the GNU General Public License.
26 This exception does not however invalidate any other reasons why
27 the executable file might be covered by the GNU General Public License. */
29 #ifndef GFOR_IO_H
30 #define GFOR_IO_H
32 /* IO library include. */
34 #include <setjmp.h>
35 #include "libgfortran.h"
37 #include <gthr.h>
39 /* Basic types used in data transfers. */
41 typedef enum
42 { BT_NULL, BT_INTEGER, BT_LOGICAL, BT_CHARACTER, BT_REAL,
43 BT_COMPLEX
45 bt;
48 struct st_parameter_dt;
50 typedef struct stream
52 char *(*alloc_w_at) (struct stream *, int *, gfc_offset);
53 char *(*alloc_r_at) (struct stream *, int *, gfc_offset);
54 try (*sfree) (struct stream *);
55 try (*close) (struct stream *);
56 try (*seek) (struct stream *, gfc_offset);
57 try (*truncate) (struct stream *);
58 int (*read) (struct stream *, void *, size_t *);
59 int (*write) (struct stream *, const void *, size_t *);
60 try (*set) (struct stream *, int, size_t);
62 stream;
65 /* Macros for doing file I/O given a stream. */
67 #define sfree(s) ((s)->sfree)(s)
68 #define sclose(s) ((s)->close)(s)
70 #define salloc_r(s, len) ((s)->alloc_r_at)(s, len, -1)
71 #define salloc_w(s, len) ((s)->alloc_w_at)(s, len, -1)
73 #define salloc_r_at(s, len, where) ((s)->alloc_r_at)(s, len, where)
74 #define salloc_w_at(s, len, where) ((s)->alloc_w_at)(s, len, where)
76 #define sseek(s, pos) ((s)->seek)(s, pos)
77 #define struncate(s) ((s)->truncate)(s)
78 #define sread(s, buf, nbytes) ((s)->read)(s, buf, nbytes)
79 #define swrite(s, buf, nbytes) ((s)->write)(s, buf, nbytes)
81 #define sset(s, c, n) ((s)->set)(s, c, n)
83 /* The array_loop_spec contains the variables for the loops over index ranges
84 that are encountered. Since the variables can be negative, ssize_t
85 is used. */
87 typedef struct array_loop_spec
89 /* Index counter for this dimension. */
90 ssize_t idx;
92 /* Start for the index counter. */
93 ssize_t start;
95 /* End for the index counter. */
96 ssize_t end;
98 /* Step for the index counter. */
99 ssize_t step;
101 array_loop_spec;
103 /* Representation of a namelist object in libgfortran
105 Namelist Records
106 &GROUPNAME OBJECT=value[s] [,OBJECT=value[s]].../
108 &GROUPNAME OBJECT=value[s] [,OBJECT=value[s]]...&END
110 The object can be a fully qualified, compound name for an intrinsic
111 type, derived types or derived type components. So, a substring
112 a(:)%b(4)%ch(2:4)(1:7) has to be treated correctly in namelist
113 read. Hence full information about the structure of the object has
114 to be available to list_read.c and write.
116 These requirements are met by the following data structures.
118 namelist_info type contains all the scalar information about the
119 object and arrays of descriptor_dimension and array_loop_spec types for
120 arrays. */
122 typedef struct namelist_type
125 /* Object type, stored as GFC_DTYPE_xxxx. */
126 bt type;
128 /* Object name. */
129 char * var_name;
131 /* Address for the start of the object's data. */
132 void * mem_pos;
134 /* Flag to show that a read is to be attempted for this node. */
135 int touched;
137 /* Length of intrinsic type in bytes. */
138 int len;
140 /* Rank of the object. */
141 int var_rank;
143 /* Overall size of the object in bytes. */
144 index_type size;
146 /* Length of character string. */
147 index_type string_length;
149 descriptor_dimension * dim;
150 array_loop_spec * ls;
151 struct namelist_type * next;
153 namelist_info;
155 /* Options for the OPEN statement. */
157 typedef enum
158 { ACCESS_SEQUENTIAL, ACCESS_DIRECT, ACCESS_APPEND, ACCESS_STREAM,
159 ACCESS_UNSPECIFIED
161 unit_access;
163 typedef enum
164 { ACTION_READ, ACTION_WRITE, ACTION_READWRITE,
165 ACTION_UNSPECIFIED
167 unit_action;
169 typedef enum
170 { BLANK_NULL, BLANK_ZERO, BLANK_UNSPECIFIED }
171 unit_blank;
173 typedef enum
174 { DELIM_NONE, DELIM_APOSTROPHE, DELIM_QUOTE,
175 DELIM_UNSPECIFIED
177 unit_delim;
179 typedef enum
180 { FORM_FORMATTED, FORM_UNFORMATTED, FORM_UNSPECIFIED }
181 unit_form;
183 typedef enum
184 { POSITION_ASIS, POSITION_REWIND, POSITION_APPEND,
185 POSITION_UNSPECIFIED
187 unit_position;
189 typedef enum
190 { STATUS_UNKNOWN, STATUS_OLD, STATUS_NEW, STATUS_SCRATCH,
191 STATUS_REPLACE, STATUS_UNSPECIFIED
193 unit_status;
195 typedef enum
196 { PAD_YES, PAD_NO, PAD_UNSPECIFIED }
197 unit_pad;
199 typedef enum
200 { ADVANCE_YES, ADVANCE_NO, ADVANCE_UNSPECIFIED }
201 unit_advance;
203 typedef enum
204 {READING, WRITING}
205 unit_mode;
207 #define CHARACTER1(name) \
208 char * name; \
209 gfc_charlen_type name ## _len
210 #define CHARACTER2(name) \
211 gfc_charlen_type name ## _len; \
212 char * name
214 typedef struct
216 st_parameter_common common;
217 GFC_INTEGER_4 recl_in;
218 CHARACTER2 (file);
219 CHARACTER1 (status);
220 CHARACTER2 (access);
221 CHARACTER1 (form);
222 CHARACTER2 (blank);
223 CHARACTER1 (position);
224 CHARACTER2 (action);
225 CHARACTER1 (delim);
226 CHARACTER2 (pad);
227 CHARACTER1 (convert);
229 st_parameter_open;
231 #define IOPARM_CLOSE_HAS_STATUS (1 << 7)
233 typedef struct
235 st_parameter_common common;
236 CHARACTER1 (status);
238 st_parameter_close;
240 typedef struct
242 st_parameter_common common;
244 st_parameter_filepos;
246 #define IOPARM_INQUIRE_HAS_EXIST (1 << 7)
247 #define IOPARM_INQUIRE_HAS_OPENED (1 << 8)
248 #define IOPARM_INQUIRE_HAS_NUMBER (1 << 9)
249 #define IOPARM_INQUIRE_HAS_NAMED (1 << 10)
250 #define IOPARM_INQUIRE_HAS_NEXTREC (1 << 11)
251 #define IOPARM_INQUIRE_HAS_RECL_OUT (1 << 12)
252 #define IOPARM_INQUIRE_HAS_STRM_POS_OUT (1 << 13)
253 #define IOPARM_INQUIRE_HAS_FILE (1 << 14)
254 #define IOPARM_INQUIRE_HAS_ACCESS (1 << 15)
255 #define IOPARM_INQUIRE_HAS_FORM (1 << 16)
256 #define IOPARM_INQUIRE_HAS_BLANK (1 << 17)
257 #define IOPARM_INQUIRE_HAS_POSITION (1 << 18)
258 #define IOPARM_INQUIRE_HAS_ACTION (1 << 19)
259 #define IOPARM_INQUIRE_HAS_DELIM (1 << 20)
260 #define IOPARM_INQUIRE_HAS_PAD (1 << 21)
261 #define IOPARM_INQUIRE_HAS_NAME (1 << 22)
262 #define IOPARM_INQUIRE_HAS_SEQUENTIAL (1 << 23)
263 #define IOPARM_INQUIRE_HAS_DIRECT (1 << 24)
264 #define IOPARM_INQUIRE_HAS_FORMATTED (1 << 25)
265 #define IOPARM_INQUIRE_HAS_UNFORMATTED (1 << 26)
266 #define IOPARM_INQUIRE_HAS_READ (1 << 27)
267 #define IOPARM_INQUIRE_HAS_WRITE (1 << 28)
268 #define IOPARM_INQUIRE_HAS_READWRITE (1 << 29)
269 #define IOPARM_INQUIRE_HAS_CONVERT (1 << 30)
271 typedef struct
273 st_parameter_common common;
274 GFC_INTEGER_4 *exist, *opened, *number, *named;
275 GFC_INTEGER_4 *nextrec, *recl_out;
276 GFC_IO_INT *strm_pos_out;
277 CHARACTER1 (file);
278 CHARACTER2 (access);
279 CHARACTER1 (form);
280 CHARACTER2 (blank);
281 CHARACTER1 (position);
282 CHARACTER2 (action);
283 CHARACTER1 (delim);
284 CHARACTER2 (pad);
285 CHARACTER1 (name);
286 CHARACTER2 (sequential);
287 CHARACTER1 (direct);
288 CHARACTER2 (formatted);
289 CHARACTER1 (unformatted);
290 CHARACTER2 (read);
291 CHARACTER1 (write);
292 CHARACTER2 (readwrite);
293 CHARACTER1 (convert);
295 st_parameter_inquire;
297 struct gfc_unit;
298 struct format_data;
300 #define IOPARM_DT_LIST_FORMAT (1 << 7)
301 #define IOPARM_DT_NAMELIST_READ_MODE (1 << 8)
302 #define IOPARM_DT_HAS_REC (1 << 9)
303 #define IOPARM_DT_HAS_SIZE (1 << 10)
304 #define IOPARM_DT_HAS_IOLENGTH (1 << 11)
305 #define IOPARM_DT_HAS_FORMAT (1 << 12)
306 #define IOPARM_DT_HAS_ADVANCE (1 << 13)
307 #define IOPARM_DT_HAS_INTERNAL_UNIT (1 << 14)
308 #define IOPARM_DT_HAS_NAMELIST_NAME (1 << 15)
309 /* Internal use bit. */
310 #define IOPARM_DT_IONML_SET (1 << 31)
312 typedef struct st_parameter_dt
314 st_parameter_common common;
315 GFC_IO_INT rec;
316 GFC_IO_INT *size, *iolength;
317 gfc_array_char *internal_unit_desc;
318 CHARACTER1 (format);
319 CHARACTER2 (advance);
320 CHARACTER1 (internal_unit);
321 CHARACTER2 (namelist_name);
322 /* Private part of the structure. The compiler just needs
323 to reserve enough space. */
324 union
326 struct
328 void (*transfer) (struct st_parameter_dt *, bt, void *, int,
329 size_t, size_t);
330 struct gfc_unit *current_unit;
331 /* Item number in a formatted data transfer. Also used in namelist
332 read_logical as an index into line_buffer. */
333 int item_count;
334 unit_mode mode;
335 unit_blank blank_status;
336 enum {SIGN_S, SIGN_SS, SIGN_SP} sign_status;
337 int scale_factor;
338 int max_pos; /* Maximum righthand column written to. */
339 /* Number of skips + spaces to be done for T and X-editing. */
340 int skips;
341 /* Number of spaces to be done for T and X-editing. */
342 int pending_spaces;
343 /* Whether an EOR condition was encountered. Value is:
344 0 if no EOR was encountered
345 1 if an EOR was encountered due to a 1-byte marker (LF)
346 2 if an EOR was encountered due to a 2-bytes marker (CRLF) */
347 int sf_seen_eor;
348 unit_advance advance_status;
350 unsigned reversion_flag : 1; /* Format reversion has occurred. */
351 unsigned first_item : 1;
352 unsigned seen_dollar : 1;
353 unsigned eor_condition : 1;
354 unsigned no_leading_blank : 1;
355 unsigned char_flag : 1;
356 unsigned input_complete : 1;
357 unsigned at_eol : 1;
358 unsigned comma_flag : 1;
359 /* A namelist specific flag used in the list directed library
360 to flag that calls are being made from namelist read (eg. to
361 ignore comments or to treat '/' as a terminator) */
362 unsigned namelist_mode : 1;
363 /* A namelist specific flag used in the list directed library
364 to flag read errors and return, so that an attempt can be
365 made to read a new object name. */
366 unsigned nml_read_error : 1;
367 /* A sequential formatted read specific flag used to signal that a
368 character string is being read so don't use commas to shorten a
369 formatted field width. */
370 unsigned sf_read_comma : 1;
371 /* A namelist specific flag used to enable reading input from
372 line_buffer for logical reads. */
373 unsigned line_buffer_enabled : 1;
374 /* An internal unit specific flag used to identify that the associated
375 unit is internal. */
376 unsigned unit_is_internal : 1;
377 /* An internal unit specific flag to signify an EOF condition for list
378 directed read. */
379 unsigned at_eof : 1;
380 /* 16 unused bits. */
382 char last_char;
383 char nml_delim;
385 int repeat_count;
386 int saved_length;
387 int saved_used;
388 bt saved_type;
389 char *saved_string;
390 char *scratch;
391 char *line_buffer;
392 struct format_data *fmt;
393 jmp_buf *eof_jump;
394 namelist_info *ionml;
395 /* A flag used to identify when a non-standard expanded namelist read
396 has occurred. */
397 int expanded_read;
398 /* Storage area for values except for strings. Must be large
399 enough to hold a complex value (two reals) of the largest
400 kind. */
401 char value[32];
402 gfc_offset size_used;
403 } p;
404 /* This pad size must be equal to the pad_size declared in
405 trans-io.c (gfc_build_io_library_fndecls). The above structure
406 must be smaller or equal to this array. */
407 char pad[16 * sizeof (char *) + 32 * sizeof (int)];
408 } u;
410 st_parameter_dt;
412 /* Ensure st_parameter_dt's u.pad is bigger or equal to u.p. */
413 extern char check_st_parameter_dt[sizeof (((st_parameter_dt *) 0)->u.pad)
414 >= sizeof (((st_parameter_dt *) 0)->u.p)
415 ? 1 : -1];
417 #undef CHARACTER1
418 #undef CHARACTER2
420 typedef struct
422 unit_access access;
423 unit_action action;
424 unit_blank blank;
425 unit_delim delim;
426 unit_form form;
427 int is_notpadded;
428 unit_position position;
429 unit_status status;
430 unit_pad pad;
431 unit_convert convert;
432 int has_recl;
434 unit_flags;
437 typedef struct gfc_unit
439 int unit_number;
440 stream *s;
442 /* Treap links. */
443 struct gfc_unit *left, *right;
444 int priority;
446 int read_bad, current_record, saved_pos;
447 enum
448 { NO_ENDFILE, AT_ENDFILE, AFTER_ENDFILE }
449 endfile;
451 unit_mode mode;
452 unit_flags flags;
454 /* recl -- Record length of the file.
455 last_record -- Last record number read or written
456 maxrec -- Maximum record number in a direct access file
457 bytes_left -- Bytes left in current record.
458 strm_pos -- Current position in file for STREAM I/O.
459 recl_subrecord -- Maximum length for subrecord.
460 bytes_left_subrecord -- Bytes left in current subrecord. */
461 gfc_offset recl, last_record, maxrec, bytes_left, strm_pos,
462 recl_subrecord, bytes_left_subrecord;
464 /* Set to 1 if we have read a subrecord. */
466 int continued;
468 __gthread_mutex_t lock;
469 /* Number of threads waiting to acquire this unit's lock.
470 When non-zero, close_unit doesn't only removes the unit
471 from the UNIT_ROOT tree, but doesn't free it and the
472 last of the waiting threads will do that.
473 This must be either atomically increased/decreased, or
474 always guarded by UNIT_LOCK. */
475 int waiting;
476 /* Flag set by close_unit if the unit as been closed.
477 Must be manipulated under unit's lock. */
478 int closed;
480 /* For traversing arrays */
481 array_loop_spec *ls;
482 int rank;
484 int file_len;
485 char *file;
487 gfc_unit;
489 /* Format tokens. Only about half of these can be stored in the
490 format nodes. */
492 typedef enum
494 FMT_NONE = 0, FMT_UNKNOWN, FMT_SIGNED_INT, FMT_ZERO, FMT_POSINT, FMT_PERIOD,
495 FMT_COMMA, FMT_COLON, FMT_SLASH, FMT_DOLLAR, FMT_T, FMT_TR, FMT_TL,
496 FMT_LPAREN, FMT_RPAREN, FMT_X, FMT_S, FMT_SS, FMT_SP, FMT_STRING,
497 FMT_BADSTRING, FMT_P, FMT_I, FMT_B, FMT_BN, FMT_BZ, FMT_O, FMT_Z, FMT_F,
498 FMT_E, FMT_EN, FMT_ES, FMT_G, FMT_L, FMT_A, FMT_D, FMT_H, FMT_END
500 format_token;
503 /* Format nodes. A format string is converted into a tree of these
504 structures, which is traversed as part of a data transfer statement. */
506 typedef struct fnode
508 format_token format;
509 int repeat;
510 struct fnode *next;
511 char *source;
513 union
515 struct
517 int w, d, e;
519 real;
521 struct
523 int length;
524 char *p;
526 string;
528 struct
530 int w, m;
532 integer;
534 int w;
535 int k;
536 int r;
537 int n;
539 struct fnode *child;
543 /* Members for traversing the tree during data transfer. */
545 int count;
546 struct fnode *current;
549 fnode;
552 /* unix.c */
554 extern int move_pos_offset (stream *, int);
555 internal_proto(move_pos_offset);
557 extern int compare_files (stream *, stream *);
558 internal_proto(compare_files);
560 extern stream *open_external (st_parameter_open *, unit_flags *);
561 internal_proto(open_external);
563 extern stream *open_internal (char *, int);
564 internal_proto(open_internal);
566 extern stream *input_stream (void);
567 internal_proto(input_stream);
569 extern stream *output_stream (void);
570 internal_proto(output_stream);
572 extern stream *error_stream (void);
573 internal_proto(error_stream);
575 extern int compare_file_filename (gfc_unit *, const char *, int);
576 internal_proto(compare_file_filename);
578 extern gfc_unit *find_file (const char *file, gfc_charlen_type file_len);
579 internal_proto(find_file);
581 extern void flush_all_units (void);
582 internal_proto(flush_all_units);
584 extern int stream_at_bof (stream *);
585 internal_proto(stream_at_bof);
587 extern int stream_at_eof (stream *);
588 internal_proto(stream_at_eof);
590 extern int delete_file (gfc_unit *);
591 internal_proto(delete_file);
593 extern int file_exists (const char *file, gfc_charlen_type file_len);
594 internal_proto(file_exists);
596 extern const char *inquire_sequential (const char *, int);
597 internal_proto(inquire_sequential);
599 extern const char *inquire_direct (const char *, int);
600 internal_proto(inquire_direct);
602 extern const char *inquire_formatted (const char *, int);
603 internal_proto(inquire_formatted);
605 extern const char *inquire_unformatted (const char *, int);
606 internal_proto(inquire_unformatted);
608 extern const char *inquire_read (const char *, int);
609 internal_proto(inquire_read);
611 extern const char *inquire_write (const char *, int);
612 internal_proto(inquire_write);
614 extern const char *inquire_readwrite (const char *, int);
615 internal_proto(inquire_readwrite);
617 extern gfc_offset file_length (stream *);
618 internal_proto(file_length);
620 extern gfc_offset file_position (stream *);
621 internal_proto(file_position);
623 extern int is_seekable (stream *);
624 internal_proto(is_seekable);
626 extern int is_special (stream *);
627 internal_proto(is_special);
629 extern int is_preconnected (stream *);
630 internal_proto(is_preconnected);
632 extern void flush_if_preconnected (stream *);
633 internal_proto(flush_if_preconnected);
635 extern void empty_internal_buffer(stream *);
636 internal_proto(empty_internal_buffer);
638 extern try flush (stream *);
639 internal_proto(flush);
641 extern int stream_isatty (stream *);
642 internal_proto(stream_isatty);
644 extern char * stream_ttyname (stream *);
645 internal_proto(stream_ttyname);
647 extern gfc_offset stream_offset (stream *s);
648 internal_proto(stream_offset);
650 extern int unpack_filename (char *, const char *, int);
651 internal_proto(unpack_filename);
653 /* unit.c */
655 /* Maximum file offset, computed at library initialization time. */
656 extern gfc_offset max_offset;
657 internal_proto(max_offset);
659 /* Unit tree root. */
660 extern gfc_unit *unit_root;
661 internal_proto(unit_root);
663 extern __gthread_mutex_t unit_lock;
664 internal_proto(unit_lock);
666 extern int close_unit (gfc_unit *);
667 internal_proto(close_unit);
669 extern gfc_unit *get_internal_unit (st_parameter_dt *);
670 internal_proto(get_internal_unit);
672 extern void free_internal_unit (st_parameter_dt *);
673 internal_proto(free_internal_unit);
675 extern int is_internal_unit (st_parameter_dt *);
676 internal_proto(is_internal_unit);
678 extern int is_array_io (st_parameter_dt *);
679 internal_proto(is_array_io);
681 extern int is_stream_io (st_parameter_dt *);
682 internal_proto(is_stream_io);
684 extern gfc_unit *find_unit (int);
685 internal_proto(find_unit);
687 extern gfc_unit *find_or_create_unit (int);
688 internal_proto(find_or_create_unit);
690 extern gfc_unit *get_unit (st_parameter_dt *, int);
691 internal_proto(get_unit);
693 extern void unlock_unit (gfc_unit *);
694 internal_proto(unlock_unit);
696 /* open.c */
698 extern gfc_unit *new_unit (st_parameter_open *, gfc_unit *, unit_flags *);
699 internal_proto(new_unit);
701 /* format.c */
703 extern void parse_format (st_parameter_dt *);
704 internal_proto(parse_format);
706 extern const fnode *next_format (st_parameter_dt *);
707 internal_proto(next_format);
709 extern void unget_format (st_parameter_dt *, const fnode *);
710 internal_proto(unget_format);
712 extern void format_error (st_parameter_dt *, const fnode *, const char *);
713 internal_proto(format_error);
715 extern void free_format_data (st_parameter_dt *);
716 internal_proto(free_format_data);
718 /* transfer.c */
720 #define SCRATCH_SIZE 300
722 extern const char *type_name (bt);
723 internal_proto(type_name);
725 extern void *read_block (st_parameter_dt *, int *);
726 internal_proto(read_block);
728 extern char *read_sf (st_parameter_dt *, int *, int);
729 internal_proto(read_sf);
731 extern void *write_block (st_parameter_dt *, int);
732 internal_proto(write_block);
734 extern gfc_offset next_array_record (st_parameter_dt *, array_loop_spec *);
735 internal_proto(next_array_record);
737 extern gfc_offset init_loop_spec (gfc_array_char *, array_loop_spec *);
738 internal_proto(init_loop_spec);
740 extern void next_record (st_parameter_dt *, int);
741 internal_proto(next_record);
743 extern void reverse_memcpy (void *, const void *, size_t);
744 internal_proto (reverse_memcpy);
746 /* read.c */
748 extern void set_integer (void *, GFC_INTEGER_LARGEST, int);
749 internal_proto(set_integer);
751 extern GFC_UINTEGER_LARGEST max_value (int, int);
752 internal_proto(max_value);
754 extern int convert_real (st_parameter_dt *, void *, const char *, int);
755 internal_proto(convert_real);
757 extern void read_a (st_parameter_dt *, const fnode *, char *, int);
758 internal_proto(read_a);
760 extern void read_f (st_parameter_dt *, const fnode *, char *, int);
761 internal_proto(read_f);
763 extern void read_l (st_parameter_dt *, const fnode *, char *, int);
764 internal_proto(read_l);
766 extern void read_x (st_parameter_dt *, int);
767 internal_proto(read_x);
769 extern void read_radix (st_parameter_dt *, const fnode *, char *, int, int);
770 internal_proto(read_radix);
772 extern void read_decimal (st_parameter_dt *, const fnode *, char *, int);
773 internal_proto(read_decimal);
775 /* list_read.c */
777 extern void list_formatted_read (st_parameter_dt *, bt, void *, int, size_t,
778 size_t);
779 internal_proto(list_formatted_read);
781 extern void finish_list_read (st_parameter_dt *);
782 internal_proto(finish_list_read);
784 extern void namelist_read (st_parameter_dt *);
785 internal_proto(namelist_read);
787 extern void namelist_write (st_parameter_dt *);
788 internal_proto(namelist_write);
790 /* write.c */
792 extern void write_a (st_parameter_dt *, const fnode *, const char *, int);
793 internal_proto(write_a);
795 extern void write_b (st_parameter_dt *, const fnode *, const char *, int);
796 internal_proto(write_b);
798 extern void write_d (st_parameter_dt *, const fnode *, const char *, int);
799 internal_proto(write_d);
801 extern void write_e (st_parameter_dt *, const fnode *, const char *, int);
802 internal_proto(write_e);
804 extern void write_en (st_parameter_dt *, const fnode *, const char *, int);
805 internal_proto(write_en);
807 extern void write_es (st_parameter_dt *, const fnode *, const char *, int);
808 internal_proto(write_es);
810 extern void write_f (st_parameter_dt *, const fnode *, const char *, int);
811 internal_proto(write_f);
813 extern void write_i (st_parameter_dt *, const fnode *, const char *, int);
814 internal_proto(write_i);
816 extern void write_l (st_parameter_dt *, const fnode *, char *, int);
817 internal_proto(write_l);
819 extern void write_o (st_parameter_dt *, const fnode *, const char *, int);
820 internal_proto(write_o);
822 extern void write_x (st_parameter_dt *, int, int);
823 internal_proto(write_x);
825 extern void write_z (st_parameter_dt *, const fnode *, const char *, int);
826 internal_proto(write_z);
828 extern void list_formatted_write (st_parameter_dt *, bt, void *, int, size_t,
829 size_t);
830 internal_proto(list_formatted_write);
832 /* size_from_kind.c */
833 extern size_t size_from_real_kind (int);
834 internal_proto(size_from_real_kind);
836 extern size_t size_from_complex_kind (int);
837 internal_proto(size_from_complex_kind);
839 /* lock.c */
840 extern void free_ionml (st_parameter_dt *);
841 internal_proto(free_ionml);
843 static inline void
844 inc_waiting_locked (gfc_unit *u)
846 #ifdef HAVE_SYNC_FETCH_AND_ADD
847 (void) __sync_fetch_and_add (&u->waiting, 1);
848 #else
849 u->waiting++;
850 #endif
853 static inline int
854 predec_waiting_locked (gfc_unit *u)
856 #ifdef HAVE_SYNC_FETCH_AND_ADD
857 return __sync_add_and_fetch (&u->waiting, -1);
858 #else
859 return --u->waiting;
860 #endif
863 static inline void
864 dec_waiting_unlocked (gfc_unit *u)
866 #ifdef HAVE_SYNC_FETCH_AND_ADD
867 (void) __sync_fetch_and_add (&u->waiting, -1);
868 #else
869 __gthread_mutex_lock (&unit_lock);
870 u->waiting--;
871 __gthread_mutex_unlock (&unit_lock);
872 #endif
875 #endif