Remove unused header include
[xapian.git] / xapian-core / common / safefcntl.h
blob30a4ef19d4e9687bb712cf365de54d7104f7efff
1 /** @file safefcntl.h
2 * @brief #include <fcntl.h>, but working around broken platforms.
3 */
4 /* Copyright (C) 2006,2007,2012 Olly Betts
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
19 * USA
22 #ifndef XAPIAN_INCLUDED_SAFEFCNTL_H
23 #define XAPIAN_INCLUDED_SAFEFCNTL_H
25 #include <fcntl.h>
27 #if defined __cplusplus && defined open
29 // On some versions of Solaris, fcntl.h pollutes the namespace by #define-ing
30 // "open" to "open64" when largefile support is enabled. This causes problems
31 // if you have a method called "open" (other symbols are also #define-d
32 // e.g. "creat" to "creat64", but only "open" is a problem for Xapian so
33 // that's the only one we currently fix).
35 #ifdef _MSC_VER
36 // MSVC #define-s open but also defines a function called open, so just undef
37 // the macro.
38 # undef open
39 #else
41 inline int fcntl_open_(const char *filename, int flags, mode_t mode) {
42 return open(filename, flags, mode);
45 inline int fcntl_open_(const char *filename, int flags) {
46 return open(filename, flags);
49 #undef open
51 inline int open(const char *filename, int flags, mode_t mode) {
52 return fcntl_open_(filename, flags, mode);
55 inline int open(const char *filename, int flags) {
56 return fcntl_open_(filename, flags);
59 #endif
61 #endif
63 // O_BINARY is only useful for platforms like Windows which distinguish between
64 // text and binary files, but it's cleaner to define it to 0 here for other
65 // platforms so we can avoid #ifdef where we need to use it in the code.
66 #ifndef __WIN32__
67 # ifndef O_BINARY
68 # define O_BINARY 0
69 # endif
70 #endif
72 // If O_CLOEXEC isn't supported, we probably can't mark fds as close-on-exec.
73 #ifndef O_CLOEXEC
74 # define O_CLOEXEC 0
75 #endif
77 #endif /* XAPIAN_INCLUDED_SAFEFCNTL_H */