1 /* 2 threads.h 3 4 Thread management 5 6 Copyright (C) 1996-1997 Id Software, Inc. 7 Copyright (C) 2002 Colin Thompson 8 9 This program is free software; you can redistribute it and/or 10 modify it under the terms of the GNU General Public License 11 as published by the Free Software Foundation; either version 2 12 of the License, or (at your option) any later version. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 18 See the GNU General Public License for more details. 19 20 You should have received a copy of the GNU General Public License 21 along with this program; if not, write to: 22 23 Free Software Foundation, Inc. 24 59 Temple Place - Suite 330 25 Boston, MA 02111-1307, USA 26 27 */ 28 29 #ifndef __threads_h 30 #define __threads_h 31 32 #if defined (HAVE_PTHREAD_H) && defined (HAVE_PTHREAD) 33 #include <pthread.h> 34 extern pthread_mutex_t *my_mutex; 35 #define LOCK do { if (options.threads > 1) pthread_mutex_lock (my_mutex); } while (0); 36 #define UNLOCK do { if (options.threads > 1) pthread_mutex_unlock (my_mutex); } while (0); 37 #else 38 #define LOCK 39 #define UNLOCK 40 #endif 41 42 extern int numthreads; 43 44 typedef void *(threadfunc_t) (void *); 45 46 void InitThreads (void); 47 void RunThreadsOn (threadfunc_t func); 48 49 #endif// __threads_h 50