Cleanse crypto/kdf directory
[openssl.git] / include / openssl / async.h
1 /*
2  * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License 2.0 (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 HEADER_ASYNC_H
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 # include <openssl/asyncerr.h>
26
27
28 # ifdef  __cplusplus
29 extern "C" {
30 # endif
31
32 typedef struct async_job_st ASYNC_JOB;
33 typedef struct async_wait_ctx_st ASYNC_WAIT_CTX;
34 typedef int (*ASYNC_callback_fn)(void *arg);
35
36 #define ASYNC_ERR      0
37 #define ASYNC_NO_JOBS  1
38 #define ASYNC_PAUSE    2
39 #define ASYNC_FINISH   3
40
41 #define ASYNC_STATUS_UNSUPPORTED    0
42 #define ASYNC_STATUS_ERR            1
43 #define ASYNC_STATUS_OK             2
44 #define ASYNC_STATUS_EAGAIN         3
45
46 int ASYNC_init_thread(size_t max_size, size_t init_size);
47 void ASYNC_cleanup_thread(void);
48
49 #ifdef OSSL_ASYNC_FD
50 ASYNC_WAIT_CTX *ASYNC_WAIT_CTX_new(void);
51 void ASYNC_WAIT_CTX_free(ASYNC_WAIT_CTX *ctx);
52 int ASYNC_WAIT_CTX_set_wait_fd(ASYNC_WAIT_CTX *ctx, const void *key,
53                                OSSL_ASYNC_FD fd,
54                                void *custom_data,
55                                void (*cleanup)(ASYNC_WAIT_CTX *, const void *,
56                                                OSSL_ASYNC_FD, void *));
57 int ASYNC_WAIT_CTX_get_fd(ASYNC_WAIT_CTX *ctx, const void *key,
58                         OSSL_ASYNC_FD *fd, void **custom_data);
59 int ASYNC_WAIT_CTX_get_all_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *fd,
60                                size_t *numfds);
61 int ASYNC_WAIT_CTX_get_callback(ASYNC_WAIT_CTX *ctx,
62                                 ASYNC_callback_fn *callback,
63                                 void **callback_arg);
64 int ASYNC_WAIT_CTX_set_callback(ASYNC_WAIT_CTX *ctx,
65                                 ASYNC_callback_fn callback,
66                                 void *callback_arg);
67 int ASYNC_WAIT_CTX_set_status(ASYNC_WAIT_CTX *ctx, int status);
68 int ASYNC_WAIT_CTX_get_status(ASYNC_WAIT_CTX *ctx);
69 int ASYNC_WAIT_CTX_get_changed_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *addfd,
70                                    size_t *numaddfds, OSSL_ASYNC_FD *delfd,
71                                    size_t *numdelfds);
72 int ASYNC_WAIT_CTX_clear_fd(ASYNC_WAIT_CTX *ctx, const void *key);
73 #endif
74
75 int ASYNC_is_capable(void);
76
77 int ASYNC_start_job(ASYNC_JOB **job, ASYNC_WAIT_CTX *ctx, int *ret,
78                     int (*func)(void *), void *args, size_t size);
79 int ASYNC_pause_job(void);
80
81 ASYNC_JOB *ASYNC_get_current_job(void);
82 ASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job);
83 void ASYNC_block_pause(void);
84 void ASYNC_unblock_pause(void);
85
86
87 # ifdef  __cplusplus
88 }
89 # endif
90 #endif