2
0

async_local.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the OpenSSL license (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. };
  40. struct fd_lookup_st {
  41. const void *key;
  42. OSSL_ASYNC_FD fd;
  43. void *custom_data;
  44. void (*cleanup)(ASYNC_WAIT_CTX *, const void *, OSSL_ASYNC_FD, void *);
  45. int add;
  46. int del;
  47. struct fd_lookup_st *next;
  48. };
  49. struct async_wait_ctx_st {
  50. struct fd_lookup_st *fds;
  51. size_t numadd;
  52. size_t numdel;
  53. };
  54. DEFINE_STACK_OF(ASYNC_JOB)
  55. struct async_pool_st {
  56. STACK_OF(ASYNC_JOB) *jobs;
  57. size_t curr_size;
  58. size_t max_size;
  59. };
  60. void async_local_cleanup(void);
  61. void async_start_func(void);
  62. async_ctx *async_get_ctx(void);
  63. void async_wait_ctx_reset_counts(ASYNC_WAIT_CTX *ctx);