lang-specs.h: Ensure -mrtp switch is passed when using either rtp-smp or ravenscar...
[official-gcc.git] / libgfortran / io / io.h
blob37353d742e87d45464c6a6cde0782ffd716cc18a
1 /* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
2 Free Software Foundation, Inc.
3 Contributed by Andy Vaught
4 F2003 I/O support contributed by Jerry DeLisle
6 This file is part of the GNU Fortran 95 runtime library (libgfortran).
8 Libgfortran is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
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 General Public License for more details.
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. */
27 #ifndef GFOR_IO_H
28 #define GFOR_IO_H
30 /* IO library include. */
32 #include "libgfortran.h"
34 #include <gthr.h>
36 /* Forward declarations. */
37 struct st_parameter_dt;
38 typedef struct stream stream;
39 struct fbuf;
40 struct format_data;
41 typedef struct fnode fnode;
42 struct gfc_unit;
45 /* Macros for testing what kinds of I/O we are doing. */
47 #define is_array_io(dtp) ((dtp)->internal_unit_desc)
49 #define is_internal_unit(dtp) ((dtp)->u.p.unit_is_internal)
51 #define is_stream_io(dtp) ((dtp)->u.p.current_unit->flags.access == ACCESS_STREAM)
53 #define is_char4_unit(dtp) ((dtp)->u.p.unit_is_internal && (dtp)->common.unit)
55 /* The array_loop_spec contains the variables for the loops over index ranges
56 that are encountered. */
58 typedef struct array_loop_spec
60 /* Index counter for this dimension. */
61 index_type idx;
63 /* Start for the index counter. */
64 index_type start;
66 /* End for the index counter. */
67 index_type end;
69 /* Step for the index counter. */
70 index_type step;
72 array_loop_spec;
74 /* A stucture to build a hash table for format data. */
76 #define FORMAT_HASH_SIZE 16
78 typedef struct format_hash_entry
80 char *key;
81 gfc_charlen_type key_len;
82 struct format_data *hashed_fmt;
84 format_hash_entry;
86 /* Representation of a namelist object in libgfortran
88 Namelist Records
89 &GROUPNAME OBJECT=value[s] [,OBJECT=value[s]].../
91 &GROUPNAME OBJECT=value[s] [,OBJECT=value[s]]...&END
93 The object can be a fully qualified, compound name for an intrinsic
94 type, derived types or derived type components. So, a substring
95 a(:)%b(4)%ch(2:4)(1:7) has to be treated correctly in namelist
96 read. Hence full information about the structure of the object has
97 to be available to list_read.c and write.
99 These requirements are met by the following data structures.
101 namelist_info type contains all the scalar information about the
102 object and arrays of descriptor_dimension and array_loop_spec types for
103 arrays. */
105 typedef struct namelist_type
107 /* Object type. */
108 bt type;
110 /* Object name. */
111 char * var_name;
113 /* Address for the start of the object's data. */
114 void * mem_pos;
116 /* Flag to show that a read is to be attempted for this node. */
117 int touched;
119 /* Length of intrinsic type in bytes. */
120 int len;
122 /* Rank of the object. */
123 int var_rank;
125 /* Overall size of the object in bytes. */
126 index_type size;
128 /* Length of character string. */
129 index_type string_length;
131 descriptor_dimension * dim;
132 array_loop_spec * ls;
133 struct namelist_type * next;
135 namelist_info;
137 /* Options for the OPEN statement. */
139 typedef enum
140 { ACCESS_SEQUENTIAL, ACCESS_DIRECT, ACCESS_APPEND, ACCESS_STREAM,
141 ACCESS_UNSPECIFIED
143 unit_access;
145 typedef enum
146 { ACTION_READ, ACTION_WRITE, ACTION_READWRITE,
147 ACTION_UNSPECIFIED
149 unit_action;
151 typedef enum
152 { BLANK_NULL, BLANK_ZERO, BLANK_UNSPECIFIED }
153 unit_blank;
155 typedef enum
156 { DELIM_NONE, DELIM_APOSTROPHE, DELIM_QUOTE,
157 DELIM_UNSPECIFIED
159 unit_delim;
161 typedef enum
162 { FORM_FORMATTED, FORM_UNFORMATTED, FORM_UNSPECIFIED }
163 unit_form;
165 typedef enum
166 { POSITION_ASIS, POSITION_REWIND, POSITION_APPEND,
167 POSITION_UNSPECIFIED
169 unit_position;
171 typedef enum
172 { STATUS_UNKNOWN, STATUS_OLD, STATUS_NEW, STATUS_SCRATCH,
173 STATUS_REPLACE, STATUS_UNSPECIFIED
175 unit_status;
177 typedef enum
178 { PAD_YES, PAD_NO, PAD_UNSPECIFIED }
179 unit_pad;
181 typedef enum
182 { DECIMAL_POINT, DECIMAL_COMMA, DECIMAL_UNSPECIFIED }
183 unit_decimal;
185 typedef enum
186 { ENCODING_UTF8, ENCODING_DEFAULT, ENCODING_UNSPECIFIED }
187 unit_encoding;
189 typedef enum
190 { ROUND_UP, ROUND_DOWN, ROUND_ZERO, ROUND_NEAREST, ROUND_COMPATIBLE,
191 ROUND_PROCDEFINED, ROUND_UNSPECIFIED }
192 unit_round;
194 /* NOTE: unit_sign must correspond with the sign_status enumerator in
195 st_parameter_dt to not break the ABI. */
196 typedef enum
197 { SIGN_PROCDEFINED, SIGN_SUPPRESS, SIGN_PLUS, SIGN_UNSPECIFIED }
198 unit_sign;
200 typedef enum
201 { ADVANCE_YES, ADVANCE_NO, ADVANCE_UNSPECIFIED }
202 unit_advance;
204 typedef enum
205 {READING, WRITING}
206 unit_mode;
208 typedef enum
209 { ASYNC_YES, ASYNC_NO, ASYNC_UNSPECIFIED }
210 unit_async;
212 typedef enum
213 { SIGN_S, SIGN_SS, SIGN_SP }
214 unit_sign_s;
216 #define CHARACTER1(name) \
217 char * name; \
218 gfc_charlen_type name ## _len
219 #define CHARACTER2(name) \
220 gfc_charlen_type name ## _len; \
221 char * name
223 typedef struct
225 st_parameter_common common;
226 GFC_INTEGER_4 recl_in;
227 CHARACTER2 (file);
228 CHARACTER1 (status);
229 CHARACTER2 (access);
230 CHARACTER1 (form);
231 CHARACTER2 (blank);
232 CHARACTER1 (position);
233 CHARACTER2 (action);
234 CHARACTER1 (delim);
235 CHARACTER2 (pad);
236 CHARACTER1 (convert);
237 CHARACTER2 (decimal);
238 CHARACTER1 (encoding);
239 CHARACTER2 (round);
240 CHARACTER1 (sign);
241 CHARACTER2 (asynchronous);
242 GFC_INTEGER_4 *newunit;
244 st_parameter_open;
246 #define IOPARM_CLOSE_HAS_STATUS (1 << 7)
248 typedef struct
250 st_parameter_common common;
251 CHARACTER1 (status);
253 st_parameter_close;
255 typedef struct
257 st_parameter_common common;
259 st_parameter_filepos;
261 #define IOPARM_INQUIRE_HAS_EXIST (1 << 7)
262 #define IOPARM_INQUIRE_HAS_OPENED (1 << 8)
263 #define IOPARM_INQUIRE_HAS_NUMBER (1 << 9)
264 #define IOPARM_INQUIRE_HAS_NAMED (1 << 10)
265 #define IOPARM_INQUIRE_HAS_NEXTREC (1 << 11)
266 #define IOPARM_INQUIRE_HAS_RECL_OUT (1 << 12)
267 #define IOPARM_INQUIRE_HAS_STRM_POS_OUT (1 << 13)
268 #define IOPARM_INQUIRE_HAS_FILE (1 << 14)
269 #define IOPARM_INQUIRE_HAS_ACCESS (1 << 15)
270 #define IOPARM_INQUIRE_HAS_FORM (1 << 16)
271 #define IOPARM_INQUIRE_HAS_BLANK (1 << 17)
272 #define IOPARM_INQUIRE_HAS_POSITION (1 << 18)
273 #define IOPARM_INQUIRE_HAS_ACTION (1 << 19)
274 #define IOPARM_INQUIRE_HAS_DELIM (1 << 20)
275 #define IOPARM_INQUIRE_HAS_PAD (1 << 21)
276 #define IOPARM_INQUIRE_HAS_NAME (1 << 22)
277 #define IOPARM_INQUIRE_HAS_SEQUENTIAL (1 << 23)
278 #define IOPARM_INQUIRE_HAS_DIRECT (1 << 24)
279 #define IOPARM_INQUIRE_HAS_FORMATTED (1 << 25)
280 #define IOPARM_INQUIRE_HAS_UNFORMATTED (1 << 26)
281 #define IOPARM_INQUIRE_HAS_READ (1 << 27)
282 #define IOPARM_INQUIRE_HAS_WRITE (1 << 28)
283 #define IOPARM_INQUIRE_HAS_READWRITE (1 << 29)
284 #define IOPARM_INQUIRE_HAS_CONVERT (1 << 30)
285 #define IOPARM_INQUIRE_HAS_FLAGS2 (1 << 31)
287 #define IOPARM_INQUIRE_HAS_ASYNCHRONOUS (1 << 0)
288 #define IOPARM_INQUIRE_HAS_DECIMAL (1 << 1)
289 #define IOPARM_INQUIRE_HAS_ENCODING (1 << 2)
290 #define IOPARM_INQUIRE_HAS_ROUND (1 << 3)
291 #define IOPARM_INQUIRE_HAS_SIGN (1 << 4)
292 #define IOPARM_INQUIRE_HAS_PENDING (1 << 5)
293 #define IOPARM_INQUIRE_HAS_SIZE (1 << 6)
294 #define IOPARM_INQUIRE_HAS_ID (1 << 7)
296 typedef struct
298 st_parameter_common common;
299 GFC_INTEGER_4 *exist, *opened, *number, *named;
300 GFC_INTEGER_4 *nextrec, *recl_out;
301 GFC_IO_INT *strm_pos_out;
302 CHARACTER1 (file);
303 CHARACTER2 (access);
304 CHARACTER1 (form);
305 CHARACTER2 (blank);
306 CHARACTER1 (position);
307 CHARACTER2 (action);
308 CHARACTER1 (delim);
309 CHARACTER2 (pad);
310 CHARACTER1 (name);
311 CHARACTER2 (sequential);
312 CHARACTER1 (direct);
313 CHARACTER2 (formatted);
314 CHARACTER1 (unformatted);
315 CHARACTER2 (read);
316 CHARACTER1 (write);
317 CHARACTER2 (readwrite);
318 CHARACTER1 (convert);
319 GFC_INTEGER_4 flags2;
320 CHARACTER1 (asynchronous);
321 CHARACTER2 (decimal);
322 CHARACTER1 (encoding);
323 CHARACTER2 (round);
324 CHARACTER1 (sign);
325 GFC_INTEGER_4 *pending;
326 GFC_IO_INT *size;
327 GFC_INTEGER_4 *id;
329 st_parameter_inquire;
332 #define IOPARM_DT_LIST_FORMAT (1 << 7)
333 #define IOPARM_DT_NAMELIST_READ_MODE (1 << 8)
334 #define IOPARM_DT_HAS_REC (1 << 9)
335 #define IOPARM_DT_HAS_SIZE (1 << 10)
336 #define IOPARM_DT_HAS_IOLENGTH (1 << 11)
337 #define IOPARM_DT_HAS_FORMAT (1 << 12)
338 #define IOPARM_DT_HAS_ADVANCE (1 << 13)
339 #define IOPARM_DT_HAS_INTERNAL_UNIT (1 << 14)
340 #define IOPARM_DT_HAS_NAMELIST_NAME (1 << 15)
341 #define IOPARM_DT_HAS_ID (1 << 16)
342 #define IOPARM_DT_HAS_POS (1 << 17)
343 #define IOPARM_DT_HAS_ASYNCHRONOUS (1 << 18)
344 #define IOPARM_DT_HAS_BLANK (1 << 19)
345 #define IOPARM_DT_HAS_DECIMAL (1 << 20)
346 #define IOPARM_DT_HAS_DELIM (1 << 21)
347 #define IOPARM_DT_HAS_PAD (1 << 22)
348 #define IOPARM_DT_HAS_ROUND (1 << 23)
349 #define IOPARM_DT_HAS_SIGN (1 << 24)
350 #define IOPARM_DT_HAS_F2003 (1 << 25)
351 /* Internal use bit. */
352 #define IOPARM_DT_IONML_SET (1 << 31)
355 typedef struct st_parameter_dt
357 st_parameter_common common;
358 GFC_IO_INT rec;
359 GFC_IO_INT *size, *iolength;
360 gfc_array_char *internal_unit_desc;
361 CHARACTER1 (format);
362 CHARACTER2 (advance);
363 CHARACTER1 (internal_unit);
364 CHARACTER2 (namelist_name);
365 /* Private part of the structure. The compiler just needs
366 to reserve enough space. */
367 union
369 struct
371 void (*transfer) (struct st_parameter_dt *, bt, void *, int,
372 size_t, size_t);
373 struct gfc_unit *current_unit;
374 /* Item number in a formatted data transfer. Also used in namelist
375 read_logical as an index into line_buffer. */
376 int item_count;
377 unit_mode mode;
378 unit_blank blank_status;
379 unit_sign sign_status;
380 int scale_factor;
381 int max_pos; /* Maximum righthand column written to. */
382 /* Number of skips + spaces to be done for T and X-editing. */
383 int skips;
384 /* Number of spaces to be done for T and X-editing. */
385 int pending_spaces;
386 /* Whether an EOR condition was encountered. Value is:
387 0 if no EOR was encountered
388 1 if an EOR was encountered due to a 1-byte marker (LF)
389 2 if an EOR was encountered due to a 2-bytes marker (CRLF) */
390 int sf_seen_eor;
391 unit_advance advance_status;
392 unsigned reversion_flag : 1; /* Format reversion has occurred. */
393 unsigned first_item : 1;
394 unsigned seen_dollar : 1;
395 unsigned eor_condition : 1;
396 unsigned no_leading_blank : 1;
397 unsigned char_flag : 1;
398 unsigned input_complete : 1;
399 unsigned at_eol : 1;
400 unsigned comma_flag : 1;
401 /* A namelist specific flag used in the list directed library
402 to flag that calls are being made from namelist read (eg. to
403 ignore comments or to treat '/' as a terminator) */
404 unsigned namelist_mode : 1;
405 /* A namelist specific flag used in the list directed library
406 to flag read errors and return, so that an attempt can be
407 made to read a new object name. */
408 unsigned nml_read_error : 1;
409 /* A sequential formatted read specific flag used to signal that a
410 character string is being read so don't use commas to shorten a
411 formatted field width. */
412 unsigned sf_read_comma : 1;
413 /* A namelist specific flag used to enable reading input from
414 line_buffer for logical reads. */
415 unsigned line_buffer_enabled : 1;
416 /* An internal unit specific flag used to identify that the associated
417 unit is internal. */
418 unsigned unit_is_internal : 1;
419 /* An internal unit specific flag to signify an EOF condition for list
420 directed read. */
421 unsigned at_eof : 1;
422 /* Used for g0 floating point output. */
423 unsigned g0_no_blanks : 1;
424 /* Used to signal use of free_format_data. */
425 unsigned format_not_saved : 1;
426 /* 14 unused bits. */
428 /* Used for ungetc() style functionality. Possible values
429 are an unsigned char, EOF, or EOF - 1 used to mark the
430 field as not valid. */
431 int last_char;
432 char nml_delim;
434 int repeat_count;
435 int saved_length;
436 int saved_used;
437 bt saved_type;
438 char *saved_string;
439 char *scratch;
440 char *line_buffer;
441 struct format_data *fmt;
442 namelist_info *ionml;
443 /* A flag used to identify when a non-standard expanded namelist read
444 has occurred. */
445 int expanded_read;
446 /* Storage area for values except for strings. Must be
447 large enough to hold a complex value (two reals) of the
448 largest kind. */
449 char value[32];
450 GFC_IO_INT size_used;
451 } p;
452 /* This pad size must be equal to the pad_size declared in
453 trans-io.c (gfc_build_io_library_fndecls). The above structure
454 must be smaller or equal to this array. */
455 char pad[16 * sizeof (char *) + 32 * sizeof (int)];
456 } u;
457 GFC_INTEGER_4 *id;
458 GFC_IO_INT pos;
459 CHARACTER1 (asynchronous);
460 CHARACTER2 (blank);
461 CHARACTER1 (decimal);
462 CHARACTER2 (delim);
463 CHARACTER1 (pad);
464 CHARACTER2 (round);
465 CHARACTER1 (sign);
467 st_parameter_dt;
469 /* Ensure st_parameter_dt's u.pad is bigger or equal to u.p. */
470 extern char check_st_parameter_dt[sizeof (((st_parameter_dt *) 0)->u.pad)
471 >= sizeof (((st_parameter_dt *) 0)->u.p)
472 ? 1 : -1];
474 #define IOPARM_WAIT_HAS_ID (1 << 7)
476 typedef struct
478 st_parameter_common common;
479 CHARACTER1 (id);
481 st_parameter_wait;
484 #undef CHARACTER1
485 #undef CHARACTER2
487 typedef struct
489 unit_access access;
490 unit_action action;
491 unit_blank blank;
492 unit_delim delim;
493 unit_form form;
494 int is_notpadded;
495 unit_position position;
496 unit_status status;
497 unit_pad pad;
498 unit_convert convert;
499 int has_recl;
500 unit_decimal decimal;
501 unit_encoding encoding;
502 unit_round round;
503 unit_sign sign;
504 unit_async async;
506 unit_flags;
509 typedef struct gfc_unit
511 int unit_number;
512 stream *s;
514 /* Treap links. */
515 struct gfc_unit *left, *right;
516 int priority;
518 int read_bad, current_record, saved_pos, previous_nonadvancing_write;
520 enum
521 { NO_ENDFILE, AT_ENDFILE, AFTER_ENDFILE }
522 endfile;
524 unit_mode mode;
525 unit_flags flags;
526 unit_pad pad_status;
527 unit_decimal decimal_status;
528 unit_delim delim_status;
529 unit_round round_status;
531 /* recl -- Record length of the file.
532 last_record -- Last record number read or written
533 maxrec -- Maximum record number in a direct access file
534 bytes_left -- Bytes left in current record.
535 strm_pos -- Current position in file for STREAM I/O.
536 recl_subrecord -- Maximum length for subrecord.
537 bytes_left_subrecord -- Bytes left in current subrecord. */
538 gfc_offset recl, last_record, maxrec, bytes_left, strm_pos,
539 recl_subrecord, bytes_left_subrecord;
541 /* Set to 1 if we have read a subrecord. */
543 int continued;
545 __gthread_mutex_t lock;
546 /* Number of threads waiting to acquire this unit's lock.
547 When non-zero, close_unit doesn't only removes the unit
548 from the UNIT_ROOT tree, but doesn't free it and the
549 last of the waiting threads will do that.
550 This must be either atomically increased/decreased, or
551 always guarded by UNIT_LOCK. */
552 int waiting;
553 /* Flag set by close_unit if the unit as been closed.
554 Must be manipulated under unit's lock. */
555 int closed;
557 /* For traversing arrays */
558 array_loop_spec *ls;
559 int rank;
561 int file_len;
562 char *file;
564 /* The format hash table. */
565 struct format_hash_entry format_hash_table[FORMAT_HASH_SIZE];
567 /* Formatting buffer. */
568 struct fbuf *fbuf;
570 gfc_unit;
573 /* unit.c */
575 /* Maximum file offset, computed at library initialization time. */
576 extern gfc_offset max_offset;
577 internal_proto(max_offset);
579 /* Unit number to be assigned when NEWUNIT is used in an OPEN statement. */
580 extern GFC_INTEGER_4 next_available_newunit;
581 internal_proto(next_available_newunit);
583 /* Unit tree root. */
584 extern gfc_unit *unit_root;
585 internal_proto(unit_root);
587 extern __gthread_mutex_t unit_lock;
588 internal_proto(unit_lock);
590 extern int close_unit (gfc_unit *);
591 internal_proto(close_unit);
593 extern gfc_unit *get_internal_unit (st_parameter_dt *);
594 internal_proto(get_internal_unit);
596 extern void free_internal_unit (st_parameter_dt *);
597 internal_proto(free_internal_unit);
599 extern gfc_unit *find_unit (int);
600 internal_proto(find_unit);
602 extern gfc_unit *find_or_create_unit (int);
603 internal_proto(find_or_create_unit);
605 extern gfc_unit *get_unit (st_parameter_dt *, int);
606 internal_proto(get_unit);
608 extern void unlock_unit (gfc_unit *);
609 internal_proto(unlock_unit);
611 extern void update_position (gfc_unit *);
612 internal_proto(update_position);
614 extern void finish_last_advance_record (gfc_unit *u);
615 internal_proto (finish_last_advance_record);
617 extern int unit_truncate (gfc_unit *, gfc_offset, st_parameter_common *);
618 internal_proto (unit_truncate);
620 extern GFC_INTEGER_4 get_unique_unit_number (st_parameter_open *);
621 internal_proto(get_unique_unit_number);
623 /* open.c */
625 extern gfc_unit *new_unit (st_parameter_open *, gfc_unit *, unit_flags *);
626 internal_proto(new_unit);
629 /* transfer.c */
631 #define SCRATCH_SIZE 300
633 extern const char *type_name (bt);
634 internal_proto(type_name);
636 extern void * read_block_form (st_parameter_dt *, int *);
637 internal_proto(read_block_form);
639 extern void * read_block_form4 (st_parameter_dt *, int *);
640 internal_proto(read_block_form4);
642 extern void *write_block (st_parameter_dt *, int);
643 internal_proto(write_block);
645 extern gfc_offset next_array_record (st_parameter_dt *, array_loop_spec *,
646 int*);
647 internal_proto(next_array_record);
649 extern gfc_offset init_loop_spec (gfc_array_char *, array_loop_spec *,
650 gfc_offset *);
651 internal_proto(init_loop_spec);
653 extern void next_record (st_parameter_dt *, int);
654 internal_proto(next_record);
656 extern void reverse_memcpy (void *, const void *, size_t);
657 internal_proto (reverse_memcpy);
659 extern void st_wait (st_parameter_wait *);
660 export_proto(st_wait);
662 extern void hit_eof (st_parameter_dt *);
663 internal_proto(hit_eof);
665 /* read.c */
667 extern void set_integer (void *, GFC_INTEGER_LARGEST, int);
668 internal_proto(set_integer);
670 extern GFC_UINTEGER_LARGEST max_value (int, int);
671 internal_proto(max_value);
673 extern int convert_real (st_parameter_dt *, void *, const char *, int);
674 internal_proto(convert_real);
676 extern int convert_infnan (st_parameter_dt *, void *, const char *, int);
677 internal_proto(convert_infnan);
679 extern void read_a (st_parameter_dt *, const fnode *, char *, int);
680 internal_proto(read_a);
682 extern void read_a_char4 (st_parameter_dt *, const fnode *, char *, int);
683 internal_proto(read_a);
685 extern void read_f (st_parameter_dt *, const fnode *, char *, int);
686 internal_proto(read_f);
688 extern void read_l (st_parameter_dt *, const fnode *, char *, int);
689 internal_proto(read_l);
691 extern void read_x (st_parameter_dt *, int);
692 internal_proto(read_x);
694 extern void read_radix (st_parameter_dt *, const fnode *, char *, int, int);
695 internal_proto(read_radix);
697 extern void read_decimal (st_parameter_dt *, const fnode *, char *, int);
698 internal_proto(read_decimal);
700 /* list_read.c */
702 extern void list_formatted_read (st_parameter_dt *, bt, void *, int, size_t,
703 size_t);
704 internal_proto(list_formatted_read);
706 extern void finish_list_read (st_parameter_dt *);
707 internal_proto(finish_list_read);
709 extern void namelist_read (st_parameter_dt *);
710 internal_proto(namelist_read);
712 extern void namelist_write (st_parameter_dt *);
713 internal_proto(namelist_write);
715 /* write.c */
717 extern void write_a (st_parameter_dt *, const fnode *, const char *, int);
718 internal_proto(write_a);
720 extern void write_a_char4 (st_parameter_dt *, const fnode *, const char *, int);
721 internal_proto(write_a_char4);
723 extern void write_b (st_parameter_dt *, const fnode *, const char *, int);
724 internal_proto(write_b);
726 extern void write_d (st_parameter_dt *, const fnode *, const char *, int);
727 internal_proto(write_d);
729 extern void write_e (st_parameter_dt *, const fnode *, const char *, int);
730 internal_proto(write_e);
732 extern void write_en (st_parameter_dt *, const fnode *, const char *, int);
733 internal_proto(write_en);
735 extern void write_es (st_parameter_dt *, const fnode *, const char *, int);
736 internal_proto(write_es);
738 extern void write_f (st_parameter_dt *, const fnode *, const char *, int);
739 internal_proto(write_f);
741 extern void write_i (st_parameter_dt *, const fnode *, const char *, int);
742 internal_proto(write_i);
744 extern void write_l (st_parameter_dt *, const fnode *, char *, int);
745 internal_proto(write_l);
747 extern void write_o (st_parameter_dt *, const fnode *, const char *, int);
748 internal_proto(write_o);
750 extern void write_real (st_parameter_dt *, const char *, int);
751 internal_proto(write_real);
753 extern void write_real_g0 (st_parameter_dt *, const char *, int, int);
754 internal_proto(write_real_g0);
756 extern void write_x (st_parameter_dt *, int, int);
757 internal_proto(write_x);
759 extern void write_z (st_parameter_dt *, const fnode *, const char *, int);
760 internal_proto(write_z);
762 extern void list_formatted_write (st_parameter_dt *, bt, void *, int, size_t,
763 size_t);
764 internal_proto(list_formatted_write);
766 /* size_from_kind.c */
767 extern size_t size_from_real_kind (int);
768 internal_proto(size_from_real_kind);
770 extern size_t size_from_complex_kind (int);
771 internal_proto(size_from_complex_kind);
774 /* lock.c */
775 extern void free_ionml (st_parameter_dt *);
776 internal_proto(free_ionml);
778 static inline void
779 inc_waiting_locked (gfc_unit *u)
781 #ifdef HAVE_SYNC_FETCH_AND_ADD
782 (void) __sync_fetch_and_add (&u->waiting, 1);
783 #else
784 u->waiting++;
785 #endif
788 static inline int
789 predec_waiting_locked (gfc_unit *u)
791 #ifdef HAVE_SYNC_FETCH_AND_ADD
792 return __sync_add_and_fetch (&u->waiting, -1);
793 #else
794 return --u->waiting;
795 #endif
798 static inline void
799 dec_waiting_unlocked (gfc_unit *u)
801 #ifdef HAVE_SYNC_FETCH_AND_ADD
802 (void) __sync_fetch_and_add (&u->waiting, -1);
803 #else
804 __gthread_mutex_lock (&unit_lock);
805 u->waiting--;
806 __gthread_mutex_unlock (&unit_lock);
807 #endif
810 #endif