DTNMA Reference Tools v2.2.0 - 14.ge930b04
Delay-Tolerant Networking Management Architecture (DTNMA) Tool Suite
Loading...
Searching...
No Matches
mutex.h File Reference

This file contains preprocessor utility definitions shared among the CACE library. More...

#include "logging.h"
#include "defs.h"
+ Include dependency graph for mutex.h:
+ This graph shows which files directly or indirectly include this file:

Macros

#define CACE_INTERNAL_LOCK(func, mutex)
 Lock a mutex and terminate if failed.
 
#define CACE_INTERNAL_UNLOCK(func, mutex)
 Unlock a mutex and terminate if failed.
 
#define CACE_MUTEX_LOCK(mutex)   CACE_INTERNAL_LOCK(pthread_mutex_lock, mutex)
 Lock a mutex and terminate if failed.
 
#define CACE_MUTEX_UNLOCK(mutex)   CACE_INTERNAL_UNLOCK(pthread_mutex_unlock, mutex)
 Unlock a mutex and terminate if failed.
 

Detailed Description

This file contains preprocessor utility definitions shared among the CACE library.

Macro Definition Documentation

◆ CACE_INTERNAL_LOCK

#define CACE_INTERNAL_LOCK (   func,
  mutex 
)
Value:
do \
{ \
CACE_LOG_DEBUG("locking mutex %s", #mutex); \
int res = (func)((mutex)); \
if (UNLIKELY(res != 0)) \
{ \
fprintf(stderr, "failed to lock mutex %s got %d", #mutex, res); \
abort(); \
} \
} \
while (false)
#define UNLIKELY(expr)
Definition defs.h:47

Lock a mutex and terminate if failed.

Warning
This macro is internal.
Parameters
funcThe locking function
mutexA pointer to the mutex

◆ CACE_INTERNAL_UNLOCK

#define CACE_INTERNAL_UNLOCK (   func,
  mutex 
)
Value:
do \
{ \
CACE_LOG_DEBUG("unlocking mutex %s", #mutex); \
int res = (func)((mutex)); \
if (UNLIKELY(res != 0)) \
{ \
fprintf(stderr, "failed to unlock mutex %s got %d", #mutex, res); \
abort(); \
} \
} \
while (false)

Unlock a mutex and terminate if failed.

Warning
This macro is internal.
Parameters
funcThe unlocking function
mutexA pointer to the mutex

◆ CACE_MUTEX_LOCK

#define CACE_MUTEX_LOCK (   mutex)    CACE_INTERNAL_LOCK(pthread_mutex_lock, mutex)

Lock a mutex and terminate if failed.

◆ CACE_MUTEX_UNLOCK

#define CACE_MUTEX_UNLOCK (   mutex)    CACE_INTERNAL_UNLOCK(pthread_mutex_unlock, mutex)

Unlock a mutex and terminate if failed.