HPGS - HPGl Script
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
hpgsmutex.h
1 /***********************************************************************
2  * *
3  * $Id: hpgsmutex.h 489 2009-02-11 14:10:30Z softadm $
4  * *
5  * hpgs - HPGl Script, a hpgl/2 interpreter, which uses a Postscript *
6  * API for rendering a scene and thus renders to a variety of *
7  * devices and fileformats. *
8  * *
9  * (C) 2004-2009 ev-i Informationstechnologie GmbH http://www.ev-i.at *
10  * *
11  * Author: Wolfgang Glas *
12  * *
13  * hpgs is free software; you can redistribute it and/or *
14  * modify it under the terms of the GNU Lesser General Public *
15  * License as published by the Free Software Foundation; either *
16  * version 2.1 of the License, or (at your option) any later version. *
17  * *
18  * hpgs is distributed in the hope that it will be useful, *
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
21  * Lesser General Public License for more details. *
22  * *
23  * You should have received a copy of the GNU Lesser General Public *
24  * License along with this library; if not, write to the *
25  * Free Software Foundation, Inc., 59 Temple Place, Suite 330, *
26  * Boston, MA 02111-1307 USA *
27  * *
28  ***********************************************************************
29  * *
30  * Private header file for thread mutex support. *
31  * *
32  ***********************************************************************/
33 
34 #ifndef __HPGS_MUTEX_H__
35 #define __HPGS_MUTEX_H__
36 
37 #ifndef __HPGS_H
38 #include <hpgs.h>
39 #endif
40 
41 #ifdef WIN32
42 #include <windows.h>
43 typedef CRITICAL_SECTION hpgs_mutex_t;
44 #else
45 #include <pthread.h>
46 typedef pthread_mutex_t hpgs_mutex_t;
47 #endif
48 
49 static void hpgs_mutex_init(hpgs_mutex_t *m);
50 static void hpgs_mutex_destroy(hpgs_mutex_t *m);
51 static void hpgs_mutex_lock(hpgs_mutex_t *m);
52 static void hpgs_mutex_unlock(hpgs_mutex_t *m);
53 
54 #ifdef WIN32
55 
56 __inline__ void hpgs_mutex_init(hpgs_mutex_t *m)
57 { InitializeCriticalSection(m); }
58 
59 __inline__ void hpgs_mutex_destroy(hpgs_mutex_t *m)
60 { DeleteCriticalSection(m); }
61 
62 __inline__ void hpgs_mutex_lock(hpgs_mutex_t *m)
63 { EnterCriticalSection(m); }
64 
65 __inline__ void hpgs_mutex_unlock(hpgs_mutex_t *m)
66 { LeaveCriticalSection(m); }
67 
68 #else
69 
70 __inline__ void hpgs_mutex_init(hpgs_mutex_t *m)
71 { pthread_mutex_init(m,0); }
72 
73 __inline__ void hpgs_mutex_destroy(hpgs_mutex_t *m)
74 { pthread_mutex_destroy(m); }
75 
76 __inline__ void hpgs_mutex_lock(hpgs_mutex_t *m)
77 { pthread_mutex_lock(m); }
78 
79 __inline__ void hpgs_mutex_unlock(hpgs_mutex_t *m)
80 { pthread_mutex_unlock(m); }
81 
82 #endif
83 
84 #endif