aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2014-01-30 03:36:23 +0000
committerMike Buland <eichlan@xagasoft.com>2014-01-30 03:36:23 +0000
commit9072b0c98ba4f9412885a1a32002ee7214fd3dc0 (patch)
tree1f6f205c8f28da415fd12ce4a835b83efc52fb8c /src
parent86e37bec7b2101555635201f83352c0e054f1849 (diff)
downloadlibbu++-9072b0c98ba4f9412885a1a32002ee7214fd3dc0.tar.gz
libbu++-9072b0c98ba4f9412885a1a32002ee7214fd3dc0.tar.bz2
libbu++-9072b0c98ba4f9412885a1a32002ee7214fd3dc0.tar.xz
libbu++-9072b0c98ba4f9412885a1a32002ee7214fd3dc0.zip
Attempting to fix OSX compatibility, it's not 100%, but it builds and most things seem to work. We've also tested against LLVM.
Diffstat (limited to '')
-rw-r--r--src/compat/osx.h23
-rw-r--r--src/stable/minicron.cpp2
-rw-r--r--src/stable/random.h2
-rw-r--r--src/stable/sharedcore.h2
-rw-r--r--src/stable/string.cpp16
-rw-r--r--src/stable/string.h4
-rw-r--r--src/unstable/cachebase.h2
-rw-r--r--src/unstable/uuid.cpp18
8 files changed, 60 insertions, 9 deletions
diff --git a/src/compat/osx.h b/src/compat/osx.h
index 26dad4d..ae55507 100644
--- a/src/compat/osx.h
+++ b/src/compat/osx.h
@@ -21,6 +21,29 @@
21 21
22#include <sched.h> 22#include <sched.h>
23 23
24#define bu_inet_ntoa inet_ntoa
25#define bu_inet_addr inet_addr
26#define bu_select select
27#define bu_socket socket
28#define bu_shutdown shutdown
29#define bu_htons htons
30#define bu_htonl htonl
31#define bu_gethostbyname gethostbyname
32#define bu_freeaddrinfo freeaddrinfo
33#define bu_getaddrinfo getaddrinfo
34#define bu_connect connect
35#define bu_getpeername getpeername
36#define bu_setsockopt setsockopt
37#define bu_bind bind
38#define bu_listen listen
39#define bu_accept accept
40#define bu_send send
41#define bu_recv recv
42#define open64 open
43#define lseek64 lseek
44
45#define bu_gai_strerror gai_strerror
46
24#define pthread_yield() sched_yield() 47#define pthread_yield() sched_yield()
25#endif /* __APPLE__ */ 48#endif /* __APPLE__ */
26#endif 49#endif
diff --git a/src/stable/minicron.cpp b/src/stable/minicron.cpp
index 2f7e868..9d98682 100644
--- a/src/stable/minicron.cpp
+++ b/src/stable/minicron.cpp
@@ -317,7 +317,7 @@ time_t Bu::MiniCron::TimerBasic::nextTime()
317 if( tLast == -1 ) 317 if( tLast == -1 )
318 tLast = time( NULL ); 318 tLast = time( NULL );
319 319
320 Bu::String::const_iterator i = sSpec.begin(); 320 Bu::String::const_iterator i = const_cast<const Bu::String &>(sSpec).begin();
321 switch( lex( i ) ) 321 switch( lex( i ) )
322 { 322 {
323 case tokDaily: 323 case tokDaily:
diff --git a/src/stable/random.h b/src/stable/random.h
index b02c9e5..6dc3b45 100644
--- a/src/stable/random.h
+++ b/src/stable/random.h
@@ -8,11 +8,11 @@
8#define BU_RANDOM_H 8#define BU_RANDOM_H
9 9
10#include "bu/singleton.h" 10#include "bu/singleton.h"
11#include "bu/randombase.h"
11#include <stdint.h> 12#include <stdint.h>
12 13
13namespace Bu 14namespace Bu
14{ 15{
15 class RandomBase;
16 class Random : public Bu::Singleton<Bu::Random> 16 class Random : public Bu::Singleton<Bu::Random>
17 { 17 {
18 friend class Bu::Singleton<Bu::Random>; 18 friend class Bu::Singleton<Bu::Random>;
diff --git a/src/stable/sharedcore.h b/src/stable/sharedcore.h
index be60588..e79c3d6 100644
--- a/src/stable/sharedcore.h
+++ b/src/stable/sharedcore.h
@@ -104,7 +104,7 @@ namespace Bu
104 Shell clone() const 104 Shell clone() const
105 { 105 {
106 Shell s( dynamic_cast<const Shell &>(*this) ); 106 Shell s( dynamic_cast<const Shell &>(*this) );
107 s._hardCopy(); 107 dynamic_cast<_SharedType &>(s)._hardCopy();
108 return s; 108 return s;
109 } 109 }
110 110
diff --git a/src/stable/string.cpp b/src/stable/string.cpp
index bf3aac0..1ceaec1 100644
--- a/src/stable/string.cpp
+++ b/src/stable/string.cpp
@@ -173,6 +173,17 @@ Bu::String::String( const Bu::String::const_iterator &s,
173 append( s, e ); 173 append( s, e );
174} 174}
175 175
176Bu::String::String( const Bu::String::iterator &s )
177{
178 append( s );
179}
180
181Bu::String::String( const Bu::String::iterator &s,
182 const Bu::String::iterator &e )
183{
184 append( s, e );
185}
186
176Bu::String::~String() 187Bu::String::~String()
177{ 188{
178} 189}
@@ -317,6 +328,11 @@ void Bu::String::append( const const_iterator &s, const const_iterator &e )
317 } 328 }
318} 329}
319 330
331void Bu::String::append( const iterator &s, const iterator &e )
332{
333 append( const_iterator( s ), const_iterator( e ) );
334}
335
320void Bu::String::prepend( const String & sData ) 336void Bu::String::prepend( const String & sData )
321{ 337{
322 prepend( sData.getStr(), sData.getSize() ); 338 prepend( sData.getStr(), sData.getSize() );
diff --git a/src/stable/string.h b/src/stable/string.h
index 3f8452d..bd1fe6c 100644
--- a/src/stable/string.h
+++ b/src/stable/string.h
@@ -569,6 +569,8 @@ namespace Bu
569 String( long nSize ); 569 String( long nSize );
570 String( const const_iterator &s ); 570 String( const const_iterator &s );
571 String( const const_iterator &s, const const_iterator &e ); 571 String( const const_iterator &s, const const_iterator &e );
572 String( const iterator &s );
573 String( const iterator &s, const iterator &e );
572 virtual ~String(); 574 virtual ~String();
573 575
574 /** 576 /**
@@ -646,6 +648,8 @@ namespace Bu
646 */ 648 */
647 void append( const const_iterator &s, const const_iterator &e ); 649 void append( const const_iterator &s, const const_iterator &e );
648 650
651 void append( const iterator &s, const iterator &e );
652
649 /** 653 /**
650 * Prepend another String to this one. 654 * Prepend another String to this one.
651 *@param sData (String &) The String to prepend. 655 *@param sData (String &) The String to prepend.
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
238 template<typename castto> 238 template<typename castto>
239 CachePtr<keytype, castto, basetype> cast() 239 CachePtr<keytype, castto, basetype> cast()
240 { 240 {
241 return pCache->cast<obtype, castto>( *this ); 241 return pCache->template cast<obtype, castto>( *this );
242 } 242 }
243 243
244 bool operator==( const MyType &rhs ) const 244 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 @@
9#include "bu/file.h" 9#include "bu/file.h"
10#include "bu/formatter.h" 10#include "bu/formatter.h"
11#include "bu/membuf.h" 11#include "bu/membuf.h"
12#include "bu/random.h"
12#include <string.h> 13#include <string.h>
13 14
14#ifdef WIN32 15#ifdef WIN32
@@ -83,6 +84,7 @@ void Bu::Uuid::clear()
83 84
84Bu::Uuid Bu::Uuid::generate( Bu::Uuid::Type eType ) 85Bu::Uuid Bu::Uuid::generate( Bu::Uuid::Type eType )
85{ 86{
87 Uuid id;
86 switch( eType ) 88 switch( eType )
87 { 89 {
88 case Version1: 90 case Version1:
@@ -90,19 +92,24 @@ Bu::Uuid Bu::Uuid::generate( Bu::Uuid::Type eType )
90 case Version3: 92 case Version3:
91 case Version4: 93 case Version4:
92 case Version5: 94 case Version5:
95 // Yeah... all of these are just random for now, a lot more
96 // platform specific code is required for a lot of these.
97 for( int j = 0; j < 16; j++ )
98 {
99 id.data[j] = Bu::Random::rand(256);
100 }
101 break;
102
93 default: 103 default:
94 case System: 104 case System:
95#if defined(linux) 105#if defined(linux)
96 Bu::File fIn( "/proc/sys/kernel/random/uuid", Bu::File::Read ); 106 Bu::File fIn( "/proc/sys/kernel/random/uuid", Bu::File::Read );
97 char dat[36]; 107 char dat[36];
98 fIn.read( dat, 36 ); 108 fIn.read( dat, 36 );
99 Uuid id;
100 id.set( dat ); 109 id.set( dat );
101 return id;
102#elif defined(WIN32) 110#elif defined(WIN32)
103 UUID uuid; 111 UUID uuid;
104 UuidCreate( &uuid ); 112 UuidCreate( &uuid );
105 Uuid id;
106 id.data[0] = ((unsigned char *)&uuid.Data1)[3]; 113 id.data[0] = ((unsigned char *)&uuid.Data1)[3];
107 id.data[1] = ((unsigned char *)&uuid.Data1)[2]; 114 id.data[1] = ((unsigned char *)&uuid.Data1)[2];
108 id.data[2] = ((unsigned char *)&uuid.Data1)[1]; 115 id.data[2] = ((unsigned char *)&uuid.Data1)[1];
@@ -113,11 +120,12 @@ Bu::Uuid Bu::Uuid::generate( Bu::Uuid::Type eType )
113 id.data[7] = ((unsigned char *)&uuid.Data3)[0]; 120 id.data[7] = ((unsigned char *)&uuid.Data3)[0];
114 memcpy( id.data+8, uuid.Data4, 8 ); 121 memcpy( id.data+8, uuid.Data4, 8 );
115 122
116 return id;
117#else 123#else
118# error We should be using one of the other fallbacks, but your platform is not supported yet. Sorry. 124#warning No platform specific UUID, falling back to random for now
125 return generate( Version4 );
119#endif 126#endif
120 } 127 }
128 return id;
121} 129}
122 130
123void Bu::Uuid::set( const Bu::String &sSrc ) 131void Bu::Uuid::set( const Bu::String &sSrc )