# HG changeset patch # User Jens Alfke # Date 1253507147 25200 # Node ID 851de24ecb61468d6479f1361548e6d12e91bce8 # Parent 6cbad782d16a703f0866015df3d7f8d509ae3fea Added library target, changed some build settings, and fixed 64-to-32-bit conversion warnings. diff -r 6cbad782d16a -r 851de24ecb61 Ottoman.xcodeproj/project.pbxproj --- a/Ottoman.xcodeproj/project.pbxproj Sun Sep 20 20:39:24 2009 -0700 +++ b/Ottoman.xcodeproj/project.pbxproj Sun Sep 20 21:25:47 2009 -0700 @@ -23,6 +23,24 @@ 276E5BDF1066D142008A2171 /* Ottoman_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5BD91066D142008A2171 /* Ottoman_test.cpp */; }; 276E5BE01066D142008A2171 /* TestUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5BDA1066D142008A2171 /* TestUtils.cpp */; }; 276E5BE11066D142008A2171 /* VersionDictionary_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5BDC1066D142008A2171 /* VersionDictionary_test.cpp */; }; + 276E5CB5106731BA008A2171 /* Base.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5BC41066D13D008A2171 /* Base.cpp */; }; + 276E5CB6106731BA008A2171 /* Chunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5BC51066D13D008A2171 /* Chunk.cpp */; }; + 276E5CB7106731BB008A2171 /* Chunk.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5BBB1066D135008A2171 /* Chunk.h */; }; + 276E5CB8106731BB008A2171 /* Dictionary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5BC61066D13D008A2171 /* Dictionary.cpp */; }; + 276E5CB9106731BC008A2171 /* File.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5BC71066D13D008A2171 /* File.cpp */; }; + 276E5CBA106731BD008A2171 /* Hash.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5BC81066D13D008A2171 /* Hash.cpp */; }; + 276E5CBB106731BD008A2171 /* Hash.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5BBE1066D135008A2171 /* Hash.h */; }; + 276E5CBC106731BE008A2171 /* Index.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5BC91066D13D008A2171 /* Index.cpp */; }; + 276E5CBD106731BF008A2171 /* Index.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5BBF1066D135008A2171 /* Index.h */; }; + 276E5CBE106731C0008A2171 /* MemoryMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5BCA1066D13D008A2171 /* MemoryMap.cpp */; }; + 276E5CBF106731C1008A2171 /* MemoryMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5BC01066D135008A2171 /* MemoryMap.h */; }; + 276E5CC0106731C1008A2171 /* Ottoman.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5BCB1066D13D008A2171 /* Ottoman.cpp */; }; + 276E5CC1106731C2008A2171 /* VersionDictionary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5BCC1066D13D008A2171 /* VersionDictionary.cpp */; }; + 276E5CC2106731C5008A2171 /* Base.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5BBA1066D135008A2171 /* Base.h */; }; + 276E5CC3106731C6008A2171 /* Dictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5BBC1066D135008A2171 /* Dictionary.h */; }; + 276E5CC4106731C7008A2171 /* File.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5BBD1066D135008A2171 /* File.h */; }; + 276E5CC5106731C8008A2171 /* Ottoman.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5BC11066D135008A2171 /* Ottoman.h */; }; + 276E5CC6106731C8008A2171 /* VersionDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5BC21066D135008A2171 /* VersionDictionary.h */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -64,10 +82,18 @@ 276E5BDA1066D142008A2171 /* TestUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestUtils.cpp; sourceTree = ""; }; 276E5BDB1066D142008A2171 /* TestUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestUtils.h; sourceTree = ""; }; 276E5BDC1066D142008A2171 /* VersionDictionary_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VersionDictionary_test.cpp; sourceTree = ""; }; - 8DD76F6C0486A84900D96B5E /* SafeStorageTest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = SafeStorageTest; sourceTree = BUILT_PRODUCTS_DIR; }; + 276E5CAE1067315D008A2171 /* libOttoman.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libOttoman.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 8DD76F6C0486A84900D96B5E /* OttomanTest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = OttomanTest; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 276E5CAC1067315D008A2171 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 8DD76F660486A84900D96B5E /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -96,7 +122,8 @@ 1AB674ADFE9D54B511CA2CBB /* Products */ = { isa = PBXGroup; children = ( - 8DD76F6C0486A84900D96B5E /* SafeStorageTest */, + 8DD76F6C0486A84900D96B5E /* OttomanTest */, + 276E5CAE1067315D008A2171 /* libOttoman.a */, ); name = Products; sourceTree = ""; @@ -148,7 +175,43 @@ }; /* End PBXGroup section */ +/* Begin PBXHeadersBuildPhase section */ + 276E5CAA1067315D008A2171 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 276E5CB7106731BB008A2171 /* Chunk.h in Headers */, + 276E5CBB106731BD008A2171 /* Hash.h in Headers */, + 276E5CBD106731BF008A2171 /* Index.h in Headers */, + 276E5CBF106731C1008A2171 /* MemoryMap.h in Headers */, + 276E5CC2106731C5008A2171 /* Base.h in Headers */, + 276E5CC3106731C6008A2171 /* Dictionary.h in Headers */, + 276E5CC4106731C7008A2171 /* File.h in Headers */, + 276E5CC5106731C8008A2171 /* Ottoman.h in Headers */, + 276E5CC6106731C8008A2171 /* VersionDictionary.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + /* Begin PBXNativeTarget section */ + 276E5CAD1067315D008A2171 /* Static Library */ = { + isa = PBXNativeTarget; + buildConfigurationList = 276E5CC9106731D5008A2171 /* Build configuration list for PBXNativeTarget "Static Library" */; + buildPhases = ( + 276E5CAA1067315D008A2171 /* Headers */, + 276E5CAB1067315D008A2171 /* Sources */, + 276E5CAC1067315D008A2171 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "Static Library"; + productName = "Static Library"; + productReference = 276E5CAE1067315D008A2171 /* libOttoman.a */; + productType = "com.apple.product-type.library.static"; + }; 8DD76F620486A84900D96B5E /* OttomanTest */ = { isa = PBXNativeTarget; buildConfigurationList = 1DEB923108733DC60010E9CD /* Build configuration list for PBXNativeTarget "OttomanTest" */; @@ -164,7 +227,7 @@ name = OttomanTest; productInstallPath = "$(HOME)/bin"; productName = BPlusTree; - productReference = 8DD76F6C0486A84900D96B5E /* SafeStorageTest */; + productReference = 8DD76F6C0486A84900D96B5E /* OttomanTest */; productType = "com.apple.product-type.tool"; }; /* End PBXNativeTarget section */ @@ -180,11 +243,28 @@ projectRoot = ""; targets = ( 8DD76F620486A84900D96B5E /* OttomanTest */, + 276E5CAD1067315D008A2171 /* Static Library */, ); }; /* End PBXProject section */ /* Begin PBXSourcesBuildPhase section */ + 276E5CAB1067315D008A2171 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 276E5CB5106731BA008A2171 /* Base.cpp in Sources */, + 276E5CB6106731BA008A2171 /* Chunk.cpp in Sources */, + 276E5CB8106731BB008A2171 /* Dictionary.cpp in Sources */, + 276E5CB9106731BC008A2171 /* File.cpp in Sources */, + 276E5CBA106731BD008A2171 /* Hash.cpp in Sources */, + 276E5CBC106731BE008A2171 /* Index.cpp in Sources */, + 276E5CBE106731C0008A2171 /* MemoryMap.cpp in Sources */, + 276E5CC0106731C1008A2171 /* Ottoman.cpp in Sources */, + 276E5CC1106731C2008A2171 /* VersionDictionary.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 8DD76F640486A84900D96B5E /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -214,21 +294,13 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - /Code/googletest/xcode/build/Debug, - ); GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_FIX_AND_CONTINUE = YES; GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ""; INSTALL_PATH = /usr/local/bin; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - /Code/googletest/xcode/build/Debug, - ); - PRODUCT_NAME = SafeStorageTest; + PRODUCT_NAME = OttomanTest; }; name = Debug; }; @@ -237,17 +309,9 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - /Code/googletest/xcode/build/Debug, - ); GCC_MODEL_TUNING = G5; INSTALL_PATH = /usr/local/bin; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - /Code/googletest/xcode/build/Debug, - ); - PRODUCT_NAME = SafeStorageTest; + PRODUCT_NAME = OttomanTest; }; name = Release; }; @@ -279,22 +343,49 @@ ARCHS = "$(ARCHS_STANDARD_32_BIT)"; DEAD_CODE_STRIPPING = YES; GCC_C_LANGUAGE_STANDARD = c99; + GCC_DYNAMIC_NO_PIC = YES; + GCC_ENABLE_CPP_RTTI = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = NDEBUG; GCC_TREAT_WARNINGS_AS_ERRORS = YES; + GCC_UNROLL_LOOPS = YES; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO; GCC_WARN_SHADOW = NO; GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; + LLVM_LTO = YES; PREBINDING = NO; + RUN_CLANG_STATIC_ANALYZER = NO; SDKROOT = macosx10.5; WARNING_CFLAGS = "-Wall"; }; name = Release; }; + 276E5CAF10673160008A2171 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = NO; + INSTALL_PATH = /usr/local/lib; + PRODUCT_NAME = Ottoman; + }; + name = Debug; + }; + 276E5CB010673160008A2171 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GENERATE_MASTER_OBJECT_FILE = YES; + INSTALL_PATH = /usr/local/lib; + PRODUCT_NAME = Ottoman; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -316,6 +407,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 276E5CC9106731D5008A2171 /* Build configuration list for PBXNativeTarget "Static Library" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 276E5CAF10673160008A2171 /* Debug */, + 276E5CB010673160008A2171 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = 08FB7793FE84155DC02AAC07 /* Project object */; diff -r 6cbad782d16a -r 851de24ecb61 include/File.h --- a/include/File.h Sun Sep 20 20:39:24 2009 -0700 +++ b/include/File.h Sun Sep 20 21:25:47 2009 -0700 @@ -89,6 +89,8 @@ private: static int _open (const char *filename, int posixMode) throw(Error); + static ssize_t _check (ssize_t result) throw(Error) {_check((int)result); return result;} + static off_t _check (off_t result) throw(Error) {_check((int)result); return result;} static int _check (int result) throw(Error); static void _checkRead (ssize_t result, size_t expectedSize) throw(Error); bool _lock (bool block); diff -r 6cbad782d16a -r 851de24ecb61 src/Chunk.cpp --- a/src/Chunk.cpp Sun Sep 20 20:39:24 2009 -0700 +++ b/src/Chunk.cpp Sun Sep 20 21:25:47 2009 -0700 @@ -37,13 +37,13 @@ } size_t Chunk::writePadding (File *file) { - int padding = file->position() & 0x03; + off_t padding = file->position() & 0x03; if (padding == 0) return 0; else { padding = 4 - padding; uint32_t zero = 0; - Blob pad(&zero, padding); + Blob pad(&zero, (size_t)padding); return writeMultiple(file, kChunkTypePadding, &pad, 1); } } @@ -103,7 +103,7 @@ ChunkIterator::ChunkIterator (File* file, FilePosition start) :_file(file), _pos(start), - _length(_file->length()), + _length((FilePosition)_file->length()), _chunk(NULL) { _loadChunk(); diff -r 6cbad782d16a -r 851de24ecb61 src/Dictionary.cpp --- a/src/Dictionary.cpp Sun Sep 20 20:39:24 2009 -0700 +++ b/src/Dictionary.cpp Sun Sep 20 21:25:47 2009 -0700 @@ -26,8 +26,8 @@ const int Dictionary::kMinSize = 8; - const float Dictionary::kMinLoadFactor = 0.25; - const float Dictionary::kMaxLoadFactor = 0.75; + const float Dictionary::kMinLoadFactor = 0.25f; + const float Dictionary::kMaxLoadFactor = 0.75f; // Choose the smallest power of two that's large enough to hold the given capacity // of entries with no greater than the given load (fraction full). diff -r 6cbad782d16a -r 851de24ecb61 src/File.cpp --- a/src/File.cpp Sun Sep 20 20:39:24 2009 -0700 +++ b/src/File.cpp Sun Sep 20 21:25:47 2009 -0700 @@ -88,7 +88,7 @@ } size_t File::writePadding (int alignment) { - off_t pad = alignment - (position() & (alignment-1)); + int pad = alignment - (int)(position() & (alignment-1)); if (pad == alignment) return 0; uint8_t zero[pad]; diff -r 6cbad782d16a -r 851de24ecb61 src/Index.cpp --- a/src/Index.cpp Sun Sep 20 20:39:24 2009 -0700 +++ b/src/Index.cpp Sun Sep 20 21:25:47 2009 -0700 @@ -24,7 +24,7 @@ #define PROBE_QUADRATIC 0 // Similarly use a higher max load than for memory-resident tables, to save space. - static const float kMaxLoadFactor = 0.85; + static const float kMaxLoadFactor = 0.85f; static const uint32_t kIndexMagicNumber = 0x54378543; diff -r 6cbad782d16a -r 851de24ecb61 src/MemoryMap.cpp --- a/src/MemoryMap.cpp Sun Sep 20 20:39:24 2009 -0700 +++ b/src/MemoryMap.cpp Sun Sep 20 21:25:47 2009 -0700 @@ -22,13 +22,13 @@ } void MemoryMap::mapRegion (off_t pos, size_t length) { - size_t end = pos+length; + off_t end = pos+length; for (int i=0; i<_nRegions; i++) { Region *region = _regions[i]; if (region->position() <= pos) { if (end <= region->end()) return; // found an existing region covering this range - else if (region->setLength(end - region->position())) + else if (region->setLength((size_t)(end - region->position()))) return; // able to grow the existing region } } diff -r 6cbad782d16a -r 851de24ecb61 src/VersionDictionary.cpp --- a/src/VersionDictionary.cpp Sun Sep 20 20:39:24 2009 -0700 +++ b/src/VersionDictionary.cpp Sun Sep 20 21:25:47 2009 -0700 @@ -127,7 +127,7 @@ off_t pos = _file->setPositionToEnd(sizeof(VersionDictionary::Trailer)); if (pos < 0 || (pos & 0x03) || pos > UINT32_MAX) throw File::Error(ERANGE, "No trailer found in file (wrong EOF)"); - trailerPos = pos; + trailerPos = (FilePosition)pos; } // Read & verify trailer: @@ -201,7 +201,7 @@ // Lock the file now, seek to the end, and make sure it's been prepared with a header, // since FilePositions of 0 and 1 are reserved. File::Lock lock(dstFile); - const FilePosition startPos = dstFile->setPositionToEnd(); + const FilePosition startPos = (FilePosition) dstFile->setPositionToEnd(); if (startPos <= 1) throw File::Error(ERANGE, "Cannot write VersionDictionary to empty file");