Fix preprocessor conditional
[deliverable/binutils-gdb.git] / gdb / common / fileio.h
CommitLineData
7823a941 1/* File-I/O functions for GDB, the GNU debugger.
791c0056
GB
2
3 Copyright (C) 2003-2015 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
7823a941
GB
20#ifndef FILEIO_H
21#define FILEIO_H
791c0056
GB
22
23#include "gdb/fileio.h"
7f3647e2 24#include <sys/stat.h>
791c0056 25
7823a941 26/* Convert a host-format errno value to a File-I/O error number. */
b88bb450 27
7823a941 28extern int host_to_fileio_error (int error);
b88bb450 29
819843c7
GB
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
33extern int fileio_to_host_openflags (int fflags, int *flags);
34
7823a941
GB
35/* Pack a host-format integer into a byte buffer in big-endian
36 format. BYTES specifies the size of the integer to pack in
37 bytes. */
791c0056
GB
38
39static inline void
7823a941 40host_to_bigendian (LONGEST num, char *buf, int bytes)
791c0056
GB
41{
42 int i;
43
44 for (i = 0; i < bytes; ++i)
45 buf[i] = (num >> (8 * (bytes - i - 1))) & 0xff;
46}
47
48/* Pack a host-format integer into an fio_uint_t. */
49
50static inline void
7823a941 51host_to_fileio_uint (long num, fio_uint_t fnum)
791c0056 52{
7823a941 53 host_to_bigendian ((LONGEST) num, (char *) fnum, 4);
791c0056
GB
54}
55
56/* Pack a host-format time_t into an fio_time_t. */
57
58static inline void
7823a941 59host_to_fileio_time (time_t num, fio_time_t fnum)
791c0056 60{
7823a941 61 host_to_bigendian ((LONGEST) num, (char *) fnum, 4);
791c0056
GB
62}
63
64/* Pack a host-format struct stat into a struct fio_stat. */
65
7823a941 66extern void host_to_fileio_stat (struct stat *st, struct fio_stat *fst);
791c0056 67
7823a941 68#endif /* FILEIO_H */
This page took 0.059992 seconds and 4 git commands to generate.