t-linux64 (MULTILIB_OSDIRNAMES): Use x86_64-linux-gnux32 as multiarch name for x32.
[official-gcc.git] / libgfortran / io / unix.h
blobf4f3ab687e28e04382016d644def77d6ecac8d41
1 /* Copyright (C) 2009, 2010
2 Free Software Foundation, Inc.
3 Contributed by Janne Blomqvist
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_UNIX_H
27 #define GFOR_UNIX_H
29 #include "io.h"
31 struct stream_vtable
33 ssize_t (* const read) (struct stream *, void *, ssize_t);
34 ssize_t (* const write) (struct stream *, const void *, ssize_t);
35 gfc_offset (* const seek) (struct stream *, gfc_offset, int);
36 gfc_offset (* const tell) (struct stream *);
37 gfc_offset (* const size) (struct stream *);
38 /* Avoid keyword truncate due to AIX namespace collision. */
39 int (* const trunc) (struct stream *, gfc_offset);
40 int (* const flush) (struct stream *);
41 int (* const close) (struct stream *);
44 struct stream
46 const struct stream_vtable *vptr;
49 /* Inline functions for doing file I/O given a stream. */
50 static inline ssize_t
51 sread (stream * s, void * buf, ssize_t nbyte)
53 return s->vptr->read (s, buf, nbyte);
56 static inline ssize_t
57 swrite (stream * s, const void * buf, ssize_t nbyte)
59 return s->vptr->write (s, buf, nbyte);
62 static inline gfc_offset
63 sseek (stream * s, gfc_offset offset, int whence)
65 return s->vptr->seek (s, offset, whence);
68 static inline gfc_offset
69 stell (stream * s)
71 return s->vptr->tell (s);
74 static inline gfc_offset
75 ssize (stream * s)
77 return s->vptr->size (s);
80 static inline int
81 struncate (stream * s, gfc_offset length)
83 return s->vptr->trunc (s, length);
86 static inline int
87 sflush (stream * s)
89 return s->vptr->flush (s);
92 static inline int
93 sclose (stream * s)
95 return s->vptr->close (s);
99 extern int compare_files (stream *, stream *);
100 internal_proto(compare_files);
102 extern stream *open_external (st_parameter_open *, unit_flags *);
103 internal_proto(open_external);
105 extern stream *open_internal (char *, int, gfc_offset);
106 internal_proto(open_internal);
108 extern stream *open_internal4 (char *, int, gfc_offset);
109 internal_proto(open_internal4);
111 extern char * mem_alloc_w (stream *, int *);
112 internal_proto(mem_alloc_w);
114 extern char * mem_alloc_r (stream *, int *);
115 internal_proto(mem_alloc_r);
117 extern gfc_char4_t * mem_alloc_w4 (stream *, int *);
118 internal_proto(mem_alloc_w4);
120 extern char * mem_alloc_r4 (stream *, int *);
121 internal_proto(mem_alloc_r4);
123 extern stream *input_stream (void);
124 internal_proto(input_stream);
126 extern stream *output_stream (void);
127 internal_proto(output_stream);
129 extern stream *error_stream (void);
130 internal_proto(error_stream);
132 extern int compare_file_filename (gfc_unit *, const char *, int);
133 internal_proto(compare_file_filename);
135 extern gfc_unit *find_file (const char *file, gfc_charlen_type file_len);
136 internal_proto(find_file);
138 extern int delete_file (gfc_unit *);
139 internal_proto(delete_file);
141 extern int file_exists (const char *file, gfc_charlen_type file_len);
142 internal_proto(file_exists);
144 extern GFC_IO_INT file_size (const char *file, gfc_charlen_type file_len);
145 internal_proto(file_size);
147 extern const char *inquire_sequential (const char *, int);
148 internal_proto(inquire_sequential);
150 extern const char *inquire_direct (const char *, int);
151 internal_proto(inquire_direct);
153 extern const char *inquire_formatted (const char *, int);
154 internal_proto(inquire_formatted);
156 extern const char *inquire_unformatted (const char *, int);
157 internal_proto(inquire_unformatted);
159 extern const char *inquire_read (const char *, int);
160 internal_proto(inquire_read);
162 extern const char *inquire_write (const char *, int);
163 internal_proto(inquire_write);
165 extern const char *inquire_readwrite (const char *, int);
166 internal_proto(inquire_readwrite);
168 extern void flush_if_preconnected (stream *);
169 internal_proto(flush_if_preconnected);
171 extern int stream_isatty (stream *);
172 internal_proto(stream_isatty);
174 #ifndef TTY_NAME_MAX
175 #ifdef _POSIX_TTY_NAME_MAX
176 #define TTY_NAME_MAX _POSIX_TTY_NAME_MAX
177 #else
178 /* sysconf(_SC_TTY_NAME_MAX) = 32 which should be enough. */
179 #define TTY_NAME_MAX 32
180 #endif
181 #endif
183 extern int stream_ttyname (stream *, char *, size_t);
184 internal_proto(stream_ttyname);
186 extern int unpack_filename (char *, const char *, int);
187 internal_proto(unpack_filename);
190 #endif