libexplain  1.4.D001
libexplain/ac/fcntl.h
Go to the documentation of this file.
00001 /*
00002  * libexplain - Explain errno values returned by libc functions
00003  * Copyright (C) 2008-2013 Peter Miller
00004  * Written by Peter Miller <pmiller@opensource.org.au>
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU Lesser General Public License as published by
00008  * the Free Software Foundation; either version 3 of the License, or (at
00009  * your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public License
00017  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00018  */
00019 
00020 #ifndef LIBEXPLAIN_AC_FCNTL_H
00021 #define LIBEXPLAIN_AC_FCNTL_H
00022 
00028 #include <libexplain/config.h>
00029 
00030 #ifdef HAVE_FCNTL_H
00031 #if defined(__alpha__) && defined(HAVE_LINUX_FCNTL_H)
00032 #include <libexplain/ac/linux/types.h> /* Ubuntu Hardy needs this first */
00033 /* This is very strange, but numerous tests fail if we use <fcntl.h>
00034    because it appears to have several incorrect macro definitions */
00035 #include <libexplain/ac/linux/fcntl.h>
00036 #else
00037 #include <fcntl.h>
00038 #endif
00039 #else
00040 #include <libexplain/ac/sys/file.h>
00041 #endif
00042 
00043 #ifndef O_BINARY
00044 #define O_BINARY 0
00045 #endif
00046 
00047 #ifndef O_TEXT
00048 #define O_TEXT 0
00049 #endif
00050 
00051 /*
00052  * Needed for explain_buffer_errno_path_resolution
00053  */
00054 #ifndef O_DIRECTORY
00055 #define O_DIRECTORY 0x40000000  /* or O_RDONLY */
00056 #endif
00057 
00058 #ifndef O_NOFOLLOW
00059 #define O_NOFOLLOW 0
00060 #endif
00061 
00062 /*
00063  * Even when O_LARGEFILE is not necessary, glibc adds one in for free.
00064  * The trouble is, this make things interesting when decoding
00065  * flags values returned by the kernel.
00066  */
00067 #if defined(__linux__) && (O_LARGEFILE == 0)
00068 #define O_LARGEFILE_HIDDEN 0100000
00069 #endif
00070 
00071 
00072 /*
00073  * From /usr/include/sharutils/fcntl.h ...
00074  *
00075  * Work around a bug in Solaris 9 and 10: AT_FDCWD is positive.
00076  * Its value exceeds INT_MAX, so its use as an int doesn't conform to
00077  * the C standard, and GCC and Sun C complain in some cases.  If the
00078  * bug is present, undef AT_FDCWD here, so it can be redefined.
00079  */
00080 #if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553
00081 #undef AT_FDCWD
00082 
00083 /*
00084  * Use the same bit pattern as Solaris 9, but with the proper signedness.
00085  * The bit pattern is important, in case this actually is Solaris with
00086  * the above workaround.
00087  */
00088 #define AT_FDCWD (-3041965)
00089 #endif
00090 
00091 
00092 /* vim: set ts=8 sw=4 et : */
00093 #endif /* LIBEXPLAIN_AC_FCNTL_H */