diff options
Diffstat (limited to 'src/posix-lock.c')
-rw-r--r-- | src/posix-lock.c | 37 |
1 files changed, 8 insertions, 29 deletions
diff --git a/src/posix-lock.c b/src/posix-lock.c index d251d2f..b5e6916 100644 --- a/src/posix-lock.c +++ b/src/posix-lock.c @@ -39,19 +39,11 @@ # include <pthread.h> #endif -#include "gpg-error.h" +#include "gpgrt-int.h" #include "lock.h" #include "posix-lock-obj.h" -/* - * Functions called before and after blocking syscalls. - * gpgrt_set_syscall_clamp is used to set them. - */ -static void (*pre_lock_func)(void); -static void (*post_lock_func)(void); - - #if USE_POSIX_THREADS # if USE_POSIX_THREADS_WEAK /* On ELF systems it is easy to use pthreads using weak @@ -111,17 +103,6 @@ use_pthread_p (void) #endif /*USE_POSIX_THREADS*/ -/* Helper to set the clamp functions. This is called as a helper from - * _gpgrt_set_syscall_clamp to keep the function pointers local. */ -void -_gpgrt_lock_set_lock_clamp (void (*pre)(void), void (*post)(void)) -{ - pre_lock_func = pre; - post_lock_func = post; -} - - - static _gpgrt_lock_t * get_lock_object (gpgrt_lock_t *lockhd) { @@ -168,7 +149,7 @@ _gpgrt_lock_init (gpgrt_lock_t *lockhd) { rc = pthread_mutex_init (&lock->u.mtx, NULL); if (rc) - rc = gpg_err_code_from_errno (rc); + rc = _gpg_err_code_from_errno (rc); } else rc = 0; /* Threads are not used. */ @@ -189,13 +170,11 @@ _gpgrt_lock_lock (gpgrt_lock_t *lockhd) #if USE_POSIX_THREADS if (use_pthread_p()) { - if (pre_lock_func) - pre_lock_func (); + _gpgrt_pre_syscall (); rc = pthread_mutex_lock (&lock->u.mtx); if (rc) - rc = gpg_err_code_from_errno (rc); - if (post_lock_func) - post_lock_func (); + rc = _gpg_err_code_from_errno (rc); + _gpgrt_post_syscall (); } else rc = 0; /* Threads are not used. */ @@ -218,7 +197,7 @@ _gpgrt_lock_trylock (gpgrt_lock_t *lockhd) { rc = pthread_mutex_trylock (&lock->u.mtx); if (rc) - rc = gpg_err_code_from_errno (rc); + rc = _gpg_err_code_from_errno (rc); } else rc = 0; /* Threads are not used. */ @@ -241,7 +220,7 @@ _gpgrt_lock_unlock (gpgrt_lock_t *lockhd) { rc = pthread_mutex_unlock (&lock->u.mtx); if (rc) - rc = gpg_err_code_from_errno (rc); + rc = _gpg_err_code_from_errno (rc); } else rc = 0; /* Threads are not used. */ @@ -266,7 +245,7 @@ _gpgrt_lock_destroy (gpgrt_lock_t *lockhd) { rc = pthread_mutex_destroy (&lock->u.mtx); if (rc) - rc = gpg_err_code_from_errno (rc); + rc = _gpg_err_code_from_errno (rc); else { /* Re-init the mutex so that it can be re-used. */ |