[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#764579: minetest: FTBFS on hurd-i386



Source: minetest
Version: 0.4.10+repack-1
Severity: important
Tags: patch
User: debian-hurd@lists.debian.org
Usertags: hurd

Hi,

minetest fails to build on GNU/Hurd due to a name clash with OSX/Apple,
both are defining the __MACH__ keyword. This package has built
previously, and the latest building version is 0.4.9+repack-6. The
attached patch fixes the build problems for version 0.4.10+repack-1.

Thanks!
--- a/src/cguittfont/irrUString.h	2014-07-07 00:06:06.000000000 +0200
+++ b/src/cguittfont/irrUString.h	2014-10-08 08:22:35.000000000 +0200
@@ -45,7 +45,7 @@
 #define __BYTE_ORDER 0
 #define __LITTLE_ENDIAN 0
 #define __BIG_ENDIAN 1
-#elif __MACH__
+#elif defined(__MACH__) && defined(__APPLE__)
 #include <machine/endian.h>
 #else
 #include <endian.h>
--- a/src/jthread/jevent.h	2014-07-07 00:06:06.000000000 +0200
+++ b/src/jthread/jevent.h	2014-10-08 08:38:33.000000000 +0200
@@ -30,7 +30,7 @@
 
 #ifdef _WIN32
 #include <windows.h>
-#elif __MACH__
+#elif defined(__MACH__) && defined(__APPLE__)
 #include <mach/mach.h>
 #include <mach/task.h>
 #include <mach/semaphore.h>
@@ -43,7 +43,7 @@
 class Event {
 #ifdef _WIN32
 	HANDLE hEvent;
-#elif __MACH__
+#elif defined(__MACH__) && defined(__APPLE__)
 	semaphore_t sem;
 #else
 	sem_t sem;
--- a/src/jthread/pthread/jevent.cpp	2014-07-07 00:06:06.000000000 +0200
+++ b/src/jthread/pthread/jevent.cpp	2014-10-08 08:27:50.000000000 +0200
@@ -29,7 +29,7 @@
 
 #define UNUSED(expr) do { (void)(expr); } while (0)
 
-#ifdef __MACH__
+#if defined(__MACH__) && defined(__APPLE__)
 #undef sem_t
 #define sem_t semaphore_t
 #undef sem_init
--- a/src/jthread/jsemaphore.h	2014-07-07 00:06:06.000000000 +0200
+++ b/src/jthread/jsemaphore.h	2014-10-08 08:29:13.000000000 +0200
@@ -24,7 +24,7 @@
 #include <windows.h>
 #include <assert.h>
 #define MAX_SEMAPHORE_COUNT 1024
-#elif __MACH__
+#elif defined(__MACH__) && defined(__APPLE__)
 #include <pthread.h>
 #include <mach/mach.h>
 #include <mach/task.h>
@@ -52,7 +52,7 @@
 private:
 #if defined(WIN32)
 	HANDLE m_hSemaphore;
-#elif __MACH__
+#elif defined(__MACH__) && defined(__APPLE__)
 	semaphore_t m_semaphore;
 	int semcount;
 #else
--- a/src/jthread/pthread/jsemaphore.cpp	2014-07-07 00:06:06.000000000 +0200
+++ b/src/jthread/pthread/jsemaphore.cpp	2014-10-08 08:30:53.000000000 +0200
@@ -20,13 +20,13 @@
 #include <errno.h>
 #include <sys/time.h>
 #include "jthread/jsemaphore.h"
-#ifdef __MACH__
+#if defined(__MACH__) && defined(__APPLE__)
 #include <unistd.h>
 #endif
 
 #define UNUSED(expr) do { (void)(expr); } while (0)
 
-#ifdef __MACH__
+#if defined(__MACH__) && defined(__APPLE__)
 #undef sem_t
 #undef sem_init
 #undef sem_wait
@@ -44,7 +44,7 @@
 	int sem_init_retval = sem_init(&m_semaphore,0,0);
 	assert(sem_init_retval == 0);
 	UNUSED(sem_init_retval);
-#ifdef __MACH__
+#if defined(__MACH__) && defined(__APPLE__)
 	semcount = 0;
 #endif
 }
@@ -73,7 +73,7 @@
 	int sem_post_retval = sem_post(&m_semaphore);
 	assert(sem_post_retval == 0);
 	UNUSED(sem_post_retval);
-#ifdef __MACH__
+#if defined(__MACH__) && defined(__APPLE__)
 	pthread_mutex_lock(&semcount_mutex);
 	semcount++;
 	pthread_mutex_unlock(&semcount_mutex);
@@ -84,7 +84,7 @@
 	int sem_wait_retval = sem_wait(&m_semaphore);
 	assert(sem_wait_retval == 0);
 	UNUSED(sem_wait_retval);
-#ifdef __MACH__
+#if defined(__MACH__) && defined(__APPLE__)
 	pthread_mutex_lock(&semcount_mutex);
 	semcount--;
 	pthread_mutex_unlock(&semcount_mutex);
@@ -92,7 +92,7 @@
 }
 
 bool JSemaphore::Wait(unsigned int time_ms) {
-#ifdef __MACH__
+#if defined(__MACH__) && defined(__APPLE__)
 	mach_timespec_t waittime;
 	waittime.tv_sec = time_ms / 1000;
 	waittime.tv_nsec = 1000000 * (time_ms % 1000);
@@ -106,14 +106,14 @@
 		return false;
 	}
 
-#ifndef __MACH__
+#if !(defined(__MACH__) && defined(__APPLE__))
 	waittime.tv_nsec = ((time_ms % 1000) * 1000 * 1000) + (now.tv_usec * 1000);
 	waittime.tv_sec  = (time_ms / 1000) + (waittime.tv_nsec / (1000*1000*1000)) + now.tv_sec;
 	waittime.tv_nsec %= 1000*1000*1000;
 #endif
 
 	errno = 0;
-#ifdef __MACH__
+#if defined(__MACH__) && defined(__APPLE__)
 	int sem_wait_retval = semaphore_timedwait(m_semaphore, waittime);
 #else
 	int sem_wait_retval = sem_timedwait(&m_semaphore, &waittime);
@@ -121,7 +121,7 @@
 
 	if (sem_wait_retval == 0)
 	{
-#ifdef __MACH__
+#if defined(__MACH__) && defined(__APPLE__)
 		pthread_mutex_lock(&semcount_mutex);
 		semcount--;
 		pthread_mutex_unlock(&semcount_mutex);
@@ -137,7 +137,7 @@
 
 int JSemaphore::GetValue() {
 	int retval = 0;
-#ifdef __MACH__
+#if defined(__MACH__) && defined(__APPLE__)
 	pthread_mutex_lock(&semcount_mutex);
 	retval = semcount;
 	pthread_mutex_unlock(&semcount_mutex);
--- a/src/porting.h	2014-07-07 00:06:06.000000000 +0200
+++ b/src/porting.h	2014-10-08 08:59:43.000000000 +0200
@@ -59,7 +59,7 @@
 	#include <unistd.h>
 	#include <stdint.h> //for uintptr_t
 
-	#if (defined(linux) || defined(__linux)) && !defined(_GNU_SOURCE)
+#if (defined(linux) || defined(__linux) || defined(__GNU__)) && !defined(_GNU_SOURCE)
 		#define _GNU_SOURCE
 	#endif
 
@@ -227,7 +227,7 @@
 #else // Posix
 #include <sys/time.h>
 #include <time.h>
-#ifdef __MACH__
+#if defined(__MACH__) && defined(__APPLE__)
 #include <mach/clock.h>
 #include <mach/mach.h>
 #endif
@@ -257,7 +257,7 @@
 	{
 		struct timespec ts;
 		// from http://stackoverflow.com/questions/5167269/clock-gettime-alternative-in-mac-os-x
-#ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time
+#if defined(__MACH__) && defined(__APPLE__) // OS X does not have clock_gettime, use clock_get_time
 		clock_serv_t cclock;
 		mach_timespec_t mts;
 		host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
@@ -359,6 +359,9 @@
 	}
 #elif defined(_WIN32)
 	inline void setThreadName(const char* name) {}
+#elif defined(__GNU__)
+	//#warning "GNU/Hurd platform, pthread_setname_np not yet supported"
+	inline void setThreadName(const char* name) {}
 #else
 	#warning "Unrecognized platform, thread names will not be available."
 	inline void setThreadName(const char* name) {}

Reply to: