mangos mac os patch change
August 19th, 2009 by song

默认官方有一个错误
修改了下
[code]diff --git a/src/framework/Platform/CompilerDefs.h b/src/framework/Platform/CompilerDefs.h
index e835491..011035f 100644
--- a/src/framework/Platform/CompilerDefs.h
+++ b/src/framework/Platform/CompilerDefs.h
@@ -29,7 +29,9 @@
#  define PLATFORM PLATFORM_WINDOWS
#elif defined( __WIN32__ ) || defined( WIN32 ) || defined( _WIN32 )
#  define PLATFORM PLATFORM_WINDOWS
-#elif defined( __APPLE_CC__ )
+// Use appropriate macros as suggested by Apple.
+// http://developer.apple.com/technotes/tn2002/tn2071.html#Section10
+#elif defined( __APPLE__ ) && defined( __MACH__ )
#  define PLATFORM PLATFORM_APPLE
#elif defined( __INTEL_COMPILER )
#  define PLATFORM PLATFORM_INTEL
diff --git a/src/framework/Platform/Define.h b/src/framework/Platform/Define.h
index 8318493..7263beb 100644
--- a/src/framework/Platform/Define.h
+++ b/src/framework/Platform/Define.h
@@ -53,14 +53,21 @@
#  define MANGOS_LOAD_LIBRARY(a) dlopen(a,RTLD_NOW)
#  define MANGOS_CLOSE_LIBRARY dlclose
#  define MANGOS_GET_PROC_ADDR dlsym
-#  if defined(__APPLE_CC__) && defined(BIG_ENDIAN)
+// longcall calling convention is only supported on Big Endian (non-intel) compilers
+// BIG_ENDIAN can be defined on some Macs, but set to 0!
+#  if MANGOS_ENDIAN == MANGOS_BIGENDIAN
#    define MANGOS_IMPORT __attribute__ ((longcall))
#  elif defined(__x86_64__)
#    define MANGOS_IMPORT
#  else
#    define MANGOS_IMPORT __attribute__ ((cdecl))
-#  endif //__APPLE_CC__ && BIG_ENDIAN
-#  define MANGOS_SCRIPT_EXT ".so"
+#  endif //MANGOS_IMPORT
+// OS X uses .dylib as the dynamic library file name suffix
+#  if PLATFORM == PLATFORM_APPLE
+#    define MANGOS_SCRIPT_EXT ".dylib"
+#  else //PLATFORM != PLATFORM_APPLE
+#    define MANGOS_SCRIPT_EXT ".so"
+#  endif //MANGOS_SCRIPT_EXT
#  define MANGOS_SCRIPT_NAME "libmangosscript"
#  define MANGOS_PATH_MAX PATH_MAX
#endif //PLATFORM
diff --git a/src/game/ScriptCalls.cpp b/src/game/ScriptCalls.cpp
index adbdcb1..4a3f146 100644
--- a/src/game/ScriptCalls.cpp
+++ b/src/game/ScriptCalls.cpp
@@ -47,6 +47,19 @@ bool LoadScriptingModule(char const* libName)

    testScript->hScriptsLib=MANGOS_LOAD_LIBRARY(name.c_str());

+// OSX: Hack for people who install into /opt but don't add it to their paths
+#if PLATFORM == PLATFORM_APPLE
+    if(!testScript->hScriptsLib )
+    {
+        // Library was not found within standard dynamic loader search paths
+        // $HOME/lib; /usr/local/lib; /usr/lib
+        // Try relative path instead for those who install into non-standard directory
+        std::string fullPath = "@executable_path/../lib/";
+        fullPath += name;
+        testScript->hScriptsLib=MANGOS_LOAD_LIBRARY(fullPath.c_str());
+    }
+#endif
+
    if(!testScript->hScriptsLib )
    {
        printf("Error loading Scripts Library %s !\n",name.c_str());
diff --git a/src/mangosd/CliRunnable.cpp b/src/mangosd/CliRunnable.cpp
index 5e7c05d..2be7967 100644
--- a/src/mangosd/CliRunnable.cpp
+++ b/src/mangosd/CliRunnable.cpp
@@ -266,7 +266,7 @@ bool ChatHandler::HandleServerSetLogLevelCommand(const char *args)

/// @}

-#ifdef linux
+#if defined( linux ) || PLATFORM == PLATFORM_APPLE
// Non-blocking keypress detector, when return pressed, return 1, else always return 0
int kb_hit_return()
{
@@ -303,7 +303,7 @@ void CliRunnable::run()
    while (!World::IsStopped())
    {
        fflush(stdout);
-        #ifdef linux
+        #if defined( linux ) || PLATFORM == PLATFORM_APPLE
        while (!kb_hit_return() && !World::IsStopped())
            // With this, we limit CLI to 10commands/second
            usleep(100);
diff --git a/src/shared/Threading.cpp b/src/shared/Threading.cpp
index 496e863..e74b12e 100644
--- a/src/shared/Threading.cpp
+++ b/src/shared/Threading.cpp
@@ -222,7 +222,8 @@
    int _priority = m_TpEnum.getPriority(type);
    int _ok = ACE_Thread::setprio(m_hThreadHandle, _priority);
    //remove this ASSERT in case you don't want to know is thread priority change was successful or not
-    ASSERT (_ok == 0);
+    //OS X Hack: ASSERT is raised and prevents worldd from executing
+  //ASSERT (_ok == 0);
}

void Thread::Sleep(unsigned long msecs)
[/code]


Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

SIDEBAR
»
S
I
D
E
B
A
R
«
»  Substance:WordPress   »