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 | #include <stdlib.h> |
11 | |
12 | #ifndef HEADER_ASYNC_H |
13 | # define |
14 | |
15 | #if defined(_WIN32) |
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 |
20 | # endif |
21 | #else |
22 | #define OSSL_ASYNC_FD int |
23 | #define OSSL_BAD_ASYNC_FD -1 |
24 | #endif |
25 | |
26 | |
27 | # ifdef __cplusplus |
28 | extern "C" { |
29 | # endif |
30 | |
31 | typedef struct async_job_st ASYNC_JOB; |
32 | typedef struct async_wait_ctx_st ASYNC_WAIT_CTX; |
33 | |
34 | #define ASYNC_ERR 0 |
35 | #define ASYNC_NO_JOBS 1 |
36 | #define ASYNC_PAUSE 2 |
37 | #define ASYNC_FINISH 3 |
38 | |
39 | int ASYNC_init_thread(size_t max_size, size_t init_size); |
40 | void ASYNC_cleanup_thread(void); |
41 | |
42 | #ifdef OSSL_ASYNC_FD |
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, |
46 | OSSL_ASYNC_FD fd, |
47 | void *custom_data, |
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, |
53 | size_t *numfds); |
54 | int ASYNC_WAIT_CTX_get_changed_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *addfd, |
55 | size_t *numaddfds, OSSL_ASYNC_FD *delfd, |
56 | size_t *numdelfds); |
57 | int ASYNC_WAIT_CTX_clear_fd(ASYNC_WAIT_CTX *ctx, const void *key); |
58 | #endif |
59 | |
60 | int ASYNC_is_capable(void); |
61 | |
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); |
65 | |
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); |
70 | |
71 | /* BEGIN ERROR CODES */ |
72 | /* |
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. |
75 | */ |
76 | |
77 | int ERR_load_ASYNC_strings(void); |
78 | |
79 | /* Error codes for the ASYNC functions. */ |
80 | |
81 | /* Function codes. */ |
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 |
88 | |
89 | /* Reason codes. */ |
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 |
94 | |
95 | # ifdef __cplusplus |
96 | } |
97 | # endif |
98 | #endif |
99 | |