Thrill  0.1
ufs_platform.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * foxxll/io/ufs_platform.hpp
3  *
4  * Platform porting code local the I/O file implementations. This header is
5  * not part of FOXXLL's public interface and must only be used inside the
6  * library.
7  *
8  * Part of FOXXLL. See http://foxxll.org
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 FOXXLL_IO_UFS_PLATFORM_HEADER
18 #define FOXXLL_IO_UFS_PLATFORM_HEADER
19 
20 #include <foxxll/config.hpp>
21 
22 #if FOXXLL_WINDOWS || defined(__MINGW32__)
23  #ifndef NOMINMAX
24  #define NOMINMAX
25  #endif
26  #include <windows.h>
27 // this is not foxxll/io/io.hpp !
28  #include <io.h>
29 #else
30  #include <unistd.h>
31 #endif
32 
33 // these exist on Windows and Unixs
34 #include <fcntl.h>
35 #include <sys/stat.h>
36 #include <sys/types.h>
37 
38 // required for ::remove()
39 #include <cstdio>
40 
41 // for systems that don't know anything about block devices.
42 #ifndef S_ISBLK
43  #define S_ISBLK(x) 0
44 #endif
45 
46 // for systems with missing flags
47 #ifndef O_SYNC
48  #define O_SYNC 0
49 #endif
50 #ifndef O_RSYNC
51  #define O_RSYNC 0
52 #endif
53 #ifndef O_DSYNC
54  #define O_DSYNC 0
55 #endif
56 
57 #if defined(__linux__)
58  #if !defined(O_DIRECT)
59  #error O_DIRECT is not defined while __linux__ is - PLEASE REPORT THIS BUG
60  #endif
61 // FIXME: In which conditions is this not defined? Why only i386 and alpha? Why not amd64?
62  #if !defined(O_DIRECT) && (defined(__alpha__) || defined(__i386__))
63  #define O_DIRECT 040000 /* direct disk access */
64  #endif
65 #endif
66 
67 #ifndef O_DIRECT
68  #define O_DIRECT O_SYNC
69 #endif
70 
71 // use 64-bit functions on Windows
72 #if FOXXLL_WINDOWS
73  #ifndef lseek
74  #define lseek _lseeki64
75  #endif
76  #ifndef off_t
77  #define off_t int64_t
78  #endif
79 #endif
80 
81 #endif // !FOXXLL_IO_UFS_PLATFORM_HEADER
82 
83 /**************************************************************************/