thread.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #ifndef OPENSSL_INTERNAL_THREAD_H
  10. # define OPENSSL_INTERNAL_THREAD_H
  11. # include <openssl/configuration.h>
  12. # include <internal/thread_arch.h>
  13. # include <openssl/e_os2.h>
  14. # include <openssl/types.h>
  15. # include <internal/cryptlib.h>
  16. # include "crypto/context.h"
  17. void *ossl_crypto_thread_start(OSSL_LIB_CTX *ctx, CRYPTO_THREAD_ROUTINE start,
  18. void *data);
  19. int ossl_crypto_thread_join(void *task, CRYPTO_THREAD_RETVAL *retval);
  20. int ossl_crypto_thread_clean(void *vhandle);
  21. uint64_t ossl_get_avail_threads(OSSL_LIB_CTX *ctx);
  22. # if defined(OPENSSL_THREADS)
  23. # define OSSL_LIB_CTX_GET_THREADS(CTX) \
  24. ossl_lib_ctx_get_data(CTX, OSSL_LIB_CTX_THREAD_INDEX);
  25. typedef struct openssl_threads_st {
  26. uint64_t max_threads;
  27. uint64_t active_threads;
  28. CRYPTO_MUTEX *lock;
  29. CRYPTO_CONDVAR *cond_finished;
  30. } OSSL_LIB_CTX_THREADS;
  31. # endif /* defined(OPENSSL_THREADS) */
  32. #endif /* OPENSSL_INTERNAL_THREAD_H */