-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored locking and mutex routines
(implemented OpenSSL mutex routines to also use in the existing locking routines)
- Loading branch information
Showing
7 changed files
with
115 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright 2019-2023 The OpenSSL Project Authors. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License 2.0 (the "License"). You may not use | ||
* this file except in compliance with the License. You can obtain a copy | ||
* in the file LICENSE in the source distribution or at | ||
* https://www.openssl.org/source/license.html | ||
*/ | ||
|
||
#include <internal/thread_arch.h> | ||
|
||
#if defined(OPENSSL_THREADS_AMISSL) | ||
|
||
# include <proto/exec.h> | ||
|
||
# if defined(__amigaos4__) | ||
|
||
# define ALLOC_LOCK(mutex) mutex = AllocSysObject(ASOT_MUTEX, NULL) | ||
# define FREE_LOCK(mutex) if (mutex != NULL) FreeSysObject(ASOT_MUTEX, mutex) | ||
# define OBTAIN_LOCK(mutex) MutexObtain(mutex) | ||
# define ATTEMPT_LOCK(mutex) MutexAttempt(mutex) | ||
# define RELEASE_LOCK(mutex) MutexRelease(mutex) | ||
|
||
# else | ||
|
||
# define ALLOC_LOCK(sem) if ((sem = OPENSSL_zalloc(sizeof(struct SignalSemaphore))) != NULL) InitSemaphore((struct SignalSemaphore *)sem) | ||
# define FREE_LOCK(sem) if (sem != NULL) OPENSSL_free(sem) | ||
# define OBTAIN_LOCK(sem) ObtainSemaphore((struct SignalSemaphore *)sem) | ||
# define ATTEMPT_LOCK(sem) AttemptSemaphore((struct SignalSemaphore *)sem) | ||
# define RELEASE_LOCK(sem) ReleaseSemaphore((struct SignalSemaphore *)sem) | ||
|
||
# endif | ||
|
||
CRYPTO_MUTEX *ossl_crypto_mutex_new(void) | ||
{ | ||
CRYPTO_MUTEX *mutex; | ||
ALLOC_LOCK(mutex); | ||
return mutex; | ||
} | ||
|
||
void ossl_crypto_mutex_lock(CRYPTO_MUTEX *mutex) | ||
{ | ||
OBTAIN_LOCK(mutex); | ||
} | ||
|
||
int ossl_crypto_mutex_try_lock(CRYPTO_MUTEX *mutex) | ||
{ | ||
return ATTEMPT_LOCK(mutex); | ||
} | ||
|
||
void ossl_crypto_mutex_unlock(CRYPTO_MUTEX *mutex) | ||
{ | ||
RELEASE_LOCK(mutex); | ||
} | ||
|
||
void ossl_crypto_mutex_free(CRYPTO_MUTEX **mutex) | ||
{ | ||
FREE_LOCK(*mutex); | ||
*mutex = NULL; | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.