Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of morran:mongo-nonx86-solaris

  • Loading branch information...
commit 84973465474aa4e634b3e5f51934947b6b506398 2 parents 0c5f8b9 + da85443
Per Ola Ingvarsson authored
View
56 SConstruct
@@ -252,6 +252,7 @@ windows = False
freebsd = False
openbsd = False
solaris = False
+bigendian = False # For snappy
force32 = has_option( "force32" )
force64 = has_option( "force64" )
if not force64 and not force32 and os.getcwd().endswith( "mongo-64" ):
@@ -514,6 +515,10 @@ elif "sunos5" == os.sys.platform:
solaris = True
env.Append( CPPDEFINES=[ "__sunos__" ] )
env.Append( LIBS=["socket","resolv"] )
+ # Need v9 for atomics when sparc
+ if processor.startswith( "sun4" ):
+ env.Append( CCFLAGS=[ "-mcpu=v9", "-m64" ] )
+ env.Append( LINKFLAGS=[ "-m64" ] )
elif os.sys.platform.startswith( "freebsd" ):
nix = True
@@ -690,8 +695,10 @@ if nix:
env.Append( CXXFLAGS=" -fprofile-arcs -ftest-coverage " )
env.Append( LINKFLAGS=" -fprofile-arcs -ftest-coverage " )
- if debugBuild:
- env.Append( CCFLAGS=["-O0", "-fstack-protector"] )
+ if debugBuild:
+ env.Append( CCFLAGS=["-O0" ] )
+ if not solaris:
+ env.Append( CCFLAGS=["-fstack-protector" ] )
env['ENV']['GLIBCXX_FORCE_NEW'] = 1; # play nice with valgrind
else:
env.Append( CCFLAGS=["-O3"] )
@@ -765,6 +772,26 @@ env.Append( CPPPATH=['$EXTRACPPPATH'],
# --- check system ---
+def CheckStackProtector( context ):
+ oldCFLAGS = context.env['CFLAGS']
+ context.env['CFLAGS'] = context.env['CFLAGS'] + " -fstack-protector "
+ context.Message( 'Checking if -fstack-protector works ...' )
+ res = context.TryLink( """
+ void __attribute__((noinline)) rolf( char* x ) {
+ for ( int i = 0; i < 8; ++i ) {
+ x[i] = 0;
+ }
+ }
+ int main( int argc, char** argv )
+ {
+ rolf( argv[0] );
+ }
+""", ".cc" )
+ context.env['CFLAGS'] = oldCFLAGS
+ context.Result( res )
+ return res
+
+
def CheckFetchAndAdd( context ):
context.Message( 'Checking for __sync_fetch_and_add ...' )
res = context.TryLink( """
@@ -821,13 +848,26 @@ def CheckAlignment( context ):
context.Result( res )
return res
+def CheckBigEndian( context ):
+ context.Message( 'Checking if system is big endian (for snappy) ...' )
+ res = context.TryCompile( """
+ #include "../src/third_party/boost/boost/detail/endian.hpp"
+ #ifdef BOOST_LITTLE_ENDIAN
+ #error "Little Endian"
+ #endif
+
+""", ".cc" )
+ context.Result( res )
+ return res
def doConfigure(myenv):
conf = Configure(myenv, custom_tests = {
'CheckFetchAndAdd' : CheckFetchAndAdd,
'CheckAlignment' : CheckAlignment,
'CheckSwap32' : CheckSwap32,
- 'CheckSwap64' : CheckSwap64
+ 'CheckSwap64' : CheckSwap64,
+ 'CheckBigEndian' : CheckBigEndian,
+ 'CheckStackProtector' : CheckStackProtector,
})
if 'CheckCXX' in dir( conf ):
@@ -887,6 +927,16 @@ def doConfigure(myenv):
env.Append( CPPDEFINES = ["HAVE_BSWAP32"] )
if conf.CheckSwap64():
env.Append( CPPDEFINES = ["HAVE_BSWAP64"] )
+ # Check endianess for snappy
+ bigendian = conf.CheckBigEndian()
+ Export( "bigendian" )
+
+ if not conf.CheckStackProtector():
+ try:
+ env['CCFLAGS'].remove( '-fstack-protector' )
+ except ValueError:
+ pass
+
# 'tcmalloc' needs to be the last library linked. Please, add new libraries before this
# point.
View
2  src/mongo/db/btree.h
@@ -181,7 +181,7 @@ namespace mongo {
// largest key size we allow. note we very much need to support bigger keys (somehow) in the future.
static const int KeyMax = OldBucketSize / 10;
// A sentinel value sometimes used to identify a deallocated bucket.
- static const int INVALID_N_SENTINEL = -1;
+ enum { INVALID_N_SENTINEL = -1 };
};
// a a a ofs ofs ofs ofs
View
1  src/mongo/db/dur.h
@@ -114,7 +114,6 @@ namespace mongo {
inline DiskLoc& writingDiskLoc(DiskLoc& d) { return *((DiskLoc*) writingPtr(&d, sizeof(d))); }
/** Declare write intent for an int */
- inline int& writingInt(int& d) { return *static_cast<int*>(writingPtr( &d, sizeof(d))); }
inline little<int>& writingInt( little<int>& d) { return *static_cast<little<int>*>(writingPtr( &d, sizeof(d))); }
/** "assume i've already indicated write intent, let me write"
View
2  src/mongo/db/dur_journalformat.h
@@ -151,7 +151,7 @@ namespace mongo {
/** declares "the next entry(s) are for this database / file path prefix" */
struct JDbContext {
JDbContext() : sentinel(JEntry::OpCode_DbContext) { }
- const unsigned sentinel; // compare to JEntry::len -- zero is our sentinel
+ const little<unsigned> sentinel; // compare to JEntry::len -- zero is our sentinel
//char dbname[];
};
View
12 src/mongo/db/instance.cpp
@@ -106,8 +106,8 @@ namespace mongo {
// OpTime::now() uses mutex, thus it is in this file not in the cpp files used by drivers and such
void BSONElementManipulator::initTimestamp() {
- massert( 10332 , "Expected CurrentTime type", _element.type() == Timestamp );
- unsigned long long &timestamp = *( reinterpret_cast< unsigned long long* >( value() ) );
+ massert( 10332 , "Expected CurrentTime type", _element.type() == Timestamp );
+ little<unsigned long long> &timestamp = little< unsigned long long >::ref( value() );
if ( timestamp == 0 ) {
mutex::scoped_lock lk(OpTime::m);
timestamp = OpTime::now(lk).asDate();
@@ -115,18 +115,18 @@ namespace mongo {
}
void BSONElementManipulator::SetNumber(double d) {
if ( _element.type() == NumberDouble )
- *getDur().writing( reinterpret_cast< double * >( value() ) ) = d;
+ *getDur().writing( &little< double >::ref( value() ) ) = d;
else if ( _element.type() == NumberInt )
- *getDur().writing( reinterpret_cast< int * >( value() ) ) = (int) d;
+ *getDur().writing( &little< int >::ref( value() ) ) = (int) d;
else verify(0);
}
void BSONElementManipulator::SetLong(long long n) {
verify( _element.type() == NumberLong );
- *getDur().writing( reinterpret_cast< long long * >(value()) ) = n;
+ *getDur().writing( &little< long long >::ref( value() ) ) = n;
}
void BSONElementManipulator::SetInt(int n) {
verify( _element.type() == NumberInt );
- getDur().writingInt( *reinterpret_cast< int * >( value() ) ) = n;
+ getDur().writingInt( little< int >::ref( value() ) ) = n;
}
/* dur:: version */
void BSONElementManipulator::ReplaceTypeAndValue( const BSONElement &e ) {
View
2  src/mongo/db/key.cpp
@@ -290,7 +290,7 @@ namespace mongo {
}
case Date:
b.appendUChar(cdate|bits);
- b.appendStruct(e.date());
+ b.appendNum( ( unsigned long long) e.date());
break;
case String:
{
View
6 src/mongo/db/matcher.cpp
@@ -1208,11 +1208,9 @@ namespace mongo {
char eoo;
};
-#pragma pack()
struct JSObj1 js1;
-
-#pragma pack(1)
+
struct JSObj2 {
JSObj2() {
totsize=sizeof(JSObj2);
@@ -1229,6 +1227,7 @@ namespace mongo {
char sval[10];
char eoo;
} js2;
+#pragma pack()
struct JSUnitTest : public StartupTest {
void run() {
@@ -1261,7 +1260,6 @@ namespace mongo {
}
} jsunittest;
-#pragma pack()
struct RXTest : public StartupTest {
View
2  src/mongo/db/pdfile.cpp
@@ -1716,10 +1716,10 @@ namespace mongo {
verify( sizeof(IDToInsert_) == 17 );
}
} idToInsert_;
+#pragma pack()
struct IDToInsert : public BSONElement {
IDToInsert() : BSONElement( ( char * )( &idToInsert_ ) ) {}
} idToInsert;
-#pragma pack()
void DataFileMgr::insertAndLog( const char *ns, const BSONObj &o, bool god, bool fromMigrate ) {
BSONObj tmp = o;
View
3  src/mongo/dbtests/perftests.cpp
@@ -1,3 +1,4 @@
+
/** @file perftests.cpp.cpp : unit tests relating to performance
The idea herein is tests that run fast and can be part of the normal CI suite. So no tests herein that take
@@ -901,7 +902,7 @@ namespace PerfTests {
void prep() {
{
// the checksum code assumes 'standard' rollover on addition overflows. let's check that:
- unsigned long long x = 0xffffffffffffffffULL;
+ little<unsigned long long> x = 0xffffffffffffffffULL;
ASSERT( x+2 == 1 );
}
View
2  src/mongo/tools/sniffer.cpp
@@ -359,7 +359,7 @@ void processMessage( Connection& c , Message& m ) {
if ( m.operation() == mongo::dbGetMore ) {
DbMessage d( m );
d.pullInt();
- little<long long> &cId = d.pullInt64();
+ mongo::little<long long> &cId = d.pullInt64();
cId = mapCursor[ c ][ cId ];
}
Message response;
View
4 src/mongo/util/checksum.h
@@ -5,14 +5,14 @@ namespace mongo {
struct Checksum {
union {
unsigned char bytes[16];
- unsigned long long words[2];
+ little_pod<unsigned long long> words[2];
};
// if you change this you must bump dur::CurrentVersion
void gen(const void *buf, unsigned len) {
wassert( ((size_t)buf) % 8 == 0 ); // performance warning
unsigned n = len / 8 / 2;
- const unsigned long long *p = (const unsigned long long *) buf;
+ const little<unsigned long long> *p = &little<unsigned long long>::ref( buf );
unsigned long long a = 0;
for( unsigned i = 0; i < n; i++ ) {
a += (*p ^ i);
View
7 src/third_party/js-1.7/SConscript
@@ -12,18 +12,21 @@ env = env.Clone()
env.Append(CPPDEFINES=["JSFILE", "EXPORT_JS_API", "JS_C_STRINGS_ARE_UTF8"])
-for to_remove in ['-Werror', '/TP', '/O2', '/Gy']:
+for to_remove in ['-Werror', '-Wcast-align', '/TP', '/O2', '/Gy']:
removeIfPresent(env['CCFLAGS'], to_remove)
if windows:
env.Append(CCFLAGS=['/wd4748'])
+else:
+ # Force language to be c. Does not work when setting --cxx=g++ otherwise
+ env.Append(CCFLAGS=['-xc'])
removeIfPresent(env['CPPDEFINES'], 'NDEBUG')
if linux or darwin or freebsd:
env.Append(CPPDEFINES=['HAVE_VA_COPY', 'VA_COPY=va_copy'])
elif solaris:
- env.Append(CPPDEFINES=['SOLARIS', 'HAVE_VA_LIST_AS_ARRAY', 'SVR4', 'SYSV', 'HAVE_LOCALTIME_R'])
+ env.Append(CPPDEFINES=['SOLARIS', 'HAVE_VA_COPY', 'VA_COPY=va_copy', 'SVR4', 'SYSV', 'HAVE_LOCALTIME_R'])
env.Program('jskwgen', 'jskwgen.c')
env.Program('jscpucfg', 'jscpucfg.c')
View
4 src/third_party/snappy/SConscript
@@ -1,9 +1,13 @@
# -*- mode: python -*-
Import("env windows")
+Import("bigendian")
if not windows:
env = env.Clone()
env.Append(CCFLAGS=['-Wno-sign-compare', '-Wno-unused-function'])
+if bigendian:
+ env.Append(CPPDEFINES=[ 'WORDS_BIGENDIAN' ])
+
env.StaticLibrary('snappy', ['snappy.cc', 'snappy-sinksource.cc'])
View
21 src/third_party/snappy/snappy-stubs-internal.h
@@ -179,8 +179,7 @@ class LogMessageVoidify {
// Potentially unaligned loads and stores.
-#if 1
-//#if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || defined(_WIN32)
+#if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || defined(_WIN32)
#define UNALIGNED_LOAD16(_p) (*reinterpret_cast<const uint16 *>(_p))
#define UNALIGNED_LOAD32(_p) (*reinterpret_cast<const uint32 *>(_p))
@@ -243,8 +242,24 @@ inline void UNALIGNED_STORE64(void *p, uint64 v) {
#define bswap_32(x) OSSwapInt32(x)
#define bswap_64(x) OSSwapInt64(x)
-#else
+#elif defined(__linux__)
#include <byteswap.h>
+#else
+inline uint16 bswap_16(uint16 x) {
+ return (x << 8) | (x >> 8);
+}
+
+inline uint32 bswap_32(uint32 x) {
+ x = ((x & 0xff00ff00UL) >> 8) | ((x & 0x00ff00ffUL) << 8);
+ return (x >> 16) | (x << 16);
+}
+
+inline uint64 bswap_64(uint64 x) {
+ x = ((x & 0xff00ff00ff00ff00ULL) >> 8) | ((x & 0x00ff00ff00ff00ffULL) << 8);
+ x = ((x & 0xffff0000ffff0000ULL) >> 16) | ((x & 0x0000ffff0000ffffULL) << 16);
+ return (x >> 32) | (x << 32);
+}
+
#endif
#endif // WORDS_BIGENDIAN
Please sign in to comment.
Something went wrong with that request. Please try again.