source: trunk/poppler/mypoppler/goo/GooMutex.h @ 277

Last change on this file since 277 was 277, checked in by rbri, 12 years ago

PDF plugin: Poppler library updated to version 0.12.3

File size: 1.8 KB
Line 
1//========================================================================
2//
3// GooMutex.h
4//
5// Portable mutex macros.
6//
7// Copyright 2002-2003 Glyph & Cog, LLC
8//
9//========================================================================
10
11//========================================================================
12//
13// Modified under the Poppler project - http://poppler.freedesktop.org
14//
15// All changes made under the Poppler project to this file are licensed
16// under GPL version 2 or later
17//
18// Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net>
19//
20// To see a description of the changes please see the Changelog file that
21// came with your tarball or type make ChangeLog if you are building from git
22//
23//========================================================================
24
25#ifndef GMUTEX_H
26#define GMUTEX_H
27
28// Usage:
29//
30// GooMutex m;
31// gInitMutex(&m);
32// ...
33// gLockMutex(&m);
34//   ... critical section ...
35// gUnlockMutex(&m);
36// ...
37// gDestroyMutex(&m);
38
39#ifdef _WIN32
40
41#include <windows.h>
42
43typedef CRITICAL_SECTION GooMutex;
44
45#define gInitMutex(m) InitializeCriticalSection(m)
46#define gDestroyMutex(m) DeleteCriticalSection(m)
47#define gLockMutex(m) EnterCriticalSection(m)
48#define gUnlockMutex(m) LeaveCriticalSection(m)
49
50#elif defined(OS2)
51
52#define INCL_DOS
53#include <os2.h>
54
55typedef HMTX GooMutex;
56
57#define gInitMutex(m) DosCreateMutexSem(NULL,m,0,FALSE)
58#define gDestroyMutex(m) DosCloseMutexSem(*m)
59#define gLockMutex(m) DosRequestMutexSem(*m,SEM_INDEFINITE_WAIT)
60#define gUnlockMutex(m) DosReleaseMutexSem(*m)
61
62#else // assume pthreads
63
64#include <pthread.h>
65
66typedef pthread_mutex_t GooMutex;
67
68#define gInitMutex(m) pthread_mutex_init(m, NULL)
69#define gDestroyMutex(m) pthread_mutex_destroy(m)
70#define gLockMutex(m) pthread_mutex_lock(m)
71#define gUnlockMutex(m) pthread_mutex_unlock(m)
72
73#endif
74
75#endif
Note: See TracBrowser for help on using the repository browser.