Wrapped mutex lock / unlock functions into function rather than macro
This commit is contained in:
parent
ed5457c76f
commit
e06ea6dc06
|
@ -5,7 +5,6 @@
|
|||
#include <openssl/crypto.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
|
22
src/util.c
22
src/util.c
|
@ -31,3 +31,25 @@ int64_t round_div(int64_t a, int64_t b)
|
|||
{
|
||||
return (a + (b / 2)) / b;
|
||||
}
|
||||
|
||||
void PTHREAD_MUTEX_UNLOCK(pthread_mutex_t *x)
|
||||
{
|
||||
int i;
|
||||
i = pthread_mutex_unlock(x);
|
||||
if (i) {
|
||||
fprintf(stderr, "pthread_mutex_unlock failed, %d, %s\n", i,
|
||||
strerror(i));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
void PTHREAD_MUTEX_LOCK(pthread_mutex_t *x)
|
||||
{
|
||||
int i;
|
||||
i = pthread_mutex_lock(x);
|
||||
if (i) {
|
||||
fprintf(stderr, "pthread_mutex_lock failed, %d, %s\n", i,
|
||||
strerror(i));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
|
24
src/util.h
24
src/util.h
|
@ -5,6 +5,7 @@
|
|||
* \brief utility functions
|
||||
*/
|
||||
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -20,30 +21,13 @@
|
|||
/**
|
||||
* \brief wrapper for pthread_mutex_lock()
|
||||
*/
|
||||
#define PTHREAD_MUTEX_LOCK(x)\
|
||||
({\
|
||||
int i;\
|
||||
i = pthread_mutex_lock(x);\
|
||||
if (i) { \
|
||||
fprintf(stderr, "pthread_mutex_lock failed, %d, %s\n", i, \
|
||||
strerror(i));\
|
||||
exit(EXIT_FAILURE);\
|
||||
}\
|
||||
})
|
||||
void PTHREAD_MUTEX_LOCK(pthread_mutex_t *x);
|
||||
|
||||
/**
|
||||
* \brief wrapper for pthread_mutex_unlock()
|
||||
*/
|
||||
#define PTHREAD_MUTEX_UNLOCK(x)\
|
||||
({\
|
||||
int i;\
|
||||
i = pthread_mutex_unlock(x);\
|
||||
if (i) { \
|
||||
fprintf(stderr, "pthread_mutex_unlock failed, %d, %s\n", i, \
|
||||
strerror(i));\
|
||||
exit(EXIT_FAILURE);\
|
||||
}\
|
||||
})
|
||||
void PTHREAD_MUTEX_UNLOCK(pthread_mutex_t *x);
|
||||
|
||||
|
||||
/**
|
||||
* \brief append a path
|
||||
|
|
Loading…
Reference in New Issue