async_local.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright 2015-2020 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. /*
  10. * Must do this before including any header files, because on MacOS/X <stlib.h>
  11. * includes <signal.h> which includes <ucontext.h>
  12. */
  13. #if defined(__APPLE__) && defined(__MACH__) && !defined(_XOPEN_SOURCE)
  14. # define _XOPEN_SOURCE /* Otherwise incomplete ucontext_t structure */
  15. # pragma GCC diagnostic ignored "-Wdeprecated-declarations"
  16. #endif
  17. #if defined(_WIN32)
  18. # include <windows.h>
  19. #endif
  20. #include "crypto/async.h"
  21. #include <openssl/crypto.h>
  22. typedef struct async_ctx_st async_ctx;
  23. typedef struct async_pool_st async_pool;
  24. #include "arch/async_win.h"
  25. #include "arch/async_posix.h"
  26. #include "arch/async_null.h"
  27. struct async_ctx_st {
  28. async_fibre dispatcher;
  29. ASYNC_JOB *currjob;
  30. unsigned int blocked;
  31. };
  32. struct async_job_st {
  33. async_fibre fibrectx;
  34. int (*func) (void *);
  35. void *funcargs;
  36. int ret;
  37. int status;
  38. ASYNC_WAIT_CTX *waitctx;
  39. OSSL_LIB_CTX *libctx;
  40. };
  41. struct fd_lookup_st {
  42. const void *key;
  43. OSSL_ASYNC_FD fd;
  44. void *custom_data;
  45. void (*cleanup)(ASYNC_WAIT_CTX *, const void *, OSSL_ASYNC_FD, void *);
  46. int add;
  47. int del;
  48. struct fd_lookup_st *next;
  49. };
  50. struct async_wait_ctx_st {
  51. struct fd_lookup_st *fds;
  52. size_t numadd;
  53. size_t numdel;
  54. ASYNC_callback_fn callback;
  55. void *callback_arg;
  56. int status;
  57. };
  58. DEFINE_STACK_OF(ASYNC_JOB)
  59. struct async_pool_st {
  60. STACK_OF(ASYNC_JOB) *jobs;
  61. size_t curr_size;
  62. size_t max_size;
  63. };
  64. void async_local_cleanup(void);
  65. void async_start_func(void);
  66. async_ctx *async_get_ctx(void);
  67. void async_wait_ctx_reset_counts(ASYNC_WAIT_CTX *ctx);