X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=pdf2swf%2Fxpdf%2FGMutex.h;fp=pdf2swf%2Fxpdf%2FGMutex.h;h=7fa93d85e06c4da8971e255edc63f856182b9ccb;hb=c7432833fe3a6469d63fad135151a92e12877b94;hp=0000000000000000000000000000000000000000;hpb=b9ddd4a2ed601bc01ddacc69d2522687a93a94ce;p=swftools.git diff --git a/pdf2swf/xpdf/GMutex.h b/pdf2swf/xpdf/GMutex.h new file mode 100644 index 0000000..7fa93d8 --- /dev/null +++ b/pdf2swf/xpdf/GMutex.h @@ -0,0 +1,49 @@ +//======================================================================== +// +// GMutex.h +// +// Portable mutex macros. +// +// Copyright 2002-2003 Glyph & Cog, LLC +// +//======================================================================== + +#ifndef GMUTEX_H +#define GMUTEX_H + +// Usage: +// +// GMutex m; +// gInitMutex(&m); +// ... +// gLockMutex(&m); +// ... critical section ... +// gUnlockMutex(&m); +// ... +// gDestroyMutex(&m); + +#ifdef WIN32 + +#include + +typedef CRITICAL_SECTION GMutex; + +#define gInitMutex(m) InitializeCriticalSection(m) +#define gDestroyMutex(m) DeleteCriticalSection(m) +#define gLockMutex(m) EnterCriticalSection(m) +#define gUnlockMutex(m) LeaveCriticalSection(m) + +#else // assume pthreads + +#include + +typedef pthread_mutex_t GMutex; + +#define gInitMutex(m) pthread_mutex_init(m, NULL) +#define gDestroyMutex(m) pthread_mutex_destroy(m) +#define gLockMutex(m) pthread_mutex_lock(m) +#define gUnlockMutex(m) pthread_mutex_unlock(m) + +#endif + +#endif