Ticket #185: poppler-netlabs-20180813-1429-shl.diff

File poppler-netlabs-20180813-1429-shl.diff, 3.6 KB (added by Gregg Young, 6 years ago)
  • poppler/GlobalParams.cc

    Generated on slamain at 08-13-18 14:29:38
    svn diff -x -w 
     
    4848#define INCL_DOSMODULEMGR
    4949#define INCL_DOSERRORS
    5050#include <os2.h>
     51
     52#define GLOBAL_PARAMS_CC                // Tell GooMutex this is us
     53
    5154#endif
    5255
    5356#ifdef USE_GCC_PRAGMAS
     
    133136
    134137GlobalParams *globalParams = NULL;
    135138
     139// 2018-08-13 SHL
     140#if MULTITHREADED
     141#if __OS2__
     142GooMutex theOS2Mutex;
     143#endif
     144#endif
     145
     146
    136147//------------------------------------------------------------------------
    137148// PSFontParam16
    138149//------------------------------------------------------------------------
     
    631642  gInitMutex(&mutex);
    632643  gInitMutex(&unicodeMapCacheMutex);
    633644  gInitMutex(&cMapCacheMutex);
     645
     646#ifdef __OS2__ // 2018-08-13 SHL Single mutux
     647  gInitMutex(&theOS2Mutex);
    634648#endif
     649#endif
    635650
    636651  initBuiltinFontTables();
    637652
     
    903918  gDestroyMutex(&mutex);
    904919  gDestroyMutex(&unicodeMapCacheMutex);
    905920  gDestroyMutex(&cMapCacheMutex);
     921
     922#ifdef __OS2__ // 2018-08-13 SHL Single mutux
     923  gDestroyMutex(&theOS2Mutex);
     924  theOS2Mutex = 0;
    906925#endif
     926#endif
    907927}
    908928
    909929//------------------------------------------------------------------------
  • goo/GooMutex.h

     
    5454#define gLockMutex(m) EnterCriticalSection(m)
    5555#define gUnlockMutex(m) LeaveCriticalSection(m)
    5656
    57 /* #elif defined(__OS2__) I don't think we still need that
     57#elif defined(__OS2__)
    5858
    59 #define INCL_DOS
    60 #include <os2.h>
     59/* OS/2 multi-threaded uses pthreads but differs from Linux support
     60   in that it uses a single mutex for all protected objects
     61   rather than a unique mutex for each object
     62   except when invoked for GlobalParams.cc
     63*/
    6164
    62 typedef HMTX GooMutex;
     65#include <pthread.h>
    6366
    64 #define gInitMutex(m) DosCreateMutexSem(NULL,m,0,FALSE)
    65 #define gDestroyMutex(m) DosCloseMutexSem(*m)
    66 #define gLockMutex(m) DosRequestMutexSem(*m,SEM_INDEFINITE_WAIT)
    67 #define gUnlockMutex(m) DosReleaseMutexSem(*m)
     67typedef pthread_mutex_t GooMutex2;
     68
     69#ifdef GLOBAL_PARAMS_CC
     70
     71typedef pthread_mutex_t GooMutex;
     72
     73// Keep in sync with Linux style mutexes
     74
     75inline void gInitMutex(GooMutex *m) {
     76  pthread_mutexattr_t mutexattr;
     77  pthread_mutexattr_init(&mutexattr);
     78  pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_RECURSIVE);
     79  pthread_mutex_init(m, &mutexattr);
     80  pthread_mutexattr_destroy(&mutexattr);
     81}
     82
     83#define gDestroyMutex(m) pthread_mutex_destroy(m)
     84
     85#define gLockMutex(m) pthread_mutex_lock(m)
     86#define gUnlockMutex(m) pthread_mutex_unlock(m)
     87
     88#else
     89
     90/* Use single mutex everywhere other than GlobalParams.cc.
     91   This avoids OS/2 running out of semaphores when documents
     92   require a large number of class instances.
     93   All classes other than those defined in GlobalParams.cc will
     94   use the same mutex (theOS2Mutex).
     95   GooMutex is typedef'ed as a pointer so macro users will pass
     96   a pointer to a pointer.
     97   The macros dereference this pointer and pass a pointer to apthread_mutex
     98   to the pthreads functions.
     99   2018-08-13 SHL
    68100*/
     101
     102class MutexLocker;
     103typedef pthread_mutex_t *GooMutex;
     104
     105inline void gInitMutex(GooMutex *m) {
     106  extern GooMutex2 theOS2Mutex;
     107  *(m) = &theOS2Mutex;
     108}
     109#define gDestroyMutex(m)                // Do nothing
     110
     111#define gLockMutex(m) pthread_mutex_lock(*(m))
     112#define gUnlockMutex(m) pthread_mutex_unlock(*(m))
     113
     114#endif // __OS2__
     115
    69116#else // assume pthreads
    70117
    71118#include <pthread.h>