1 /* Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
2 Contributed by Andy Vaught
4 This file is part of the GNU Fortran 95 runtime library (libgfortran).
6 Libgfortran is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 Libgfortran is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Libgfortran; see the file COPYING. If not, write to
18 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
21 /* As a special exception, if you link this library with other files,
22 some of which are compiled with GCC, to produce an executable,
23 this library does not by itself cause the resulting executable
24 to be covered by the GNU General Public License.
25 This exception does not however invalidate any other reasons why
26 the executable file might be covered by the GNU General Public License. */
31 /* IO library include. */
34 #include "libgfortran.h"
38 #define DEFAULT_TEMPDIR "/tmp"
40 /* Basic types used in data transfers. */
43 { BT_NULL, BT_INTEGER, BT_LOGICAL, BT_CHARACTER, BT_REAL,
49 struct st_parameter_dt;
53 char *(*alloc_w_at) (struct stream *, int *, gfc_offset);
54 char *(*alloc_r_at) (struct stream *, int *, gfc_offset);
55 try (*sfree) (struct stream *);
56 try (*close) (struct stream *);
57 try (*seek) (struct stream *, gfc_offset);
58 try (*truncate) (struct stream *);
59 int (*read) (struct stream *, void *, size_t *);
60 int (*write) (struct stream *, const void *, size_t *);
61 try (*set) (struct stream *, int, size_t);
66 /* Macros for doing file I/O given a stream. */
68 #define sfree(s) ((s)->sfree)(s)
69 #define sclose(s) ((s)->close)(s)
71 #define salloc_r(s, len) ((s)->alloc_r_at)(s, len, -1)
72 #define salloc_w(s, len) ((s)->alloc_w_at)(s, len, -1)
74 #define salloc_r_at(s, len, where) ((s)->alloc_r_at)(s, len, where)
75 #define salloc_w_at(s, len, where) ((s)->alloc_w_at)(s, len, where)
77 #define sseek(s, pos) ((s)->seek)(s, pos)
78 #define struncate(s) ((s)->truncate)(s)
79 #define sread(s, buf, nbytes) ((s)->read)(s, buf, nbytes)
80 #define swrite(s, buf, nbytes) ((s)->write)(s, buf, nbytes)
82 #define sset(s, c, n) ((s)->set)(s, c, n)
84 /* The array_loop_spec contains the variables for the loops over index ranges
85 that are encountered. Since the variables can be negative, ssize_t
88 typedef struct array_loop_spec
90 /* Index counter for this dimension. */
93 /* Start for the index counter. */
96 /* End for the index counter. */
99 /* Step for the index counter. */
104 /* Representation of a namelist object in libgfortran
107 &GROUPNAME OBJECT=value[s] [,OBJECT=value[s]].../
109 &GROUPNAME OBJECT=value[s] [,OBJECT=value[s]]...&END
111 The object can be a fully qualified, compound name for an instrinsic
112 type, derived types or derived type components. So, a substring
113 a(:)%b(4)%ch(2:4)(1:7) has to be treated correctly in namelist
114 read. Hence full information about the structure of the object has
115 to be available to list_read.c and write.
117 These requirements are met by the following data structures.
119 namelist_info type contains all the scalar information about the
120 object and arrays of descriptor_dimension and array_loop_spec types for
123 typedef struct namelist_type
126 /* Object type, stored as GFC_DTYPE_xxxx. */
132 /* Address for the start of the object's data. */
135 /* Flag to show that a read is to be attempted for this node. */
138 /* Length of intrinsic type in bytes. */
141 /* Rank of the object. */
144 /* Overall size of the object in bytes. */
147 /* Length of character string. */
148 index_type string_length;
150 descriptor_dimension * dim;
151 array_loop_spec * ls;
152 struct namelist_type * next;
156 /* Options for the OPEN statement. */
159 { ACCESS_SEQUENTIAL, ACCESS_DIRECT, ACCESS_APPEND,
165 { ACTION_READ, ACTION_WRITE, ACTION_READWRITE,
171 { BLANK_NULL, BLANK_ZERO, BLANK_UNSPECIFIED }
175 { DELIM_NONE, DELIM_APOSTROPHE, DELIM_QUOTE,
181 { FORM_FORMATTED, FORM_UNFORMATTED, FORM_UNSPECIFIED }
185 { POSITION_ASIS, POSITION_REWIND, POSITION_APPEND,
191 { STATUS_UNKNOWN, STATUS_OLD, STATUS_NEW, STATUS_SCRATCH,
192 STATUS_REPLACE, STATUS_UNSPECIFIED
197 { PAD_YES, PAD_NO, PAD_UNSPECIFIED }
201 { ADVANCE_YES, ADVANCE_NO, ADVANCE_UNSPECIFIED }
209 { CONVERT_NONE=-1, CONVERT_NATIVE, CONVERT_SWAP, CONVERT_BIG, CONVERT_LITTLE }
212 #define CHARACTER1(name) \
214 gfc_charlen_type name ## _len
215 #define CHARACTER2(name) \
216 gfc_charlen_type name ## _len; \
219 #define IOPARM_LIBRETURN_MASK (3 << 0)
220 #define IOPARM_LIBRETURN_OK (0 << 0)
221 #define IOPARM_LIBRETURN_ERROR (1 << 0)
222 #define IOPARM_LIBRETURN_END (2 << 0)
223 #define IOPARM_LIBRETURN_EOR (3 << 0)
224 #define IOPARM_ERR (1 << 2)
225 #define IOPARM_END (1 << 3)
226 #define IOPARM_EOR (1 << 4)
227 #define IOPARM_HAS_IOSTAT (1 << 5)
228 #define IOPARM_HAS_IOMSG (1 << 6)
230 #define IOPARM_COMMON_MASK ((1 << 7) - 1)
232 typedef struct st_parameter_common
236 const char *filename;
239 GFC_INTEGER_4 *iostat;
243 #define IOPARM_OPEN_HAS_RECL_IN (1 << 7)
244 #define IOPARM_OPEN_HAS_FILE (1 << 8)
245 #define IOPARM_OPEN_HAS_STATUS (1 << 9)
246 #define IOPARM_OPEN_HAS_ACCESS (1 << 10)
247 #define IOPARM_OPEN_HAS_FORM (1 << 11)
248 #define IOPARM_OPEN_HAS_BLANK (1 << 12)
249 #define IOPARM_OPEN_HAS_POSITION (1 << 13)
250 #define IOPARM_OPEN_HAS_ACTION (1 << 14)
251 #define IOPARM_OPEN_HAS_DELIM (1 << 15)
252 #define IOPARM_OPEN_HAS_PAD (1 << 16)
253 #define IOPARM_OPEN_HAS_CONVERT (1 << 17)
257 st_parameter_common common;
258 GFC_INTEGER_4 recl_in;
264 CHARACTER1 (position);
268 CHARACTER1 (convert);
272 #define IOPARM_CLOSE_HAS_STATUS (1 << 7)
276 st_parameter_common common;
283 st_parameter_common common;
285 st_parameter_filepos;
287 #define IOPARM_INQUIRE_HAS_EXIST (1 << 7)
288 #define IOPARM_INQUIRE_HAS_OPENED (1 << 8)
289 #define IOPARM_INQUIRE_HAS_NUMBER (1 << 9)
290 #define IOPARM_INQUIRE_HAS_NAMED (1 << 10)
291 #define IOPARM_INQUIRE_HAS_NEXTREC (1 << 11)
292 #define IOPARM_INQUIRE_HAS_RECL_OUT (1 << 12)
293 #define IOPARM_INQUIRE_HAS_FILE (1 << 13)
294 #define IOPARM_INQUIRE_HAS_ACCESS (1 << 14)
295 #define IOPARM_INQUIRE_HAS_FORM (1 << 15)
296 #define IOPARM_INQUIRE_HAS_BLANK (1 << 16)
297 #define IOPARM_INQUIRE_HAS_POSITION (1 << 17)
298 #define IOPARM_INQUIRE_HAS_ACTION (1 << 18)
299 #define IOPARM_INQUIRE_HAS_DELIM (1 << 19)
300 #define IOPARM_INQUIRE_HAS_PAD (1 << 20)
301 #define IOPARM_INQUIRE_HAS_NAME (1 << 21)
302 #define IOPARM_INQUIRE_HAS_SEQUENTIAL (1 << 22)
303 #define IOPARM_INQUIRE_HAS_DIRECT (1 << 23)
304 #define IOPARM_INQUIRE_HAS_FORMATTED (1 << 24)
305 #define IOPARM_INQUIRE_HAS_UNFORMATTED (1 << 25)
306 #define IOPARM_INQUIRE_HAS_READ (1 << 26)
307 #define IOPARM_INQUIRE_HAS_WRITE (1 << 27)
308 #define IOPARM_INQUIRE_HAS_READWRITE (1 << 28)
309 #define IOPARM_INQUIRE_HAS_CONVERT (1 << 29)
313 st_parameter_common common;
314 GFC_INTEGER_4 *exist, *opened, *number, *named;
315 GFC_INTEGER_4 *nextrec, *recl_out;
320 CHARACTER1 (position);
325 CHARACTER2 (sequential);
327 CHARACTER2 (formatted);
328 CHARACTER1 (unformatted);
331 CHARACTER2 (readwrite);
332 CHARACTER1 (convert);
334 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 /* Internal use bit. */
349 #define IOPARM_DT_IONML_SET (1 << 31)
351 typedef struct st_parameter_dt
353 st_parameter_common common;
354 GFC_LARGE_IO_INT rec;
355 GFC_INTEGER_4 *size, *iolength;
356 gfc_array_char *internal_unit_desc;
358 CHARACTER2 (advance);
359 CHARACTER1 (internal_unit);
360 CHARACTER2 (namelist_name);
361 /* Private part of the structure. The compiler just needs
362 to reserve enough space. */
367 void (*transfer) (struct st_parameter_dt *, bt, void *, int,
369 struct gfc_unit *current_unit;
370 /* Item number in a formatted data transfer. Also used in namelist
371 read_logical as an index into line_buffer. */
374 unit_blank blank_status;
375 enum {SIGN_S, SIGN_SS, SIGN_SP} sign_status;
377 int max_pos; /* Maximum righthand column written to. */
378 /* Number of skips + spaces to be done for T and X-editing. */
380 /* Number of spaces to be done for T and X-editing. */
382 /* Whether an EOR condition was encountered. Value is:
383 0 if no EOR was encountered
384 1 if an EOR was encountered due to a 1-byte marker (LF)
385 2 if an EOR was encountered due to a 2-bytes marker (CRLF) */
387 unit_advance advance_status;
389 unsigned reversion_flag : 1; /* Format reversion has occurred. */
390 unsigned first_item : 1;
391 unsigned seen_dollar : 1;
392 unsigned eor_condition : 1;
393 unsigned no_leading_blank : 1;
394 unsigned char_flag : 1;
395 unsigned input_complete : 1;
397 unsigned comma_flag : 1;
398 /* A namelist specific flag used in the list directed library
399 to flag that calls are being made from namelist read (eg. to
400 ignore comments or to treat '/' as a terminator) */
401 unsigned namelist_mode : 1;
402 /* A namelist specific flag used in the list directed library
403 to flag read errors and return, so that an attempt can be
404 made to read a new object name. */
405 unsigned nml_read_error : 1;
406 /* A sequential formatted read specific flag used to signal that a
407 character string is being read so don't use commas to shorten a
408 formatted field width. */
409 unsigned sf_read_comma : 1;
410 /* A namelist specific flag used to enable reading input from
411 line_buffer for logical reads. */
412 unsigned line_buffer_enabled : 1;
413 /* An internal unit specific flag used to identify that the associated
415 unsigned unit_is_internal : 1;
416 /* 17 unused bits. */
428 struct format_data *fmt;
430 namelist_info *ionml;
431 /* A flag used to identify when a non-standard expanded namelist read
434 /* Storage area for values except for strings. Must be large
435 enough to hold a complex value (two reals) of the largest
438 gfc_offset size_used;
440 /* This pad size must be equal to the pad_size declared in
441 trans-io.c (gfc_build_io_library_fndecls). The above structure
442 must be smaller or equal to this array. */
443 char pad[16 * sizeof (char *) + 32 * sizeof (int)];
448 /* Ensure st_parameter_dt's u.pad is bigger or equal to u.p. */
449 extern char check_st_parameter_dt[sizeof (((st_parameter_dt *) 0)->u.pad)
450 >= sizeof (((st_parameter_dt *) 0)->u.p)
464 unit_position position;
467 unit_convert convert;
472 /* The default value of record length for preconnected units is defined
473 here. This value can be overriden by an environment variable.
474 Default value is 1 Gb. */
476 #define DEFAULT_RECL 1073741824
479 typedef struct gfc_unit
485 struct gfc_unit *left, *right;
488 int read_bad, current_record;
490 { NO_ENDFILE, AT_ENDFILE, AFTER_ENDFILE }
496 /* recl -- Record length of the file.
497 last_record -- Last record number read or written
498 maxrec -- Maximum record number in a direct access file
499 bytes_left -- Bytes left in current record. */
500 gfc_offset recl, last_record, maxrec, bytes_left;
502 __gthread_mutex_t lock;
503 /* Number of threads waiting to acquire this unit's lock.
504 When non-zero, close_unit doesn't only removes the unit
505 from the UNIT_ROOT tree, but doesn't free it and the
506 last of the waiting threads will do that.
507 This must be either atomically increased/decreased, or
508 always guarded by UNIT_LOCK. */
510 /* Flag set by close_unit if the unit as been closed.
511 Must be manipulated under unit's lock. */
514 /* For traversing arrays */
523 /* Format tokens. Only about half of these can be stored in the
528 FMT_NONE = 0, FMT_UNKNOWN, FMT_SIGNED_INT, FMT_ZERO, FMT_POSINT, FMT_PERIOD,
529 FMT_COMMA, FMT_COLON, FMT_SLASH, FMT_DOLLAR, FMT_T, FMT_TR, FMT_TL,
530 FMT_LPAREN, FMT_RPAREN, FMT_X, FMT_S, FMT_SS, FMT_SP, FMT_STRING,
531 FMT_BADSTRING, FMT_P, FMT_I, FMT_B, FMT_BN, FMT_BZ, FMT_O, FMT_Z, FMT_F,
532 FMT_E, FMT_EN, FMT_ES, FMT_G, FMT_L, FMT_A, FMT_D, FMT_H, FMT_END
537 /* Format nodes. A format string is converted into a tree of these
538 structures, which is traversed as part of a data transfer statement. */
577 /* Members for traversing the tree during data transfer. */
580 struct fnode *current;
588 extern int move_pos_offset (stream *, int);
589 internal_proto(move_pos_offset);
591 extern int compare_files (stream *, stream *);
592 internal_proto(compare_files);
594 extern stream *open_external (st_parameter_open *, unit_flags *);
595 internal_proto(open_external);
597 extern stream *open_internal (char *, int);
598 internal_proto(open_internal);
600 extern stream *input_stream (void);
601 internal_proto(input_stream);
603 extern stream *output_stream (void);
604 internal_proto(output_stream);
606 extern stream *error_stream (void);
607 internal_proto(error_stream);
609 extern int compare_file_filename (gfc_unit *, const char *, int);
610 internal_proto(compare_file_filename);
612 extern gfc_unit *find_file (const char *file, gfc_charlen_type file_len);
613 internal_proto(find_file);
615 extern void flush_all_units (void);
616 internal_proto(flush_all_units);
618 extern int stream_at_bof (stream *);
619 internal_proto(stream_at_bof);
621 extern int stream_at_eof (stream *);
622 internal_proto(stream_at_eof);
624 extern int delete_file (gfc_unit *);
625 internal_proto(delete_file);
627 extern int file_exists (const char *file, gfc_charlen_type file_len);
628 internal_proto(file_exists);
630 extern const char *inquire_sequential (const char *, int);
631 internal_proto(inquire_sequential);
633 extern const char *inquire_direct (const char *, int);
634 internal_proto(inquire_direct);
636 extern const char *inquire_formatted (const char *, int);
637 internal_proto(inquire_formatted);
639 extern const char *inquire_unformatted (const char *, int);
640 internal_proto(inquire_unformatted);
642 extern const char *inquire_read (const char *, int);
643 internal_proto(inquire_read);
645 extern const char *inquire_write (const char *, int);
646 internal_proto(inquire_write);
648 extern const char *inquire_readwrite (const char *, int);
649 internal_proto(inquire_readwrite);
651 extern gfc_offset file_length (stream *);
652 internal_proto(file_length);
654 extern gfc_offset file_position (stream *);
655 internal_proto(file_position);
657 extern int is_seekable (stream *);
658 internal_proto(is_seekable);
660 extern int is_preconnected (stream *);
661 internal_proto(is_preconnected);
663 extern void flush_if_preconnected (stream *);
664 internal_proto(flush_if_preconnected);
666 extern void empty_internal_buffer(stream *);
667 internal_proto(empty_internal_buffer);
669 extern try flush (stream *);
670 internal_proto(flush);
672 extern int stream_isatty (stream *);
673 internal_proto(stream_isatty);
675 extern char * stream_ttyname (stream *);
676 internal_proto(stream_ttyname);
678 extern gfc_offset stream_offset (stream *s);
679 internal_proto(stream_offset);
681 extern int unpack_filename (char *, const char *, int);
682 internal_proto(unpack_filename);
686 /* Maximum file offset, computed at library initialization time. */
687 extern gfc_offset max_offset;
688 internal_proto(max_offset);
690 /* Unit tree root. */
691 extern gfc_unit *unit_root;
692 internal_proto(unit_root);
694 extern __gthread_mutex_t unit_lock;
695 internal_proto(unit_lock);
697 extern int close_unit (gfc_unit *);
698 internal_proto(close_unit);
700 extern gfc_unit *get_internal_unit (st_parameter_dt *);
701 internal_proto(get_internal_unit);
703 extern void free_internal_unit (st_parameter_dt *);
704 internal_proto(free_internal_unit);
706 extern int is_internal_unit (st_parameter_dt *);
707 internal_proto(is_internal_unit);
709 extern int is_array_io (st_parameter_dt *);
710 internal_proto(is_array_io);
712 extern gfc_unit *find_unit (int);
713 internal_proto(find_unit);
715 extern gfc_unit *find_or_create_unit (int);
716 internal_proto(find_or_create_unit);
718 extern gfc_unit *get_unit (st_parameter_dt *, int);
719 internal_proto(get_unit);
721 extern void unlock_unit (gfc_unit *);
722 internal_proto(unlock_unit);
726 extern void test_endfile (gfc_unit *);
727 internal_proto(test_endfile);
729 extern gfc_unit *new_unit (st_parameter_open *, gfc_unit *, unit_flags *);
730 internal_proto(new_unit);
734 extern void parse_format (st_parameter_dt *);
735 internal_proto(parse_format);
737 extern const fnode *next_format (st_parameter_dt *);
738 internal_proto(next_format);
740 extern void unget_format (st_parameter_dt *, const fnode *);
741 internal_proto(unget_format);
743 extern void format_error (st_parameter_dt *, const fnode *, const char *);
744 internal_proto(format_error);
746 extern void free_format_data (st_parameter_dt *);
747 internal_proto(free_format_data);
751 #define SCRATCH_SIZE 300
753 extern const char *type_name (bt);
754 internal_proto(type_name);
756 extern void *read_block (st_parameter_dt *, int *);
757 internal_proto(read_block);
759 extern char *read_sf (st_parameter_dt *, int *, int);
760 internal_proto(read_sf);
762 extern void *write_block (st_parameter_dt *, int);
763 internal_proto(write_block);
765 extern gfc_offset next_array_record (st_parameter_dt *, array_loop_spec *);
766 internal_proto(next_array_record);
768 extern gfc_offset init_loop_spec (gfc_array_char *, array_loop_spec *);
769 internal_proto(init_loop_spec);
771 extern void next_record (st_parameter_dt *, int);
772 internal_proto(next_record);
774 extern void reverse_memcpy (void *, const void *, size_t);
775 internal_proto (reverse_memcpy);
779 extern void set_integer (void *, GFC_INTEGER_LARGEST, int);
780 internal_proto(set_integer);
782 extern GFC_UINTEGER_LARGEST max_value (int, int);
783 internal_proto(max_value);
785 extern int convert_real (st_parameter_dt *, void *, const char *, int);
786 internal_proto(convert_real);
788 extern void read_a (st_parameter_dt *, const fnode *, char *, int);
789 internal_proto(read_a);
791 extern void read_f (st_parameter_dt *, const fnode *, char *, int);
792 internal_proto(read_f);
794 extern void read_l (st_parameter_dt *, const fnode *, char *, int);
795 internal_proto(read_l);
797 extern void read_x (st_parameter_dt *, int);
798 internal_proto(read_x);
800 extern void read_radix (st_parameter_dt *, const fnode *, char *, int, int);
801 internal_proto(read_radix);
803 extern void read_decimal (st_parameter_dt *, const fnode *, char *, int);
804 internal_proto(read_decimal);
808 extern void list_formatted_read (st_parameter_dt *, bt, void *, int, size_t,
810 internal_proto(list_formatted_read);
812 extern void finish_list_read (st_parameter_dt *);
813 internal_proto(finish_list_read);
815 extern void namelist_read (st_parameter_dt *);
816 internal_proto(namelist_read);
818 extern void namelist_write (st_parameter_dt *);
819 internal_proto(namelist_write);
823 extern void write_a (st_parameter_dt *, const fnode *, const char *, int);
824 internal_proto(write_a);
826 extern void write_b (st_parameter_dt *, const fnode *, const char *, int);
827 internal_proto(write_b);
829 extern void write_d (st_parameter_dt *, const fnode *, const char *, int);
830 internal_proto(write_d);
832 extern void write_e (st_parameter_dt *, const fnode *, const char *, int);
833 internal_proto(write_e);
835 extern void write_en (st_parameter_dt *, const fnode *, const char *, int);
836 internal_proto(write_en);
838 extern void write_es (st_parameter_dt *, const fnode *, const char *, int);
839 internal_proto(write_es);
841 extern void write_f (st_parameter_dt *, const fnode *, const char *, int);
842 internal_proto(write_f);
844 extern void write_i (st_parameter_dt *, const fnode *, const char *, int);
845 internal_proto(write_i);
847 extern void write_l (st_parameter_dt *, const fnode *, char *, int);
848 internal_proto(write_l);
850 extern void write_o (st_parameter_dt *, const fnode *, const char *, int);
851 internal_proto(write_o);
853 extern void write_x (st_parameter_dt *, int, int);
854 internal_proto(write_x);
856 extern void write_z (st_parameter_dt *, const fnode *, const char *, int);
857 internal_proto(write_z);
859 extern void list_formatted_write (st_parameter_dt *, bt, void *, int, size_t,
861 internal_proto(list_formatted_write);
864 extern notification notification_std(int);
865 internal_proto(notification_std);
867 /* size_from_kind.c */
868 extern size_t size_from_real_kind (int);
869 internal_proto(size_from_real_kind);
871 extern size_t size_from_complex_kind (int);
872 internal_proto(size_from_complex_kind);
875 extern void free_ionml (st_parameter_dt *);
876 internal_proto(free_ionml);
879 inc_waiting_locked (gfc_unit *u)
881 #ifdef HAVE_SYNC_FETCH_AND_ADD
882 (void) __sync_fetch_and_add (&u->waiting, 1);
889 predec_waiting_locked (gfc_unit *u)
891 #ifdef HAVE_SYNC_FETCH_AND_ADD
892 return __sync_add_and_fetch (&u->waiting, -1);
899 dec_waiting_unlocked (gfc_unit *u)
901 #ifdef HAVE_SYNC_FETCH_AND_ADD
902 (void) __sync_fetch_and_add (&u->waiting, -1);
904 __gthread_mutex_lock (&unit_lock);
906 __gthread_mutex_unlock (&unit_lock);
912 /* ../runtime/environ.c This is here because we return unit_convert. */
914 unit_convert get_unformatted_convert (int);
915 internal_proto(get_unformatted_convert);