diff --git a/SConstruct b/SConstruct index 18178dafe3..da429bacac 100644 --- a/SConstruct +++ b/SConstruct @@ -3,16 +3,22 @@ # 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 # env = Environment( - tools = ['default', 'protoc'] - ) + tools = ['default', 'protoc'] +) # Use clang #env.Replace(CC = 'clang') @@ -23,73 +29,83 @@ 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. # 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' - ] +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']) -NEWCOIN_SRCS = glob.glob('src/*.cpp') -PROTO_SRCS = env.Protoc([], 'src/newcoin.proto', PROTOCOUTDIR='obj', PROTOCPYTHONOUTDIR=None) +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' + ] + +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) diff --git a/newcoin.vcxproj b/newcoin.vcxproj index 0f21cebefa..9837569aed 100644 --- a/newcoin.vcxproj +++ b/newcoin.vcxproj @@ -103,10 +103,10 @@ - + @@ -136,6 +136,7 @@ + @@ -156,7 +157,9 @@ + + @@ -270,6 +273,7 @@ ..\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 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 122550eb18..be5fe00201 100644 --- a/src/FieldNames.cpp +++ b/src/FieldNames.cpp @@ -34,6 +34,8 @@ SField::ref SField::getField(int code) if ((type <= 0) || (field <= 0)) return sfInvalid; + boost::mutex::scoped_lock sl(mapMutex); + boost::recursive_mutex::scoped_lock sl(mapMutex); std::map::iterator it = codeToField.find(code); diff --git a/src/utils.h b/src/utils.h index eab185b34a..5b4d184e73 100644 --- a/src/utils.h +++ b/src/utils.h @@ -18,13 +18,32 @@ #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__ +#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 + #define vt_f_black "\033[30m" #define vt_f_red "\033[31m" #define vt_f_green "\033[32m"