Added library target, changed some build settings, and fixed 64-to-32-bit conversion warnings.
1.1 --- a/Ottoman.xcodeproj/project.pbxproj Sun Sep 20 20:39:24 2009 -0700
1.2 +++ b/Ottoman.xcodeproj/project.pbxproj Sun Sep 20 21:25:47 2009 -0700
1.3 @@ -23,6 +23,24 @@
1.4 276E5BDF1066D142008A2171 /* Ottoman_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5BD91066D142008A2171 /* Ottoman_test.cpp */; };
1.5 276E5BE01066D142008A2171 /* TestUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5BDA1066D142008A2171 /* TestUtils.cpp */; };
1.6 276E5BE11066D142008A2171 /* VersionDictionary_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5BDC1066D142008A2171 /* VersionDictionary_test.cpp */; };
1.7 + 276E5CB5106731BA008A2171 /* Base.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5BC41066D13D008A2171 /* Base.cpp */; };
1.8 + 276E5CB6106731BA008A2171 /* Chunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5BC51066D13D008A2171 /* Chunk.cpp */; };
1.9 + 276E5CB7106731BB008A2171 /* Chunk.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5BBB1066D135008A2171 /* Chunk.h */; };
1.10 + 276E5CB8106731BB008A2171 /* Dictionary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5BC61066D13D008A2171 /* Dictionary.cpp */; };
1.11 + 276E5CB9106731BC008A2171 /* File.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5BC71066D13D008A2171 /* File.cpp */; };
1.12 + 276E5CBA106731BD008A2171 /* Hash.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5BC81066D13D008A2171 /* Hash.cpp */; };
1.13 + 276E5CBB106731BD008A2171 /* Hash.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5BBE1066D135008A2171 /* Hash.h */; };
1.14 + 276E5CBC106731BE008A2171 /* Index.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5BC91066D13D008A2171 /* Index.cpp */; };
1.15 + 276E5CBD106731BF008A2171 /* Index.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5BBF1066D135008A2171 /* Index.h */; };
1.16 + 276E5CBE106731C0008A2171 /* MemoryMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5BCA1066D13D008A2171 /* MemoryMap.cpp */; };
1.17 + 276E5CBF106731C1008A2171 /* MemoryMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5BC01066D135008A2171 /* MemoryMap.h */; };
1.18 + 276E5CC0106731C1008A2171 /* Ottoman.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5BCB1066D13D008A2171 /* Ottoman.cpp */; };
1.19 + 276E5CC1106731C2008A2171 /* VersionDictionary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5BCC1066D13D008A2171 /* VersionDictionary.cpp */; };
1.20 + 276E5CC2106731C5008A2171 /* Base.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5BBA1066D135008A2171 /* Base.h */; };
1.21 + 276E5CC3106731C6008A2171 /* Dictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5BBC1066D135008A2171 /* Dictionary.h */; };
1.22 + 276E5CC4106731C7008A2171 /* File.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5BBD1066D135008A2171 /* File.h */; };
1.23 + 276E5CC5106731C8008A2171 /* Ottoman.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5BC11066D135008A2171 /* Ottoman.h */; };
1.24 + 276E5CC6106731C8008A2171 /* VersionDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5BC21066D135008A2171 /* VersionDictionary.h */; };
1.25 /* End PBXBuildFile section */
1.26
1.27 /* Begin PBXCopyFilesBuildPhase section */
1.28 @@ -64,10 +82,18 @@
1.29 276E5BDA1066D142008A2171 /* TestUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestUtils.cpp; sourceTree = "<group>"; };
1.30 276E5BDB1066D142008A2171 /* TestUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestUtils.h; sourceTree = "<group>"; };
1.31 276E5BDC1066D142008A2171 /* VersionDictionary_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VersionDictionary_test.cpp; sourceTree = "<group>"; };
1.32 - 8DD76F6C0486A84900D96B5E /* SafeStorageTest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = SafeStorageTest; sourceTree = BUILT_PRODUCTS_DIR; };
1.33 + 276E5CAE1067315D008A2171 /* libOttoman.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libOttoman.a; sourceTree = BUILT_PRODUCTS_DIR; };
1.34 + 8DD76F6C0486A84900D96B5E /* OttomanTest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = OttomanTest; sourceTree = BUILT_PRODUCTS_DIR; };
1.35 /* End PBXFileReference section */
1.36
1.37 /* Begin PBXFrameworksBuildPhase section */
1.38 + 276E5CAC1067315D008A2171 /* Frameworks */ = {
1.39 + isa = PBXFrameworksBuildPhase;
1.40 + buildActionMask = 2147483647;
1.41 + files = (
1.42 + );
1.43 + runOnlyForDeploymentPostprocessing = 0;
1.44 + };
1.45 8DD76F660486A84900D96B5E /* Frameworks */ = {
1.46 isa = PBXFrameworksBuildPhase;
1.47 buildActionMask = 2147483647;
1.48 @@ -96,7 +122,8 @@
1.49 1AB674ADFE9D54B511CA2CBB /* Products */ = {
1.50 isa = PBXGroup;
1.51 children = (
1.52 - 8DD76F6C0486A84900D96B5E /* SafeStorageTest */,
1.53 + 8DD76F6C0486A84900D96B5E /* OttomanTest */,
1.54 + 276E5CAE1067315D008A2171 /* libOttoman.a */,
1.55 );
1.56 name = Products;
1.57 sourceTree = "<group>";
1.58 @@ -148,7 +175,43 @@
1.59 };
1.60 /* End PBXGroup section */
1.61
1.62 +/* Begin PBXHeadersBuildPhase section */
1.63 + 276E5CAA1067315D008A2171 /* Headers */ = {
1.64 + isa = PBXHeadersBuildPhase;
1.65 + buildActionMask = 2147483647;
1.66 + files = (
1.67 + 276E5CB7106731BB008A2171 /* Chunk.h in Headers */,
1.68 + 276E5CBB106731BD008A2171 /* Hash.h in Headers */,
1.69 + 276E5CBD106731BF008A2171 /* Index.h in Headers */,
1.70 + 276E5CBF106731C1008A2171 /* MemoryMap.h in Headers */,
1.71 + 276E5CC2106731C5008A2171 /* Base.h in Headers */,
1.72 + 276E5CC3106731C6008A2171 /* Dictionary.h in Headers */,
1.73 + 276E5CC4106731C7008A2171 /* File.h in Headers */,
1.74 + 276E5CC5106731C8008A2171 /* Ottoman.h in Headers */,
1.75 + 276E5CC6106731C8008A2171 /* VersionDictionary.h in Headers */,
1.76 + );
1.77 + runOnlyForDeploymentPostprocessing = 0;
1.78 + };
1.79 +/* End PBXHeadersBuildPhase section */
1.80 +
1.81 /* Begin PBXNativeTarget section */
1.82 + 276E5CAD1067315D008A2171 /* Static Library */ = {
1.83 + isa = PBXNativeTarget;
1.84 + buildConfigurationList = 276E5CC9106731D5008A2171 /* Build configuration list for PBXNativeTarget "Static Library" */;
1.85 + buildPhases = (
1.86 + 276E5CAA1067315D008A2171 /* Headers */,
1.87 + 276E5CAB1067315D008A2171 /* Sources */,
1.88 + 276E5CAC1067315D008A2171 /* Frameworks */,
1.89 + );
1.90 + buildRules = (
1.91 + );
1.92 + dependencies = (
1.93 + );
1.94 + name = "Static Library";
1.95 + productName = "Static Library";
1.96 + productReference = 276E5CAE1067315D008A2171 /* libOttoman.a */;
1.97 + productType = "com.apple.product-type.library.static";
1.98 + };
1.99 8DD76F620486A84900D96B5E /* OttomanTest */ = {
1.100 isa = PBXNativeTarget;
1.101 buildConfigurationList = 1DEB923108733DC60010E9CD /* Build configuration list for PBXNativeTarget "OttomanTest" */;
1.102 @@ -164,7 +227,7 @@
1.103 name = OttomanTest;
1.104 productInstallPath = "$(HOME)/bin";
1.105 productName = BPlusTree;
1.106 - productReference = 8DD76F6C0486A84900D96B5E /* SafeStorageTest */;
1.107 + productReference = 8DD76F6C0486A84900D96B5E /* OttomanTest */;
1.108 productType = "com.apple.product-type.tool";
1.109 };
1.110 /* End PBXNativeTarget section */
1.111 @@ -180,11 +243,28 @@
1.112 projectRoot = "";
1.113 targets = (
1.114 8DD76F620486A84900D96B5E /* OttomanTest */,
1.115 + 276E5CAD1067315D008A2171 /* Static Library */,
1.116 );
1.117 };
1.118 /* End PBXProject section */
1.119
1.120 /* Begin PBXSourcesBuildPhase section */
1.121 + 276E5CAB1067315D008A2171 /* Sources */ = {
1.122 + isa = PBXSourcesBuildPhase;
1.123 + buildActionMask = 2147483647;
1.124 + files = (
1.125 + 276E5CB5106731BA008A2171 /* Base.cpp in Sources */,
1.126 + 276E5CB6106731BA008A2171 /* Chunk.cpp in Sources */,
1.127 + 276E5CB8106731BB008A2171 /* Dictionary.cpp in Sources */,
1.128 + 276E5CB9106731BC008A2171 /* File.cpp in Sources */,
1.129 + 276E5CBA106731BD008A2171 /* Hash.cpp in Sources */,
1.130 + 276E5CBC106731BE008A2171 /* Index.cpp in Sources */,
1.131 + 276E5CBE106731C0008A2171 /* MemoryMap.cpp in Sources */,
1.132 + 276E5CC0106731C1008A2171 /* Ottoman.cpp in Sources */,
1.133 + 276E5CC1106731C2008A2171 /* VersionDictionary.cpp in Sources */,
1.134 + );
1.135 + runOnlyForDeploymentPostprocessing = 0;
1.136 + };
1.137 8DD76F640486A84900D96B5E /* Sources */ = {
1.138 isa = PBXSourcesBuildPhase;
1.139 buildActionMask = 2147483647;
1.140 @@ -214,21 +294,13 @@
1.141 buildSettings = {
1.142 ALWAYS_SEARCH_USER_PATHS = NO;
1.143 COPY_PHASE_STRIP = NO;
1.144 - FRAMEWORK_SEARCH_PATHS = (
1.145 - "$(inherited)",
1.146 - /Code/googletest/xcode/build/Debug,
1.147 - );
1.148 GCC_DYNAMIC_NO_PIC = NO;
1.149 GCC_ENABLE_FIX_AND_CONTINUE = YES;
1.150 GCC_MODEL_TUNING = G5;
1.151 GCC_OPTIMIZATION_LEVEL = 0;
1.152 GCC_PREPROCESSOR_DEFINITIONS = "";
1.153 INSTALL_PATH = /usr/local/bin;
1.154 - LIBRARY_SEARCH_PATHS = (
1.155 - "$(inherited)",
1.156 - /Code/googletest/xcode/build/Debug,
1.157 - );
1.158 - PRODUCT_NAME = SafeStorageTest;
1.159 + PRODUCT_NAME = OttomanTest;
1.160 };
1.161 name = Debug;
1.162 };
1.163 @@ -237,17 +309,9 @@
1.164 buildSettings = {
1.165 ALWAYS_SEARCH_USER_PATHS = NO;
1.166 DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
1.167 - FRAMEWORK_SEARCH_PATHS = (
1.168 - "$(inherited)",
1.169 - /Code/googletest/xcode/build/Debug,
1.170 - );
1.171 GCC_MODEL_TUNING = G5;
1.172 INSTALL_PATH = /usr/local/bin;
1.173 - LIBRARY_SEARCH_PATHS = (
1.174 - "$(inherited)",
1.175 - /Code/googletest/xcode/build/Debug,
1.176 - );
1.177 - PRODUCT_NAME = SafeStorageTest;
1.178 + PRODUCT_NAME = OttomanTest;
1.179 };
1.180 name = Release;
1.181 };
1.182 @@ -279,22 +343,49 @@
1.183 ARCHS = "$(ARCHS_STANDARD_32_BIT)";
1.184 DEAD_CODE_STRIPPING = YES;
1.185 GCC_C_LANGUAGE_STANDARD = c99;
1.186 + GCC_DYNAMIC_NO_PIC = YES;
1.187 + GCC_ENABLE_CPP_RTTI = NO;
1.188 GCC_PRECOMPILE_PREFIX_HEADER = YES;
1.189 GCC_PREPROCESSOR_DEFINITIONS = NDEBUG;
1.190 GCC_TREAT_WARNINGS_AS_ERRORS = YES;
1.191 + GCC_UNROLL_LOOPS = YES;
1.192 GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
1.193 + GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
1.194 GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
1.195 GCC_WARN_ABOUT_RETURN_TYPE = YES;
1.196 GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO;
1.197 GCC_WARN_SHADOW = NO;
1.198 GCC_WARN_UNINITIALIZED_AUTOS = YES;
1.199 + GCC_WARN_UNUSED_FUNCTION = YES;
1.200 GCC_WARN_UNUSED_VARIABLE = YES;
1.201 + LLVM_LTO = YES;
1.202 PREBINDING = NO;
1.203 + RUN_CLANG_STATIC_ANALYZER = NO;
1.204 SDKROOT = macosx10.5;
1.205 WARNING_CFLAGS = "-Wall";
1.206 };
1.207 name = Release;
1.208 };
1.209 + 276E5CAF10673160008A2171 /* Debug */ = {
1.210 + isa = XCBuildConfiguration;
1.211 + buildSettings = {
1.212 + COPY_PHASE_STRIP = NO;
1.213 + INSTALL_PATH = /usr/local/lib;
1.214 + PRODUCT_NAME = Ottoman;
1.215 + };
1.216 + name = Debug;
1.217 + };
1.218 + 276E5CB010673160008A2171 /* Release */ = {
1.219 + isa = XCBuildConfiguration;
1.220 + buildSettings = {
1.221 + COPY_PHASE_STRIP = YES;
1.222 + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
1.223 + GENERATE_MASTER_OBJECT_FILE = YES;
1.224 + INSTALL_PATH = /usr/local/lib;
1.225 + PRODUCT_NAME = Ottoman;
1.226 + };
1.227 + name = Release;
1.228 + };
1.229 /* End XCBuildConfiguration section */
1.230
1.231 /* Begin XCConfigurationList section */
1.232 @@ -316,6 +407,15 @@
1.233 defaultConfigurationIsVisible = 0;
1.234 defaultConfigurationName = Release;
1.235 };
1.236 + 276E5CC9106731D5008A2171 /* Build configuration list for PBXNativeTarget "Static Library" */ = {
1.237 + isa = XCConfigurationList;
1.238 + buildConfigurations = (
1.239 + 276E5CAF10673160008A2171 /* Debug */,
1.240 + 276E5CB010673160008A2171 /* Release */,
1.241 + );
1.242 + defaultConfigurationIsVisible = 0;
1.243 + defaultConfigurationName = Release;
1.244 + };
1.245 /* End XCConfigurationList section */
1.246 };
1.247 rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
2.1 --- a/include/File.h Sun Sep 20 20:39:24 2009 -0700
2.2 +++ b/include/File.h Sun Sep 20 21:25:47 2009 -0700
2.3 @@ -89,6 +89,8 @@
2.4
2.5 private:
2.6 static int _open (const char *filename, int posixMode) throw(Error);
2.7 + static ssize_t _check (ssize_t result) throw(Error) {_check((int)result); return result;}
2.8 + static off_t _check (off_t result) throw(Error) {_check((int)result); return result;}
2.9 static int _check (int result) throw(Error);
2.10 static void _checkRead (ssize_t result, size_t expectedSize) throw(Error);
2.11 bool _lock (bool block);
3.1 --- a/src/Chunk.cpp Sun Sep 20 20:39:24 2009 -0700
3.2 +++ b/src/Chunk.cpp Sun Sep 20 21:25:47 2009 -0700
3.3 @@ -37,13 +37,13 @@
3.4 }
3.5
3.6 size_t Chunk::writePadding (File *file) {
3.7 - int padding = file->position() & 0x03;
3.8 + off_t padding = file->position() & 0x03;
3.9 if (padding == 0)
3.10 return 0;
3.11 else {
3.12 padding = 4 - padding;
3.13 uint32_t zero = 0;
3.14 - Blob pad(&zero, padding);
3.15 + Blob pad(&zero, (size_t)padding);
3.16 return writeMultiple(file, kChunkTypePadding, &pad, 1);
3.17 }
3.18 }
3.19 @@ -103,7 +103,7 @@
3.20 ChunkIterator::ChunkIterator (File* file, FilePosition start)
3.21 :_file(file),
3.22 _pos(start),
3.23 - _length(_file->length()),
3.24 + _length((FilePosition)_file->length()),
3.25 _chunk(NULL)
3.26 {
3.27 _loadChunk();
4.1 --- a/src/Dictionary.cpp Sun Sep 20 20:39:24 2009 -0700
4.2 +++ b/src/Dictionary.cpp Sun Sep 20 21:25:47 2009 -0700
4.3 @@ -26,8 +26,8 @@
4.4
4.5
4.6 const int Dictionary::kMinSize = 8;
4.7 - const float Dictionary::kMinLoadFactor = 0.25;
4.8 - const float Dictionary::kMaxLoadFactor = 0.75;
4.9 + const float Dictionary::kMinLoadFactor = 0.25f;
4.10 + const float Dictionary::kMaxLoadFactor = 0.75f;
4.11
4.12 // Choose the smallest power of two that's large enough to hold the given capacity
4.13 // of entries with no greater than the given load (fraction full).
5.1 --- a/src/File.cpp Sun Sep 20 20:39:24 2009 -0700
5.2 +++ b/src/File.cpp Sun Sep 20 21:25:47 2009 -0700
5.3 @@ -88,7 +88,7 @@
5.4 }
5.5
5.6 size_t File::writePadding (int alignment) {
5.7 - off_t pad = alignment - (position() & (alignment-1));
5.8 + int pad = alignment - (int)(position() & (alignment-1));
5.9 if (pad == alignment)
5.10 return 0;
5.11 uint8_t zero[pad];
6.1 --- a/src/Index.cpp Sun Sep 20 20:39:24 2009 -0700
6.2 +++ b/src/Index.cpp Sun Sep 20 21:25:47 2009 -0700
6.3 @@ -24,7 +24,7 @@
6.4 #define PROBE_QUADRATIC 0
6.5
6.6 // Similarly use a higher max load than for memory-resident tables, to save space.
6.7 - static const float kMaxLoadFactor = 0.85;
6.8 + static const float kMaxLoadFactor = 0.85f;
6.9
6.10 static const uint32_t kIndexMagicNumber = 0x54378543;
6.11
7.1 --- a/src/MemoryMap.cpp Sun Sep 20 20:39:24 2009 -0700
7.2 +++ b/src/MemoryMap.cpp Sun Sep 20 21:25:47 2009 -0700
7.3 @@ -22,13 +22,13 @@
7.4 }
7.5
7.6 void MemoryMap::mapRegion (off_t pos, size_t length) {
7.7 - size_t end = pos+length;
7.8 + off_t end = pos+length;
7.9 for (int i=0; i<_nRegions; i++) {
7.10 Region *region = _regions[i];
7.11 if (region->position() <= pos) {
7.12 if (end <= region->end())
7.13 return; // found an existing region covering this range
7.14 - else if (region->setLength(end - region->position()))
7.15 + else if (region->setLength((size_t)(end - region->position())))
7.16 return; // able to grow the existing region
7.17 }
7.18 }
8.1 --- a/src/VersionDictionary.cpp Sun Sep 20 20:39:24 2009 -0700
8.2 +++ b/src/VersionDictionary.cpp Sun Sep 20 21:25:47 2009 -0700
8.3 @@ -127,7 +127,7 @@
8.4 off_t pos = _file->setPositionToEnd(sizeof(VersionDictionary::Trailer));
8.5 if (pos < 0 || (pos & 0x03) || pos > UINT32_MAX)
8.6 throw File::Error(ERANGE, "No trailer found in file (wrong EOF)");
8.7 - trailerPos = pos;
8.8 + trailerPos = (FilePosition)pos;
8.9 }
8.10
8.11 // Read & verify trailer:
8.12 @@ -201,7 +201,7 @@
8.13 // Lock the file now, seek to the end, and make sure it's been prepared with a header,
8.14 // since FilePositions of 0 and 1 are reserved.
8.15 File::Lock lock(dstFile);
8.16 - const FilePosition startPos = dstFile->setPositionToEnd();
8.17 + const FilePosition startPos = (FilePosition) dstFile->setPositionToEnd();
8.18 if (startPos <= 1)
8.19 throw File::Error(ERANGE, "Cannot write VersionDictionary to empty file");
8.20