exp2l: Work around a NetBSD 10.0/i386 bug.
[gnulib.git] / lib / xbinary-io.h
blob67d3334ce2e6bb6c9b818ec78cc70abc15b96f6e
1 /* Binary mode I/O with checking
2 Copyright 2017-2024 Free Software Foundation, Inc.
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation, either version 3 of the
7 License, or (at your option) any later version.
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 #ifndef _XBINARY_IO_H
18 #define _XBINARY_IO_H
20 /* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _Noreturn. */
21 #if !_GL_CONFIG_H_INCLUDED
22 #error "Please include config.h first."
23 #endif
25 #include "binary-io.h"
27 _GL_INLINE_HEADER_BEGIN
28 #ifndef XBINARY_IO_INLINE
29 # define XBINARY_IO_INLINE _GL_INLINE
30 #endif
32 #if O_BINARY
33 extern _Noreturn void xset_binary_mode_error (void);
34 #else
35 XBINARY_IO_INLINE void xset_binary_mode_error (void) {}
36 #endif
38 /* Set the mode of FD to MODE, which should be either O_TEXT or O_BINARY.
39 Report an error and exit if this fails. */
41 XBINARY_IO_INLINE void
42 xset_binary_mode (int fd, int mode)
44 if (set_binary_mode (fd, mode) < 0)
45 xset_binary_mode_error ();
48 _GL_INLINE_HEADER_END
50 #endif /* _XBINARY_IO_H */