Merge pull request #657 from yuslepukhin/ensure_clean_public_headers
Ensure Windows build w/o port/port.h in public headers
This commit is contained in:
commit
d730c36777
@ -72,6 +72,7 @@ set(SOURCES
|
||||
db/builder.cc
|
||||
db/c.cc
|
||||
db/column_family.cc
|
||||
db/compacted_db_impl.cc
|
||||
db/compaction.cc
|
||||
db/compaction_job.cc
|
||||
db/compaction_picker.cc
|
||||
@ -202,7 +203,6 @@ set(SOURCES
|
||||
util/xxhash.cc
|
||||
utilities/backupable/backupable_db.cc
|
||||
utilities/checkpoint/checkpoint.cc
|
||||
utilities/compacted_db/compacted_db_impl.cc
|
||||
utilities/document/document_db.cc
|
||||
utilities/document/json_document.cc
|
||||
utilities/document/json_document_builder.cc
|
||||
@ -215,8 +215,8 @@ set(SOURCES
|
||||
utilities/merge_operators/uint64add.cc
|
||||
utilities/redis/redis_lists.cc
|
||||
utilities/spatialdb/spatial_db.cc
|
||||
utilities/transactions/optimistic_transaction_db_impl.cc
|
||||
utilities/transactions/optimistic_transaction_impl.cc
|
||||
utilities/transactions/optimistic_transaction_db_impl.cc
|
||||
utilities/ttl/db_ttl_impl.cc
|
||||
utilities/write_batch_with_index/write_batch_with_index.cc
|
||||
utilities/write_batch_with_index/write_batch_with_index_internal.cc
|
||||
|
@ -46,7 +46,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef OS_WIN
|
||||
#ifdef _WIN32
|
||||
#ifdef ROCKSDB_DLL
|
||||
#ifdef ROCKSDB_LIBRARY_EXPORTS
|
||||
#define ROCKSDB_LIBRARY_API __declspec(dllexport)
|
||||
|
@ -24,6 +24,12 @@
|
||||
#include "rocksdb/listener.h"
|
||||
#include "rocksdb/thread_status.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
// Windows API macro interference
|
||||
#undef DeleteFile
|
||||
#endif
|
||||
|
||||
|
||||
namespace rocksdb {
|
||||
|
||||
struct Options;
|
||||
@ -431,7 +437,12 @@ class DB {
|
||||
return CompactRange(options, DefaultColumnFamily(), begin, end);
|
||||
}
|
||||
|
||||
__attribute__((deprecated)) virtual Status
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
__attribute__((deprecated))
|
||||
#elif _WIN32
|
||||
__declspec(deprecated)
|
||||
#endif
|
||||
virtual Status
|
||||
CompactRange(ColumnFamilyHandle* column_family, const Slice* begin,
|
||||
const Slice* end, bool change_level = false,
|
||||
int target_level = -1, uint32_t target_path_id = 0) {
|
||||
@ -441,7 +452,12 @@ class DB {
|
||||
options.target_path_id = target_path_id;
|
||||
return CompactRange(options, column_family, begin, end);
|
||||
}
|
||||
__attribute__((deprecated)) virtual Status
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
__attribute__((deprecated))
|
||||
#elif _WIN32
|
||||
__declspec(deprecated)
|
||||
#endif
|
||||
virtual Status
|
||||
CompactRange(const Slice* begin, const Slice* end,
|
||||
bool change_level = false, int target_level = -1,
|
||||
uint32_t target_path_id = 0) {
|
||||
|
@ -26,7 +26,9 @@
|
||||
#include "rocksdb/status.h"
|
||||
#include "rocksdb/thread_status.h"
|
||||
|
||||
#ifdef GetCurrentTime
|
||||
#ifdef _WIN32
|
||||
// Windows API macro interference
|
||||
#undef DeleteFile
|
||||
#undef GetCurrentTime
|
||||
#endif
|
||||
|
||||
@ -163,7 +165,6 @@ class Env {
|
||||
virtual Status GetChildren(const std::string& dir,
|
||||
std::vector<std::string>* result) = 0;
|
||||
|
||||
#undef DeleteFile
|
||||
// Delete the named file.
|
||||
virtual Status DeleteFile(const std::string& fname) = 0;
|
||||
|
||||
@ -650,27 +651,8 @@ class Logger {
|
||||
// and format. Any log with level under the internal log level
|
||||
// of *this (see @SetInfoLogLevel and @GetInfoLogLevel) will not be
|
||||
// printed.
|
||||
virtual void Logv(const InfoLogLevel log_level, const char* format, va_list ap) {
|
||||
static const char* kInfoLogLevelNames[5] = {"DEBUG", "INFO", "WARN",
|
||||
"ERROR", "FATAL"};
|
||||
if (log_level < log_level_) {
|
||||
return;
|
||||
}
|
||||
virtual void Logv(const InfoLogLevel log_level, const char* format, va_list ap);
|
||||
|
||||
if (log_level == InfoLogLevel::INFO_LEVEL) {
|
||||
// Doesn't print log level if it is INFO level.
|
||||
// This is to avoid unexpected performance regression after we add
|
||||
// the feature of log level. All the logs before we add the feature
|
||||
// are INFO level. We don't want to add extra costs to those existing
|
||||
// logging.
|
||||
Logv(format, ap);
|
||||
} else {
|
||||
char new_format[500];
|
||||
snprintf(new_format, sizeof(new_format) - 1, "[%s] %s",
|
||||
kInfoLogLevelNames[log_level], format);
|
||||
Logv(new_format, ap);
|
||||
}
|
||||
}
|
||||
virtual size_t GetLogFileSize() const { return kDoNotSupportGetLogFileSize; }
|
||||
// Flush to the OS buffers
|
||||
virtual void Flush() {}
|
||||
|
@ -44,7 +44,11 @@ struct IOStatsContext {
|
||||
};
|
||||
|
||||
#ifndef IOS_CROSS_COMPILE
|
||||
# ifdef _WIN32
|
||||
extern __declspec(thread) IOStatsContext iostats_context;
|
||||
# else
|
||||
extern __thread IOStatsContext iostats_context;
|
||||
# endif
|
||||
#endif // IOS_CROSS_COMPILE
|
||||
|
||||
} // namespace rocksdb
|
||||
|
@ -87,6 +87,8 @@ struct PerfContext {
|
||||
|
||||
#if defined(NPERF_CONTEXT) || defined(IOS_CROSS_COMPILE)
|
||||
extern PerfContext perf_context;
|
||||
#elif _WIN32
|
||||
extern __declspec(thread) PerfContext perf_context;
|
||||
#else
|
||||
extern __thread PerfContext perf_context;
|
||||
#endif
|
||||
|
@ -6,6 +6,12 @@
|
||||
#include <string>
|
||||
#include "rocksdb/db.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
// Windows API macro interference
|
||||
#undef DeleteFile
|
||||
#endif
|
||||
|
||||
|
||||
namespace rocksdb {
|
||||
|
||||
// This class contains APIs to stack rocksdb wrappers.Eg. Stack TTL over base d
|
||||
|
@ -19,7 +19,12 @@ class UtilityDB {
|
||||
// This function is here only for backwards compatibility. Please use the
|
||||
// functions defined in DBWithTTl (rocksdb/utilities/db_ttl.h)
|
||||
// (deprecated)
|
||||
__attribute__((deprecated)) static Status OpenTtlDB(const Options& options,
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
__attribute__((deprecated))
|
||||
#elif _WIN32
|
||||
__declspec(deprecated)
|
||||
#endif
|
||||
static Status OpenTtlDB(const Options& options,
|
||||
const std::string& name,
|
||||
StackableDB** dbptr,
|
||||
int32_t ttl = 0,
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
#define ROCKSDB_WARNING(x) _Pragma(RDB_STR(GCC warning x))
|
||||
|
||||
#elif defined(OS_WIN)
|
||||
#elif defined(_WIN32)
|
||||
|
||||
// Wrap unportable warning macro
|
||||
#if defined(_MSC_VER)
|
||||
|
@ -31,6 +31,12 @@
|
||||
|
||||
#include "rocksdb/options.h"
|
||||
|
||||
#undef min
|
||||
#undef max
|
||||
#undef DeleteFile
|
||||
#undef GetCurrentTime
|
||||
|
||||
|
||||
#ifndef strcasecmp
|
||||
#define strcasecmp _stricmp
|
||||
#endif
|
||||
@ -40,12 +46,17 @@
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#undef GetCurrentTime
|
||||
#undef DeleteFile
|
||||
|
||||
typedef SSIZE_T ssize_t;
|
||||
|
||||
// size_t printf formatting named in the manner of C99 standard formatting
|
||||
// strings such as PRIu64
|
||||
// in fact, we could use that one
|
||||
#ifndef ROCKSDB_PRIszt
|
||||
#define ROCKSDB_PRIszt "Iu"
|
||||
#endif
|
||||
|
||||
#define __attribute__(A)
|
||||
|
||||
@ -68,7 +79,9 @@ typedef SSIZE_T ssize_t;
|
||||
|
||||
// Thread local storage on Linux
|
||||
// There is thread_local in C++11
|
||||
#ifndef __thread
|
||||
#define __thread __declspec(thread)
|
||||
#endif
|
||||
|
||||
#ifndef PLATFORM_IS_LITTLE_ENDIAN
|
||||
#define PLATFORM_IS_LITTLE_ENDIAN (__BYTE_ORDER == __LITTLE_ENDIAN)
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "table/adaptive_table_factory.h"
|
||||
|
||||
#include "table/format.h"
|
||||
#include "port/port.h"
|
||||
|
||||
namespace rocksdb {
|
||||
|
||||
|
@ -14,7 +14,9 @@
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <inttypes.h>
|
||||
#ifndef OS_WIN
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
@ -36,7 +38,7 @@
|
||||
#include "rocksdb/slice.h"
|
||||
#include "rocksdb/table.h"
|
||||
#include "rocksdb/utilities/checkpoint.h"
|
||||
#include "rocksdb/utilities/convenience.h"
|
||||
#include "rocksdb/convenience.h"
|
||||
#include "table/block_based_table_factory.h"
|
||||
#include "table/mock_table.h"
|
||||
#include "table/plain_table_factory.h"
|
||||
|
25
util/env.cc
25
util/env.cc
@ -10,7 +10,9 @@
|
||||
#include "rocksdb/env.h"
|
||||
|
||||
#include <thread>
|
||||
#include "port/port.h"
|
||||
#include "port/sys_time.h"
|
||||
#include "port/port.h"
|
||||
|
||||
#include "rocksdb/options.h"
|
||||
#include "util/arena.h"
|
||||
@ -56,6 +58,29 @@ void Log(Logger* info_log, const char* format, ...) {
|
||||
}
|
||||
}
|
||||
|
||||
void Logger::Logv(const InfoLogLevel log_level, const char* format, va_list ap) {
|
||||
static const char* kInfoLogLevelNames[5] = { "DEBUG", "INFO", "WARN",
|
||||
"ERROR", "FATAL" };
|
||||
if (log_level < log_level_) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (log_level == InfoLogLevel::INFO_LEVEL) {
|
||||
// Doesn't print log level if it is INFO level.
|
||||
// This is to avoid unexpected performance regression after we add
|
||||
// the feature of log level. All the logs before we add the feature
|
||||
// are INFO level. We don't want to add extra costs to those existing
|
||||
// logging.
|
||||
Logv(format, ap);
|
||||
} else {
|
||||
char new_format[500];
|
||||
snprintf(new_format, sizeof(new_format) - 1, "[%s] %s",
|
||||
kInfoLogLevelNames[log_level], format);
|
||||
Logv(new_format, ap);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Log(const InfoLogLevel log_level, Logger* info_log, const char* format,
|
||||
...) {
|
||||
if (info_log && info_log->GetInfoLogLevel() <= log_level) {
|
||||
|
@ -10,7 +10,11 @@
|
||||
namespace rocksdb {
|
||||
|
||||
#ifndef IOS_CROSS_COMPILE
|
||||
# ifdef _WIN32
|
||||
__declspec(thread) IOStatsContext iostats_context;
|
||||
# else
|
||||
__thread IOStatsContext iostats_context;
|
||||
# endif
|
||||
#endif // IOS_CROSS_COMPILE
|
||||
|
||||
void IOStatsContext::Reset() {
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "rocksdb/slice.h"
|
||||
#include "rocksdb/write_batch.h"
|
||||
#include "util/testharness.h"
|
||||
#include "port/port.h"
|
||||
|
||||
using namespace rocksdb;
|
||||
|
||||
|
@ -10,10 +10,11 @@
|
||||
namespace rocksdb {
|
||||
|
||||
#if defined(NPERF_CONTEXT) || defined(IOS_CROSS_COMPILE)
|
||||
// This is a dummy variable since some place references it
|
||||
PerfContext perf_context;
|
||||
PerfContext perf_context;
|
||||
#elif _WIN32
|
||||
__declspec(thread) PerfContext perf_context;
|
||||
#else
|
||||
__thread PerfContext perf_context;
|
||||
__thread PerfContext perf_context;
|
||||
#endif
|
||||
|
||||
void PerfContext::Reset() {
|
||||
|
@ -35,6 +35,8 @@
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include "port/port.h"
|
||||
|
||||
|
||||
namespace rocksdb {
|
||||
|
||||
|
@ -17,6 +17,12 @@
|
||||
#include "rocksdb/utilities/db_ttl.h"
|
||||
#include "db/db_impl.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
// Windows API macro interference
|
||||
#undef GetCurrentTime
|
||||
#endif
|
||||
|
||||
|
||||
namespace rocksdb {
|
||||
|
||||
class DBWithTTLImpl : public DBWithTTL {
|
||||
|
Loading…
Reference in New Issue
Block a user