Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

Commit

Permalink
Merge pull request #5 from isaachier/hunter-macro-fix
Browse files Browse the repository at this point in the history
Add file function macros back
  • Loading branch information
ruslo authored Dec 4, 2017
2 parents fa170f1 + 5da59cc commit 3286e43
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ HunterGate(
SHA1 "1b94f895831f76e5a63e0537dd366ae142543c02"
)

project(leveldb VERSION 0.1.0 LANGUAGES C CXX)
project(leveldb VERSION 1.20 LANGUAGES C CXX)

option(LEVELDB_BUILD_TESTS "Build LevelDB's unit tests" ON)
option(LEVELDB_BUILD_BENCHMARKS "Build LevelDB's benchmarks" ON)
Expand Down Expand Up @@ -42,6 +42,11 @@ if(LEVELDB_WITH_SNAPPY)
endif()

include(CheckSymbolExists)
foreach(file_operation read write flush)
set(func "f${file_operation}_unlocked")
string(TOUPPER "HAVE_${func}" config_var)
check_symbol_exists("${func}" "unistd.h" ${config_var})
endforeach()
check_symbol_exists(fdatasync "unistd.h" HAVE_FDATASYNC)

configure_file(
Expand Down
21 changes: 18 additions & 3 deletions port/port_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,25 @@
#ifndef STORAGE_LEVELDB_PORT_PORT_CONFIG_H_
#define STORAGE_LEVELDB_PORT_PORT_CONFIG_H_

// Define to 1 if you have a definition for fread_unlocked() in <unistd.h>.
#if !defined(HAVE_FREAD_UNLOCKED)
#cmakedefine01 HAVE_FREAD_UNLOCKED
#endif // !defined(HAVE_FREAD_UNLOCKED)

// Define to 1 if you have a definition for fwrite_unlocked() in <unistd.h>.
#if !defined(HAVE_FWRITE_UNLOCKED)
#cmakedefine01 HAVE_FWRITE_UNLOCKED
#endif // !defined(HAVE_FWRITE_UNLOCKED)

// Define to 1 if you have a definition for fflush_unlocked() in <unistd.h>.
#if !defined(HAVE_FFLUSH_UNLOCKED)
#cmakedefine01 HAVE_FFLUSH_UNLOCKED
#endif // !defined(HAVE_FFLUSH_UNLOCKED)

// Define to 1 if you have a definition for fdatasync() in <unistd.h>.
#if !defined(HAVE_FUNC_FDATASYNC)
#cmakedefine01 HAVE_FUNC_FDATASYNC
#endif // !defined(HAVE_FUNC_FDATASYNC)
#if !defined(HAVE_FDATASYNC)
#cmakedefine01 HAVE_FDATASYNC
#endif // !defined(HAVE_FDATASYNC)

// Define to 1 if you have Google CRC32C.
#if !defined(HAVE_CRC32C)
Expand Down
15 changes: 15 additions & 0 deletions port/port_posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@
#define fdatasync fsync
#endif // !HAVE_FDATASYNC

#if !HAVE_FREAD_UNLOCKED
// Use fread() on platforms without fread_unlocked()
#define fread_unlocked fread
#endif // !HAVE_FREAD_UNLOCKED

#if !HAVE_FWRITE_UNLOCKED
// Use fwrite() on platforms without fwrite_unlocked()
#define fwrite_unlocked fwrite
#endif // !HAVE_FWRITE_UNLOCKED

#if !HAVE_FFLUSH_UNLOCKED
// Use fflush() on platforms without fflush_unlocked()
#define fflush_unlocked fflush
#endif // !HAVE_FFLUSH_UNLOCKED

namespace leveldb {
namespace port {

Expand Down

0 comments on commit 3286e43

Please sign in to comment.