// The below define is necessary to use
// pthreads extensions like pthread_mutexattr_settype
#define _GNU_SOURCE
-#include <pthread.h>
-#endif
+#endif // !GDEF_OS_WINDOWS
#include "cmdlib.h"
#include "mathlib.h"
if ( work == -1 ) {
break;
}
-//Sys_Printf ("thread %i, work %i\n", threadnum, work);
+ //Sys_Printf ("thread %i, work %i\n", threadnum, work);
workfunction( work );
}
}
}
+#if GDEF_OS_WINDOWS
+
/*
===================================================================
===================================================================
*/
-#if GDEF_OS_WINDOWS
-
-#define USED
#include <windows.h>
-int numthreads = -1;
+// Setting default Threads to 1
+int numthreads = 1;
CRITICAL_SECTION crit;
static int enter;
}
-#endif
+#elif GDEF_OS_OSF1
/*
===================================================================
===================================================================
*/
-#ifdef __osf__
-#define USED
-
int numthreads = 4;
void ThreadSetDefault( void ){
}
-#endif
+#elif GDEF_OS_IRIX
/*
===================================================================
===================================================================
*/
-#ifdef _MIPS_ISA
-#define USED
-
#include <task.h>
#include <abi_mutex.h>
#include <sys/types.h>
#include <sys/prctl.h>
-
int numthreads = -1;
abilock_t lck;
}
-#endif
-
+#elif GDEF_OS_LINUX || GDEF_OS_BSD || GDEF_OS_MACOS
/*
=======================================================================
=======================================================================
*/
-#if GDEF_OS_LINUX
-#define USED
-
-int numthreads = 4;
+// Setting default Threads to 1
+int numthreads = 1;
void ThreadSetDefault( void ){
if ( numthreads == -1 ) { // not set manually
if ( pthread_mutexattr_init( &mattrib ) != 0 ) {
Error( "pthread_mutexattr_init failed" );
}
-#if __GLIBC_MINOR__ == 1
- if ( pthread_mutexattr_settype( &mattrib, PTHREAD_MUTEX_FAST_NP ) != 0 )
-#else
- if ( pthread_mutexattr_settype( &mattrib, PTHREAD_MUTEX_ADAPTIVE_NP ) != 0 )
-#endif
- { Error( "pthread_mutexattr_settype failed" ); }
+ if ( pthread_mutexattr_settype( &mattrib, PTHREAD_MUTEX_ERRORCHECK ) != 0 ) {
+ Error( "pthread_mutexattr_settype failed" );
+ }
recursive_mutex_init( mattrib );
for ( i = 0 ; i < numthreads ; i++ )
Sys_Printf( " (%i)\n", end - start );
}
}
-#endif // ifdef __linux__
+#else // UNKNOWN OS
+
/*
=======================================================================
=======================================================================
*/
-#ifndef USED
-
int numthreads = 1;
void ThreadSetDefault( void ){
}
}
-#endif
+#endif // UNKNOWN OS