diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..a1e9a48e4 --- /dev/null +++ b/.clang-format @@ -0,0 +1,47 @@ +# Complete list of style options can be found at: +# http://clang.llvm.org/docs/ClangFormatStyleOptions.html +--- +BasedOnStyle: Google +AccessModifierOffset: -1 +ConstructorInitializerIndentWidth: 4 +AlignEscapedNewlinesLeft: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakTemplateDeclarations: true +AlwaysBreakBeforeMultilineStrings: true +BreakBeforeBinaryOperators: false +BreakConstructorInitializersBeforeComma: false +BinPackParameters: false +ColumnLimit: 80 +ConstructorInitializerAllOnOneLineOrOnePerLine: true +DerivePointerBinding: true +ExperimentalAutoDetectBinPacking: true +IndentCaseLabels: false +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCSpaceBeforeProtocolList: false +PenaltyBreakBeforeFirstCallParameter: 10 +PenaltyBreakComment: 60 +PenaltyBreakString: 1000 +PenaltyBreakFirstLessLess: 20 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerBindsToType: true +SpacesBeforeTrailingComments: 2 +Cpp11BracedListStyle: true +Standard: Cpp11 +IndentWidth: 2 +TabWidth: 8 +UseTab: Never +BreakBeforeBraces: Attach +IndentFunctionDeclarationAfterType: false +SpacesInParentheses: false +SpacesInAngles: false +SpaceInEmptyParentheses: false +SpacesInCStyleCastParentheses: false +SpaceAfterControlStatementKeyword: true +SpaceBeforeAssignmentOperators: true +ContinuationIndentWidth: 4 +... diff --git a/.gitignore b/.gitignore index 1c2d2b378..03a5f1761 100644 --- a/.gitignore +++ b/.gitignore @@ -19,5 +19,4 @@ sst_dump util/build_version.cc build_tools/VALGRIND_LOGS/ coverage/COVERAGE_REPORT -util/build_version.cc.tmp .gdbhistory diff --git a/build_tools/build_detect_version b/build_tools/build_detect_version index 3ee6c92bd..f7d711f0d 100755 --- a/build_tools/build_detect_version +++ b/build_tools/build_detect_version @@ -5,38 +5,18 @@ # is then built as a regular source file as part of the compilation process. # One can run "strings executable_filename | grep _build_" to find the version of # the source that we used to build the executable file. -# -# create git version file -VFILE=$PWD/util/build_version.cc.tmp -trap "rm $VFILE" EXIT +OUTFILE="$PWD/util/build_version.cc" -# check to see if git is in the path -which git > /dev/null - -if [ "$?" = 0 ]; then - env -i git rev-parse HEAD 2>&1 | - awk ' - BEGIN { - print "#include \"build_version.h\"\n" - } - { print "const char* rocksdb_build_git_sha = \"rocksdb_build_git_sha:" $0"\";" } - ' > ${VFILE} -else - echo "git not found" | - awk ' - BEGIN { - print "#include \"build_version.h\"" - } - { print "const char* rocksdb_build_git_sha = \"rocksdb_build_git_sha:git not found\";" } - ' > ${VFILE} +GIT_SHA="" +if command -v git >/dev/null 2>&1; then + GIT_SHA=$(git rev-parse HEAD 2>/dev/null) fi -echo "const char* rocksdb_build_git_datetime = \"rocksdb_build_git_datetime:$(date)\";" >> ${VFILE} -echo "const char* rocksdb_build_compile_date = __DATE__;" >> ${VFILE} -echo "const char* rocksdb_build_compile_time = __TIME__;" >> ${VFILE} - -OUTFILE=$PWD/util/build_version.cc -if [ ! -e $OUTFILE ] || ! cmp -s $VFILE $OUTFILE; then - cp $VFILE $OUTFILE -fi +cat > "${OUTFILE}" <Release(h); } -static Slice GetSliceForFileNumber(uint64_t file_number) { - return Slice(reinterpret_cast(&file_number), - sizeof(file_number)); +static Slice GetSliceForFileNumber(uint64_t* file_number) { + return Slice(reinterpret_cast(file_number), + sizeof(*file_number)); } TableCache::TableCache(const std::string& dbname, @@ -55,7 +55,7 @@ Status TableCache::FindTable(const EnvOptions& toptions, Cache::Handle** handle, bool* table_io, const bool no_io) { Status s; - Slice key = GetSliceForFileNumber(file_number); + Slice key = GetSliceForFileNumber(&file_number); *handle = cache_->Lookup(key); if (*handle == nullptr) { if (no_io) { // Dont do IO and return a not-found status @@ -168,7 +168,7 @@ bool TableCache::PrefixMayMatch(const ReadOptions& options, } void TableCache::Evict(uint64_t file_number) { - cache_->Erase(GetSliceForFileNumber(file_number)); + cache_->Erase(GetSliceForFileNumber(&file_number)); } } // namespace rocksdb diff --git a/util/autovector_test.cc b/util/autovector_test.cc index 6d709a374..eb244aabf 100644 --- a/util/autovector_test.cc +++ b/util/autovector_test.cc @@ -17,7 +17,7 @@ using namespace std; class AutoVectorTest { }; -const size_t kSize = 8; +const unsigned long kSize = 8; TEST(AutoVectorTest, PushBackAndPopBack) { autovector vec; ASSERT_TRUE(vec.empty());