IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 21349


Ignore:
Timestamp:
Feb 5, 2009, 3:06:45 PM (17 years ago)
Author:
eugene
Message:

fixed macros to work under USE_GNU and PS_MUTEX_CAREFUL (removed inline comments)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/sys/psMutex.h

    r19232 r21349  
    1717
    1818// These bells and whistles are only defined if PS_MUTEX_CAREFUL and __USE_GNU are both defined
    19 #define PS_MUTEX_TYPE PTHREAD_MUTEX_ERRORCHECK_NP // Error-checking mutex
    20 #define PS_MUTEX_TRACE(LEVEL, STRING, PTR) psTrace("psLib.sys.mutex", LEVEL, STRING, #PTR); // Trace message
    21 #define PS_MUTEX_TRACE_THREAD(LEVEL, STRING, PTR) \ // Trace message with thread and pointer
    22     psTrace("psLib.sys.mutex", LEVEL, STRING, (void*)pthread_self(), #PTR);
    23 #define PS_MUTEX_CHECK_DEADLOCK() \     // Check for dead-locked mutex
     19
     20// Error-checking mutex
     21#define PS_MUTEX_TYPE PTHREAD_MUTEX_ERRORCHECK_NP
     22
     23#define PS_MUTEX_TRACE(LEVEL, STRING, PTR) psTrace("psLib.sys.mutex", LEVEL, STRING, #PTR, (unsigned long) PTR); // Trace message
     24
     25// Trace message with thread and pointer
     26#define PS_MUTEX_TRACE_THREAD(LEVEL, STRING, PTR) \
     27    psTrace("psLib.sys.mutex", LEVEL, STRING, (void*)pthread_self(), #PTR, (unsigned long) PTR);
     28
     29// Check for dead-locked mutex
     30#define PS_MUTEX_CHECK_DEADLOCK(PTR) \
    2431    if (pml == EDEADLK) { \
    25         psAbort("Deadlocked mutex on %s", #PTR); \
     32        psAbort("Deadlocked mutex on %s (%lx)", #PTR, (unsigned long) PTR); \
    2633    }
    27 #define PS_MUTEX_CHECK_STOLEN(PTR) \       // Check for stolen mutex
     34
     35// Check for stolen mutex
     36#define PS_MUTEX_CHECK_STOLEN(PTR) \
    2837    if (pmu == EPERM) { \
    29         psAbort("Unlocking stolen mutex on %s", #PTR); \
     38        psAbort("Unlocking stolen mutex on %s (%lx)", #PTR, (unsigned long) PTR);       \
    3039    }
    3140
     
    5362#define psMutexInit(PTR) { \
    5463    psAssert(PTR, "Require non-NULL pointer to initialise mutex"); \
    55     PS_MUTEX_TRACE(3, "Initialising mutex on %s...", PTR); \
     64    PS_MUTEX_TRACE(3, "Initialising mutex on %s (%lx)...", PTR); \
    5665    /* Gotta go the long way, since we can't use PTHREAD_MUTEX_INITIALIZER after we declare the variable */ \
    5766    pthread_mutexattr_t attr; /* Mutex attributes */ \
     
    6574#define psMutexLock(PTR) { \
    6675    psAssert(PTR, "Require non-NULL pointer to lock mutex"); \
    67     PS_MUTEX_TRACE_THREAD(1, "Thread %p waiting for mutex lock on %s...", PTR); \
     76    PS_MUTEX_TRACE_THREAD(1, "Thread %p waiting for mutex lock on %s (%lx)...", PTR); \
    6877    int pml = pthread_mutex_lock(&(PTR)->lock); \
    69     PS_MUTEX_TRACE_THREAD(1, "Thread %p locked mutex on %s", PTR); \
     78    PS_MUTEX_TRACE_THREAD(1, "Thread %p locked mutex on %s (%lx)", PTR); \
    7079    if (pml == EINVAL) { \
    71         psAbort("Cannot lock mutex on %s: not initialised", #PTR); \
     80        psAbort("Cannot lock mutex on %s (%lx): not initialised", #PTR, (unsigned long) PTR); \
    7281    } \
    7382    PS_MUTEX_CHECK_DEADLOCK(PTR); \
     
    7786#define psMutexUnlock(PTR) { \
    7887    psAssert(PTR, "Require non-NULL pointer to unlock mutex"); \
    79     PS_MUTEX_TRACE_THREAD(1, "Thread %p unlocking mutex on %s", PTR); \
     88    PS_MUTEX_TRACE_THREAD(1, "Thread %p unlocking mutex on %s (%lx)", PTR); \
    8089    int pmu = pthread_mutex_unlock(&(PTR)->lock); \
    8190    if (pmu == EINVAL) { \
    82         psAbort("Cannot unlock mutex on %s: not initialised", #PTR); \
     91        psAbort("Cannot unlock mutex on %s (%lx): not initialised", #PTR, (unsigned long) PTR); \
    8392    } \
    8493    PS_MUTEX_CHECK_STOLEN(PTR); \
     
    8998    psAssert(PTR, "Require non-NULL pointer to destroy mutex"); \
    9099    if (pthread_mutex_destroy(&(PTR)->lock) == EBUSY) { \
    91         psAbort("Cannot destroy mutex on %s: is busy", #PTR); \
     100        psAbort("Cannot destroy mutex on %s (%lx): is busy", #PTR, (unsigned long) PTR);        \
    92101    } \
    93102}
Note: See TracChangeset for help on using the changeset viewer.