From 9072b0c98ba4f9412885a1a32002ee7214fd3dc0 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 30 Jan 2014 03:36:23 +0000 Subject: Attempting to fix OSX compatibility, it's not 100%, but it builds and most things seem to work. We've also tested against LLVM. --- src/unstable/cachebase.h | 2 +- src/unstable/uuid.cpp | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src/unstable') diff --git a/src/unstable/cachebase.h b/src/unstable/cachebase.h index bb543dd..f3152d9 100644 --- a/src/unstable/cachebase.h +++ b/src/unstable/cachebase.h @@ -238,7 +238,7 @@ namespace Bu template CachePtr cast() { - return pCache->cast( *this ); + return pCache->template cast( *this ); } bool operator==( const MyType &rhs ) const diff --git a/src/unstable/uuid.cpp b/src/unstable/uuid.cpp index 304ea4a..bd6662a 100644 --- a/src/unstable/uuid.cpp +++ b/src/unstable/uuid.cpp @@ -9,6 +9,7 @@ #include "bu/file.h" #include "bu/formatter.h" #include "bu/membuf.h" +#include "bu/random.h" #include #ifdef WIN32 @@ -83,6 +84,7 @@ void Bu::Uuid::clear() Bu::Uuid Bu::Uuid::generate( Bu::Uuid::Type eType ) { + Uuid id; switch( eType ) { case Version1: @@ -90,19 +92,24 @@ Bu::Uuid Bu::Uuid::generate( Bu::Uuid::Type eType ) case Version3: case Version4: case Version5: + // Yeah... all of these are just random for now, a lot more + // platform specific code is required for a lot of these. + for( int j = 0; j < 16; j++ ) + { + id.data[j] = Bu::Random::rand(256); + } + break; + default: case System: #if defined(linux) Bu::File fIn( "/proc/sys/kernel/random/uuid", Bu::File::Read ); char dat[36]; fIn.read( dat, 36 ); - Uuid id; id.set( dat ); - return id; #elif defined(WIN32) UUID uuid; UuidCreate( &uuid ); - Uuid id; id.data[0] = ((unsigned char *)&uuid.Data1)[3]; id.data[1] = ((unsigned char *)&uuid.Data1)[2]; id.data[2] = ((unsigned char *)&uuid.Data1)[1]; @@ -113,11 +120,12 @@ Bu::Uuid Bu::Uuid::generate( Bu::Uuid::Type eType ) id.data[7] = ((unsigned char *)&uuid.Data3)[0]; memcpy( id.data+8, uuid.Data4, 8 ); - return id; #else -# error We should be using one of the other fallbacks, but your platform is not supported yet. Sorry. +#warning No platform specific UUID, falling back to random for now + return generate( Version4 ); #endif } + return id; } void Bu::Uuid::set( const Bu::String &sSrc ) -- cgit v1.2.3