Add missing testcase.
[official-gcc.git] / libgfortran / io / io.h
blob1dcf72e7163f1c4370235db778e67eb915fe0e21
1 /* Copyright (C) 2002-2013 Free Software Foundation, Inc.
2 Contributed by Andy Vaught
3 F2003 I/O support contributed by Jerry DeLisle
5 This file is part of the GNU Fortran 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 3, 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 Under Section 7 of GPL version 3, you are granted additional
18 permissions described in the GCC Runtime Library Exception, version
19 3.1, as published by the Free Software Foundation.
21 You should have received a copy of the GNU General Public License and
22 a copy of the GCC Runtime Library Exception along with this program;
23 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 <http://www.gnu.org/licenses/>. */
26 #ifndef GFOR_IO_H
27 #define GFOR_IO_H
29 /* IO library include. */
31 #include "libgfortran.h"
33 #include <gthr.h>
35 /* Forward declarations. */
36 struct st_parameter_dt;
37 typedef struct stream stream;
38 struct fbuf;
39 struct format_data;
40 typedef struct fnode fnode;
41 struct gfc_unit;
44 /* Macros for testing what kinds of I/O we are doing. */
46 #define is_array_io(dtp) ((dtp)->internal_unit_desc)
48 #define is_internal_unit(dtp) ((dtp)->u.p.unit_is_internal)
50 #define is_stream_io(dtp) ((dtp)->u.p.current_unit->flags.access == ACCESS_STREAM)
52 #define is_char4_unit(dtp) ((dtp)->u.p.unit_is_internal && (dtp)->common.unit)
54 /* The array_loop_spec contains the variables for the loops over index ranges
55 that are encountered. */
57 typedef struct array_loop_spec
59 /* Index counter for this dimension. */
60 index_type idx;
62 /* Start for the index counter. */
63 index_type start;
65 /* End for the index counter. */
66 index_type end;
68 /* Step for the index counter. */
69 index_type step;
71 array_loop_spec;
73 /* A structure to build a hash table for format data. */
75 #define FORMAT_HASH_SIZE 16
77 typedef struct format_hash_entry
79 char *key;
80 gfc_charlen_type key_len;
81 struct format_data *hashed_fmt;
83 format_hash_entry;
85 /* Representation of a namelist object in libgfortran
87 Namelist Records
88 &GROUPNAME OBJECT=value[s] [,OBJECT=value[s]].../
90 &GROUPNAME OBJECT=value[s] [,OBJECT=value[s]]...&END
92 The object can be a fully qualified, compound name for an intrinsic
93 type, derived types or derived type components. So, a substring
94 a(:)%b(4)%ch(2:4)(1:7) has to be treated correctly in namelist
95 read. Hence full information about the structure of the object has
96 to be available to list_read.c and write.
98 These requirements are met by the following data structures.
100 namelist_info type contains all the scalar information about the
101 object and arrays of descriptor_dimension and array_loop_spec types for
102 arrays. */
104 typedef struct namelist_type
106 /* Object type. */
107 bt type;
109 /* Object name. */
110 char * var_name;
112 /* Address for the start of the object's data. */
113 void * mem_pos;
115 /* Flag to show that a read is to be attempted for this node. */
116 int touched;
118 /* Length of intrinsic type in bytes. */
119 int len;
121 /* Rank of the object. */
122 int var_rank;
124 /* Overall size of the object in bytes. */
125 index_type size;
127 /* Length of character string. */
128 index_type string_length;
130 descriptor_dimension * dim;
131 array_loop_spec * ls;
132 struct namelist_type * next;
134 namelist_info;
136 /* Options for the OPEN statement. */
138 typedef enum
139 { ACCESS_SEQUENTIAL, ACCESS_DIRECT, ACCESS_APPEND, ACCESS_STREAM,
140 ACCESS_UNSPECIFIED
142 unit_access;
144 typedef enum
145 { ACTION_READ, ACTION_WRITE, ACTION_READWRITE,
146 ACTION_UNSPECIFIED
148 unit_action;
150 typedef enum
151 { BLANK_NULL, BLANK_ZERO, BLANK_UNSPECIFIED }
152 unit_blank;
154 typedef enum
155 { DELIM_NONE, DELIM_APOSTROPHE, DELIM_QUOTE,
156 DELIM_UNSPECIFIED
158 unit_delim;
160 typedef enum
161 { FORM_FORMATTED, FORM_UNFORMATTED, FORM_UNSPECIFIED }
162 unit_form;
164 typedef enum
165 { POSITION_ASIS, POSITION_REWIND, POSITION_APPEND,
166 POSITION_UNSPECIFIED
168 unit_position;
170 typedef enum
171 { STATUS_UNKNOWN, STATUS_OLD, STATUS_NEW, STATUS_SCRATCH,
172 STATUS_REPLACE, STATUS_UNSPECIFIED
174 unit_status;
176 typedef enum
177 { PAD_YES, PAD_NO, PAD_UNSPECIFIED }
178 unit_pad;
180 typedef enum
181 { DECIMAL_POINT, DECIMAL_COMMA, DECIMAL_UNSPECIFIED }
182 unit_decimal;
184 typedef enum
185 { ENCODING_UTF8, ENCODING_DEFAULT, ENCODING_UNSPECIFIED }
186 unit_encoding;
188 typedef enum
189 { ROUND_UP = GFC_FPE_UPWARD,
190 ROUND_DOWN = GFC_FPE_DOWNWARD,
191 ROUND_ZERO = GFC_FPE_TOWARDZERO,
192 ROUND_NEAREST = GFC_FPE_TONEAREST,
193 ROUND_COMPATIBLE = 10, /* round away from zero. */
194 ROUND_PROCDEFINED, /* Here as ROUND_NEAREST. */
195 ROUND_UNSPECIFIED /* Should never occur. */
197 unit_round;
199 /* NOTE: unit_sign must correspond with the sign_status enumerator in
200 st_parameter_dt to not break the ABI. */
201 typedef enum
202 { SIGN_PROCDEFINED, SIGN_SUPPRESS, SIGN_PLUS, SIGN_UNSPECIFIED }
203 unit_sign;
205 typedef enum
206 { ADVANCE_YES, ADVANCE_NO, ADVANCE_UNSPECIFIED }
207 unit_advance;
209 typedef enum
210 {READING, WRITING}
211 unit_mode;
213 typedef enum
214 { ASYNC_YES, ASYNC_NO, ASYNC_UNSPECIFIED }
215 unit_async;
217 typedef enum
218 { SIGN_S, SIGN_SS, SIGN_SP }
219 unit_sign_s;
221 #define CHARACTER1(name) \
222 char * name; \
223 gfc_charlen_type name ## _len
224 #define CHARACTER2(name) \
225 gfc_charlen_type name ## _len; \
226 char * name
228 typedef struct
230 st_parameter_common common;
231 GFC_INTEGER_4 recl_in;
232 CHARACTER2 (file);
233 CHARACTER1 (status);
234 CHARACTER2 (access);
235 CHARACTER1 (form);
236 CHARACTER2 (blank);
237 CHARACTER1 (position);
238 CHARACTER2 (action);
239 CHARACTER1 (delim);
240 CHARACTER2 (pad);
241 CHARACTER1 (convert);
242 CHARACTER2 (decimal);
243 CHARACTER1 (encoding);
244 CHARACTER2 (round);
245 CHARACTER1 (sign);
246 CHARACTER2 (asynchronous);
247 GFC_INTEGER_4 *newunit;
249 st_parameter_open;
251 #define IOPARM_CLOSE_HAS_STATUS (1 << 7)
253 typedef struct
255 st_parameter_common common;
256 CHARACTER1 (status);
258 st_parameter_close;
260 typedef struct
262 st_parameter_common common;
264 st_parameter_filepos;
266 #define IOPARM_INQUIRE_HAS_EXIST (1 << 7)
267 #define IOPARM_INQUIRE_HAS_OPENED (1 << 8)
268 #define IOPARM_INQUIRE_HAS_NUMBER (1 << 9)
269 #define IOPARM_INQUIRE_HAS_NAMED (1 << 10)
270 #define IOPARM_INQUIRE_HAS_NEXTREC (1 << 11)
271 #define IOPARM_INQUIRE_HAS_RECL_OUT (1 << 12)
272 #define IOPARM_INQUIRE_HAS_STRM_POS_OUT (1 << 13)
273 #define IOPARM_INQUIRE_HAS_FILE (1 << 14)
274 #define IOPARM_INQUIRE_HAS_ACCESS (1 << 15)
275 #define IOPARM_INQUIRE_HAS_FORM (1 << 16)
276 #define IOPARM_INQUIRE_HAS_BLANK (1 << 17)
277 #define IOPARM_INQUIRE_HAS_POSITION (1 << 18)
278 #define IOPARM_INQUIRE_HAS_ACTION (1 << 19)
279 #define IOPARM_INQUIRE_HAS_DELIM (1 << 20)
280 #define IOPARM_INQUIRE_HAS_PAD (1 << 21)
281 #define IOPARM_INQUIRE_HAS_NAME (1 << 22)
282 #define IOPARM_INQUIRE_HAS_SEQUENTIAL (1 << 23)
283 #define IOPARM_INQUIRE_HAS_DIRECT (1 << 24)
284 #define IOPARM_INQUIRE_HAS_FORMATTED (1 << 25)
285 #define IOPARM_INQUIRE_HAS_UNFORMATTED (1 << 26)
286 #define IOPARM_INQUIRE_HAS_READ (1 << 27)
287 #define IOPARM_INQUIRE_HAS_WRITE (1 << 28)
288 #define IOPARM_INQUIRE_HAS_READWRITE (1 << 29)
289 #define IOPARM_INQUIRE_HAS_CONVERT (1 << 30)
290 #define IOPARM_INQUIRE_HAS_FLAGS2 (1 << 31)
292 #define IOPARM_INQUIRE_HAS_ASYNCHRONOUS (1 << 0)
293 #define IOPARM_INQUIRE_HAS_DECIMAL (1 << 1)
294 #define IOPARM_INQUIRE_HAS_ENCODING (1 << 2)
295 #define IOPARM_INQUIRE_HAS_ROUND (1 << 3)
296 #define IOPARM_INQUIRE_HAS_SIGN (1 << 4)
297 #define IOPARM_INQUIRE_HAS_PENDING (1 << 5)
298 #define IOPARM_INQUIRE_HAS_SIZE (1 << 6)
299 #define IOPARM_INQUIRE_HAS_ID (1 << 7)
300 #define IOPARM_INQUIRE_HAS_IQSTREAM (1 << 8)
302 typedef struct
304 st_parameter_common common;
305 GFC_INTEGER_4 *exist, *opened, *number, *named;
306 GFC_INTEGER_4 *nextrec, *recl_out;
307 GFC_IO_INT *strm_pos_out;
308 CHARACTER1 (file);
309 CHARACTER2 (access);
310 CHARACTER1 (form);
311 CHARACTER2 (blank);
312 CHARACTER1 (position);
313 CHARACTER2 (action);
314 CHARACTER1 (delim);
315 CHARACTER2 (pad);
316 CHARACTER1 (name);
317 CHARACTER2 (sequential);
318 CHARACTER1 (direct);
319 CHARACTER2 (formatted);
320 CHARACTER1 (unformatted);
321 CHARACTER2 (read);
322 CHARACTER1 (write);
323 CHARACTER2 (readwrite);
324 CHARACTER1 (convert);
325 GFC_INTEGER_4 flags2;
326 CHARACTER1 (asynchronous);
327 CHARACTER2 (decimal);
328 CHARACTER1 (encoding);
329 CHARACTER2 (round);
330 CHARACTER1 (sign);
331 GFC_INTEGER_4 *pending;
332 GFC_IO_INT *size;
333 GFC_INTEGER_4 *id;
334 CHARACTER1 (iqstream);
336 st_parameter_inquire;
339 #define IOPARM_DT_LIST_FORMAT (1 << 7)
340 #define IOPARM_DT_NAMELIST_READ_MODE (1 << 8)
341 #define IOPARM_DT_HAS_REC (1 << 9)
342 #define IOPARM_DT_HAS_SIZE (1 << 10)
343 #define IOPARM_DT_HAS_IOLENGTH (1 << 11)
344 #define IOPARM_DT_HAS_FORMAT (1 << 12)
345 #define IOPARM_DT_HAS_ADVANCE (1 << 13)
346 #define IOPARM_DT_HAS_INTERNAL_UNIT (1 << 14)
347 #define IOPARM_DT_HAS_NAMELIST_NAME (1 << 15)
348 #define IOPARM_DT_HAS_ID (1 << 16)
349 #define IOPARM_DT_HAS_POS (1 << 17)
350 #define IOPARM_DT_HAS_ASYNCHRONOUS (1 << 18)
351 #define IOPARM_DT_HAS_BLANK (1 << 19)
352 #define IOPARM_DT_HAS_DECIMAL (1 << 20)
353 #define IOPARM_DT_HAS_DELIM (1 << 21)
354 #define IOPARM_DT_HAS_PAD (1 << 22)
355 #define IOPARM_DT_HAS_ROUND (1 << 23)
356 #define IOPARM_DT_HAS_SIGN (1 << 24)
357 #define IOPARM_DT_HAS_F2003 (1 << 25)
358 /* Internal use bit. */
359 #define IOPARM_DT_IONML_SET (1 << 31)
362 typedef struct st_parameter_dt
364 st_parameter_common common;
365 GFC_IO_INT rec;
366 GFC_IO_INT *size, *iolength;
367 gfc_array_char *internal_unit_desc;
368 CHARACTER1 (format);
369 CHARACTER2 (advance);
370 CHARACTER1 (internal_unit);
371 CHARACTER2 (namelist_name);
372 /* Private part of the structure. The compiler just needs
373 to reserve enough space. */
374 union
376 struct
378 void (*transfer) (struct st_parameter_dt *, bt, void *, int,
379 size_t, size_t);
380 struct gfc_unit *current_unit;
381 /* Item number in a formatted data transfer. Also used in namelist
382 read_logical as an index into line_buffer. */
383 int item_count;
384 unit_mode mode;
385 unit_blank blank_status;
386 unit_sign sign_status;
387 int scale_factor;
388 int max_pos; /* Maximum righthand column written to. */
389 /* Number of skips + spaces to be done for T and X-editing. */
390 int skips;
391 /* Number of spaces to be done for T and X-editing. */
392 int pending_spaces;
393 /* Whether an EOR condition was encountered. Value is:
394 0 if no EOR was encountered
395 1 if an EOR was encountered due to a 1-byte marker (LF)
396 2 if an EOR was encountered due to a 2-bytes marker (CRLF) */
397 int sf_seen_eor;
398 unit_advance advance_status;
399 unsigned reversion_flag : 1; /* Format reversion has occurred. */
400 unsigned first_item : 1;
401 unsigned seen_dollar : 1;
402 unsigned eor_condition : 1;
403 unsigned no_leading_blank : 1;
404 unsigned char_flag : 1;
405 unsigned input_complete : 1;
406 unsigned at_eol : 1;
407 unsigned comma_flag : 1;
408 /* A namelist specific flag used in the list directed library
409 to flag that calls are being made from namelist read (e.g. to
410 ignore comments or to treat '/' as a terminator) */
411 unsigned namelist_mode : 1;
412 /* A namelist specific flag used in the list directed library
413 to flag read errors and return, so that an attempt can be
414 made to read a new object name. */
415 unsigned nml_read_error : 1;
416 /* A sequential formatted read specific flag used to signal that a
417 character string is being read so don't use commas to shorten a
418 formatted field width. */
419 unsigned sf_read_comma : 1;
420 /* A namelist specific flag used to enable reading input from
421 line_buffer for logical reads. */
422 unsigned line_buffer_enabled : 1;
423 /* An internal unit specific flag used to identify that the associated
424 unit is internal. */
425 unsigned unit_is_internal : 1;
426 /* An internal unit specific flag to signify an EOF condition for list
427 directed read. */
428 unsigned at_eof : 1;
429 /* Used for g0 floating point output. */
430 unsigned g0_no_blanks : 1;
431 /* Used to signal use of free_format_data. */
432 unsigned format_not_saved : 1;
433 /* 14 unused bits. */
435 /* Used for ungetc() style functionality. Possible values
436 are an unsigned char, EOF, or EOF - 1 used to mark the
437 field as not valid. */
438 int last_char;
439 char nml_delim;
441 int repeat_count;
442 int saved_length;
443 int saved_used;
444 bt saved_type;
445 char *saved_string;
446 char *scratch;
447 char *line_buffer;
448 struct format_data *fmt;
449 namelist_info *ionml;
450 /* A flag used to identify when a non-standard expanded namelist read
451 has occurred. */
452 int expanded_read;
453 /* Storage area for values except for strings. Must be
454 large enough to hold a complex value (two reals) of the
455 largest kind. */
456 char value[32];
457 GFC_IO_INT size_used;
458 } p;
459 /* This pad size must be equal to the pad_size declared in
460 trans-io.c (gfc_build_io_library_fndecls). The above structure
461 must be smaller or equal to this array. */
462 char pad[16 * sizeof (char *) + 32 * sizeof (int)];
463 } u;
464 GFC_INTEGER_4 *id;
465 GFC_IO_INT pos;
466 CHARACTER1 (asynchronous);
467 CHARACTER2 (blank);
468 CHARACTER1 (decimal);
469 CHARACTER2 (delim);
470 CHARACTER1 (pad);
471 CHARACTER2 (round);
472 CHARACTER1 (sign);
474 st_parameter_dt;
476 /* Ensure st_parameter_dt's u.pad is bigger or equal to u.p. */
477 extern char check_st_parameter_dt[sizeof (((st_parameter_dt *) 0)->u.pad)
478 >= sizeof (((st_parameter_dt *) 0)->u.p)
479 ? 1 : -1];
481 #define IOPARM_WAIT_HAS_ID (1 << 7)
483 typedef struct
485 st_parameter_common common;
486 CHARACTER1 (id);
488 st_parameter_wait;
491 #undef CHARACTER1
492 #undef CHARACTER2
494 typedef struct
496 unit_access access;
497 unit_action action;
498 unit_blank blank;
499 unit_delim delim;
500 unit_form form;
501 int is_notpadded;
502 unit_position position;
503 unit_status status;
504 unit_pad pad;
505 unit_convert convert;
506 int has_recl;
507 unit_decimal decimal;
508 unit_encoding encoding;
509 unit_round round;
510 unit_sign sign;
511 unit_async async;
513 unit_flags;
516 typedef struct gfc_unit
518 int unit_number;
519 stream *s;
521 /* Treap links. */
522 struct gfc_unit *left, *right;
523 int priority;
525 int read_bad, current_record, saved_pos, previous_nonadvancing_write;
527 enum
528 { NO_ENDFILE, AT_ENDFILE, AFTER_ENDFILE }
529 endfile;
531 unit_mode mode;
532 unit_flags flags;
533 unit_pad pad_status;
534 unit_decimal decimal_status;
535 unit_delim delim_status;
536 unit_round round_status;
538 /* recl -- Record length of the file.
539 last_record -- Last record number read or written
540 maxrec -- Maximum record number in a direct access file
541 bytes_left -- Bytes left in current record.
542 strm_pos -- Current position in file for STREAM I/O.
543 recl_subrecord -- Maximum length for subrecord.
544 bytes_left_subrecord -- Bytes left in current subrecord. */
545 gfc_offset recl, last_record, maxrec, bytes_left, strm_pos,
546 recl_subrecord, bytes_left_subrecord;
548 /* Set to 1 if we have read a subrecord. */
550 int continued;
552 __gthread_mutex_t lock;
553 /* Number of threads waiting to acquire this unit's lock.
554 When non-zero, close_unit doesn't only removes the unit
555 from the UNIT_ROOT tree, but doesn't free it and the
556 last of the waiting threads will do that.
557 This must be either atomically increased/decreased, or
558 always guarded by UNIT_LOCK. */
559 int waiting;
560 /* Flag set by close_unit if the unit as been closed.
561 Must be manipulated under unit's lock. */
562 int closed;
564 /* For traversing arrays */
565 array_loop_spec *ls;
566 int rank;
568 int file_len;
569 char *file;
571 /* The format hash table. */
572 struct format_hash_entry format_hash_table[FORMAT_HASH_SIZE];
574 /* Formatting buffer. */
575 struct fbuf *fbuf;
577 gfc_unit;
580 /* unit.c */
582 /* Maximum file offset, computed at library initialization time. */
583 extern gfc_offset max_offset;
584 internal_proto(max_offset);
586 /* Unit tree root. */
587 extern gfc_unit *unit_root;
588 internal_proto(unit_root);
590 extern __gthread_mutex_t unit_lock;
591 internal_proto(unit_lock);
593 extern int close_unit (gfc_unit *);
594 internal_proto(close_unit);
596 extern gfc_unit *get_internal_unit (st_parameter_dt *);
597 internal_proto(get_internal_unit);
599 extern void free_internal_unit (st_parameter_dt *);
600 internal_proto(free_internal_unit);
602 extern gfc_unit *find_unit (int);
603 internal_proto(find_unit);
605 extern gfc_unit *find_or_create_unit (int);
606 internal_proto(find_or_create_unit);
608 extern gfc_unit *get_unit (st_parameter_dt *, int);
609 internal_proto(get_unit);
611 extern void unlock_unit (gfc_unit *);
612 internal_proto(unlock_unit);
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 st_wait (st_parameter_wait *);
657 export_proto(st_wait);
659 extern void hit_eof (st_parameter_dt *);
660 internal_proto(hit_eof);
662 /* read.c */
664 extern void set_integer (void *, GFC_INTEGER_LARGEST, int);
665 internal_proto(set_integer);
667 extern GFC_UINTEGER_LARGEST si_max (int);
668 internal_proto(si_max);
670 extern int convert_real (st_parameter_dt *, void *, const char *, int);
671 internal_proto(convert_real);
673 extern int convert_infnan (st_parameter_dt *, void *, const char *, int);
674 internal_proto(convert_infnan);
676 extern void read_a (st_parameter_dt *, const fnode *, char *, int);
677 internal_proto(read_a);
679 extern void read_a_char4 (st_parameter_dt *, const fnode *, char *, int);
680 internal_proto(read_a);
682 extern void read_f (st_parameter_dt *, const fnode *, char *, int);
683 internal_proto(read_f);
685 extern void read_l (st_parameter_dt *, const fnode *, char *, int);
686 internal_proto(read_l);
688 extern void read_x (st_parameter_dt *, int);
689 internal_proto(read_x);
691 extern void read_radix (st_parameter_dt *, const fnode *, char *, int, int);
692 internal_proto(read_radix);
694 extern void read_decimal (st_parameter_dt *, const fnode *, char *, int);
695 internal_proto(read_decimal);
697 /* list_read.c */
699 extern void list_formatted_read (st_parameter_dt *, bt, void *, int, size_t,
700 size_t);
701 internal_proto(list_formatted_read);
703 extern void finish_list_read (st_parameter_dt *);
704 internal_proto(finish_list_read);
706 extern void namelist_read (st_parameter_dt *);
707 internal_proto(namelist_read);
709 extern void namelist_write (st_parameter_dt *);
710 internal_proto(namelist_write);
712 /* write.c */
714 extern void write_a (st_parameter_dt *, const fnode *, const char *, int);
715 internal_proto(write_a);
717 extern void write_a_char4 (st_parameter_dt *, const fnode *, const char *, int);
718 internal_proto(write_a_char4);
720 extern void write_b (st_parameter_dt *, const fnode *, const char *, int);
721 internal_proto(write_b);
723 extern void write_d (st_parameter_dt *, const fnode *, const char *, int);
724 internal_proto(write_d);
726 extern void write_e (st_parameter_dt *, const fnode *, const char *, int);
727 internal_proto(write_e);
729 extern void write_en (st_parameter_dt *, const fnode *, const char *, int);
730 internal_proto(write_en);
732 extern void write_es (st_parameter_dt *, const fnode *, const char *, int);
733 internal_proto(write_es);
735 extern void write_f (st_parameter_dt *, const fnode *, const char *, int);
736 internal_proto(write_f);
738 extern void write_i (st_parameter_dt *, const fnode *, const char *, int);
739 internal_proto(write_i);
741 extern void write_l (st_parameter_dt *, const fnode *, char *, int);
742 internal_proto(write_l);
744 extern void write_o (st_parameter_dt *, const fnode *, const char *, int);
745 internal_proto(write_o);
747 extern void write_real (st_parameter_dt *, const char *, int);
748 internal_proto(write_real);
750 extern void write_real_g0 (st_parameter_dt *, const char *, int, int);
751 internal_proto(write_real_g0);
753 extern void write_x (st_parameter_dt *, int, int);
754 internal_proto(write_x);
756 extern void write_z (st_parameter_dt *, const fnode *, const char *, int);
757 internal_proto(write_z);
759 extern void list_formatted_write (st_parameter_dt *, bt, void *, int, size_t,
760 size_t);
761 internal_proto(list_formatted_write);
763 /* size_from_kind.c */
764 extern size_t size_from_real_kind (int);
765 internal_proto(size_from_real_kind);
767 extern size_t size_from_complex_kind (int);
768 internal_proto(size_from_complex_kind);
771 /* lock.c */
772 extern void free_ionml (st_parameter_dt *);
773 internal_proto(free_ionml);
775 static inline void
776 inc_waiting_locked (gfc_unit *u)
778 #ifdef HAVE_SYNC_FETCH_AND_ADD
779 (void) __sync_fetch_and_add (&u->waiting, 1);
780 #else
781 u->waiting++;
782 #endif
785 static inline int
786 predec_waiting_locked (gfc_unit *u)
788 #ifdef HAVE_SYNC_FETCH_AND_ADD
789 return __sync_add_and_fetch (&u->waiting, -1);
790 #else
791 return --u->waiting;
792 #endif
795 static inline void
796 dec_waiting_unlocked (gfc_unit *u)
798 #ifdef HAVE_SYNC_FETCH_AND_ADD
799 (void) __sync_fetch_and_add (&u->waiting, -1);
800 #else
801 __gthread_mutex_lock (&unit_lock);
802 u->waiting--;
803 __gthread_mutex_unlock (&unit_lock);
804 #endif
808 static inline void
809 memset4 (gfc_char4_t *p, gfc_char4_t c, int k)
811 int j;
812 for (j = 0; j < k; j++)
813 *p++ = c;
816 #endif