PR 43726 * config/lm32/lm32.h: Remove definition of GO_IF_MODE_DEPENDENT_ADDRESS.
[official-gcc.git] / libgfortran / io / io.h
blobacbec77e62a6c43c464d9ba647121dedae7b9915
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 <setjmp.h>
35 #include <gthr.h>
37 /* Basic types used in data transfers. */
39 typedef enum
40 { BT_NULL, BT_INTEGER, BT_LOGICAL, BT_CHARACTER, BT_REAL,
41 BT_COMPLEX
43 bt;
45 /* Forward declarations. */
46 struct st_parameter_dt;
47 typedef struct stream stream;
48 struct fbuf;
49 struct format_data;
50 typedef struct fnode fnode;
51 struct gfc_unit;
54 /* Macros for testing what kinds of I/O we are doing. */
56 #define is_array_io(dtp) ((dtp)->internal_unit_desc)
58 #define is_internal_unit(dtp) ((dtp)->u.p.unit_is_internal)
60 #define is_stream_io(dtp) ((dtp)->u.p.current_unit->flags.access == ACCESS_STREAM)
62 /* The array_loop_spec contains the variables for the loops over index ranges
63 that are encountered. Since the variables can be negative, ssize_t
64 is used. */
66 typedef struct array_loop_spec
68 /* Index counter for this dimension. */
69 ssize_t idx;
71 /* Start for the index counter. */
72 ssize_t start;
74 /* End for the index counter. */
75 ssize_t end;
77 /* Step for the index counter. */
78 ssize_t step;
80 array_loop_spec;
82 /* A stucture to build a hash table for format data. */
84 #define FORMAT_HASH_SIZE 16
86 typedef struct format_hash_entry
88 char *key;
89 gfc_charlen_type key_len;
90 struct format_data *hashed_fmt;
92 format_hash_entry;
94 /* Representation of a namelist object in libgfortran
96 Namelist Records
97 &GROUPNAME OBJECT=value[s] [,OBJECT=value[s]].../
99 &GROUPNAME OBJECT=value[s] [,OBJECT=value[s]]...&END
101 The object can be a fully qualified, compound name for an intrinsic
102 type, derived types or derived type components. So, a substring
103 a(:)%b(4)%ch(2:4)(1:7) has to be treated correctly in namelist
104 read. Hence full information about the structure of the object has
105 to be available to list_read.c and write.
107 These requirements are met by the following data structures.
109 namelist_info type contains all the scalar information about the
110 object and arrays of descriptor_dimension and array_loop_spec types for
111 arrays. */
113 typedef struct namelist_type
115 /* Object type, stored as GFC_DTYPE_xxxx. */
116 dtype type;
118 /* Object name. */
119 char * var_name;
121 /* Address for the start of the object's data. */
122 void * mem_pos;
124 /* Flag to show that a read is to be attempted for this node. */
125 int touched;
127 /* Length of intrinsic type in bytes. */
128 int len;
130 /* Rank of the object. */
131 int var_rank;
133 /* Overall size of the object in bytes. */
134 index_type size;
136 /* Length of character string. */
137 index_type string_length;
139 descriptor_dimension * dim;
140 array_loop_spec * ls;
141 struct namelist_type * next;
143 namelist_info;
145 /* Options for the OPEN statement. */
147 typedef enum
148 { ACCESS_SEQUENTIAL, ACCESS_DIRECT, ACCESS_APPEND, ACCESS_STREAM,
149 ACCESS_UNSPECIFIED
151 unit_access;
153 typedef enum
154 { ACTION_READ, ACTION_WRITE, ACTION_READWRITE,
155 ACTION_UNSPECIFIED
157 unit_action;
159 typedef enum
160 { BLANK_NULL, BLANK_ZERO, BLANK_UNSPECIFIED }
161 unit_blank;
163 typedef enum
164 { DELIM_NONE, DELIM_APOSTROPHE, DELIM_QUOTE,
165 DELIM_UNSPECIFIED
167 unit_delim;
169 typedef enum
170 { FORM_FORMATTED, FORM_UNFORMATTED, FORM_UNSPECIFIED }
171 unit_form;
173 typedef enum
174 { POSITION_ASIS, POSITION_REWIND, POSITION_APPEND,
175 POSITION_UNSPECIFIED
177 unit_position;
179 typedef enum
180 { STATUS_UNKNOWN, STATUS_OLD, STATUS_NEW, STATUS_SCRATCH,
181 STATUS_REPLACE, STATUS_UNSPECIFIED
183 unit_status;
185 typedef enum
186 { PAD_YES, PAD_NO, PAD_UNSPECIFIED }
187 unit_pad;
189 typedef enum
190 { DECIMAL_POINT, DECIMAL_COMMA, DECIMAL_UNSPECIFIED }
191 unit_decimal;
193 typedef enum
194 { ENCODING_UTF8, ENCODING_DEFAULT, ENCODING_UNSPECIFIED }
195 unit_encoding;
197 typedef enum
198 { ROUND_UP, ROUND_DOWN, ROUND_ZERO, ROUND_NEAREST, ROUND_COMPATIBLE,
199 ROUND_PROCDEFINED, ROUND_UNSPECIFIED }
200 unit_round;
202 /* NOTE: unit_sign must correspond with the sign_status enumerator in
203 st_parameter_dt to not break the ABI. */
204 typedef enum
205 { SIGN_PROCDEFINED, SIGN_SUPPRESS, SIGN_PLUS, SIGN_UNSPECIFIED }
206 unit_sign;
208 typedef enum
209 { ADVANCE_YES, ADVANCE_NO, ADVANCE_UNSPECIFIED }
210 unit_advance;
212 typedef enum
213 {READING, WRITING}
214 unit_mode;
216 typedef enum
217 { ASYNC_YES, ASYNC_NO, ASYNC_UNSPECIFIED }
218 unit_async;
220 typedef enum
221 { SIGN_S, SIGN_SS, SIGN_SP }
222 unit_sign_s;
224 #define CHARACTER1(name) \
225 char * name; \
226 gfc_charlen_type name ## _len
227 #define CHARACTER2(name) \
228 gfc_charlen_type name ## _len; \
229 char * name
231 typedef struct
233 st_parameter_common common;
234 GFC_INTEGER_4 recl_in;
235 CHARACTER2 (file);
236 CHARACTER1 (status);
237 CHARACTER2 (access);
238 CHARACTER1 (form);
239 CHARACTER2 (blank);
240 CHARACTER1 (position);
241 CHARACTER2 (action);
242 CHARACTER1 (delim);
243 CHARACTER2 (pad);
244 CHARACTER1 (convert);
245 CHARACTER2 (decimal);
246 CHARACTER1 (encoding);
247 CHARACTER2 (round);
248 CHARACTER1 (sign);
249 CHARACTER2 (asynchronous);
250 GFC_INTEGER_4 *newunit;
252 st_parameter_open;
254 #define IOPARM_CLOSE_HAS_STATUS (1 << 7)
256 typedef struct
258 st_parameter_common common;
259 CHARACTER1 (status);
261 st_parameter_close;
263 typedef struct
265 st_parameter_common common;
267 st_parameter_filepos;
269 #define IOPARM_INQUIRE_HAS_EXIST (1 << 7)
270 #define IOPARM_INQUIRE_HAS_OPENED (1 << 8)
271 #define IOPARM_INQUIRE_HAS_NUMBER (1 << 9)
272 #define IOPARM_INQUIRE_HAS_NAMED (1 << 10)
273 #define IOPARM_INQUIRE_HAS_NEXTREC (1 << 11)
274 #define IOPARM_INQUIRE_HAS_RECL_OUT (1 << 12)
275 #define IOPARM_INQUIRE_HAS_STRM_POS_OUT (1 << 13)
276 #define IOPARM_INQUIRE_HAS_FILE (1 << 14)
277 #define IOPARM_INQUIRE_HAS_ACCESS (1 << 15)
278 #define IOPARM_INQUIRE_HAS_FORM (1 << 16)
279 #define IOPARM_INQUIRE_HAS_BLANK (1 << 17)
280 #define IOPARM_INQUIRE_HAS_POSITION (1 << 18)
281 #define IOPARM_INQUIRE_HAS_ACTION (1 << 19)
282 #define IOPARM_INQUIRE_HAS_DELIM (1 << 20)
283 #define IOPARM_INQUIRE_HAS_PAD (1 << 21)
284 #define IOPARM_INQUIRE_HAS_NAME (1 << 22)
285 #define IOPARM_INQUIRE_HAS_SEQUENTIAL (1 << 23)
286 #define IOPARM_INQUIRE_HAS_DIRECT (1 << 24)
287 #define IOPARM_INQUIRE_HAS_FORMATTED (1 << 25)
288 #define IOPARM_INQUIRE_HAS_UNFORMATTED (1 << 26)
289 #define IOPARM_INQUIRE_HAS_READ (1 << 27)
290 #define IOPARM_INQUIRE_HAS_WRITE (1 << 28)
291 #define IOPARM_INQUIRE_HAS_READWRITE (1 << 29)
292 #define IOPARM_INQUIRE_HAS_CONVERT (1 << 30)
293 #define IOPARM_INQUIRE_HAS_FLAGS2 (1 << 31)
295 #define IOPARM_INQUIRE_HAS_ASYNCHRONOUS (1 << 0)
296 #define IOPARM_INQUIRE_HAS_DECIMAL (1 << 1)
297 #define IOPARM_INQUIRE_HAS_ENCODING (1 << 2)
298 #define IOPARM_INQUIRE_HAS_ROUND (1 << 3)
299 #define IOPARM_INQUIRE_HAS_SIGN (1 << 4)
300 #define IOPARM_INQUIRE_HAS_PENDING (1 << 5)
301 #define IOPARM_INQUIRE_HAS_SIZE (1 << 6)
302 #define IOPARM_INQUIRE_HAS_ID (1 << 7)
304 typedef struct
306 st_parameter_common common;
307 GFC_INTEGER_4 *exist, *opened, *number, *named;
308 GFC_INTEGER_4 *nextrec, *recl_out;
309 GFC_IO_INT *strm_pos_out;
310 CHARACTER1 (file);
311 CHARACTER2 (access);
312 CHARACTER1 (form);
313 CHARACTER2 (blank);
314 CHARACTER1 (position);
315 CHARACTER2 (action);
316 CHARACTER1 (delim);
317 CHARACTER2 (pad);
318 CHARACTER1 (name);
319 CHARACTER2 (sequential);
320 CHARACTER1 (direct);
321 CHARACTER2 (formatted);
322 CHARACTER1 (unformatted);
323 CHARACTER2 (read);
324 CHARACTER1 (write);
325 CHARACTER2 (readwrite);
326 CHARACTER1 (convert);
327 GFC_INTEGER_4 flags2;
328 CHARACTER1 (asynchronous);
329 CHARACTER2 (decimal);
330 CHARACTER1 (encoding);
331 CHARACTER2 (round);
332 CHARACTER1 (sign);
333 GFC_INTEGER_4 *pending;
334 GFC_IO_INT *size;
335 GFC_INTEGER_4 *id;
337 st_parameter_inquire;
340 #define IOPARM_DT_LIST_FORMAT (1 << 7)
341 #define IOPARM_DT_NAMELIST_READ_MODE (1 << 8)
342 #define IOPARM_DT_HAS_REC (1 << 9)
343 #define IOPARM_DT_HAS_SIZE (1 << 10)
344 #define IOPARM_DT_HAS_IOLENGTH (1 << 11)
345 #define IOPARM_DT_HAS_FORMAT (1 << 12)
346 #define IOPARM_DT_HAS_ADVANCE (1 << 13)
347 #define IOPARM_DT_HAS_INTERNAL_UNIT (1 << 14)
348 #define IOPARM_DT_HAS_NAMELIST_NAME (1 << 15)
349 #define IOPARM_DT_HAS_ID (1 << 16)
350 #define IOPARM_DT_HAS_POS (1 << 17)
351 #define IOPARM_DT_HAS_ASYNCHRONOUS (1 << 18)
352 #define IOPARM_DT_HAS_BLANK (1 << 19)
353 #define IOPARM_DT_HAS_DECIMAL (1 << 20)
354 #define IOPARM_DT_HAS_DELIM (1 << 21)
355 #define IOPARM_DT_HAS_PAD (1 << 22)
356 #define IOPARM_DT_HAS_ROUND (1 << 23)
357 #define IOPARM_DT_HAS_SIGN (1 << 24)
358 #define IOPARM_DT_HAS_F2003 (1 << 25)
359 /* Internal use bit. */
360 #define IOPARM_DT_IONML_SET (1 << 31)
363 typedef struct st_parameter_dt
365 st_parameter_common common;
366 GFC_IO_INT rec;
367 GFC_IO_INT *size, *iolength;
368 gfc_array_char *internal_unit_desc;
369 CHARACTER1 (format);
370 CHARACTER2 (advance);
371 CHARACTER1 (internal_unit);
372 CHARACTER2 (namelist_name);
373 /* Private part of the structure. The compiler just needs
374 to reserve enough space. */
375 union
377 struct
379 void (*transfer) (struct st_parameter_dt *, bt, void *, int,
380 size_t, size_t);
381 struct gfc_unit *current_unit;
382 /* Item number in a formatted data transfer. Also used in namelist
383 read_logical as an index into line_buffer. */
384 int item_count;
385 unit_mode mode;
386 unit_blank blank_status;
387 unit_sign sign_status;
388 int scale_factor;
389 int max_pos; /* Maximum righthand column written to. */
390 /* Number of skips + spaces to be done for T and X-editing. */
391 int skips;
392 /* Number of spaces to be done for T and X-editing. */
393 int pending_spaces;
394 /* Whether an EOR condition was encountered. Value is:
395 0 if no EOR was encountered
396 1 if an EOR was encountered due to a 1-byte marker (LF)
397 2 if an EOR was encountered due to a 2-bytes marker (CRLF) */
398 int sf_seen_eor;
399 unit_advance advance_status;
400 unsigned reversion_flag : 1; /* Format reversion has occurred. */
401 unsigned first_item : 1;
402 unsigned seen_dollar : 1;
403 unsigned eor_condition : 1;
404 unsigned no_leading_blank : 1;
405 unsigned char_flag : 1;
406 unsigned input_complete : 1;
407 unsigned at_eol : 1;
408 unsigned comma_flag : 1;
409 /* A namelist specific flag used in the list directed library
410 to flag that calls are being made from namelist read (eg. to
411 ignore comments or to treat '/' as a terminator) */
412 unsigned namelist_mode : 1;
413 /* A namelist specific flag used in the list directed library
414 to flag read errors and return, so that an attempt can be
415 made to read a new object name. */
416 unsigned nml_read_error : 1;
417 /* A sequential formatted read specific flag used to signal that a
418 character string is being read so don't use commas to shorten a
419 formatted field width. */
420 unsigned sf_read_comma : 1;
421 /* A namelist specific flag used to enable reading input from
422 line_buffer for logical reads. */
423 unsigned line_buffer_enabled : 1;
424 /* An internal unit specific flag used to identify that the associated
425 unit is internal. */
426 unsigned unit_is_internal : 1;
427 /* An internal unit specific flag to signify an EOF condition for list
428 directed read. */
429 unsigned at_eof : 1;
430 /* Used for g0 floating point output. */
431 unsigned g0_no_blanks : 1;
432 /* Used to signal use of free_format_data. */
433 unsigned format_not_saved : 1;
434 /* 14 unused bits. */
436 char last_char;
437 char nml_delim;
439 int repeat_count;
440 int saved_length;
441 int saved_used;
442 bt saved_type;
443 char *saved_string;
444 char *scratch;
445 char *line_buffer;
446 struct format_data *fmt;
447 jmp_buf *eof_jump;
448 namelist_info *ionml;
449 /* A flag used to identify when a non-standard expanded namelist read
450 has occurred. */
451 int expanded_read;
452 /* Storage area for values except for strings. Must be
453 large enough to hold a complex value (two reals) of the
454 largest kind. */
455 char value[32];
456 GFC_IO_INT size_used;
457 } p;
458 /* This pad size must be equal to the pad_size declared in
459 trans-io.c (gfc_build_io_library_fndecls). The above structure
460 must be smaller or equal to this array. */
461 char pad[16 * sizeof (char *) + 32 * sizeof (int)];
462 } u;
463 GFC_INTEGER_4 *id;
464 GFC_IO_INT pos;
465 CHARACTER1 (asynchronous);
466 CHARACTER2 (blank);
467 CHARACTER1 (decimal);
468 CHARACTER2 (delim);
469 CHARACTER1 (pad);
470 CHARACTER2 (round);
471 CHARACTER1 (sign);
473 st_parameter_dt;
475 /* Ensure st_parameter_dt's u.pad is bigger or equal to u.p. */
476 extern char check_st_parameter_dt[sizeof (((st_parameter_dt *) 0)->u.pad)
477 >= sizeof (((st_parameter_dt *) 0)->u.p)
478 ? 1 : -1];
480 #define IOPARM_WAIT_HAS_ID (1 << 7)
482 typedef struct
484 st_parameter_common common;
485 CHARACTER1 (id);
487 st_parameter_wait;
490 #undef CHARACTER1
491 #undef CHARACTER2
493 typedef struct
495 unit_access access;
496 unit_action action;
497 unit_blank blank;
498 unit_delim delim;
499 unit_form form;
500 int is_notpadded;
501 unit_position position;
502 unit_status status;
503 unit_pad pad;
504 unit_convert convert;
505 int has_recl;
506 unit_decimal decimal;
507 unit_encoding encoding;
508 unit_round round;
509 unit_sign sign;
510 unit_async async;
512 unit_flags;
515 typedef struct gfc_unit
517 int unit_number;
518 stream *s;
520 /* Treap links. */
521 struct gfc_unit *left, *right;
522 int priority;
524 int read_bad, current_record, saved_pos, previous_nonadvancing_write;
526 enum
527 { NO_ENDFILE, AT_ENDFILE, AFTER_ENDFILE }
528 endfile;
530 unit_mode mode;
531 unit_flags flags;
532 unit_pad pad_status;
533 unit_decimal decimal_status;
534 unit_delim delim_status;
535 unit_round round_status;
537 /* recl -- Record length of the file.
538 last_record -- Last record number read or written
539 maxrec -- Maximum record number in a direct access file
540 bytes_left -- Bytes left in current record.
541 strm_pos -- Current position in file for STREAM I/O.
542 recl_subrecord -- Maximum length for subrecord.
543 bytes_left_subrecord -- Bytes left in current subrecord. */
544 gfc_offset recl, last_record, maxrec, bytes_left, strm_pos,
545 recl_subrecord, bytes_left_subrecord;
547 /* Set to 1 if we have read a subrecord. */
549 int continued;
551 __gthread_mutex_t lock;
552 /* Number of threads waiting to acquire this unit's lock.
553 When non-zero, close_unit doesn't only removes the unit
554 from the UNIT_ROOT tree, but doesn't free it and the
555 last of the waiting threads will do that.
556 This must be either atomically increased/decreased, or
557 always guarded by UNIT_LOCK. */
558 int waiting;
559 /* Flag set by close_unit if the unit as been closed.
560 Must be manipulated under unit's lock. */
561 int closed;
563 /* For traversing arrays */
564 array_loop_spec *ls;
565 int rank;
567 int file_len;
568 char *file;
570 /* The format hash table. */
571 struct format_hash_entry format_hash_table[FORMAT_HASH_SIZE];
573 /* Formatting buffer. */
574 struct fbuf *fbuf;
576 gfc_unit;
579 /* unit.c */
581 /* Maximum file offset, computed at library initialization time. */
582 extern gfc_offset max_offset;
583 internal_proto(max_offset);
585 /* Unit number to be assigned when NEWUNIT is used in an OPEN statement. */
586 extern GFC_INTEGER_4 next_available_newunit;
587 internal_proto(next_available_newunit);
589 /* Unit tree root. */
590 extern gfc_unit *unit_root;
591 internal_proto(unit_root);
593 extern __gthread_mutex_t unit_lock;
594 internal_proto(unit_lock);
596 extern int close_unit (gfc_unit *);
597 internal_proto(close_unit);
599 extern gfc_unit *get_internal_unit (st_parameter_dt *);
600 internal_proto(get_internal_unit);
602 extern void free_internal_unit (st_parameter_dt *);
603 internal_proto(free_internal_unit);
605 extern gfc_unit *find_unit (int);
606 internal_proto(find_unit);
608 extern gfc_unit *find_or_create_unit (int);
609 internal_proto(find_or_create_unit);
611 extern gfc_unit *get_unit (st_parameter_dt *, int);
612 internal_proto(get_unit);
614 extern void unlock_unit (gfc_unit *);
615 internal_proto(unlock_unit);
617 extern void update_position (gfc_unit *);
618 internal_proto(update_position);
620 extern void finish_last_advance_record (gfc_unit *u);
621 internal_proto (finish_last_advance_record);
623 extern int unit_truncate (gfc_unit *, gfc_offset, st_parameter_common *);
624 internal_proto (unit_truncate);
626 extern GFC_INTEGER_4 get_unique_unit_number (st_parameter_open *);
627 internal_proto(get_unique_unit_number);
629 /* open.c */
631 extern gfc_unit *new_unit (st_parameter_open *, gfc_unit *, unit_flags *);
632 internal_proto(new_unit);
635 /* transfer.c */
637 #define SCRATCH_SIZE 300
639 extern const char *type_name (bt);
640 internal_proto(type_name);
642 extern void * read_block_form (st_parameter_dt *, int *);
643 internal_proto(read_block_form);
645 extern void *write_block (st_parameter_dt *, int);
646 internal_proto(write_block);
648 extern gfc_offset next_array_record (st_parameter_dt *, array_loop_spec *,
649 int*);
650 internal_proto(next_array_record);
652 extern gfc_offset init_loop_spec (gfc_array_char *, array_loop_spec *,
653 gfc_offset *);
654 internal_proto(init_loop_spec);
656 extern void next_record (st_parameter_dt *, int);
657 internal_proto(next_record);
659 extern void reverse_memcpy (void *, const void *, size_t);
660 internal_proto (reverse_memcpy);
662 extern void st_wait (st_parameter_wait *);
663 export_proto(st_wait);
665 extern void hit_eof (st_parameter_dt *);
666 internal_proto(hit_eof);
668 /* read.c */
670 extern void set_integer (void *, GFC_INTEGER_LARGEST, int);
671 internal_proto(set_integer);
673 extern GFC_UINTEGER_LARGEST max_value (int, int);
674 internal_proto(max_value);
676 extern int convert_real (st_parameter_dt *, void *, const char *, int);
677 internal_proto(convert_real);
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