Patch provided in answer to my request regarding conflicts with ruby's pthread definitions
diff --git a/pthread.h.orig b/pthread.h
index 2029713..c488aa1 100644
--- a/pthread.h.orig
+++ b/pthread.h
@@ -68,6 +68,8 @@
#include <signal.h>
#include <sys/timeb.h>
+#include <time.h>
+#include <sched.h>
#include "pthread_compat.h"
@@ -414,48 +416,66 @@ int WINPTHREAD_API pthread_rwlockattr_init(pthread_rwlock
int WINPTHREAD_API pthread_rwlockattr_setpshared(pthread_rwlockattr_t *a, int s);
/* Recursive API emulation. */
-#undef localtime_r
-#define localtime_r(_Time, _Tm) ({ struct tm *___tmp_tm; \
- pthread_testcancel(); \
- ___tmp_tm = localtime((_Time));\
- if (___tmp_tm) { \
- *(_Tm) = *___tmp_tm; \
- ___tmp_tm = (_Tm); \
- } \
- ___tmp_tm; })
-
-#undef gmtime_r
-#define gmtime_r(_Time,_Tm) ({ struct tm *___tmp_tm; \
- pthread_testcancel(); \
- ___tmp_tm = gmtime((_Time)); \
- if (___tmp_tm) { \
- *(_Tm) = *___tmp_tm; \
- ___tmp_tm = (_Tm); \
- } \
- ___tmp_tm; })
-
-#undef ctime_r
-#define ctime_r(_Time,_Str) ({ char *___tmp_tm; \
- pthread_testcancel(); \
- ___tmp_tm = ctime((_Time)); \
- if (___tmp_tm) \
- ___tmp_tm = \
- strcpy((_Str),___tmp_tm); \
- ___tmp_tm; })
-
-#undef asctime_r
-#define asctime_r(_Tm, _Buf) ({ char *___tmp_tm; \
- pthread_testcancel(); \
- ___tmp_tm = asctime((_Tm)); \
- if (___tmp_tm) \
- ___tmp_tm = \
- strcpy((_Buf),___tmp_tm);\
- ___tmp_tm; })
-
-#ifndef rand_r
-#define rand_r(__seed) (__seed == __seed ? rand () : rand ())
+#ifdef __GNUC__
+#define PTHREAD_ALWAYS_INLINE static inline __attribute__((always_inline))
+#else
+#define PTHREAD_ALWAYS_INLINE static
#endif
+PTHREAD_ALWAYS_INLINE struct tm * localtime_r(const time_t *_Time, struct tm *_Tm){
+ struct tm *___tmp_tm;
+ pthread_testcancel();
+ ___tmp_tm = localtime(_Time);
+ if (___tmp_tm) {
+ *_Tm = *___tmp_tm;
+ ___tmp_tm = _Tm;
+ }
+ return ___tmp_tm;
+}
+
+PTHREAD_ALWAYS_INLINE struct tm * gmtime_r(const time_t *_Time, struct tm *_Tm){
+ struct tm *___tmp_tm;
+ pthread_testcancel();
+ ___tmp_tm = gmtime(_Time);
+ if (___tmp_tm) {
+ *(_Tm) = *___tmp_tm;
+ ___tmp_tm = (_Tm);
+ }
+ return ___tmp_tm;
+}
+
+PTHREAD_ALWAYS_INLINE char *_ptstrcpy(char *_Str, const char *_Src){
+ char *ret = _Str;
+ while(_Src) {
+ if((*_Str = *_Src) == '\0') break;
+ _Src++;
+ _Str++;
+ }
+ return ret;
+}
+
+PTHREAD_ALWAYS_INLINE char * ctime_r(const time_t *_Time, char *_Str){
+ char *___tmp_tm;
+ pthread_testcancel();
+ ___tmp_tm = ctime((_Time));
+ if (___tmp_tm)
+ ___tmp_tm = _ptstrcpy((_Str),___tmp_tm);
+ return ___tmp_tm;
+}
+
+PTHREAD_ALWAYS_INLINE char * asctime_r(const struct tm *_Tm, char *_Buf){
+ char *___tmp_tm;
+ pthread_testcancel();
+ ___tmp_tm = asctime((_Tm));
+ if (___tmp_tm)
+ ___tmp_tm = _ptstrcpy((_Buf),___tmp_tm);
+ return ___tmp_tm;
+}
+
+PTHREAD_ALWAYS_INLINE int rand_r(unsigned int *__seed){
+ return __seed ? rand () : rand ();
+}
+
#ifndef SIG_BLOCK
#define SIG_BLOCK 0
#endif
signature.asc
Description: OpenPGP digital signature
------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
