]> git.ipfire.org Git - thirdparty/cups.git/blame - pdftops/GMutex.h
Load cups into easysw/current.
[thirdparty/cups.git] / pdftops / GMutex.h
CommitLineData
ef416fc2 1//========================================================================
2//
3// GMutex.h
4//
5// Portable mutex macros.
6//
7// Copyright 2002-2003 Glyph & Cog, LLC
8//
9//========================================================================
10
11#ifndef GMUTEX_H
12#define GMUTEX_H
13
14// Usage:
15//
16// GMutex m;
17// gInitMutex(&m);
18// ...
19// gLockMutex(&m);
20// ... critical section ...
21// gUnlockMutex(&m);
22// ...
23// gDestroyMutex(&m);
24
25#ifdef WIN32
26
27#include <windows.h>
28
29typedef CRITICAL_SECTION GMutex;
30
31#define gInitMutex(m) InitializeCriticalSection(m)
32#define gDestroyMutex(m) DeleteCriticalSection(m)
33#define gLockMutex(m) EnterCriticalSection(m)
34#define gUnlockMutex(m) LeaveCriticalSection(m)
35
36#else // assume pthreads
37
38#include <pthread.h>
39
40typedef pthread_mutex_t GMutex;
41
42#define gInitMutex(m) pthread_mutex_init(m, NULL)
43#define gDestroyMutex(m) pthread_mutex_destroy(m)
44#define gLockMutex(m) pthread_mutex_lock(m)
45#define gUnlockMutex(m) pthread_mutex_unlock(m)
46
47#endif
48
49#endif