annotate libgfortran/io/io.h @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1 /* Copyright (C) 2002-2020 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
2 Contributed by Andy Vaught
kono
parents:
diff changeset
3 F2003 I/O support contributed by Jerry DeLisle
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 This file is part of the GNU Fortran runtime library (libgfortran).
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 Libgfortran is free software; you can redistribute it and/or modify
kono
parents:
diff changeset
8 it under the terms of the GNU General Public License as published by
kono
parents:
diff changeset
9 the Free Software Foundation; either version 3, or (at your option)
kono
parents:
diff changeset
10 any later version.
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 Libgfortran is distributed in the hope that it will be useful,
kono
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
kono
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
kono
parents:
diff changeset
15 GNU General Public License for more details.
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 Under Section 7 of GPL version 3, you are granted additional
kono
parents:
diff changeset
18 permissions described in the GCC Runtime Library Exception, version
kono
parents:
diff changeset
19 3.1, as published by the Free Software Foundation.
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 You should have received a copy of the GNU General Public License and
kono
parents:
diff changeset
22 a copy of the GCC Runtime Library Exception along with this program;
kono
parents:
diff changeset
23 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
kono
parents:
diff changeset
24 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 #ifndef GFOR_IO_H
kono
parents:
diff changeset
27 #define GFOR_IO_H
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 /* IO library include. */
kono
parents:
diff changeset
30
kono
parents:
diff changeset
31 #include "libgfortran.h"
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 #include <gthr.h>
kono
parents:
diff changeset
34
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
35 #define gcc_unreachable() __builtin_unreachable ()
111
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 /* POSIX 2008 specifies that the extended locale stuff is found in
kono
parents:
diff changeset
38 locale.h, but some systems have them in xlocale.h. */
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 #include <locale.h>
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 #ifdef HAVE_XLOCALE_H
kono
parents:
diff changeset
43 #include <xlocale.h>
kono
parents:
diff changeset
44 #endif
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 /* Forward declarations. */
kono
parents:
diff changeset
48 struct st_parameter_dt;
kono
parents:
diff changeset
49 typedef struct stream stream;
kono
parents:
diff changeset
50 struct fbuf;
kono
parents:
diff changeset
51 struct format_data;
kono
parents:
diff changeset
52 typedef struct fnode fnode;
kono
parents:
diff changeset
53 struct gfc_unit;
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 #ifdef HAVE_NEWLOCALE
kono
parents:
diff changeset
56 /* We have POSIX 2008 extended locale stuff. */
kono
parents:
diff changeset
57 extern locale_t c_locale;
kono
parents:
diff changeset
58 internal_proto(c_locale);
kono
parents:
diff changeset
59 #else
kono
parents:
diff changeset
60 extern char* old_locale;
kono
parents:
diff changeset
61 internal_proto(old_locale);
kono
parents:
diff changeset
62 extern int old_locale_ctr;
kono
parents:
diff changeset
63 internal_proto(old_locale_ctr);
kono
parents:
diff changeset
64 extern __gthread_mutex_t old_locale_lock;
kono
parents:
diff changeset
65 internal_proto(old_locale_lock);
kono
parents:
diff changeset
66 #endif
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 /* Macros for testing what kinds of I/O we are doing. */
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 #define is_array_io(dtp) ((dtp)->internal_unit_desc)
kono
parents:
diff changeset
72
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
73 #define is_internal_unit(dtp) ((dtp)->u.p.unit_is_internal)
111
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 #define is_stream_io(dtp) ((dtp)->u.p.current_unit->flags.access == ACCESS_STREAM)
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 #define is_char4_unit(dtp) ((dtp)->u.p.current_unit->internal_unit_kind == 4)
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 /* The array_loop_spec contains the variables for the loops over index ranges
kono
parents:
diff changeset
80 that are encountered. */
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 typedef struct array_loop_spec
kono
parents:
diff changeset
83 {
kono
parents:
diff changeset
84 /* Index counter for this dimension. */
kono
parents:
diff changeset
85 index_type idx;
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 /* Start for the index counter. */
kono
parents:
diff changeset
88 index_type start;
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 /* End for the index counter. */
kono
parents:
diff changeset
91 index_type end;
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 /* Step for the index counter. */
kono
parents:
diff changeset
94 index_type step;
kono
parents:
diff changeset
95 }
kono
parents:
diff changeset
96 array_loop_spec;
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 /* User defined input/output iomsg length. */
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 #define IOMSG_LEN 256
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 /* Subroutine formatted_dtio (struct, unit, iotype, v_list, iostat,
kono
parents:
diff changeset
103 iomsg, (_iotype), (_iomsg)) */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
104 typedef void (*formatted_dtio)(void *, GFC_INTEGER_4 *, char *,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
105 gfc_full_array_i4 *,
111
kono
parents:
diff changeset
106 GFC_INTEGER_4 *, char *,
kono
parents:
diff changeset
107 gfc_charlen_type, gfc_charlen_type);
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 /* Subroutine unformatted_dtio (struct, unit, iostat, iomsg, (_iomsg)) */
kono
parents:
diff changeset
110 typedef void (*unformatted_dtio)(void *, GFC_INTEGER_4 *, GFC_INTEGER_4 *,
kono
parents:
diff changeset
111 char *, gfc_charlen_type);
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 /* The dtio calls for namelist require a CLASS object to be built. */
kono
parents:
diff changeset
114 typedef struct gfc_class
kono
parents:
diff changeset
115 {
kono
parents:
diff changeset
116 void *data;
kono
parents:
diff changeset
117 void *vptr;
kono
parents:
diff changeset
118 index_type len;
kono
parents:
diff changeset
119 }
kono
parents:
diff changeset
120 gfc_class;
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 /* A structure to build a hash table for format data. */
kono
parents:
diff changeset
124
kono
parents:
diff changeset
125 #define FORMAT_HASH_SIZE 16
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 typedef struct format_hash_entry
kono
parents:
diff changeset
128 {
kono
parents:
diff changeset
129 char *key;
kono
parents:
diff changeset
130 gfc_charlen_type key_len;
kono
parents:
diff changeset
131 struct format_data *hashed_fmt;
kono
parents:
diff changeset
132 }
kono
parents:
diff changeset
133 format_hash_entry;
kono
parents:
diff changeset
134
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
135 /* Format tokens. Only about half of these can be stored in the
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
136 format nodes. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
137
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
138 typedef enum
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
139 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
140 FMT_NONE = 0, FMT_UNKNOWN, FMT_SIGNED_INT, FMT_ZERO, FMT_POSINT, FMT_PERIOD,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
141 FMT_COMMA, FMT_COLON, FMT_SLASH, FMT_DOLLAR, FMT_T, FMT_TR, FMT_TL,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
142 FMT_LPAREN, FMT_RPAREN, FMT_X, FMT_S, FMT_SS, FMT_SP, FMT_STRING,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
143 FMT_BADSTRING, FMT_P, FMT_I, FMT_B, FMT_BN, FMT_BZ, FMT_O, FMT_Z, FMT_F,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
144 FMT_E, FMT_EN, FMT_ES, FMT_G, FMT_L, FMT_A, FMT_D, FMT_H, FMT_END, FMT_DC,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
145 FMT_DP, FMT_STAR, FMT_RC, FMT_RD, FMT_RN, FMT_RP, FMT_RU, FMT_RZ, FMT_DT
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
146 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
147 format_token;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
148
111
kono
parents:
diff changeset
149 /* Representation of a namelist object in libgfortran
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151 Namelist Records
kono
parents:
diff changeset
152 &GROUPNAME OBJECT=value[s] [,OBJECT=value[s]].../
kono
parents:
diff changeset
153 or
kono
parents:
diff changeset
154 &GROUPNAME OBJECT=value[s] [,OBJECT=value[s]]...&END
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 The object can be a fully qualified, compound name for an intrinsic
kono
parents:
diff changeset
157 type, derived types or derived type components. So, a substring
kono
parents:
diff changeset
158 a(:)%b(4)%ch(2:4)(1:7) has to be treated correctly in namelist
kono
parents:
diff changeset
159 read. Hence full information about the structure of the object has
kono
parents:
diff changeset
160 to be available to list_read.c and write.
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 These requirements are met by the following data structures.
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 namelist_info type contains all the scalar information about the
kono
parents:
diff changeset
165 object and arrays of descriptor_dimension and array_loop_spec types for
kono
parents:
diff changeset
166 arrays. */
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 typedef struct namelist_type
kono
parents:
diff changeset
169 {
kono
parents:
diff changeset
170 /* Object type. */
kono
parents:
diff changeset
171 bt type;
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 /* Object name. */
kono
parents:
diff changeset
174 char * var_name;
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 /* Address for the start of the object's data. */
kono
parents:
diff changeset
177 void * mem_pos;
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 /* Address of specific DTIO subroutine. */
kono
parents:
diff changeset
180 void * dtio_sub;
kono
parents:
diff changeset
181
kono
parents:
diff changeset
182 /* Address of vtable if dtio_sub non-null. */
kono
parents:
diff changeset
183 void * vtable;
kono
parents:
diff changeset
184
kono
parents:
diff changeset
185 /* Flag to show that a read is to be attempted for this node. */
kono
parents:
diff changeset
186 int touched;
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 /* Length of intrinsic type in bytes. */
kono
parents:
diff changeset
189 int len;
kono
parents:
diff changeset
190
kono
parents:
diff changeset
191 /* Rank of the object. */
kono
parents:
diff changeset
192 int var_rank;
kono
parents:
diff changeset
193
kono
parents:
diff changeset
194 /* Overall size of the object in bytes. */
kono
parents:
diff changeset
195 index_type size;
kono
parents:
diff changeset
196
kono
parents:
diff changeset
197 /* Length of character string. */
kono
parents:
diff changeset
198 index_type string_length;
kono
parents:
diff changeset
199
kono
parents:
diff changeset
200 descriptor_dimension * dim;
kono
parents:
diff changeset
201 array_loop_spec * ls;
kono
parents:
diff changeset
202 struct namelist_type * next;
kono
parents:
diff changeset
203 }
kono
parents:
diff changeset
204 namelist_info;
kono
parents:
diff changeset
205
kono
parents:
diff changeset
206 /* Options for the OPEN statement. */
kono
parents:
diff changeset
207
kono
parents:
diff changeset
208 typedef enum
kono
parents:
diff changeset
209 { ACCESS_SEQUENTIAL, ACCESS_DIRECT, ACCESS_APPEND, ACCESS_STREAM,
kono
parents:
diff changeset
210 ACCESS_UNSPECIFIED
kono
parents:
diff changeset
211 }
kono
parents:
diff changeset
212 unit_access;
kono
parents:
diff changeset
213
kono
parents:
diff changeset
214 typedef enum
kono
parents:
diff changeset
215 { ACTION_READ, ACTION_WRITE, ACTION_READWRITE,
kono
parents:
diff changeset
216 ACTION_UNSPECIFIED
kono
parents:
diff changeset
217 }
kono
parents:
diff changeset
218 unit_action;
kono
parents:
diff changeset
219
kono
parents:
diff changeset
220 typedef enum
kono
parents:
diff changeset
221 { BLANK_NULL, BLANK_ZERO, BLANK_UNSPECIFIED }
kono
parents:
diff changeset
222 unit_blank;
kono
parents:
diff changeset
223
kono
parents:
diff changeset
224 typedef enum
kono
parents:
diff changeset
225 { DELIM_NONE, DELIM_APOSTROPHE, DELIM_QUOTE,
kono
parents:
diff changeset
226 DELIM_UNSPECIFIED
kono
parents:
diff changeset
227 }
kono
parents:
diff changeset
228 unit_delim;
kono
parents:
diff changeset
229
kono
parents:
diff changeset
230 typedef enum
kono
parents:
diff changeset
231 { FORM_FORMATTED, FORM_UNFORMATTED, FORM_UNSPECIFIED }
kono
parents:
diff changeset
232 unit_form;
kono
parents:
diff changeset
233
kono
parents:
diff changeset
234 typedef enum
kono
parents:
diff changeset
235 { POSITION_ASIS, POSITION_REWIND, POSITION_APPEND,
kono
parents:
diff changeset
236 POSITION_UNSPECIFIED
kono
parents:
diff changeset
237 }
kono
parents:
diff changeset
238 unit_position;
kono
parents:
diff changeset
239
kono
parents:
diff changeset
240 typedef enum
kono
parents:
diff changeset
241 { STATUS_UNKNOWN, STATUS_OLD, STATUS_NEW, STATUS_SCRATCH,
kono
parents:
diff changeset
242 STATUS_REPLACE, STATUS_UNSPECIFIED
kono
parents:
diff changeset
243 }
kono
parents:
diff changeset
244 unit_status;
kono
parents:
diff changeset
245
kono
parents:
diff changeset
246 typedef enum
kono
parents:
diff changeset
247 { PAD_YES, PAD_NO, PAD_UNSPECIFIED }
kono
parents:
diff changeset
248 unit_pad;
kono
parents:
diff changeset
249
kono
parents:
diff changeset
250 typedef enum
kono
parents:
diff changeset
251 { DECIMAL_POINT, DECIMAL_COMMA, DECIMAL_UNSPECIFIED }
kono
parents:
diff changeset
252 unit_decimal;
kono
parents:
diff changeset
253
kono
parents:
diff changeset
254 typedef enum
kono
parents:
diff changeset
255 { ENCODING_UTF8, ENCODING_DEFAULT, ENCODING_UNSPECIFIED }
kono
parents:
diff changeset
256 unit_encoding;
kono
parents:
diff changeset
257
kono
parents:
diff changeset
258 typedef enum
kono
parents:
diff changeset
259 { ROUND_UP = GFC_FPE_UPWARD,
kono
parents:
diff changeset
260 ROUND_DOWN = GFC_FPE_DOWNWARD,
kono
parents:
diff changeset
261 ROUND_ZERO = GFC_FPE_TOWARDZERO,
kono
parents:
diff changeset
262 ROUND_NEAREST = GFC_FPE_TONEAREST,
kono
parents:
diff changeset
263 ROUND_COMPATIBLE = 10, /* round away from zero. */
kono
parents:
diff changeset
264 ROUND_PROCDEFINED, /* Here as ROUND_NEAREST. */
kono
parents:
diff changeset
265 ROUND_UNSPECIFIED /* Should never occur. */
kono
parents:
diff changeset
266 }
kono
parents:
diff changeset
267 unit_round;
kono
parents:
diff changeset
268
kono
parents:
diff changeset
269 /* NOTE: unit_sign must correspond with the sign_status enumerator in
kono
parents:
diff changeset
270 st_parameter_dt to not break the ABI. */
kono
parents:
diff changeset
271 typedef enum
kono
parents:
diff changeset
272 { SIGN_PROCDEFINED, SIGN_SUPPRESS, SIGN_PLUS, SIGN_UNSPECIFIED }
kono
parents:
diff changeset
273 unit_sign;
kono
parents:
diff changeset
274
kono
parents:
diff changeset
275 typedef enum
kono
parents:
diff changeset
276 { ADVANCE_YES, ADVANCE_NO, ADVANCE_UNSPECIFIED }
kono
parents:
diff changeset
277 unit_advance;
kono
parents:
diff changeset
278
kono
parents:
diff changeset
279 typedef enum
kono
parents:
diff changeset
280 {READING, WRITING, LIST_READING, LIST_WRITING}
kono
parents:
diff changeset
281 unit_mode;
kono
parents:
diff changeset
282
kono
parents:
diff changeset
283 typedef enum
kono
parents:
diff changeset
284 { ASYNC_YES, ASYNC_NO, ASYNC_UNSPECIFIED }
kono
parents:
diff changeset
285 unit_async;
kono
parents:
diff changeset
286
kono
parents:
diff changeset
287 typedef enum
kono
parents:
diff changeset
288 { SHARE_DENYRW, SHARE_DENYNONE,
kono
parents:
diff changeset
289 SHARE_UNSPECIFIED
kono
parents:
diff changeset
290 }
kono
parents:
diff changeset
291 unit_share;
kono
parents:
diff changeset
292
kono
parents:
diff changeset
293 typedef enum
kono
parents:
diff changeset
294 { CC_LIST, CC_FORTRAN, CC_NONE,
kono
parents:
diff changeset
295 CC_UNSPECIFIED
kono
parents:
diff changeset
296 }
kono
parents:
diff changeset
297 unit_cc;
kono
parents:
diff changeset
298
kono
parents:
diff changeset
299 /* End-of-record types for CC_FORTRAN. */
kono
parents:
diff changeset
300 typedef enum
kono
parents:
diff changeset
301 { CCF_DEFAULT=0x0,
kono
parents:
diff changeset
302 CCF_OVERPRINT=0x1,
kono
parents:
diff changeset
303 CCF_ONE_LF=0x2,
kono
parents:
diff changeset
304 CCF_TWO_LF=0x4,
kono
parents:
diff changeset
305 CCF_PAGE_FEED=0x8,
kono
parents:
diff changeset
306 CCF_PROMPT=0x10,
kono
parents:
diff changeset
307 CCF_OVERPRINT_NOA=0x20,
kono
parents:
diff changeset
308 } /* 6 bits */
kono
parents:
diff changeset
309 cc_fortran;
kono
parents:
diff changeset
310
kono
parents:
diff changeset
311 typedef enum
kono
parents:
diff changeset
312 { SIGN_S, SIGN_SS, SIGN_SP }
kono
parents:
diff changeset
313 unit_sign_s;
kono
parents:
diff changeset
314
kono
parents:
diff changeset
315 /* Make sure to keep st_parameter_* in sync with gcc/fortran/ioparm.def. */
kono
parents:
diff changeset
316
kono
parents:
diff changeset
317 #define CHARACTER1(name) \
kono
parents:
diff changeset
318 char * name; \
kono
parents:
diff changeset
319 gfc_charlen_type name ## _len
kono
parents:
diff changeset
320 #define CHARACTER2(name) \
kono
parents:
diff changeset
321 gfc_charlen_type name ## _len; \
kono
parents:
diff changeset
322 char * name
kono
parents:
diff changeset
323
kono
parents:
diff changeset
324 typedef struct
kono
parents:
diff changeset
325 {
kono
parents:
diff changeset
326 st_parameter_common common;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
327 GFC_IO_INT recl_in;
111
kono
parents:
diff changeset
328 CHARACTER2 (file);
kono
parents:
diff changeset
329 CHARACTER1 (status);
kono
parents:
diff changeset
330 CHARACTER2 (access);
kono
parents:
diff changeset
331 CHARACTER1 (form);
kono
parents:
diff changeset
332 CHARACTER2 (blank);
kono
parents:
diff changeset
333 CHARACTER1 (position);
kono
parents:
diff changeset
334 CHARACTER2 (action);
kono
parents:
diff changeset
335 CHARACTER1 (delim);
kono
parents:
diff changeset
336 CHARACTER2 (pad);
kono
parents:
diff changeset
337 CHARACTER1 (convert);
kono
parents:
diff changeset
338 CHARACTER2 (decimal);
kono
parents:
diff changeset
339 CHARACTER1 (encoding);
kono
parents:
diff changeset
340 CHARACTER2 (round);
kono
parents:
diff changeset
341 CHARACTER1 (sign);
kono
parents:
diff changeset
342 CHARACTER2 (asynchronous);
kono
parents:
diff changeset
343 GFC_INTEGER_4 *newunit;
kono
parents:
diff changeset
344 GFC_INTEGER_4 readonly;
kono
parents:
diff changeset
345 CHARACTER2 (cc);
kono
parents:
diff changeset
346 CHARACTER1 (share);
kono
parents:
diff changeset
347 }
kono
parents:
diff changeset
348 st_parameter_open;
kono
parents:
diff changeset
349
kono
parents:
diff changeset
350 #define IOPARM_CLOSE_HAS_STATUS (1 << 7)
kono
parents:
diff changeset
351
kono
parents:
diff changeset
352 typedef struct
kono
parents:
diff changeset
353 {
kono
parents:
diff changeset
354 st_parameter_common common;
kono
parents:
diff changeset
355 CHARACTER1 (status);
kono
parents:
diff changeset
356 }
kono
parents:
diff changeset
357 st_parameter_close;
kono
parents:
diff changeset
358
kono
parents:
diff changeset
359 typedef struct
kono
parents:
diff changeset
360 {
kono
parents:
diff changeset
361 st_parameter_common common;
kono
parents:
diff changeset
362 }
kono
parents:
diff changeset
363 st_parameter_filepos;
kono
parents:
diff changeset
364
kono
parents:
diff changeset
365 #define IOPARM_INQUIRE_HAS_EXIST (1 << 7)
kono
parents:
diff changeset
366 #define IOPARM_INQUIRE_HAS_OPENED (1 << 8)
kono
parents:
diff changeset
367 #define IOPARM_INQUIRE_HAS_NUMBER (1 << 9)
kono
parents:
diff changeset
368 #define IOPARM_INQUIRE_HAS_NAMED (1 << 10)
kono
parents:
diff changeset
369 #define IOPARM_INQUIRE_HAS_NEXTREC (1 << 11)
kono
parents:
diff changeset
370 #define IOPARM_INQUIRE_HAS_RECL_OUT (1 << 12)
kono
parents:
diff changeset
371 #define IOPARM_INQUIRE_HAS_STRM_POS_OUT (1 << 13)
kono
parents:
diff changeset
372 #define IOPARM_INQUIRE_HAS_FILE (1 << 14)
kono
parents:
diff changeset
373 #define IOPARM_INQUIRE_HAS_ACCESS (1 << 15)
kono
parents:
diff changeset
374 #define IOPARM_INQUIRE_HAS_FORM (1 << 16)
kono
parents:
diff changeset
375 #define IOPARM_INQUIRE_HAS_BLANK (1 << 17)
kono
parents:
diff changeset
376 #define IOPARM_INQUIRE_HAS_POSITION (1 << 18)
kono
parents:
diff changeset
377 #define IOPARM_INQUIRE_HAS_ACTION (1 << 19)
kono
parents:
diff changeset
378 #define IOPARM_INQUIRE_HAS_DELIM (1 << 20)
kono
parents:
diff changeset
379 #define IOPARM_INQUIRE_HAS_PAD (1 << 21)
kono
parents:
diff changeset
380 #define IOPARM_INQUIRE_HAS_NAME (1 << 22)
kono
parents:
diff changeset
381 #define IOPARM_INQUIRE_HAS_SEQUENTIAL (1 << 23)
kono
parents:
diff changeset
382 #define IOPARM_INQUIRE_HAS_DIRECT (1 << 24)
kono
parents:
diff changeset
383 #define IOPARM_INQUIRE_HAS_FORMATTED (1 << 25)
kono
parents:
diff changeset
384 #define IOPARM_INQUIRE_HAS_UNFORMATTED (1 << 26)
kono
parents:
diff changeset
385 #define IOPARM_INQUIRE_HAS_READ (1 << 27)
kono
parents:
diff changeset
386 #define IOPARM_INQUIRE_HAS_WRITE (1 << 28)
kono
parents:
diff changeset
387 #define IOPARM_INQUIRE_HAS_READWRITE (1 << 29)
kono
parents:
diff changeset
388 #define IOPARM_INQUIRE_HAS_CONVERT (1 << 30)
kono
parents:
diff changeset
389 #define IOPARM_INQUIRE_HAS_FLAGS2 (1u << 31)
kono
parents:
diff changeset
390
kono
parents:
diff changeset
391 #define IOPARM_INQUIRE_HAS_ASYNCHRONOUS (1 << 0)
kono
parents:
diff changeset
392 #define IOPARM_INQUIRE_HAS_DECIMAL (1 << 1)
kono
parents:
diff changeset
393 #define IOPARM_INQUIRE_HAS_ENCODING (1 << 2)
kono
parents:
diff changeset
394 #define IOPARM_INQUIRE_HAS_ROUND (1 << 3)
kono
parents:
diff changeset
395 #define IOPARM_INQUIRE_HAS_SIGN (1 << 4)
kono
parents:
diff changeset
396 #define IOPARM_INQUIRE_HAS_PENDING (1 << 5)
kono
parents:
diff changeset
397 #define IOPARM_INQUIRE_HAS_SIZE (1 << 6)
kono
parents:
diff changeset
398 #define IOPARM_INQUIRE_HAS_ID (1 << 7)
kono
parents:
diff changeset
399 #define IOPARM_INQUIRE_HAS_IQSTREAM (1 << 8)
kono
parents:
diff changeset
400 #define IOPARM_INQUIRE_HAS_SHARE (1 << 9)
kono
parents:
diff changeset
401 #define IOPARM_INQUIRE_HAS_CC (1 << 10)
kono
parents:
diff changeset
402
kono
parents:
diff changeset
403 typedef struct
kono
parents:
diff changeset
404 {
kono
parents:
diff changeset
405 st_parameter_common common;
kono
parents:
diff changeset
406 GFC_INTEGER_4 *exist, *opened, *number, *named;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
407 GFC_IO_INT *nextrec, *recl_out, *strm_pos_out;
111
kono
parents:
diff changeset
408 CHARACTER1 (file);
kono
parents:
diff changeset
409 CHARACTER2 (access);
kono
parents:
diff changeset
410 CHARACTER1 (form);
kono
parents:
diff changeset
411 CHARACTER2 (blank);
kono
parents:
diff changeset
412 CHARACTER1 (position);
kono
parents:
diff changeset
413 CHARACTER2 (action);
kono
parents:
diff changeset
414 CHARACTER1 (delim);
kono
parents:
diff changeset
415 CHARACTER2 (pad);
kono
parents:
diff changeset
416 CHARACTER1 (name);
kono
parents:
diff changeset
417 CHARACTER2 (sequential);
kono
parents:
diff changeset
418 CHARACTER1 (direct);
kono
parents:
diff changeset
419 CHARACTER2 (formatted);
kono
parents:
diff changeset
420 CHARACTER1 (unformatted);
kono
parents:
diff changeset
421 CHARACTER2 (read);
kono
parents:
diff changeset
422 CHARACTER1 (write);
kono
parents:
diff changeset
423 CHARACTER2 (readwrite);
kono
parents:
diff changeset
424 CHARACTER1 (convert);
kono
parents:
diff changeset
425 GFC_INTEGER_4 flags2;
kono
parents:
diff changeset
426 CHARACTER1 (asynchronous);
kono
parents:
diff changeset
427 CHARACTER2 (decimal);
kono
parents:
diff changeset
428 CHARACTER1 (encoding);
kono
parents:
diff changeset
429 CHARACTER2 (round);
kono
parents:
diff changeset
430 CHARACTER1 (sign);
kono
parents:
diff changeset
431 GFC_INTEGER_4 *pending;
kono
parents:
diff changeset
432 GFC_IO_INT *size;
kono
parents:
diff changeset
433 GFC_INTEGER_4 *id;
kono
parents:
diff changeset
434 CHARACTER1 (iqstream);
kono
parents:
diff changeset
435 CHARACTER2 (share);
kono
parents:
diff changeset
436 CHARACTER1 (cc);
kono
parents:
diff changeset
437 }
kono
parents:
diff changeset
438 st_parameter_inquire;
kono
parents:
diff changeset
439
kono
parents:
diff changeset
440
kono
parents:
diff changeset
441 #define IOPARM_DT_LIST_FORMAT (1 << 7)
kono
parents:
diff changeset
442 #define IOPARM_DT_NAMELIST_READ_MODE (1 << 8)
kono
parents:
diff changeset
443 #define IOPARM_DT_HAS_REC (1 << 9)
kono
parents:
diff changeset
444 #define IOPARM_DT_HAS_SIZE (1 << 10)
kono
parents:
diff changeset
445 #define IOPARM_DT_HAS_IOLENGTH (1 << 11)
kono
parents:
diff changeset
446 #define IOPARM_DT_HAS_FORMAT (1 << 12)
kono
parents:
diff changeset
447 #define IOPARM_DT_HAS_ADVANCE (1 << 13)
kono
parents:
diff changeset
448 #define IOPARM_DT_HAS_INTERNAL_UNIT (1 << 14)
kono
parents:
diff changeset
449 #define IOPARM_DT_HAS_NAMELIST_NAME (1 << 15)
kono
parents:
diff changeset
450 #define IOPARM_DT_HAS_ID (1 << 16)
kono
parents:
diff changeset
451 #define IOPARM_DT_HAS_POS (1 << 17)
kono
parents:
diff changeset
452 #define IOPARM_DT_HAS_ASYNCHRONOUS (1 << 18)
kono
parents:
diff changeset
453 #define IOPARM_DT_HAS_BLANK (1 << 19)
kono
parents:
diff changeset
454 #define IOPARM_DT_HAS_DECIMAL (1 << 20)
kono
parents:
diff changeset
455 #define IOPARM_DT_HAS_DELIM (1 << 21)
kono
parents:
diff changeset
456 #define IOPARM_DT_HAS_PAD (1 << 22)
kono
parents:
diff changeset
457 #define IOPARM_DT_HAS_ROUND (1 << 23)
kono
parents:
diff changeset
458 #define IOPARM_DT_HAS_SIGN (1 << 24)
kono
parents:
diff changeset
459 #define IOPARM_DT_HAS_F2003 (1 << 25)
kono
parents:
diff changeset
460 #define IOPARM_DT_HAS_UDTIO (1 << 26)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
461 #define IOPARM_DT_DEC_EXT (1 << 27)
111
kono
parents:
diff changeset
462 /* Internal use bit. */
kono
parents:
diff changeset
463 #define IOPARM_DT_IONML_SET (1u << 31)
kono
parents:
diff changeset
464
kono
parents:
diff changeset
465
kono
parents:
diff changeset
466 typedef struct st_parameter_dt
kono
parents:
diff changeset
467 {
kono
parents:
diff changeset
468 st_parameter_common common;
kono
parents:
diff changeset
469 GFC_IO_INT rec;
kono
parents:
diff changeset
470 GFC_IO_INT *size, *iolength;
kono
parents:
diff changeset
471 gfc_array_char *internal_unit_desc;
kono
parents:
diff changeset
472 CHARACTER1 (format);
kono
parents:
diff changeset
473 CHARACTER2 (advance);
kono
parents:
diff changeset
474 CHARACTER1 (internal_unit);
kono
parents:
diff changeset
475 CHARACTER2 (namelist_name);
kono
parents:
diff changeset
476 GFC_INTEGER_4 *id;
kono
parents:
diff changeset
477 GFC_IO_INT pos;
kono
parents:
diff changeset
478 CHARACTER1 (asynchronous);
kono
parents:
diff changeset
479 CHARACTER2 (blank);
kono
parents:
diff changeset
480 CHARACTER1 (decimal);
kono
parents:
diff changeset
481 CHARACTER2 (delim);
kono
parents:
diff changeset
482 CHARACTER1 (pad);
kono
parents:
diff changeset
483 CHARACTER2 (round);
kono
parents:
diff changeset
484 CHARACTER1 (sign);
kono
parents:
diff changeset
485 /* Private part of the structure. The compiler just needs
kono
parents:
diff changeset
486 to reserve enough space. */
kono
parents:
diff changeset
487 union
kono
parents:
diff changeset
488 {
kono
parents:
diff changeset
489 struct
kono
parents:
diff changeset
490 {
kono
parents:
diff changeset
491 void (*transfer) (struct st_parameter_dt *, bt, void *, int,
kono
parents:
diff changeset
492 size_t, size_t);
kono
parents:
diff changeset
493 struct gfc_unit *current_unit;
kono
parents:
diff changeset
494 /* Item number in a formatted data transfer. Also used in namelist
kono
parents:
diff changeset
495 read_logical as an index into line_buffer. */
kono
parents:
diff changeset
496 int item_count;
kono
parents:
diff changeset
497 unit_mode mode;
kono
parents:
diff changeset
498 unit_blank blank_status;
kono
parents:
diff changeset
499 unit_sign sign_status;
kono
parents:
diff changeset
500 int scale_factor;
kono
parents:
diff changeset
501 /* Maximum righthand column written to. */
kono
parents:
diff changeset
502 int max_pos;
kono
parents:
diff changeset
503 /* Number of skips + spaces to be done for T and X-editing. */
kono
parents:
diff changeset
504 int skips;
kono
parents:
diff changeset
505 /* Number of spaces to be done for T and X-editing. */
kono
parents:
diff changeset
506 int pending_spaces;
kono
parents:
diff changeset
507 /* Whether an EOR condition was encountered. Value is:
kono
parents:
diff changeset
508 0 if no EOR was encountered
kono
parents:
diff changeset
509 1 if an EOR was encountered due to a 1-byte marker (LF)
kono
parents:
diff changeset
510 2 if an EOR was encountered due to a 2-bytes marker (CRLF) */
kono
parents:
diff changeset
511 int sf_seen_eor;
kono
parents:
diff changeset
512 unit_advance advance_status;
kono
parents:
diff changeset
513 unsigned reversion_flag : 1; /* Format reversion has occurred. */
kono
parents:
diff changeset
514 unsigned first_item : 1;
kono
parents:
diff changeset
515 unsigned seen_dollar : 1;
kono
parents:
diff changeset
516 unsigned eor_condition : 1;
kono
parents:
diff changeset
517 unsigned no_leading_blank : 1;
kono
parents:
diff changeset
518 unsigned char_flag : 1;
kono
parents:
diff changeset
519 unsigned input_complete : 1;
kono
parents:
diff changeset
520 unsigned at_eol : 1;
kono
parents:
diff changeset
521 unsigned comma_flag : 1;
kono
parents:
diff changeset
522 /* A namelist specific flag used in the list directed library
kono
parents:
diff changeset
523 to flag that calls are being made from namelist read (e.g. to
kono
parents:
diff changeset
524 ignore comments or to treat '/' as a terminator) */
kono
parents:
diff changeset
525 unsigned namelist_mode : 1;
kono
parents:
diff changeset
526 /* A namelist specific flag used in the list directed library
kono
parents:
diff changeset
527 to flag read errors and return, so that an attempt can be
kono
parents:
diff changeset
528 made to read a new object name. */
kono
parents:
diff changeset
529 unsigned nml_read_error : 1;
kono
parents:
diff changeset
530 /* A sequential formatted read specific flag used to signal that a
kono
parents:
diff changeset
531 character string is being read so don't use commas to shorten a
kono
parents:
diff changeset
532 formatted field width. */
kono
parents:
diff changeset
533 unsigned sf_read_comma : 1;
kono
parents:
diff changeset
534 /* A namelist specific flag used to enable reading input from
kono
parents:
diff changeset
535 line_buffer for logical reads. */
kono
parents:
diff changeset
536 unsigned line_buffer_enabled : 1;
kono
parents:
diff changeset
537 /* An internal unit specific flag used to identify that the associated
kono
parents:
diff changeset
538 unit is internal. */
kono
parents:
diff changeset
539 unsigned unit_is_internal : 1;
kono
parents:
diff changeset
540 /* An internal unit specific flag to signify an EOF condition for list
kono
parents:
diff changeset
541 directed read. */
kono
parents:
diff changeset
542 unsigned at_eof : 1;
kono
parents:
diff changeset
543 /* Used for g0 floating point output. */
kono
parents:
diff changeset
544 unsigned g0_no_blanks : 1;
kono
parents:
diff changeset
545 /* Used to signal use of free_format_data. */
kono
parents:
diff changeset
546 unsigned format_not_saved : 1;
kono
parents:
diff changeset
547 /* A flag used to identify when a non-standard expanded namelist read
kono
parents:
diff changeset
548 has occurred. */
kono
parents:
diff changeset
549 unsigned expanded_read : 1;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
550 /* Flag to indicate if the statement has async="YES". */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
551 unsigned async : 1;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
552 /* 12 unused bits. */
111
kono
parents:
diff changeset
553
kono
parents:
diff changeset
554 int child_saved_iostat;
kono
parents:
diff changeset
555 int nml_delim;
kono
parents:
diff changeset
556 int repeat_count;
kono
parents:
diff changeset
557 int saved_length;
kono
parents:
diff changeset
558 int saved_used;
kono
parents:
diff changeset
559 bt saved_type;
kono
parents:
diff changeset
560 char *saved_string;
kono
parents:
diff changeset
561 char *scratch;
kono
parents:
diff changeset
562 char *line_buffer;
kono
parents:
diff changeset
563 struct format_data *fmt;
kono
parents:
diff changeset
564 namelist_info *ionml;
kono
parents:
diff changeset
565 #ifdef HAVE_NEWLOCALE
kono
parents:
diff changeset
566 locale_t old_locale;
kono
parents:
diff changeset
567 #endif
kono
parents:
diff changeset
568 /* Current position within the look-ahead line buffer. */
kono
parents:
diff changeset
569 int line_buffer_pos;
kono
parents:
diff changeset
570 /* Storage area for values except for strings. Must be
kono
parents:
diff changeset
571 large enough to hold a complex value (two reals) of the
kono
parents:
diff changeset
572 largest kind. */
kono
parents:
diff changeset
573 char value[32];
kono
parents:
diff changeset
574 GFC_IO_INT not_used; /* Needed for alignment. */
kono
parents:
diff changeset
575 formatted_dtio fdtio_ptr;
kono
parents:
diff changeset
576 unformatted_dtio ufdtio_ptr;
kono
parents:
diff changeset
577 /* With CC_FORTRAN, the first character of a record determines the
kono
parents:
diff changeset
578 style of record end (and start) to use. We must mark down the type
kono
parents:
diff changeset
579 when we write first in write_a so we remember the end type later in
kono
parents:
diff changeset
580 next_record_w. */
kono
parents:
diff changeset
581 struct
kono
parents:
diff changeset
582 {
kono
parents:
diff changeset
583 unsigned type : 6; /* See enum cc_fortran. */
kono
parents:
diff changeset
584 unsigned len : 2; /* Always 0, 1, or 2. */
kono
parents:
diff changeset
585 /* The union is updated after start-of-record is written. */
kono
parents:
diff changeset
586 union
kono
parents:
diff changeset
587 {
kono
parents:
diff changeset
588 char start; /* Output character for start of record. */
kono
parents:
diff changeset
589 char end; /* Output character for end of record. */
kono
parents:
diff changeset
590 } u;
kono
parents:
diff changeset
591 } cc;
kono
parents:
diff changeset
592 } p;
kono
parents:
diff changeset
593 /* This pad size must be equal to the pad_size declared in
kono
parents:
diff changeset
594 trans-io.c (gfc_build_io_library_fndecls). The above structure
kono
parents:
diff changeset
595 must be smaller or equal to this array. */
kono
parents:
diff changeset
596 char pad[16 * sizeof (char *) + 32 * sizeof (int)];
kono
parents:
diff changeset
597 } u;
kono
parents:
diff changeset
598 }
kono
parents:
diff changeset
599 st_parameter_dt;
kono
parents:
diff changeset
600
kono
parents:
diff changeset
601 /* Ensure st_parameter_dt's u.pad is bigger or equal to u.p. */
kono
parents:
diff changeset
602 extern char check_st_parameter_dt[sizeof (((st_parameter_dt *) 0)->u.pad)
kono
parents:
diff changeset
603 >= sizeof (((st_parameter_dt *) 0)->u.p)
kono
parents:
diff changeset
604 ? 1 : -1];
kono
parents:
diff changeset
605
kono
parents:
diff changeset
606 #define IOPARM_WAIT_HAS_ID (1 << 7)
kono
parents:
diff changeset
607
kono
parents:
diff changeset
608 typedef struct
kono
parents:
diff changeset
609 {
kono
parents:
diff changeset
610 st_parameter_common common;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
611 GFC_INTEGER_4 *id;
111
kono
parents:
diff changeset
612 }
kono
parents:
diff changeset
613 st_parameter_wait;
kono
parents:
diff changeset
614
kono
parents:
diff changeset
615
kono
parents:
diff changeset
616 #undef CHARACTER1
kono
parents:
diff changeset
617 #undef CHARACTER2
kono
parents:
diff changeset
618
kono
parents:
diff changeset
619 typedef struct
kono
parents:
diff changeset
620 {
kono
parents:
diff changeset
621 unit_access access;
kono
parents:
diff changeset
622 unit_action action;
kono
parents:
diff changeset
623 unit_blank blank;
kono
parents:
diff changeset
624 unit_delim delim;
kono
parents:
diff changeset
625 unit_form form;
kono
parents:
diff changeset
626 int is_notpadded;
kono
parents:
diff changeset
627 unit_position position;
kono
parents:
diff changeset
628 unit_status status;
kono
parents:
diff changeset
629 unit_pad pad;
kono
parents:
diff changeset
630 unit_convert convert;
kono
parents:
diff changeset
631 int has_recl;
kono
parents:
diff changeset
632 unit_decimal decimal;
kono
parents:
diff changeset
633 unit_encoding encoding;
kono
parents:
diff changeset
634 unit_round round;
kono
parents:
diff changeset
635 unit_sign sign;
kono
parents:
diff changeset
636 unit_async async;
kono
parents:
diff changeset
637 unit_share share;
kono
parents:
diff changeset
638 unit_cc cc;
kono
parents:
diff changeset
639 int readonly;
kono
parents:
diff changeset
640 }
kono
parents:
diff changeset
641 unit_flags;
kono
parents:
diff changeset
642
kono
parents:
diff changeset
643
kono
parents:
diff changeset
644 typedef struct gfc_unit
kono
parents:
diff changeset
645 {
kono
parents:
diff changeset
646 int unit_number;
kono
parents:
diff changeset
647 stream *s;
kono
parents:
diff changeset
648
kono
parents:
diff changeset
649 /* Treap links. */
kono
parents:
diff changeset
650 struct gfc_unit *left, *right;
kono
parents:
diff changeset
651 int priority;
kono
parents:
diff changeset
652
kono
parents:
diff changeset
653 int read_bad, current_record, saved_pos, previous_nonadvancing_write;
kono
parents:
diff changeset
654
kono
parents:
diff changeset
655 enum
kono
parents:
diff changeset
656 { NO_ENDFILE, AT_ENDFILE, AFTER_ENDFILE }
kono
parents:
diff changeset
657 endfile;
kono
parents:
diff changeset
658
kono
parents:
diff changeset
659 unit_mode mode;
kono
parents:
diff changeset
660 unit_flags flags;
kono
parents:
diff changeset
661 unit_pad pad_status;
kono
parents:
diff changeset
662 unit_decimal decimal_status;
kono
parents:
diff changeset
663 unit_delim delim_status;
kono
parents:
diff changeset
664 unit_round round_status;
kono
parents:
diff changeset
665
kono
parents:
diff changeset
666 /* recl -- Record length of the file.
kono
parents:
diff changeset
667 last_record -- Last record number read or written
kono
parents:
diff changeset
668 maxrec -- Maximum record number in a direct access file
kono
parents:
diff changeset
669 bytes_left -- Bytes left in current record.
kono
parents:
diff changeset
670 strm_pos -- Current position in file for STREAM I/O.
kono
parents:
diff changeset
671 recl_subrecord -- Maximum length for subrecord.
kono
parents:
diff changeset
672 bytes_left_subrecord -- Bytes left in current subrecord. */
kono
parents:
diff changeset
673 gfc_offset recl, last_record, maxrec, bytes_left, strm_pos,
kono
parents:
diff changeset
674 recl_subrecord, bytes_left_subrecord;
kono
parents:
diff changeset
675
kono
parents:
diff changeset
676 /* Set to 1 if we have read a subrecord. */
kono
parents:
diff changeset
677
kono
parents:
diff changeset
678 int continued;
kono
parents:
diff changeset
679
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
680 /* Contains the pointer to the async unit. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
681 struct async_unit *au;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
682
111
kono
parents:
diff changeset
683 __gthread_mutex_t lock;
kono
parents:
diff changeset
684 /* Number of threads waiting to acquire this unit's lock.
kono
parents:
diff changeset
685 When non-zero, close_unit doesn't only removes the unit
kono
parents:
diff changeset
686 from the UNIT_ROOT tree, but doesn't free it and the
kono
parents:
diff changeset
687 last of the waiting threads will do that.
kono
parents:
diff changeset
688 This must be either atomically increased/decreased, or
kono
parents:
diff changeset
689 always guarded by UNIT_LOCK. */
kono
parents:
diff changeset
690 int waiting;
kono
parents:
diff changeset
691 /* Flag set by close_unit if the unit as been closed.
kono
parents:
diff changeset
692 Must be manipulated under unit's lock. */
kono
parents:
diff changeset
693 int closed;
kono
parents:
diff changeset
694
kono
parents:
diff changeset
695 /* For traversing arrays */
kono
parents:
diff changeset
696 array_loop_spec *ls;
kono
parents:
diff changeset
697 int rank;
kono
parents:
diff changeset
698
kono
parents:
diff changeset
699 /* Name of the file at the time OPEN was executed, as a
kono
parents:
diff changeset
700 null-terminated C string. */
kono
parents:
diff changeset
701 char *filename;
kono
parents:
diff changeset
702
kono
parents:
diff changeset
703 /* The format hash table. */
kono
parents:
diff changeset
704 struct format_hash_entry format_hash_table[FORMAT_HASH_SIZE];
kono
parents:
diff changeset
705
kono
parents:
diff changeset
706 /* Formatting buffer. */
kono
parents:
diff changeset
707 struct fbuf *fbuf;
kono
parents:
diff changeset
708
kono
parents:
diff changeset
709 /* Function pointer, points to list_read worker functions. */
kono
parents:
diff changeset
710 int (*next_char_fn_ptr) (st_parameter_dt *);
kono
parents:
diff changeset
711 void (*push_char_fn_ptr) (st_parameter_dt *, int);
kono
parents:
diff changeset
712
kono
parents:
diff changeset
713 /* Internal unit char string data. */
kono
parents:
diff changeset
714 char * internal_unit;
kono
parents:
diff changeset
715 gfc_charlen_type internal_unit_len;
kono
parents:
diff changeset
716 gfc_array_char *string_unit_desc;
kono
parents:
diff changeset
717 int internal_unit_kind;
kono
parents:
diff changeset
718
kono
parents:
diff changeset
719 /* DTIO Parent/Child procedure, 0 = parent, >0 = child level. */
kono
parents:
diff changeset
720 int child_dtio;
kono
parents:
diff changeset
721
kono
parents:
diff changeset
722 /* Used for ungetc() style functionality. Possible values
kono
parents:
diff changeset
723 are an unsigned char, EOF, or EOF - 1 used to mark the
kono
parents:
diff changeset
724 field as not valid. */
kono
parents:
diff changeset
725 int last_char;
kono
parents:
diff changeset
726 bool has_size;
kono
parents:
diff changeset
727 GFC_IO_INT size_used;
kono
parents:
diff changeset
728 }
kono
parents:
diff changeset
729 gfc_unit;
kono
parents:
diff changeset
730
kono
parents:
diff changeset
731 typedef struct gfc_saved_unit
kono
parents:
diff changeset
732 {
kono
parents:
diff changeset
733 GFC_INTEGER_4 unit_number;
kono
parents:
diff changeset
734 gfc_unit *unit;
kono
parents:
diff changeset
735 }
kono
parents:
diff changeset
736 gfc_saved_unit;
kono
parents:
diff changeset
737
kono
parents:
diff changeset
738 /* TEMP_FAILURE_RETRY macro from glibc. */
kono
parents:
diff changeset
739
kono
parents:
diff changeset
740 #ifndef TEMP_FAILURE_RETRY
kono
parents:
diff changeset
741 /* Evaluate EXPRESSION, and repeat as long as it returns -1 with `errno'
kono
parents:
diff changeset
742 set to EINTR. */
kono
parents:
diff changeset
743
kono
parents:
diff changeset
744 # define TEMP_FAILURE_RETRY(expression) \
kono
parents:
diff changeset
745 (__extension__ \
kono
parents:
diff changeset
746 ({ long int __result; \
kono
parents:
diff changeset
747 do __result = (long int) (expression); \
kono
parents:
diff changeset
748 while (__result == -1L && errno == EINTR); \
kono
parents:
diff changeset
749 __result; }))
kono
parents:
diff changeset
750 #endif
kono
parents:
diff changeset
751
kono
parents:
diff changeset
752
kono
parents:
diff changeset
753 /* unit.c */
kono
parents:
diff changeset
754
kono
parents:
diff changeset
755 /* Maximum file offset, computed at library initialization time. */
kono
parents:
diff changeset
756 extern gfc_offset max_offset;
kono
parents:
diff changeset
757 internal_proto(max_offset);
kono
parents:
diff changeset
758
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
759 /* Default RECL for sequential access if not given in OPEN statement,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
760 computed at library initialization time. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
761 extern gfc_offset default_recl;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
762 internal_proto(default_recl);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
763
111
kono
parents:
diff changeset
764 /* Unit tree root. */
kono
parents:
diff changeset
765 extern gfc_unit *unit_root;
kono
parents:
diff changeset
766 internal_proto(unit_root);
kono
parents:
diff changeset
767
kono
parents:
diff changeset
768 extern __gthread_mutex_t unit_lock;
kono
parents:
diff changeset
769 internal_proto(unit_lock);
kono
parents:
diff changeset
770
kono
parents:
diff changeset
771 extern int close_unit (gfc_unit *);
kono
parents:
diff changeset
772 internal_proto(close_unit);
kono
parents:
diff changeset
773
kono
parents:
diff changeset
774 extern gfc_unit *set_internal_unit (st_parameter_dt *, gfc_unit *, int);
kono
parents:
diff changeset
775 internal_proto(set_internal_unit);
kono
parents:
diff changeset
776
kono
parents:
diff changeset
777 extern void stash_internal_unit (st_parameter_dt *);
kono
parents:
diff changeset
778 internal_proto(stash_internal_unit);
kono
parents:
diff changeset
779
kono
parents:
diff changeset
780 extern gfc_unit *find_unit (int);
kono
parents:
diff changeset
781 internal_proto(find_unit);
kono
parents:
diff changeset
782
kono
parents:
diff changeset
783 extern gfc_unit *find_or_create_unit (int);
kono
parents:
diff changeset
784 internal_proto(find_or_create_unit);
kono
parents:
diff changeset
785
kono
parents:
diff changeset
786 extern gfc_unit *get_unit (st_parameter_dt *, int);
kono
parents:
diff changeset
787 internal_proto(get_unit);
kono
parents:
diff changeset
788
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
789 extern void unlock_unit(gfc_unit *);
111
kono
parents:
diff changeset
790 internal_proto(unlock_unit);
kono
parents:
diff changeset
791
kono
parents:
diff changeset
792 extern void finish_last_advance_record (gfc_unit *u);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
793 internal_proto(finish_last_advance_record);
111
kono
parents:
diff changeset
794
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
795 extern int unit_truncate(gfc_unit *, gfc_offset, st_parameter_common *);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
796 internal_proto(unit_truncate);
111
kono
parents:
diff changeset
797
kono
parents:
diff changeset
798 extern int newunit_alloc (void);
kono
parents:
diff changeset
799 internal_proto(newunit_alloc);
kono
parents:
diff changeset
800
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
801 extern void newunit_free (int);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
802 internal_proto(newunit_free);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
803
111
kono
parents:
diff changeset
804
kono
parents:
diff changeset
805 /* open.c */
kono
parents:
diff changeset
806
kono
parents:
diff changeset
807 extern gfc_unit *new_unit (st_parameter_open *, gfc_unit *, unit_flags *);
kono
parents:
diff changeset
808 internal_proto(new_unit);
kono
parents:
diff changeset
809
kono
parents:
diff changeset
810
kono
parents:
diff changeset
811 /* transfer.c */
kono
parents:
diff changeset
812
kono
parents:
diff changeset
813 #define SCRATCH_SIZE 300
kono
parents:
diff changeset
814
kono
parents:
diff changeset
815 extern const char *type_name (bt);
kono
parents:
diff changeset
816 internal_proto(type_name);
kono
parents:
diff changeset
817
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
818 extern void * read_block_form (st_parameter_dt *, size_t *);
111
kono
parents:
diff changeset
819 internal_proto(read_block_form);
kono
parents:
diff changeset
820
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
821 extern void * read_block_form4 (st_parameter_dt *, size_t *);
111
kono
parents:
diff changeset
822 internal_proto(read_block_form4);
kono
parents:
diff changeset
823
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
824 extern void *write_block (st_parameter_dt *, size_t);
111
kono
parents:
diff changeset
825 internal_proto(write_block);
kono
parents:
diff changeset
826
kono
parents:
diff changeset
827 extern gfc_offset next_array_record (st_parameter_dt *, array_loop_spec *,
kono
parents:
diff changeset
828 int*);
kono
parents:
diff changeset
829 internal_proto(next_array_record);
kono
parents:
diff changeset
830
kono
parents:
diff changeset
831 extern gfc_offset init_loop_spec (gfc_array_char *, array_loop_spec *,
kono
parents:
diff changeset
832 gfc_offset *);
kono
parents:
diff changeset
833 internal_proto(init_loop_spec);
kono
parents:
diff changeset
834
kono
parents:
diff changeset
835 extern void next_record (st_parameter_dt *, int);
kono
parents:
diff changeset
836 internal_proto(next_record);
kono
parents:
diff changeset
837
kono
parents:
diff changeset
838 extern void st_wait (st_parameter_wait *);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
839 export_proto (st_wait);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
840
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
841 extern void st_wait_async (st_parameter_wait *);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
842 export_proto (st_wait_async);
111
kono
parents:
diff changeset
843
kono
parents:
diff changeset
844 extern void hit_eof (st_parameter_dt *);
kono
parents:
diff changeset
845 internal_proto(hit_eof);
kono
parents:
diff changeset
846
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
847 extern void transfer_array_inner (st_parameter_dt *, gfc_array_char *, int,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
848 gfc_charlen_type);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
849 internal_proto (transfer_array_inner);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
850
111
kono
parents:
diff changeset
851 /* read.c */
kono
parents:
diff changeset
852
kono
parents:
diff changeset
853 extern void set_integer (void *, GFC_INTEGER_LARGEST, int);
kono
parents:
diff changeset
854 internal_proto(set_integer);
kono
parents:
diff changeset
855
kono
parents:
diff changeset
856 extern GFC_UINTEGER_LARGEST si_max (int);
kono
parents:
diff changeset
857 internal_proto(si_max);
kono
parents:
diff changeset
858
kono
parents:
diff changeset
859 extern int convert_real (st_parameter_dt *, void *, const char *, int);
kono
parents:
diff changeset
860 internal_proto(convert_real);
kono
parents:
diff changeset
861
kono
parents:
diff changeset
862 extern int convert_infnan (st_parameter_dt *, void *, const char *, int);
kono
parents:
diff changeset
863 internal_proto(convert_infnan);
kono
parents:
diff changeset
864
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
865 extern void read_a (st_parameter_dt *, const fnode *, char *, size_t);
111
kono
parents:
diff changeset
866 internal_proto(read_a);
kono
parents:
diff changeset
867
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
868 extern void read_a_char4 (st_parameter_dt *, const fnode *, char *, size_t);
111
kono
parents:
diff changeset
869 internal_proto(read_a);
kono
parents:
diff changeset
870
kono
parents:
diff changeset
871 extern void read_f (st_parameter_dt *, const fnode *, char *, int);
kono
parents:
diff changeset
872 internal_proto(read_f);
kono
parents:
diff changeset
873
kono
parents:
diff changeset
874 extern void read_l (st_parameter_dt *, const fnode *, char *, int);
kono
parents:
diff changeset
875 internal_proto(read_l);
kono
parents:
diff changeset
876
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
877 extern void read_x (st_parameter_dt *, size_t);
111
kono
parents:
diff changeset
878 internal_proto(read_x);
kono
parents:
diff changeset
879
kono
parents:
diff changeset
880 extern void read_radix (st_parameter_dt *, const fnode *, char *, int, int);
kono
parents:
diff changeset
881 internal_proto(read_radix);
kono
parents:
diff changeset
882
kono
parents:
diff changeset
883 extern void read_decimal (st_parameter_dt *, const fnode *, char *, int);
kono
parents:
diff changeset
884 internal_proto(read_decimal);
kono
parents:
diff changeset
885
kono
parents:
diff changeset
886 extern void read_user_defined (st_parameter_dt *, void *);
kono
parents:
diff changeset
887 internal_proto(read_user_defined);
kono
parents:
diff changeset
888
kono
parents:
diff changeset
889 extern void read_user_defined (st_parameter_dt *, void *);
kono
parents:
diff changeset
890 internal_proto(read_user_defined);
kono
parents:
diff changeset
891
kono
parents:
diff changeset
892 /* list_read.c */
kono
parents:
diff changeset
893
kono
parents:
diff changeset
894 extern void list_formatted_read (st_parameter_dt *, bt, void *, int, size_t,
kono
parents:
diff changeset
895 size_t);
kono
parents:
diff changeset
896 internal_proto(list_formatted_read);
kono
parents:
diff changeset
897
kono
parents:
diff changeset
898 extern void finish_list_read (st_parameter_dt *);
kono
parents:
diff changeset
899 internal_proto(finish_list_read);
kono
parents:
diff changeset
900
kono
parents:
diff changeset
901 extern void namelist_read (st_parameter_dt *);
kono
parents:
diff changeset
902 internal_proto(namelist_read);
kono
parents:
diff changeset
903
kono
parents:
diff changeset
904 extern void namelist_write (st_parameter_dt *);
kono
parents:
diff changeset
905 internal_proto(namelist_write);
kono
parents:
diff changeset
906
kono
parents:
diff changeset
907 /* write.c */
kono
parents:
diff changeset
908
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
909 extern void write_a (st_parameter_dt *, const fnode *, const char *, size_t);
111
kono
parents:
diff changeset
910 internal_proto(write_a);
kono
parents:
diff changeset
911
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
912 extern void write_a_char4 (st_parameter_dt *, const fnode *, const char *, size_t);
111
kono
parents:
diff changeset
913 internal_proto(write_a_char4);
kono
parents:
diff changeset
914
kono
parents:
diff changeset
915 extern void write_b (st_parameter_dt *, const fnode *, const char *, int);
kono
parents:
diff changeset
916 internal_proto(write_b);
kono
parents:
diff changeset
917
kono
parents:
diff changeset
918 extern void write_d (st_parameter_dt *, const fnode *, const char *, int);
kono
parents:
diff changeset
919 internal_proto(write_d);
kono
parents:
diff changeset
920
kono
parents:
diff changeset
921 extern void write_e (st_parameter_dt *, const fnode *, const char *, int);
kono
parents:
diff changeset
922 internal_proto(write_e);
kono
parents:
diff changeset
923
kono
parents:
diff changeset
924 extern void write_en (st_parameter_dt *, const fnode *, const char *, int);
kono
parents:
diff changeset
925 internal_proto(write_en);
kono
parents:
diff changeset
926
kono
parents:
diff changeset
927 extern void write_es (st_parameter_dt *, const fnode *, const char *, int);
kono
parents:
diff changeset
928 internal_proto(write_es);
kono
parents:
diff changeset
929
kono
parents:
diff changeset
930 extern void write_f (st_parameter_dt *, const fnode *, const char *, int);
kono
parents:
diff changeset
931 internal_proto(write_f);
kono
parents:
diff changeset
932
kono
parents:
diff changeset
933 extern void write_i (st_parameter_dt *, const fnode *, const char *, int);
kono
parents:
diff changeset
934 internal_proto(write_i);
kono
parents:
diff changeset
935
kono
parents:
diff changeset
936 extern void write_l (st_parameter_dt *, const fnode *, char *, int);
kono
parents:
diff changeset
937 internal_proto(write_l);
kono
parents:
diff changeset
938
kono
parents:
diff changeset
939 extern void write_o (st_parameter_dt *, const fnode *, const char *, int);
kono
parents:
diff changeset
940 internal_proto(write_o);
kono
parents:
diff changeset
941
kono
parents:
diff changeset
942 extern void write_real (st_parameter_dt *, const char *, int);
kono
parents:
diff changeset
943 internal_proto(write_real);
kono
parents:
diff changeset
944
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
945 extern void write_real_w0 (st_parameter_dt *, const char *, int, const fnode*);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
946 internal_proto(write_real_w0);
111
kono
parents:
diff changeset
947
kono
parents:
diff changeset
948 extern void write_x (st_parameter_dt *, int, int);
kono
parents:
diff changeset
949 internal_proto(write_x);
kono
parents:
diff changeset
950
kono
parents:
diff changeset
951 extern void write_z (st_parameter_dt *, const fnode *, const char *, int);
kono
parents:
diff changeset
952 internal_proto(write_z);
kono
parents:
diff changeset
953
kono
parents:
diff changeset
954 extern void write_user_defined (st_parameter_dt *, void *);
kono
parents:
diff changeset
955 internal_proto(write_user_defined);
kono
parents:
diff changeset
956
kono
parents:
diff changeset
957 extern void write_user_defined (st_parameter_dt *, void *);
kono
parents:
diff changeset
958 internal_proto(write_user_defined);
kono
parents:
diff changeset
959
kono
parents:
diff changeset
960 extern void list_formatted_write (st_parameter_dt *, bt, void *, int, size_t,
kono
parents:
diff changeset
961 size_t);
kono
parents:
diff changeset
962 internal_proto(list_formatted_write);
kono
parents:
diff changeset
963
kono
parents:
diff changeset
964 /* size_from_kind.c */
kono
parents:
diff changeset
965 extern size_t size_from_real_kind (int);
kono
parents:
diff changeset
966 internal_proto(size_from_real_kind);
kono
parents:
diff changeset
967
kono
parents:
diff changeset
968 extern size_t size_from_complex_kind (int);
kono
parents:
diff changeset
969 internal_proto(size_from_complex_kind);
kono
parents:
diff changeset
970
kono
parents:
diff changeset
971
kono
parents:
diff changeset
972 /* lock.c */
kono
parents:
diff changeset
973 extern void free_ionml (st_parameter_dt *);
kono
parents:
diff changeset
974 internal_proto(free_ionml);
kono
parents:
diff changeset
975
kono
parents:
diff changeset
976 static inline void
kono
parents:
diff changeset
977 inc_waiting_locked (gfc_unit *u)
kono
parents:
diff changeset
978 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
979 #ifdef HAVE_ATOMIC_FETCH_ADD
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
980 (void) __atomic_fetch_add (&u->waiting, 1, __ATOMIC_RELAXED);
111
kono
parents:
diff changeset
981 #else
kono
parents:
diff changeset
982 u->waiting++;
kono
parents:
diff changeset
983 #endif
kono
parents:
diff changeset
984 }
kono
parents:
diff changeset
985
kono
parents:
diff changeset
986 static inline int
kono
parents:
diff changeset
987 predec_waiting_locked (gfc_unit *u)
kono
parents:
diff changeset
988 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
989 #ifdef HAVE_ATOMIC_FETCH_ADD
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
990 /* Note that the pattern
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
991
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
992 if (predec_waiting_locked (u) == 0)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
993 // destroy u
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
994
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
995 could be further optimized by making this be an __ATOMIC_RELEASE,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
996 and then inserting a
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
997
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
998 __atomic_thread_fence (__ATOMIC_ACQUIRE);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
999
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1000 inside the branch before destroying. But for now, lets keep it
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1001 simple. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1002 return __atomic_add_fetch (&u->waiting, -1, __ATOMIC_ACQ_REL);
111
kono
parents:
diff changeset
1003 #else
kono
parents:
diff changeset
1004 return --u->waiting;
kono
parents:
diff changeset
1005 #endif
kono
parents:
diff changeset
1006 }
kono
parents:
diff changeset
1007
kono
parents:
diff changeset
1008 static inline void
kono
parents:
diff changeset
1009 dec_waiting_unlocked (gfc_unit *u)
kono
parents:
diff changeset
1010 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1011 #ifdef HAVE_ATOMIC_FETCH_ADD
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1012 (void) __atomic_fetch_add (&u->waiting, -1, __ATOMIC_RELAXED);
111
kono
parents:
diff changeset
1013 #else
kono
parents:
diff changeset
1014 __gthread_mutex_lock (&unit_lock);
kono
parents:
diff changeset
1015 u->waiting--;
kono
parents:
diff changeset
1016 __gthread_mutex_unlock (&unit_lock);
kono
parents:
diff changeset
1017 #endif
kono
parents:
diff changeset
1018 }
kono
parents:
diff changeset
1019
kono
parents:
diff changeset
1020
kono
parents:
diff changeset
1021 static inline void
kono
parents:
diff changeset
1022 memset4 (gfc_char4_t *p, gfc_char4_t c, int k)
kono
parents:
diff changeset
1023 {
kono
parents:
diff changeset
1024 int j;
kono
parents:
diff changeset
1025 for (j = 0; j < k; j++)
kono
parents:
diff changeset
1026 *p++ = c;
kono
parents:
diff changeset
1027 }
kono
parents:
diff changeset
1028
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1029 /* Used in width fields to indicate that the default should be used */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1030 #define DEFAULT_WIDTH -1
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1031
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1032 /* Defaults for certain format field descriptors. These are decided based on
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1033 * the type of the value being formatted.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1034 *
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1035 * The behaviour here is modelled on the Oracle Fortran compiler. At the time
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1036 * of writing, the details were available at this URL:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1037 *
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1038 * https://docs.oracle.com/cd/E19957-01/805-4939/6j4m0vnc3/index.html#z4000743746d
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1039 */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1040
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1041 static inline int
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1042 default_width_for_integer (int kind)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1043 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1044 switch (kind)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1045 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1046 case 1:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1047 case 2: return 7;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1048 case 4: return 12;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1049 case 8: return 23;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1050 case 16: return 44;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1051 default: return 0;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1052 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1053 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1054
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1055 static inline int
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1056 default_width_for_float (int kind)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1057 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1058 switch (kind)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1059 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1060 case 4: return 15;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1061 case 8: return 25;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1062 case 16: return 42;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1063 default: return 0;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1064 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1065 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1066
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1067 static inline int
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1068 default_precision_for_float (int kind)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1069 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1070 switch (kind)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1071 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1072 case 4: return 7;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1073 case 8: return 16;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1074 case 16: return 33;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1075 default: return 0;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1076 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1077 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1078
111
kono
parents:
diff changeset
1079 #endif
kono
parents:
diff changeset
1080
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1081 extern void
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1082 st_write_done_worker (st_parameter_dt *);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1083 internal_proto (st_write_done_worker);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1084
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1085 extern void
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1086 st_read_done_worker (st_parameter_dt *);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1087 internal_proto (st_read_done_worker);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1088
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1089 extern void
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1090 data_transfer_init_worker (st_parameter_dt *, int);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1091 internal_proto (data_transfer_init_worker);