From 2eb219a77d0f2ea6dc87be2cb054a7ea06f6e457 Mon Sep 17 00:00:00 2001 From: Jerome Duval Date: Sun, 17 May 2015 18:03:50 +0000 Subject: Haiku patch diff --git a/SConstruct b/SConstruct index afdb48f..5637922 100644 --- a/SConstruct +++ b/SConstruct @@ -102,8 +102,8 @@ else: env.Append(CCFLAGS=['-O3']) env.Append(CPPFLAGS=['-O3']) - env.Append(CPPFLAGS=['-Wall', '-Wno-deprecated', '-pedantic', '-Wno-long-long', '-pipe', '-pthread']) - env.Append(CCFLAGS=['-Wall', '-Wno-deprecated', '-pedantic', '-Wno-long-long', '-pipe', '-pthread']) + env.Append(CPPFLAGS=['-Wall', '-Wno-deprecated', '-pedantic', '-Wno-long-long', '-pipe']) + env.Append(CCFLAGS=['-Wall', '-Wno-deprecated', '-pedantic', '-Wno-long-long', '-pipe']) conf_env = env.Clone() @@ -154,7 +154,10 @@ if sys.platform == 'win32': Exit(1) if sys.platform != 'win32': - have_sse = conf.CheckLibWithHeader('m', "xmmintrin.h", 'c', '_mm_set_ss(1.0f);', False) + if sys.platform != 'haiku1': + have_sse = conf.CheckLibWithHeader('m', "xmmintrin.h", 'c', '_mm_set_ss(1.0f);', False) + else: + have_sse = False else: have_sse = conf.CheckLibWithHeader('kernel32', "xmmintrin.h", 'c', '_mm_set_ss(1.0f);', False) # hackish lib :( diff --git a/clunk/SConscript b/clunk/SConscript index d528be8..4211daf 100644 --- a/clunk/SConscript +++ b/clunk/SConscript @@ -17,7 +17,8 @@ clunk_libs = ['SDL'] if sys.platform != 'win32': env.Append(LINKFLAGS=['-Wl,-rpath,'+ lib_dir]) - clunk_libs.append('m') + if sys.platform != 'haiku1': + clunk_libs.append('m') env.MergeFlags(sdl_cflags, sdl_libs) diff --git a/clunk/source.cpp b/clunk/source.cpp index d7829c8..64bfc5a 100644 --- a/clunk/source.cpp +++ b/clunk/source.cpp @@ -27,7 +27,7 @@ #include #include "clunk_assert.h" -#if defined _MSC_VER || __APPLE__ || __FreeBSD__ +#if defined _MSC_VER || __APPLE__ || __FreeBSD__ || __HAIKU__ # define pow10f(x) powf(10.0f, (x)) # define log2f(x) (logf(x) / M_LN2) #endif diff --git a/engine/luaxx/state.cpp b/engine/luaxx/state.cpp index 4bd218d..8ac233d 100644 --- a/engine/luaxx/state.cpp +++ b/engine/luaxx/state.cpp @@ -5,6 +5,10 @@ #include #include "mrt/chunk.h" +#ifndef lua_open +#define lua_open() luaL_newstate() +#endif + using namespace luaxx; /* static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { @@ -59,7 +63,7 @@ static const char * chunk_reader(lua_State *L, void *data, size_t *size) { void State::load(const std::string &fname, const mrt::Chunk &data) { //throw_ex(("implement me[%s]", fname.c_str())); reader_state x(data); - int err = lua_load(state, chunk_reader, &x, fname.c_str()); + int err = lua_load(state, chunk_reader, &x, fname.c_str(), NULL); check_error(state, err); } diff --git a/engine/sl08/sl08.h b/engine/sl08/sl08.h index dd06f9e..92fc8dd 100644 --- a/engine/sl08/sl08.h +++ b/engine/sl08/sl08.h @@ -22,6 +22,7 @@ /* DO NOT MODIFY THIS FILE: IT'S AUTOGENERATED */ #include +#include #ifndef NULL #define NULL ((void*) 0) @@ -117,7 +118,7 @@ namespace sl08 { inline slot0 () : object(NULL), func(NULL) {} inline slot0 (object_type *object, func_t func) : object(object), func(func) {} inline void assign(object_type *o, func_t f) { object = o; func = f; } - inline void assign(object_type *o, func_t f, signal_type &signal_ref) { object = o; func = f; connect(signal_ref); } + inline void assign(object_type *o, func_t f, signal_type &signal_ref) { object = o; func = f; this->connect(signal_ref); } inline void operator() () const { (object->*func) (); @@ -271,7 +272,7 @@ namespace sl08 { inline slot1(object_type *object, func_t func, signal_type * signal = NULL) : object(object), func(func) {} inline void assign(object_type *o, func_t f) { object = o; func = f; } - inline void assign(object_type *o, func_t f, signal_type &signal_ref = NULL) { object = o; func = f; connect(signal_ref); } + inline void assign(object_type *o, func_t f, signal_type &signal_ref = NULL) { object = o; func = f; this->connect(signal_ref); } inline return_type operator() (arg1_type a1) const { return (object->*func) (a1) ; @@ -292,7 +293,7 @@ namespace sl08 { inline slot1 () : object(NULL), func(NULL) {} inline slot1 (object_type *object, func_t func) : object(object), func(func) {} inline void assign(object_type *o, func_t f) { object = o; func = f; } - inline void assign(object_type *o, func_t f, signal_type &signal_ref) { object = o; func = f; connect(signal_ref); } + inline void assign(object_type *o, func_t f, signal_type &signal_ref) { object = o; func = f; this->connect(signal_ref); } inline void operator() (arg1_type a1) const { (object->*func) (a1); @@ -446,7 +447,7 @@ namespace sl08 { inline slot2(object_type *object, func_t func, signal_type * signal = NULL) : object(object), func(func) {} inline void assign(object_type *o, func_t f) { object = o; func = f; } - inline void assign(object_type *o, func_t f, signal_type &signal_ref = NULL) { object = o; func = f; connect(signal_ref); } + inline void assign(object_type *o, func_t f, signal_type &signal_ref = NULL) { object = o; func = f; this->connect(signal_ref); } inline return_type operator() (arg1_type a1, arg2_type a2) const { return (object->*func) (a1, a2) ; @@ -467,7 +468,7 @@ namespace sl08 { inline slot2 () : object(NULL), func(NULL) {} inline slot2 (object_type *object, func_t func) : object(object), func(func) {} inline void assign(object_type *o, func_t f) { object = o; func = f; } - inline void assign(object_type *o, func_t f, signal_type &signal_ref) { object = o; func = f; connect(signal_ref); } + inline void assign(object_type *o, func_t f, signal_type &signal_ref) { object = o; func = f; this->connect(signal_ref); } inline void operator() (arg1_type a1, arg2_type a2) const { (object->*func) (a1, a2); @@ -621,7 +622,7 @@ namespace sl08 { inline slot3(object_type *object, func_t func, signal_type * signal = NULL) : object(object), func(func) {} inline void assign(object_type *o, func_t f) { object = o; func = f; } - inline void assign(object_type *o, func_t f, signal_type &signal_ref = NULL) { object = o; func = f; connect(signal_ref); } + inline void assign(object_type *o, func_t f, signal_type &signal_ref = NULL) { object = o; func = f; this->connect(signal_ref); } inline return_type operator() (arg1_type a1, arg2_type a2, arg3_type a3) const { return (object->*func) (a1, a2, a3) ; @@ -642,7 +643,7 @@ namespace sl08 { inline slot3 () : object(NULL), func(NULL) {} inline slot3 (object_type *object, func_t func) : object(object), func(func) {} inline void assign(object_type *o, func_t f) { object = o; func = f; } - inline void assign(object_type *o, func_t f, signal_type &signal_ref) { object = o; func = f; connect(signal_ref); } + inline void assign(object_type *o, func_t f, signal_type &signal_ref) { object = o; func = f; this->connect(signal_ref); } inline void operator() (arg1_type a1, arg2_type a2, arg3_type a3) const { (object->*func) (a1, a2, a3); @@ -796,7 +797,7 @@ namespace sl08 { inline slot4(object_type *object, func_t func, signal_type * signal = NULL) : object(object), func(func) {} inline void assign(object_type *o, func_t f) { object = o; func = f; } - inline void assign(object_type *o, func_t f, signal_type &signal_ref = NULL) { object = o; func = f; connect(signal_ref); } + inline void assign(object_type *o, func_t f, signal_type &signal_ref = NULL) { object = o; func = f; this->connect(signal_ref); } inline return_type operator() (arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4) const { return (object->*func) (a1, a2, a3, a4) ; @@ -817,7 +818,7 @@ namespace sl08 { inline slot4 () : object(NULL), func(NULL) {} inline slot4 (object_type *object, func_t func) : object(object), func(func) {} inline void assign(object_type *o, func_t f) { object = o; func = f; } - inline void assign(object_type *o, func_t f, signal_type &signal_ref) { object = o; func = f; connect(signal_ref); } + inline void assign(object_type *o, func_t f, signal_type &signal_ref) { object = o; func = f; this->connect(signal_ref); } inline void operator() (arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4) const { (object->*func) (a1, a2, a3, a4); @@ -971,7 +972,7 @@ namespace sl08 { inline slot5(object_type *object, func_t func, signal_type * signal = NULL) : object(object), func(func) {} inline void assign(object_type *o, func_t f) { object = o; func = f; } - inline void assign(object_type *o, func_t f, signal_type &signal_ref = NULL) { object = o; func = f; connect(signal_ref); } + inline void assign(object_type *o, func_t f, signal_type &signal_ref = NULL) { object = o; func = f; this->connect(signal_ref); } inline return_type operator() (arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5) const { return (object->*func) (a1, a2, a3, a4, a5) ; @@ -992,7 +993,7 @@ namespace sl08 { inline slot5 () : object(NULL), func(NULL) {} inline slot5 (object_type *object, func_t func) : object(object), func(func) {} inline void assign(object_type *o, func_t f) { object = o; func = f; } - inline void assign(object_type *o, func_t f, signal_type &signal_ref) { object = o; func = f; connect(signal_ref); } + inline void assign(object_type *o, func_t f, signal_type &signal_ref) { object = o; func = f; this->connect(signal_ref); } inline void operator() (arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5) const { (object->*func) (a1, a2, a3, a4, a5); diff --git a/math/range_list.h b/math/range_list.h index 4d73341..c47fc13 100644 --- a/math/range_list.h +++ b/math/range_list.h @@ -53,14 +53,14 @@ public: return; } - typename parent_type::iterator i = lower_bound(value); + typename parent_type::iterator i = this->lower_bound(value); if (i != parent_type::end()) { if (i->first == value) return; if (value + 1 == i->first) { T e = i->second; - erase(i); + this->erase(i); i = parent_type::insert(typename parent_type::value_type(value, e)).first; //expand beginning i = pack_left(i); } diff --git a/mrt/SConscript b/mrt/SConscript index 2660d69..8b59e3b 100644 --- a/mrt/SConscript +++ b/mrt/SConscript @@ -10,6 +10,8 @@ libs = ['expat', 'z'] if sys.platform == "win32": libs.append('Ws2_32') libs.append('shell32') +if sys.platform == "haiku1": + libs.append('bnetapi') mrt = env.SharedLibrary('mrt', \ ['exception.cpp', 'fmt.cpp', 'ioexception.cpp', 'logger.cpp', 'chunk.cpp', 'random.cpp', diff --git a/mrt/sys_socket.cpp b/mrt/sys_socket.cpp index 4212a76..f276894 100644 --- a/mrt/sys_socket.cpp +++ b/mrt/sys_socket.cpp @@ -34,6 +34,7 @@ #include #include +#include using namespace mrt; diff --git a/mrt/udp_socket.cpp b/mrt/udp_socket.cpp index 19c2756..d352f5d 100644 --- a/mrt/udp_socket.cpp +++ b/mrt/udp_socket.cpp @@ -37,6 +37,8 @@ # include /* superset of previous */ # include # include +#define _BSD_SOURCE +# include #endif diff --git a/sdlx/SConscript b/sdlx/SConscript index ede453b..dd8bc93 100644 --- a/sdlx/SConscript +++ b/sdlx/SConscript @@ -19,11 +19,12 @@ if sys.platform != "win32": #c_map_env.Append(CXXFLAGS=['-fforce-addr', '-fprefetch-loop-arrays']) c_map = c_map_env.SharedObject('c_map.cpp') #libs.append('GL') - libs.append('rt') - libs.append('X11') + if sys.platform != "haiku1": + libs.append('rt') + libs.append('X11') - env.Append(LINKFLAGS=['-Wl,-rpath,'+ lib_dir]) - env.Append(LINKFLAGS=['-Wl,-rpath-link,build/' + env['mode'] + '/mrt']) + env.Append(LINKFLAGS=['-Wl,-rpath,'+ lib_dir]) + env.Append(LINKFLAGS=['-Wl,-rpath-link,build/' + env['mode'] + '/mrt']) else: c_map = env.SharedObject('c_map.cpp') libs.append('opengl32') diff --git a/sdlx/system.cpp b/sdlx/system.cpp index c239b53..1afab0c 100644 --- a/sdlx/system.cpp +++ b/sdlx/system.cpp @@ -41,6 +41,8 @@ static void WIN_FlushMessageQueue() } #elif defined __APPLE__ //nothing here +#elif defined __HAIKU__ + //nothing here #else # include # include @@ -134,7 +136,7 @@ TRY { DestroyWindow(hwnd); WIN_FlushMessageQueue(); #endif -#if !defined(_WINDOWS) && !defined(__APPLE__) +#if !defined(_WINDOWS) && !defined(__APPLE__) && !defined(__HAIKU__) int errorBase, eventBase; if (SDL_GL_LoadLibrary(NULL) != 0) { -- 2.37.3 From 075b9c43837b6db1517f1b2844b139f958f059a1 Mon Sep 17 00:00:00 2001 From: Jerome Duval Date: Sun, 17 May 2015 21:20:06 +0000 Subject: Settings directory diff --git a/mrt/directory.cpp b/mrt/directory.cpp index dfc672f..8881eaa 100644 --- a/mrt/directory.cpp +++ b/mrt/directory.cpp @@ -21,6 +21,10 @@ #include #include +#ifdef __HAIKU__ + #include +#endif + using namespace mrt; Directory::Directory() : _handle(0) {} @@ -195,7 +199,14 @@ const std::string Directory::get_home() { } const std::string Directory::get_app_dir(const std::string &name, const std::string &shortname) { +#ifdef __HAIKU__ + char settingsPath[PATH_MAX]; + find_directory(B_USER_SETTINGS_DIRECTORY, -1, false, settingsPath, sizeof(settingsPath)); + std::string path = settingsPath; + path += "/" + shortname; +#else std::string path = get_home() + "/." + shortname; +#endif mrt::Directory dir; try { dir.create(path); -- 2.37.3