1/*
2 * Copyright 2015-2018 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 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
29extern "C" {
30# endif
31
32typedef struct async_job_st ASYNC_JOB;
33typedef struct async_wait_ctx_st ASYNC_WAIT_CTX;
34
35#define ASYNC_ERR 0
36#define ASYNC_NO_JOBS 1
37#define ASYNC_PAUSE 2
38#define ASYNC_FINISH 3
39
40int ASYNC_init_thread(size_t max_size, size_t init_size);
41void ASYNC_cleanup_thread(void);
42
43#ifdef OSSL_ASYNC_FD
44ASYNC_WAIT_CTX *ASYNC_WAIT_CTX_new(void);
45void ASYNC_WAIT_CTX_free(ASYNC_WAIT_CTX *ctx);
46int ASYNC_WAIT_CTX_set_wait_fd(ASYNC_WAIT_CTX *ctx, const void *key,
47 OSSL_ASYNC_FD fd,
48 void *custom_data,
49 void (*cleanup)(ASYNC_WAIT_CTX *, const void *,
50 OSSL_ASYNC_FD, void *));
51int ASYNC_WAIT_CTX_get_fd(ASYNC_WAIT_CTX *ctx, const void *key,
52 OSSL_ASYNC_FD *fd, void **custom_data);
53int ASYNC_WAIT_CTX_get_all_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *fd,
54 size_t *numfds);
55int ASYNC_WAIT_CTX_get_changed_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *addfd,
56 size_t *numaddfds, OSSL_ASYNC_FD *delfd,
57 size_t *numdelfds);
58int ASYNC_WAIT_CTX_clear_fd(ASYNC_WAIT_CTX *ctx, const void *key);
59#endif
60
61int ASYNC_is_capable(void);
62
63int ASYNC_start_job(ASYNC_JOB **job, ASYNC_WAIT_CTX *ctx, int *ret,
64 int (*func)(void *), void *args, size_t size);
65int ASYNC_pause_job(void);
66
67ASYNC_JOB *ASYNC_get_current_job(void);
68ASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job);
69void ASYNC_block_pause(void);
70void ASYNC_unblock_pause(void);
71
72
73# ifdef __cplusplus
74}
75# endif
76#endif
77