GDB (xrefs)

fileio.h
Go to the documentation of this file.
1 /* File-I/O functions for GDB, the GNU debugger.
2
3 Copyright (C) 2003-2018 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program 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 of the License, or
10 (at your option) any later version.
11
12 This program 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.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 #ifndef FILEIO_H
21 #define FILEIO_H
22
23 #include "gdb/fileio.h"
24 #include <sys/stat.h>
25
26 /* Convert a host-format errno value to a File-I/O error number. */
27
28 extern int host_to_fileio_error (int error);
29
30 /* Convert File-I/O open flags FFLAGS to host format, storing
31 the result in *FLAGS. Return 0 on success, -1 on error. */
32
33 extern int fileio_to_host_openflags (int fflags, int *flags);
34
35 /* Convert File-I/O mode FMODE to host format, storing
36 the result in *MODE. Return 0 on success, -1 on error. */
37
38 extern int fileio_to_host_mode (int fmode, mode_t *mode);
39
40 /* Pack a host-format integer into a byte buffer in big-endian
41 format. BYTES specifies the size of the integer to pack in
42 bytes. */
43
44 static inline void
45 host_to_bigendian (LONGEST num, char *buf, int bytes)
46 {
47 int i;
48
49 for (i = 0; i < bytes; ++i)
50 buf[i] = (num >> (8 * (bytes - i - 1))) & 0xff;
51 }
52
53 /* Pack a host-format integer into an fio_uint_t. */
54
55 static inline void
56 host_to_fileio_uint (long num, fio_uint_t fnum)
57 {
58 host_to_bigendian ((LONGEST) num, (char *) fnum, 4);
59 }
60
61 /* Pack a host-format time_t into an fio_time_t. */
62
63 static inline void
64 host_to_fileio_time (time_t num, fio_time_t fnum)
65 {
66 host_to_bigendian ((LONGEST) num, (char *) fnum, 4);
67 }
68
69 /* Pack a host-format struct stat into a struct fio_stat. */
70
71 extern void host_to_fileio_stat (struct stat *st, struct fio_stat *fst);
72
73 #endif /* FILEIO_H */
fileio_to_host_openflags
int fileio_to_host_openflags(int fflags, int *flags)
Definition: fileio.c:81
fileio_to_host_mode
int fileio_to_host_mode(int fmode, mode_t *mode)
Definition: fileio.c:115
host_to_fileio_error
int host_to_fileio_error(int error)
Definition: fileio.c:28
flags
mach_port_t kern_return_t mach_port_t msgports mach_port_t kern_return_t pid_t pid mach_port_t kern_return_t mach_port_t task mach_port_t kern_return_t int flags
Definition: gnu-nat.c:1891
host_to_fileio_time
static void host_to_fileio_time(time_t num, fio_time_t fnum)
Definition: fileio.h:64
host_to_fileio_stat
void host_to_fileio_stat(struct stat *st, struct fio_stat *fst)
Definition: fileio.c:224
host_to_fileio_uint
static void host_to_fileio_uint(long num, fio_uint_t fnum)
Definition: fileio.h:56
host_to_bigendian
static void host_to_bigendian(LONGEST num, char *buf, int bytes)
Definition: fileio.h:45
error
void error(const char *fmt,...)
Definition: errors.c:38
LONGEST
long long LONGEST
Definition: common-types.h:52