From 2ecba0797ceb66fd6d11deac2faddb815240150d Mon Sep 17 00:00:00 2001 From: jed Date: Thu, 4 Oct 2012 02:31:31 -0700 Subject: [PATCH 1/7] windows --- newcoin.vcxproj | 5 +---- newcoin.vcxproj.filters | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/newcoin.vcxproj b/newcoin.vcxproj index c053c90f59..aafa214ad2 100644 --- a/newcoin.vcxproj +++ b/newcoin.vcxproj @@ -248,17 +248,14 @@ Designer - - - Document ..\protoc-2.4.1-win32\protoc -I=..\newcoin\src --cpp_out=..\newcoin\obj\src ..\newcoin\src\newcoin.proto obj\src\newcoin.pb.h + - diff --git a/newcoin.vcxproj.filters b/newcoin.vcxproj.filters index b8c3acee1e..9a6fa8ac81 100644 --- a/newcoin.vcxproj.filters +++ b/newcoin.vcxproj.filters @@ -506,16 +506,13 @@ - html - - - + From 70b01af8bf7196c3210ed901439665a4384bb4a1 Mon Sep 17 00:00:00 2001 From: jed Date: Fri, 5 Oct 2012 04:13:18 -0700 Subject: [PATCH 2/7] build on mac --- src/utils.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/utils.h b/src/utils.h index eab185b34a..3237d6d555 100644 --- a/src/utils.h +++ b/src/utils.h @@ -18,13 +18,21 @@ #define isSetBit(x,y) (!!((x) & (y))) +// maybe use http://www.mail-archive.com/licq-commits@googlegroups.com/msg02334.html #ifdef WIN32 extern uint64_t htobe64(uint64_t value); extern uint64_t be64toh(uint64_t value); extern uint32_t htobe32(uint32_t value); extern uint32_t be32toh(uint32_t value); +#elif __APPLE__ +#define be16toh(x) betoh16(x) +#define be32toh(x) betoh32(x) +#define be64toh(x) betoh64(x) +#define h64tobe(x) htobe64(x) +#define h32tobe(x) htobe32(x) #endif + #define vt_f_black "\033[30m" #define vt_f_red "\033[31m" #define vt_f_green "\033[32m" From 75bf3204769e00d86ec7e4c83990009c48edbb97 Mon Sep 17 00:00:00 2001 From: jed Date: Fri, 5 Oct 2012 07:23:10 -0700 Subject: [PATCH 3/7] fix deadlock --- newcoin.vcxproj | 5 ++++- newcoin.vcxproj.filters | 16 +++++++++++++--- src/FieldNames.cpp | 25 ++++++++++++++----------- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/newcoin.vcxproj b/newcoin.vcxproj index 4a7bdee1dd..9837569aed 100644 --- a/newcoin.vcxproj +++ b/newcoin.vcxproj @@ -103,10 +103,10 @@ - + @@ -136,6 +136,7 @@ + @@ -156,7 +157,9 @@ + + diff --git a/newcoin.vcxproj.filters b/newcoin.vcxproj.filters index f569d1ac42..b638955b76 100644 --- a/newcoin.vcxproj.filters +++ b/newcoin.vcxproj.filters @@ -63,9 +63,6 @@ Source Files - - Source Files - Source Files @@ -294,6 +291,18 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + @@ -557,6 +566,7 @@ + diff --git a/src/FieldNames.cpp b/src/FieldNames.cpp index 2946ca2552..545f8af3d0 100644 --- a/src/FieldNames.cpp +++ b/src/FieldNames.cpp @@ -33,15 +33,16 @@ SField::ref SField::getField(int code) if ((type <= 0) || (field <= 0)) return sfInvalid; + { //JED: Did this to fix a deadlock. david you should check. Line after this block also has a scoped lock + // why doe sthis thing even need a mutex? + boost::mutex::scoped_lock sl(mapMutex); - boost::mutex::scoped_lock sl(mapMutex); + std::map::iterator it = codeToField.find(code); + if (it != codeToField.end()) + return *(it->second); - std::map::iterator it = codeToField.find(code); - if (it != codeToField.end()) - return *(it->second); - - switch (type) - { // types we are willing to dynamically extend + switch (type) + { // types we are willing to dynamically extend #define FIELD(name, type, index) #define TYPE(name, type, index) case STI_##type: @@ -50,11 +51,13 @@ SField::ref SField::getField(int code) #undef TYPE break; - default: - return sfInvalid; - } +default: + return sfInvalid; + } - std::string dynName = lexical_cast_i(type) + "/" + lexical_cast_i(field); + std::string dynName = lexical_cast_i(type) + "/" + lexical_cast_i(field); + }// end scope lock + return *(new SField(code, static_cast(type), field, dynName.c_str())); } From 720178cc0d84e6eca462e5af2289dcab7c1470d0 Mon Sep 17 00:00:00 2001 From: jed Date: Fri, 5 Oct 2012 07:24:46 -0700 Subject: [PATCH 4/7] . --- src/FieldNames.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/FieldNames.cpp b/src/FieldNames.cpp index 545f8af3d0..32d4e6b6ea 100644 --- a/src/FieldNames.cpp +++ b/src/FieldNames.cpp @@ -55,9 +55,9 @@ default: return sfInvalid; } - std::string dynName = lexical_cast_i(type) + "/" + lexical_cast_i(field); + }// end scope lock - + std::string dynName = lexical_cast_i(type) + "/" + lexical_cast_i(field); return *(new SField(code, static_cast(type), field, dynName.c_str())); } From 047548b30bd5807c3b878bebde9209e7fe368148 Mon Sep 17 00:00:00 2001 From: Andrey Fedorov Date: Fri, 5 Oct 2012 11:31:45 -0400 Subject: [PATCH 5/7] fix for building on OSX Copied from this fink package: http://mirror.lug.udel.edu/pub/fink/finkinfo/10.7/stable/main/finkinfo/d evel/endian-dev.info --- src/utils.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/utils.h b/src/utils.h index 3237d6d555..5b4d184e73 100644 --- a/src/utils.h +++ b/src/utils.h @@ -25,11 +25,22 @@ extern uint64_t be64toh(uint64_t value); extern uint32_t htobe32(uint32_t value); extern uint32_t be32toh(uint32_t value); #elif __APPLE__ -#define be16toh(x) betoh16(x) -#define be32toh(x) betoh32(x) -#define be64toh(x) betoh64(x) -#define h64tobe(x) htobe64(x) -#define h32tobe(x) htobe32(x) +#include + +#define htobe16(x) OSSwapHostToBigInt16(x) +#define htole16(x) OSSwapHostToLittleInt16(x) +#define be16toh(x) OSSwapBigToHostInt16(x) +#define le16toh(x) OSSwapLittleToHostInt16(x) + +#define htobe32(x) OSSwapHostToBigInt32(x) +#define htole32(x) OSSwapHostToLittleInt32(x) +#define be32toh(x) OSSwapBigToHostInt32(x) +#define le32toh(x) OSSwapLittleToHostInt32(x) + +#define htobe64(x) OSSwapHostToBigInt64(x) +#define htole64(x) OSSwapHostToLittleInt64(x) +#define be64toh(x) OSSwapBigToHostInt64(x) +#define le64toh(x) OSSwapLittleToHostInt64(x) #endif From 8c4ac316cc893f6f9569c50bd5711d4c85e08e70 Mon Sep 17 00:00:00 2001 From: Andrey Fedorov Date: Fri, 5 Oct 2012 12:32:17 -0400 Subject: [PATCH 6/7] formatting fixes in SConstruct --- SConstruct | 79 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/SConstruct b/SConstruct index 18178dafe3..43a3db27bc 100644 --- a/SConstruct +++ b/SConstruct @@ -11,8 +11,8 @@ CTAGS = '/usr/bin/exuberant-ctags' # env = Environment( - tools = ['default', 'protoc'] - ) + tools = ['default', 'protoc'] +) # Use clang #env.Replace(CC = 'clang') @@ -29,67 +29,70 @@ env.Replace(CTAGS = CTAGS, CTAGSOPTIONS = '--tag-relative') # Put objects files in their own directory. # for dir in ['src', 'database', 'json', 'websocketpp']: - VariantDir('obj/'+dir, dir, duplicate=0) + VariantDir('obj/'+dir, dir, duplicate=0) # Use openssl env.ParseConfig('pkg-config --cflags --libs openssl') -env.Append(LIBS = [ - 'boost_date_time-mt', - 'boost_filesystem-mt', - 'boost_program_options-mt', - 'boost_regex-mt', - 'boost_system-mt', - 'boost_thread-mt', - 'protobuf', - 'dl', # dynamic linking - 'z' - ]) +env.Append( + LIBS = [ + 'boost_date_time-mt', + 'boost_filesystem-mt', + 'boost_program_options-mt', + 'boost_regex-mt', + 'boost_system-mt', + 'boost_thread-mt', + 'protobuf', + 'dl', # dynamic linking + 'z' + ] +) -DEBUGFLAGS = ['-g', '-DDEBUG'] -BOOSTFLAGS = ['-DBOOST_TEST_DYN_LINK', '-DBOOST_FILESYSTEM_NO_DEPRECATED'] +DEBUGFLAGS = ['-g', '-DDEBUG'] +BOOSTFLAGS = ['-DBOOST_TEST_DYN_LINK', '-DBOOST_FILESYSTEM_NO_DEPRECATED'] env.Append(LINKFLAGS = ['-rdynamic', '-pthread']) env.Append(CCFLAGS = ['-pthread', '-Wall', '-Wno-sign-compare', '-Wno-char-subscripts', '-DSQLITE_THREADSAFE']) env.Append(CXXFLAGS = ['-O0', '-pthread', '-Wno-invalid-offsetof', '-Wformat']+BOOSTFLAGS+DEBUGFLAGS) -DB_SRCS = glob.glob('database/*.c') + glob.glob('database/*.cpp') -JSON_SRCS = glob.glob('json/*.cpp') -WEBSOCKETPP_SRCS = [ - 'websocketpp/src/base64/base64.cpp', - 'websocketpp/src/md5/md5.c', - 'websocketpp/src/messages/data.cpp', - 'websocketpp/src/network_utilities.cpp', - 'websocketpp/src/processors/hybi_header.cpp', - 'websocketpp/src/processors/hybi_util.cpp', - 'websocketpp/src/sha1/sha1.cpp', - 'websocketpp/src/uri.cpp' - ] +DB_SRCS = glob.glob('database/*.c') + glob.glob('database/*.cpp') +JSON_SRCS = glob.glob('json/*.cpp') -NEWCOIN_SRCS = glob.glob('src/*.cpp') -PROTO_SRCS = env.Protoc([], 'src/newcoin.proto', PROTOCOUTDIR='obj', PROTOCPYTHONOUTDIR=None) +WEBSOCKETPP_SRCS = [ + 'websocketpp/src/base64/base64.cpp', + 'websocketpp/src/md5/md5.c', + 'websocketpp/src/messages/data.cpp', + 'websocketpp/src/network_utilities.cpp', + 'websocketpp/src/processors/hybi_header.cpp', + 'websocketpp/src/processors/hybi_util.cpp', + 'websocketpp/src/sha1/sha1.cpp', + 'websocketpp/src/uri.cpp' + ] + +NEWCOIN_SRCS = glob.glob('src/*.cpp') +PROTO_SRCS = env.Protoc([], 'src/newcoin.proto', PROTOCOUTDIR='obj', PROTOCPYTHONOUTDIR=None) env.Clean(PROTO_SRCS, 'site_scons/site_tools/protoc.pyc') # Remove unused source files. -UNUSED_SRCS = ['src/HttpReply.cpp'] +UNUSED_SRCS = ['src/HttpReply.cpp'] for file in UNUSED_SRCS: - NEWCOIN_SRCS.remove(file) + NEWCOIN_SRCS.remove(file) -NEWCOIN_SRCS += DB_SRCS + JSON_SRCS + WEBSOCKETPP_SRCS +NEWCOIN_SRCS += DB_SRCS + JSON_SRCS + WEBSOCKETPP_SRCS # Derive the object files from the source files. -NEWCOIN_OBJS = [] +NEWCOIN_OBJS = [] for file in NEWCOIN_SRCS: - NEWCOIN_OBJS.append('obj/' + file) + NEWCOIN_OBJS.append('obj/' + file) -NEWCOIN_OBJS += PROTO_SRCS +NEWCOIN_OBJS += PROTO_SRCS -newcoind = env.Program('newcoind', NEWCOIN_OBJS) +newcoind = env.Program('newcoind', NEWCOIN_OBJS) -tags = env.CTags('obj/tags', NEWCOIN_SRCS) +tags = env.CTags('obj/tags', NEWCOIN_SRCS) Default(newcoind, tags) From b304d9ae4326ee3342de880437c612fb9900b3a7 Mon Sep 17 00:00:00 2001 From: Andrey Fedorov Date: Fri, 5 Oct 2012 12:34:14 -0400 Subject: [PATCH 7/7] fixed SConstruct to build on OSX --- SConstruct | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/SConstruct b/SConstruct index 43a3db27bc..da429bacac 100644 --- a/SConstruct +++ b/SConstruct @@ -3,8 +3,14 @@ # import glob +import platform -CTAGS = '/usr/bin/exuberant-ctags' +OSX = bool(platform.mac_ver()[0]) + +if OSX: + CTAGS = '/usr/bin/ctags' +else: + CTAGS = '/usr/bin/exuberant-ctags' # # scons tools @@ -23,7 +29,10 @@ env = Environment( # ctags = Builder(action = '$CTAGS $CTAGSOPTIONS -f $TARGET $SOURCES') env.Append(BUILDERS = { 'CTags' : ctags }) -env.Replace(CTAGS = CTAGS, CTAGSOPTIONS = '--tag-relative') +if OSX: + env.Replace(CTAGS = CTAGS) +else: + env.Replace(CTAGS = CTAGS, CTAGSOPTIONS = '--tag-relative') # # Put objects files in their own directory. @@ -55,6 +64,10 @@ env.Append(LINKFLAGS = ['-rdynamic', '-pthread']) env.Append(CCFLAGS = ['-pthread', '-Wall', '-Wno-sign-compare', '-Wno-char-subscripts', '-DSQLITE_THREADSAFE']) env.Append(CXXFLAGS = ['-O0', '-pthread', '-Wno-invalid-offsetof', '-Wformat']+BOOSTFLAGS+DEBUGFLAGS) +if OSX: + env.Append(LINKFLAGS = ['-L/usr/local/Cellar/openssl/1.0.1c/lib']) + env.Append(CXXFLAGS = ['-I/usr/local/Cellar/openssl/1.0.1c/include']) + DB_SRCS = glob.glob('database/*.c') + glob.glob('database/*.cpp') JSON_SRCS = glob.glob('json/*.cpp')