File indexing completed on 2025-01-18 10:05:38
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <stdlib.h>
0011
0012 #ifndef OPENSSL_ASYNC_H
0013 # define OPENSSL_ASYNC_H
0014 # pragma once
0015
0016 # include <openssl/macros.h>
0017 # ifndef OPENSSL_NO_DEPRECATED_3_0
0018 # define HEADER_ASYNC_H
0019 # endif
0020
0021 #if defined(_WIN32)
0022 # if defined(BASETYPES) || defined(_WINDEF_H)
0023
0024 #define OSSL_ASYNC_FD HANDLE
0025 #define OSSL_BAD_ASYNC_FD INVALID_HANDLE_VALUE
0026 # endif
0027 #else
0028 #define OSSL_ASYNC_FD int
0029 #define OSSL_BAD_ASYNC_FD -1
0030 #endif
0031 # include <openssl/asyncerr.h>
0032
0033
0034 # ifdef __cplusplus
0035 extern "C" {
0036 # endif
0037
0038 typedef struct async_job_st ASYNC_JOB;
0039 typedef struct async_wait_ctx_st ASYNC_WAIT_CTX;
0040 typedef int (*ASYNC_callback_fn)(void *arg);
0041
0042 #define ASYNC_ERR 0
0043 #define ASYNC_NO_JOBS 1
0044 #define ASYNC_PAUSE 2
0045 #define ASYNC_FINISH 3
0046
0047 #define ASYNC_STATUS_UNSUPPORTED 0
0048 #define ASYNC_STATUS_ERR 1
0049 #define ASYNC_STATUS_OK 2
0050 #define ASYNC_STATUS_EAGAIN 3
0051
0052 int ASYNC_init_thread(size_t max_size, size_t init_size);
0053 void ASYNC_cleanup_thread(void);
0054
0055 #ifdef OSSL_ASYNC_FD
0056 ASYNC_WAIT_CTX *ASYNC_WAIT_CTX_new(void);
0057 void ASYNC_WAIT_CTX_free(ASYNC_WAIT_CTX *ctx);
0058 int ASYNC_WAIT_CTX_set_wait_fd(ASYNC_WAIT_CTX *ctx, const void *key,
0059 OSSL_ASYNC_FD fd,
0060 void *custom_data,
0061 void (*cleanup)(ASYNC_WAIT_CTX *, const void *,
0062 OSSL_ASYNC_FD, void *));
0063 int ASYNC_WAIT_CTX_get_fd(ASYNC_WAIT_CTX *ctx, const void *key,
0064 OSSL_ASYNC_FD *fd, void **custom_data);
0065 int ASYNC_WAIT_CTX_get_all_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *fd,
0066 size_t *numfds);
0067 int ASYNC_WAIT_CTX_get_callback(ASYNC_WAIT_CTX *ctx,
0068 ASYNC_callback_fn *callback,
0069 void **callback_arg);
0070 int ASYNC_WAIT_CTX_set_callback(ASYNC_WAIT_CTX *ctx,
0071 ASYNC_callback_fn callback,
0072 void *callback_arg);
0073 int ASYNC_WAIT_CTX_set_status(ASYNC_WAIT_CTX *ctx, int status);
0074 int ASYNC_WAIT_CTX_get_status(ASYNC_WAIT_CTX *ctx);
0075 int ASYNC_WAIT_CTX_get_changed_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *addfd,
0076 size_t *numaddfds, OSSL_ASYNC_FD *delfd,
0077 size_t *numdelfds);
0078 int ASYNC_WAIT_CTX_clear_fd(ASYNC_WAIT_CTX *ctx, const void *key);
0079 #endif
0080
0081 int ASYNC_is_capable(void);
0082
0083 typedef void *(*ASYNC_stack_alloc_fn)(size_t *num);
0084 typedef void (*ASYNC_stack_free_fn)(void *addr);
0085
0086 int ASYNC_set_mem_functions(ASYNC_stack_alloc_fn alloc_fn,
0087 ASYNC_stack_free_fn free_fn);
0088 void ASYNC_get_mem_functions(ASYNC_stack_alloc_fn *alloc_fn,
0089 ASYNC_stack_free_fn *free_fn);
0090
0091 int ASYNC_start_job(ASYNC_JOB **job, ASYNC_WAIT_CTX *ctx, int *ret,
0092 int (*func)(void *), void *args, size_t size);
0093 int ASYNC_pause_job(void);
0094
0095 ASYNC_JOB *ASYNC_get_current_job(void);
0096 ASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job);
0097 void ASYNC_block_pause(void);
0098 void ASYNC_unblock_pause(void);
0099
0100
0101 # ifdef __cplusplus
0102 }
0103 # endif
0104 #endif