00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00020
00021 #ifndef _ARCH_SPECIFIC_H_
00022 #define _ARCH_SPECIFIC_H_
00023
00024 #include "config.h"
00025
00026
00027
00028 #if defined(WIN32) || defined(__WIN32__) || defined(_WIN32)
00029
00030
00031
00032 #ifndef WIN32
00033 #define WIN32 1
00034 #endif
00035
00036
00037 #pragma inline_depth(255)
00038 #define inline __forceinline
00039
00040 #include <windows.h>
00041 #include <process.h>
00042
00043 typedef long hoardLockType;
00044 typedef HANDLE hoardThreadType;
00045
00046 #elif USE_SPROC
00047
00048
00049
00050 #include <sys/types.h>
00051 #include <sys/prctl.h>
00052
00053 #else
00054
00055
00056
00057 #if defined(__SVR4) // Solaris
00058 #include <thread.h>
00059 #endif
00060
00061 #include <pthread.h>
00062 #include <unistd.h>
00063
00064 #endif
00065
00066
00067 #ifndef WIN32
00068 #if USER_LOCKS && (defined(i386) || defined(sparc) || defined(__sgi))
00069 typedef unsigned long hoardLockType;
00070 #else
00071 typedef pthread_mutex_t hoardLockType;
00072 #endif
00073
00074 #if USE_SPROC
00075 typedef pid_t hoardThreadType;
00076 #else
00077 typedef pthread_t hoardThreadType;
00078 #endif
00079
00080 #endif
00081
00082 extern "C" {
00083
00085
00086 void hoardCreateThread (hoardThreadType& t,
00087 void *(*function) (void *),
00088 void * arg);
00089 void hoardJoinThread (hoardThreadType& t);
00090 void hoardSetConcurrency (int n);
00091
00092
00093
00094
00095 int hoardGetThreadID (void);
00096
00098
00099 #if !defined(WIN32) && !USER_LOCKS
00100
00101
00102
00103 inline void hoardLockInit (hoardLockType& lock) {
00104 pthread_mutex_init (&lock, NULL);
00105 }
00106
00107 inline void hoardLock (hoardLockType& lock) {
00108 pthread_mutex_lock (&lock);
00109 }
00110
00111 inline void hoardUnlock (hoardLockType& lock) {
00112 pthread_mutex_unlock (&lock);
00113 }
00114
00115 #else
00116 void hoardLockInit (hoardLockType& lock);
00117 void hoardLock (hoardLockType& lock);
00118 void hoardUnlock (hoardLockType& lock);
00119 #endif
00120
00121 inline void hoardLockDestroy (hoardLockType&) {
00122 }
00123
00125
00126 int hoardGetPageSize (void);
00127 void * hoardGetMemory (long size);
00128 void hoardFreeMemory (void * ptr);
00129
00131
00132 void hoardYield (void);
00133 int hoardGetNumProcessors (void);
00134 unsigned long hoardInterlockedExchange (unsigned long * oldval,
00135 unsigned long newval);
00136 }
00137
00138 #endif // _ARCH_SPECIFIC_H_
00139