On Solaris, _FILE_OFFSET_BITS must be defined before including sys/stat.h
[haskell-directory.git] / include / HsDirectory.h
1 /* -----------------------------------------------------------------------------
2  *
3  * (c) The University of Glasgow 2001-2004
4  *
5  * Definitions for package `directory' which are visible in Haskell land.
6  *
7  * ---------------------------------------------------------------------------*/
8
9 #ifndef __HSDIRECTORY_H__
10 #define __HSDIRECTORY_H__
11
12 #ifdef __NHC__
13 #include "Nhc98BaseConfig.h"
14 #else
15
16 // On Solaris we have to make sure _FILE_OFFSET_BITS is defined 
17 // before including <sys/stat.h> below, because that header
18 // will try and define it if it isn't already.
19 #include "HsFFI.h"
20
21 #include "HsDirectoryConfig.h"
22 #endif
23 // Otherwise these clash with similar definitions from other packages:
24 #undef PACKAGE_BUGREPORT
25 #undef PACKAGE_NAME
26 #undef PACKAGE_STRING
27 #undef PACKAGE_TARNAME
28 #undef PACKAGE_VERSION
29
30 #if HAVE_SYS_STAT_H
31 #include <sys/stat.h>
32 #endif
33
34 #if HAVE_SYS_TYPES_H
35 #include <sys/types.h>
36 #endif
37
38 #include "HsFFI.h"
39
40 /* -----------------------------------------------------------------------------
41    INLINE functions.
42
43    These functions are given as inlines here for when compiling via C,
44    but we also generate static versions into the cbits library for
45    when compiling to native code.
46    -------------------------------------------------------------------------- */
47
48 #ifndef INLINE
49 # if defined(_MSC_VER)
50 #  define INLINE extern __inline
51 # else
52 #  define INLINE static inline
53 # endif
54 #endif
55
56 /* A size that will contain many path names, but not necessarily all
57  * (PATH_MAX is not defined on systems with unlimited path length,
58  * e.g. the Hurd).
59  */
60 INLINE HsInt __hscore_long_path_size() {
61 #ifdef PATH_MAX
62     return PATH_MAX;
63 #else
64     return 4096;
65 #endif
66 }
67
68 INLINE mode_t __hscore_S_IRUSR() { return S_IRUSR; }
69 INLINE mode_t __hscore_S_IWUSR() { return S_IWUSR; }
70 INLINE mode_t __hscore_S_IXUSR() { return S_IXUSR; }
71 INLINE mode_t __hscore_S_IFDIR() { return S_IFDIR; }
72
73 #endif /* __HSDIRECTORY_H__ */
74