diff options
Diffstat (limited to 'tests/mock-module.c')
-rw-r--r-- | tests/mock-module.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/tests/mock-module.c b/tests/mock-module.c index 201fffc..1b7822a 100644 --- a/tests/mock-module.c +++ b/tests/mock-module.c @@ -34,10 +34,12 @@ #include "config.h" +#define CRYPTOKI_EXPORTS #include "pkcs11.h" #include "mock-module.h" -#include <pthread.h> +#include "p11-kit/compat.h" + #include <stdarg.h> #include <stdio.h> #include <string.h> @@ -48,7 +50,7 @@ */ /* Various mutexes */ -static pthread_mutex_t init_mutex = PTHREAD_MUTEX_INITIALIZER; +static mutex_t init_mutex; /* Whether we've been initialized, and on what process id it happened */ static int pkcs11_initialized = 0; @@ -95,7 +97,7 @@ mock_C_Initialize (CK_VOID_PTR init_args) debug (("C_Initialize: enter")); - pthread_mutex_lock (&init_mutex); + mutex_lock (&init_mutex); if (init_args != NULL) { int supplied_ok; @@ -146,7 +148,7 @@ done: pkcs11_initialized_pid = 0; } - pthread_mutex_unlock (&init_mutex); + mutex_unlock (&init_mutex); debug (("C_Initialize: %d", ret)); return ret; @@ -159,13 +161,13 @@ mock_C_Finalize (CK_VOID_PTR reserved) return_val_if_fail (pkcs11_initialized != 0, CKR_CRYPTOKI_NOT_INITIALIZED); return_val_if_fail (reserved == NULL, CKR_ARGUMENTS_BAD); - pthread_mutex_lock (&init_mutex); + mutex_lock (&init_mutex); /* This should stop all other calls in */ pkcs11_initialized = 0; pkcs11_initialized_pid = 0; - pthread_mutex_unlock (&init_mutex); + mutex_unlock (&init_mutex); debug (("C_Finalize: %d", CKR_OK)); return CKR_OK; @@ -884,3 +886,9 @@ CK_FUNCTION_LIST mock_module_no_slots = { mock_C_CancelFunction__not_parallel, mock_C_WaitForSlotEvent__no_event, }; + +void +mock_module_init (void) +{ + mutex_init (&init_mutex); +} |