Skip to content

Commit 7d46e41

Browse files
authored
Fix build on FreeBSD. (#7206)
1 parent c467cdf commit 7d46e41

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/tools/io-benchmark.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#ifdef __FreeBSD__
2+
#pragma clang diagnostic ignored "-Wunreachable-code"
3+
#endif
4+
15
#include "util/exception.hpp"
26
#include "util/exception_utils.hpp"
37
#include "util/log.hpp"
@@ -9,6 +13,9 @@
913
#ifdef __linux__
1014
#include <malloc.h>
1115
#endif
16+
#ifdef __FreeBSD__
17+
#include <unistd.h>
18+
#endif
1219

1320
#include <algorithm>
1421
#include <filesystem>
@@ -89,6 +96,14 @@ int main(int argc, char *argv[])
8996
TIMER_STOP(write_1gb);
9097
fclose(fd);
9198
#endif
99+
#ifdef __FreeBSD__
100+
int fd = open(test_path.string().c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_DIRECT, 0644);
101+
fcntl(fd, F_RDAHEAD, 0);
102+
TIMER_START(write_1gb);
103+
write(fd, (char *)random_array, osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned));
104+
TIMER_STOP(write_1gb);
105+
close(fd);
106+
#endif
92107
#ifdef __linux__
93108
int file_desc =
94109
open(test_path.string().c_str(), O_CREAT | O_TRUNC | O_WRONLY | O_SYNC, S_IRWXU);

0 commit comments

Comments
 (0)