All pastes #1027026 Raw Edit

Patch for MaNGOS on MacOS X

public diff v1 · immutable
#1027026 ·published 2008-05-23 12:43 UTC
rendered paste body
Index: src/framework/Platform/Define.h===================================================================--- src/framework/Platform/Define.h	(revision 5927)+++ src/framework/Platform/Define.h	(working copy)@@ -23,6 +23,7 @@ #include <sys/types.h>  #if PLATFORM == PLATFORM_WINDOWS+ #define MANGOS_EXPORT __declspec(dllexport) #define MANGOS_LIBRARY_HANDLE HMODULE #define MANGOS_LOAD_LIBRARY(a) LoadLibrary(a)@@ -32,23 +33,32 @@ #define MANGOS_SCRIPT_EXT ".dll" #define MANGOS_SCRIPT_NAME "MaNGOSScript" #define SIGQUIT 3+ #else+ #define MANGOS_LIBRARY_HANDLE void* #define MANGOS_EXPORT export #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)+#if PLATFORM == PLATFORM_APPLE && defined(BIG_ENDIAN) #define MANGOS_IMPORT __attribute__ ((longcall)) #else #define MANGOS_IMPORT __attribute__ ((cdecl)) #endif +#if PLATFORM == PLATFORM_APPLE+#define MANGOS_SCRIPT_EXT ".dylib"+#define MANGOS_SCRIPT_NAME "../lib/libmangosscript"+#else #define MANGOS_SCRIPT_EXT ".so" #define MANGOS_SCRIPT_NAME "libmangosscript" #endif +#endif++ #ifdef WIN32 #ifdef MANGOS_WIN32_DLL_IMPORT Index: contrib/map_extractor/libmpq/mpq.h===================================================================--- contrib/map_extractor/libmpq/mpq.h	(revision 5927)+++ contrib/map_extractor/libmpq/mpq.h	(working copy)@@ -36,7 +36,11 @@ 	#define PATH_MAX 260 #endif +#if defined(__APPLE_CC__)+    #define lseek64 lseek+#endif + #define LIBMPQ_MAJOR_VERSION		0		/* Major version number... maybe sometimes we reach version 1 :) */ #define LIBMPQ_MINOR_VERSION		3		/* Minor version number - increased only for small changes */ #define LIBMPQ_PATCH_VERSION		0		/* Patchlevel - changed on bugfixes etc... */Index: dep/include/zthread/Time.h===================================================================--- dep/include/zthread/Time.h	(revision 5927)+++ dep/include/zthread/Time.h	(working copy)@@ -1,225 +0,0 @@-/*- * Copyright (c) 2005, Eric Crahen- *- * Permission is hereby granted, free of charge, to any person obtaining a copy- * of this software and associated documentation files (the "Software"), to deal- * in the Software without restriction, including without limitation the rights- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell- * copies of the Software, and to permit persons to whom the Software is furnished- * to do so, subject to the following conditions:- *- * The above copyright notice and this permission notice shall be included in all- * copies or substantial portions of the Software.- *- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.- *- */--#ifndef __ZTTIME_H__-#define __ZTTIME_H__--#include "zthread/Config.h"--namespace ZThread {--/**- * @class Time- * @author Eric Crahen <http://www.code-foo.com>- * @date <2003-07-16T17:52:46-0400>- * @version 2.2.11- *- * The Time class provides access to time values relative to when the program- * was started. In other words, this class might be thought of as a timer that- * starts at 0 and counts upwards. This class offers millisecond resolution.- */-class ZTHREAD_API Time {--  unsigned long _seconds;-  unsigned long _milliseconds;--  //! Create a new Time object-  Time(unsigned long secs, unsigned long millis)-    : _seconds(secs), _milliseconds(millis) { }--  /**-   * Set the number of milliseconds in this Time object.-   *-   * @param millis - new milliseconds value-   * @return unsigned long old milliseconds value-   */-  unsigned long milliseconds(unsigned long millis) {--    unsigned long n = _milliseconds;-    _milliseconds = millis;--    return n;--  }--  /**-   * Set the number of seconds in this Time object.-   *-   * @param secs - new seconds value-   * @return unsigned long old seconds value-   */-  unsigned long seconds(unsigned long secs) {--    unsigned long n = _seconds;-    _seconds = secs;--    return n;--  }-- public:---  /**-   * Create a Time object with the current time relative to the-   * beginning of the program.-   */-  Time();--  /**-   * Create a Time object by copying another.-   *-   * @param t - Time object to copy.-   */-  Time(const Time& t)-    : _seconds(t._seconds), _milliseconds(t._milliseconds) { }---  /**-   * Get the number of milliseconds in this Time object.-   *-   * @return unsigned long milliseconds value-   */-  unsigned long milliseconds() const {-    return _milliseconds;-  }--  /**-   * Get the number of seconds in this Time object.-   *-   * @return unsigned long seconds value-   */-  unsigned long seconds() const {-    return _seconds;-  }--  /**-   * Add some number of milliseconds to this Time object.-   *-   * @param millis - number of milliseconds to add to this Time object-   * @return const Time& this object-   */-  const Time& operator+=(unsigned long millis) {--    _milliseconds += millis;-    _seconds += (_milliseconds / 1000);-    _milliseconds %= 1000;--    return *this;--  }--  /**-   * Subtract some number of milliseconds to this Time object.-   *-   * @param millis - number of milliseconds to subtract from this Time object-   * @return const Time& this object-   */-const Time& operator-=(unsigned long millis) {--    if(_milliseconds > millis)-      _milliseconds -= millis;--    else {--      while(_seconds > 0 && _milliseconds < millis) {--        _milliseconds += 1000;-        _seconds -= 1;--      }--      _milliseconds = (_milliseconds < millis) ? 0 : (_milliseconds - millis);--    }--    return *this;--}---  /**-   * Add the value of another Time object to this one.-   *-   * @param t - Time object whose value should be added to this object-   * @return const Time& this object-   */-  const Time& operator+=(const Time& t) {--    _milliseconds += t.milliseconds();-    _seconds += (_milliseconds / 1000) + t.seconds();-    _milliseconds %= 1000;--    return *this;--  }--  /**-   * Subtract the value of another Time object from this one.-   * This function has a floor of 0.-   *-   * @param t - Time object whose value should be subtracted from this object-   * @return const Time& this object-   */-const Time& operator-=(const Time& t) {--  unsigned long millis = t.milliseconds();-  unsigned long secs = t.seconds();--  if(_seconds >= secs) {--    if(_milliseconds > millis) {-      _milliseconds -= millis;-      _seconds -= secs;--    } else {--      while(_seconds > 0 && _milliseconds < millis) {--        _milliseconds += 1000;-        _seconds -= 1;--      }--      _milliseconds = (_milliseconds < millis) ? 0 : (_milliseconds - millis);-      _seconds = (_seconds < secs) ? 0 : (_seconds - secs);--    }--  } else {--    _milliseconds = 0;-    _seconds = 0;--  }--  return *this;--}--};----} // namespace ZThread--#endif // __ZTTIME_H__Index: dep/include/zthread/zthreadTime.h===================================================================--- dep/include/zthread/zthreadTime.h	(revision 0)+++ dep/include/zthread/zthreadTime.h	(revision 0)@@ -0,0 +1,225 @@+/*+ * Copyright (c) 2005, Eric Crahen+ *+ * Permission is hereby granted, free of charge, to any person obtaining a copy+ * of this software and associated documentation files (the "Software"), to deal+ * in the Software without restriction, including without limitation the rights+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+ * copies of the Software, and to permit persons to whom the Software is furnished+ * to do so, subject to the following conditions:+ *+ * The above copyright notice and this permission notice shall be included in all+ * copies or substantial portions of the Software.+ *+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.+ *+ */++#ifndef __ZTTIME_H__+#define __ZTTIME_H__++#include "zthread/Config.h"++namespace ZThread {++/**+ * @class Time+ * @author Eric Crahen <http://www.code-foo.com>+ * @date <2003-07-16T17:52:46-0400>+ * @version 2.2.11+ *+ * The Time class provides access to time values relative to when the program+ * was started. In other words, this class might be thought of as a timer that+ * starts at 0 and counts upwards. This class offers millisecond resolution.+ */+class ZTHREAD_API Time {++  unsigned long _seconds;+  unsigned long _milliseconds;++  //! Create a new Time object+  Time(unsigned long secs, unsigned long millis)+    : _seconds(secs), _milliseconds(millis) { }++  /**+   * Set the number of milliseconds in this Time object.+   *+   * @param millis - new milliseconds value+   * @return unsigned long old milliseconds value+   */+  unsigned long milliseconds(unsigned long millis) {++    unsigned long n = _milliseconds;+    _milliseconds = millis;++    return n;++  }++  /**+   * Set the number of seconds in this Time object.+   *+   * @param secs - new seconds value+   * @return unsigned long old seconds value+   */+  unsigned long seconds(unsigned long secs) {++    unsigned long n = _seconds;+    _seconds = secs;++    return n;++  }++ public:+++  /**+   * Create a Time object with the current time relative to the+   * beginning of the program.+   */+  Time();++  /**+   * Create a Time object by copying another.+   *+   * @param t - Time object to copy.+   */+  Time(const Time& t)+    : _seconds(t._seconds), _milliseconds(t._milliseconds) { }+++  /**+   * Get the number of milliseconds in this Time object.+   *+   * @return unsigned long milliseconds value+   */+  unsigned long milliseconds() const {+    return _milliseconds;+  }++  /**+   * Get the number of seconds in this Time object.+   *+   * @return unsigned long seconds value+   */+  unsigned long seconds() const {+    return _seconds;+  }++  /**+   * Add some number of milliseconds to this Time object.+   *+   * @param millis - number of milliseconds to add to this Time object+   * @return const Time& this object+   */+  const Time& operator+=(unsigned long millis) {++    _milliseconds += millis;+    _seconds += (_milliseconds / 1000);+    _milliseconds %= 1000;++    return *this;++  }++  /**+   * Subtract some number of milliseconds to this Time object.+   *+   * @param millis - number of milliseconds to subtract from this Time object+   * @return const Time& this object+   */+const Time& operator-=(unsigned long millis) {++    if(_milliseconds > millis)+      _milliseconds -= millis;++    else {++      while(_seconds > 0 && _milliseconds < millis) {++        _milliseconds += 1000;+        _seconds -= 1;++      }++      _milliseconds = (_milliseconds < millis) ? 0 : (_milliseconds - millis);++    }++    return *this;++}+++  /**+   * Add the value of another Time object to this one.+   *+   * @param t - Time object whose value should be added to this object+   * @return const Time& this object+   */+  const Time& operator+=(const Time& t) {++    _milliseconds += t.milliseconds();+    _seconds += (_milliseconds / 1000) + t.seconds();+    _milliseconds %= 1000;++    return *this;++  }++  /**+   * Subtract the value of another Time object from this one.+   * This function has a floor of 0.+   *+   * @param t - Time object whose value should be subtracted from this object+   * @return const Time& this object+   */+const Time& operator-=(const Time& t) {++  unsigned long millis = t.milliseconds();+  unsigned long secs = t.seconds();++  if(_seconds >= secs) {++    if(_milliseconds > millis) {+      _milliseconds -= millis;+      _seconds -= secs;++    } else {++      while(_seconds > 0 && _milliseconds < millis) {++        _milliseconds += 1000;+        _seconds -= 1;++      }++      _milliseconds = (_milliseconds < millis) ? 0 : (_milliseconds - millis);+      _seconds = (_seconds < secs) ? 0 : (_seconds - secs);++    }++  } else {++    _milliseconds = 0;+    _seconds = 0;++  }++  return *this;++}++};++++} // namespace ZThread++#endif // __ZTTIME_H__Index: dep/src/zthread/Time.cxx===================================================================--- dep/src/zthread/Time.cxx	(revision 5927)+++ dep/src/zthread/Time.cxx	(working copy)@@ -20,7 +20,7 @@  *  */ -#include "zthread/Time.h"+#include "zthread/zthreadTime.h" #include "TimeStrategy.h"  Index: dep/src/zthread/ThreadedExecutor.cxx===================================================================--- dep/src/zthread/ThreadedExecutor.cxx	(revision 5927)+++ dep/src/zthread/ThreadedExecutor.cxx	(working copy)@@ -23,7 +23,7 @@ #include "zthread/ThreadedExecutor.h" #include "zthread/Guard.h" #include "zthread/FastMutex.h"-#include "zthread/Time.h"+#include "zthread/zthreadTime.h"  #include "ThreadImpl.h" Index: dep/src/sockets/TcpSocket.cpp===================================================================--- dep/src/sockets/TcpSocket.cpp	(revision 5927)+++ dep/src/sockets/TcpSocket.cpp	(working copy)@@ -39,6 +39,9 @@ #include <fcntl.h> #include <assert.h> #include <stdarg.h>+#if defined(__APPLE_CC__)+#include <signal.h>+#endif #ifdef HAVE_OPENSSL #include <openssl/rand.h> #include <openssl/err.h>@@ -498,7 +501,12 @@ 	else #endif // HAVE_OPENSSL 	{+#if defined(__APPLE_CC__)+        sigignore(SIGPIPE);+		n = recv(GetSocket(), buf, TCP_BUFSIZE_READ, 0);+#else 		n = recv(GetSocket(), buf, TCP_BUFSIZE_READ, MSG_NOSIGNAL);+#endif 		if (n == -1) 		{ 			Handler().LogError(this, "read", Errno, StrError(Errno), LOG_LEVEL_FATAL);@@ -753,7 +761,12 @@ 	else #endif // HAVE_OPENSSL 	{+#if defined(__APPLE_CC__)+        sigignore(SIGPIPE);+		n = send(GetSocket(), buf, (int)len, 0);+#else 		n = send(GetSocket(), buf, (int)len, MSG_NOSIGNAL);+#endif 		if (n == -1) 		{ 		// normal error codes: