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
16 # if defined(BASETYPES) || defined(_WINDEF_H)
17 /* application has to include <windows.h> to use this */
18 #define OSSL_ASYNC_FD HANDLE
19 #define OSSL_BAD_ASYNC_FD INVALID_HANDLE_VALUE
22 #define OSSL_ASYNC_FD int
23 #define OSSL_BAD_ASYNC_FD -1
31 typedef struct async_job_st ASYNC_JOB;
32 typedef struct async_wait_ctx_st ASYNC_WAIT_CTX;
35 #define ASYNC_NO_JOBS 1
37 #define ASYNC_FINISH 3
39 int ASYNC_init_thread(size_t max_size, size_t init_size);
40 void ASYNC_cleanup_thread(void);
43 ASYNC_WAIT_CTX *ASYNC_WAIT_CTX_new(void);
44 void ASYNC_WAIT_CTX_free(ASYNC_WAIT_CTX *ctx);
45 int ASYNC_WAIT_CTX_set_wait_fd(ASYNC_WAIT_CTX *ctx, const void *key,
48 void (*cleanup)(ASYNC_WAIT_CTX *, const void *,
49 OSSL_ASYNC_FD, void *));
50 int ASYNC_WAIT_CTX_get_fd(ASYNC_WAIT_CTX *ctx, const void *key,
51 OSSL_ASYNC_FD *fd, void **custom_data);
52 int ASYNC_WAIT_CTX_get_all_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *fd,
54 int ASYNC_WAIT_CTX_get_changed_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *addfd,
55 size_t *numaddfds, OSSL_ASYNC_FD *delfd,
57 int ASYNC_WAIT_CTX_clear_fd(ASYNC_WAIT_CTX *ctx, const void *key);
60 int ASYNC_is_capable(void);
62 int ASYNC_start_job(ASYNC_JOB **job, ASYNC_WAIT_CTX *ctx, int *ret,
63 int (*func)(void *), void *args, size_t size);
64 int ASYNC_pause_job(void);
66 ASYNC_JOB *ASYNC_get_current_job(void);
67 ASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job);
68 void ASYNC_block_pause(void);
69 void ASYNC_unblock_pause(void);
71 /* BEGIN ERROR CODES */
73 * The following lines are auto generated by the script mkerr.pl. Any changes
74 * made after this point may be overwritten when the script is next run.
77 int ERR_load_ASYNC_strings(void);
79 /* Error codes for the ASYNC functions. */
82 # define ASYNC_F_ASYNC_CTX_NEW 100
83 # define ASYNC_F_ASYNC_INIT_THREAD 101
84 # define ASYNC_F_ASYNC_JOB_NEW 102
85 # define ASYNC_F_ASYNC_PAUSE_JOB 103
86 # define ASYNC_F_ASYNC_START_FUNC 104
87 # define ASYNC_F_ASYNC_START_JOB 105
90 # define ASYNC_R_FAILED_TO_SET_POOL 101
91 # define ASYNC_R_FAILED_TO_SWAP_CONTEXT 102
92 # define ASYNC_R_INIT_FAILED 105
93 # define ASYNC_R_INVALID_POOL_SIZE 103