async.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright 2015-2018 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. #include <stdlib.h>
  10. #ifndef HEADER_ASYNC_H
  11. # define HEADER_ASYNC_H
  12. #if defined(_WIN32)
  13. # if defined(BASETYPES) || defined(_WINDEF_H)
  14. /* application has to include <windows.h> to use this */
  15. #define OSSL_ASYNC_FD HANDLE
  16. #define OSSL_BAD_ASYNC_FD INVALID_HANDLE_VALUE
  17. # endif
  18. #else
  19. #define OSSL_ASYNC_FD int
  20. #define OSSL_BAD_ASYNC_FD -1
  21. #endif
  22. # include <openssl/asyncerr.h>
  23. # ifdef __cplusplus
  24. extern "C" {
  25. # endif
  26. typedef struct async_job_st ASYNC_JOB;
  27. typedef struct async_wait_ctx_st ASYNC_WAIT_CTX;
  28. #define ASYNC_ERR 0
  29. #define ASYNC_NO_JOBS 1
  30. #define ASYNC_PAUSE 2
  31. #define ASYNC_FINISH 3
  32. int ASYNC_init_thread(size_t max_size, size_t init_size);
  33. void ASYNC_cleanup_thread(void);
  34. #ifdef OSSL_ASYNC_FD
  35. ASYNC_WAIT_CTX *ASYNC_WAIT_CTX_new(void);
  36. void ASYNC_WAIT_CTX_free(ASYNC_WAIT_CTX *ctx);
  37. int ASYNC_WAIT_CTX_set_wait_fd(ASYNC_WAIT_CTX *ctx, const void *key,
  38. OSSL_ASYNC_FD fd,
  39. void *custom_data,
  40. void (*cleanup)(ASYNC_WAIT_CTX *, const void *,
  41. OSSL_ASYNC_FD, void *));
  42. int ASYNC_WAIT_CTX_get_fd(ASYNC_WAIT_CTX *ctx, const void *key,
  43. OSSL_ASYNC_FD *fd, void **custom_data);
  44. int ASYNC_WAIT_CTX_get_all_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *fd,
  45. size_t *numfds);
  46. int ASYNC_WAIT_CTX_get_changed_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *addfd,
  47. size_t *numaddfds, OSSL_ASYNC_FD *delfd,
  48. size_t *numdelfds);
  49. int ASYNC_WAIT_CTX_clear_fd(ASYNC_WAIT_CTX *ctx, const void *key);
  50. #endif
  51. int ASYNC_is_capable(void);
  52. int ASYNC_start_job(ASYNC_JOB **job, ASYNC_WAIT_CTX *ctx, int *ret,
  53. int (*func)(void *), void *args, size_t size);
  54. int ASYNC_pause_job(void);
  55. ASYNC_JOB *ASYNC_get_current_job(void);
  56. ASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job);
  57. void ASYNC_block_pause(void);
  58. void ASYNC_unblock_pause(void);
  59. # ifdef __cplusplus
  60. }
  61. # endif
  62. #endif