STXXL  1.4-dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ufs_platform.h
Go to the documentation of this file.
1 /***************************************************************************
2  * lib/io/ufs_platform.h
3  *
4  * Platform porting code local the I/O file implementations. This header is
5  * not part of STXXL's template library interface and must only be used inside
6  * libstxxl.
7  *
8  * Part of the STXXL. See http://stxxl.sourceforge.net
9  *
10  * Copyright (C) 2013 Timo Bingmann <[email protected]>
11  *
12  * Distributed under the Boost Software License, Version 1.0.
13  * (See accompanying file LICENSE_1_0.txt or copy at
14  * http://www.boost.org/LICENSE_1_0.txt)
15  **************************************************************************/
16 
17 #ifndef STXXL_IO_UFS_PLATFORM_HEADER
18 #define STXXL_IO_UFS_PLATFORM_HEADER
19 
20 #if STXXL_WINDOWS || defined(__MINGW32__)
21  #ifndef NOMINMAX
22  #define NOMINMAX
23  #endif
24  #include <windows.h>
25 // this is not stxxl/bits/io/io.h !
26  #include <io.h>
27 #else
28  #include <unistd.h>
29 #endif
30 
31 // these exist on Windows and Unixs
32 #include <fcntl.h>
33 #include <sys/types.h>
34 #include <sys/stat.h>
35 
36 // required for ::remove()
37 #include <cstdio>
38 
39 // for systems that don't know anything about block devices.
40 #ifndef S_ISBLK
41  #define S_ISBLK(x) 0
42 #endif
43 
44 // for systems with missing flags
45 #ifndef O_SYNC
46  #define O_SYNC 0
47 #endif
48 #ifndef O_RSYNC
49  #define O_RSYNC 0
50 #endif
51 #ifndef O_DSYNC
52  #define O_DSYNC 0
53 #endif
54 
55 #if defined (__linux__)
56  #if !defined(O_DIRECT)
57  #error O_DIRECT is not defined while __linux__ is - PLEASE REPORT THIS BUG
58  #endif
59 // FIXME: In which conditions is this not defined? Why only i386 and alpha? Why not amd64?
60  #if !defined (O_DIRECT) && (defined (__alpha__) || defined (__i386__))
61  #define O_DIRECT 040000 /* direct disk access */
62  #endif
63 #endif
64 
65 #ifndef O_DIRECT
66  #define O_DIRECT O_SYNC
67 #endif
68 
69 // use 64-bit functions on Windows
70 #if STXXL_WINDOWS
71  #ifndef lseek
72  #define lseek _lseeki64
73  #endif
74  #ifndef off_t
75  #define off_t int64
76  #endif
77 #endif
78 
79 #endif // !STXXL_IO_UFS_PLATFORM_HEADER