2 * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
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
12 #ifndef HEADER_ASYNC_H
13 # define HEADER_ASYNC_H
17 #define OSSL_ASYNC_FD HANDLE
18 #define OSSL_BAD_ASYNC_FD INVALID_HANDLE_VALUE
20 #define OSSL_ASYNC_FD int
21 #define OSSL_BAD_ASYNC_FD -1
29 typedef struct async_job_st ASYNC_JOB;
30 typedef struct async_wait_ctx_st ASYNC_WAIT_CTX;
33 #define ASYNC_NO_JOBS 1
35 #define ASYNC_FINISH 3
37 int ASYNC_init_thread(size_t max_size, size_t init_size);
38 void ASYNC_cleanup_thread(void);
40 ASYNC_WAIT_CTX *ASYNC_WAIT_CTX_new(void);
41 void ASYNC_WAIT_CTX_free(ASYNC_WAIT_CTX *ctx);
42 int ASYNC_WAIT_CTX_set_wait_fd(ASYNC_WAIT_CTX *ctx, const void *key,
45 void (*cleanup)(ASYNC_WAIT_CTX *, const void *,
46 OSSL_ASYNC_FD, void *));
47 int ASYNC_WAIT_CTX_get_fd(ASYNC_WAIT_CTX *ctx, const void *key,
48 OSSL_ASYNC_FD *fd, void **custom_data);
49 int ASYNC_WAIT_CTX_get_all_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *fd,
51 int ASYNC_WAIT_CTX_get_changed_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *addfd,
52 size_t *numaddfds, OSSL_ASYNC_FD *delfd,
54 int ASYNC_WAIT_CTX_clear_fd(ASYNC_WAIT_CTX *ctx, const void *key);
56 int ASYNC_is_capable(void);
58 int ASYNC_start_job(ASYNC_JOB **job, ASYNC_WAIT_CTX *ctx, int *ret,
59 int (*func)(void *), void *args, size_t size);
60 int ASYNC_pause_job(void);
62 ASYNC_JOB *ASYNC_get_current_job(void);
63 ASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job);
64 void ASYNC_block_pause(void);
65 void ASYNC_unblock_pause(void);
67 /* BEGIN ERROR CODES */
69 * The following lines are auto generated by the script mkerr.pl. Any changes
70 * made after this point may be overwritten when the script is next run.
72 void ERR_load_ASYNC_strings(void);
74 /* Error codes for the ASYNC functions. */
77 # define ASYNC_F_ASYNC_CTX_NEW 100
78 # define ASYNC_F_ASYNC_INIT_THREAD 101
79 # define ASYNC_F_ASYNC_JOB_NEW 102
80 # define ASYNC_F_ASYNC_PAUSE_JOB 103
81 # define ASYNC_F_ASYNC_START_FUNC 104
82 # define ASYNC_F_ASYNC_START_JOB 105
85 # define ASYNC_R_CANNOT_CREATE_WAIT_PIPE 100
86 # define ASYNC_R_FAILED_TO_SET_POOL 101
87 # define ASYNC_R_FAILED_TO_SWAP_CONTEXT 102
88 # define ASYNC_R_INIT_FAILED 105
89 # define ASYNC_R_INVALID_POOL_SIZE 103
90 # define ASYNC_R_POOL_ALREADY_INITED 104