Skip to content

mv ldb config h

Matthew Von-Maszewski edited this page Jan 5, 2016 · 6 revisions

Status

  • merged to master - January 1, 2016
  • code complete - December 31, 2015
  • development started - December 30, 2015

History / Context

Google provided an extremely clean and useful public API for leveldb. Basho continues to work within that framework for most features. However, Basho has added some internal functionality to leveldb that is useful in other contexts. The first items for functionality reuse are the mutex wrappers and hot threads.

The mutex wrappers depend upon several compile time variable declarations. Google's implementation only presents those variable declarations on the compiler's command line. The declarations are therefore not available to independent projects trying to use the mutex wrappers. This branch duplicates the variable declarations into a new header file, leveldb/ldb_config.h. This new header file enables the leveldb mutex wrappers to compile properly when used by independent projects.

Branch Description

.gitignore

include/leveldb/ldb_config.h is added to the list of files to NEVER save into git. This file is generated for each compile environment via the saved build_detect_platform script.

Makefile

include/leveldb/ldb_config.h is added to the list of files removed as part of the "make clean" command.

build_detect_platform

This script now creates both build_config.mk and the new include/leveldb/ldb_config.h. build_config.mk receives variable definitions used by make when issuing compile commands. include/leveldb/ldb_config.h receives the same variable definitions to allow reuse of internal include files outside of leveldb's build environment.

The variable PLATFORM_CXXFLAGS was previously used to hold the LEVELDB_VSN variable definition. LEVELDB_VSN is Basho specific change. This branch adjusts the code to place LEVELDB_VSN within COMMON_FLAGS instead. This better matches Google's original intention for PLATFORM_CXXFLAGS and COMMON_FLAGS.

build_detect_platform is a Bourne shell script. The shell function write_config_h() performs substring manipulations to discover and reuse compiler "-D" parameters found within the shell variable $COMMON_FILES.

port/atomic_pointer.h

Google created a cascading set of alternatives for defining their AtomicPointer class. The last alternative is to use the C++11 class std::atomic. This class is not used within the Linux environments because there exists a more preferred memory barrier implementation that is embedded within the gcc compiler. However, the C++11 std::atomic class's include file cstdatomic is always included, though not used, when it exists. This causes compile time errors in the independent projects attempting to reuse leveldb's mutex wrappers.

The simple adjustment is to only include cstdatomic when the std::atomic class is actually going to be used. NOTE: this initial implementation of ldb_config.h does NOT automatically pass the --std=c++0x command line parameter to the independent project.

port/port.h

Line added to include the new leveldb/ldb_config.h file.

Clone this wiki locally