]> git.ipfire.org Git - thirdparty/openssl.git/blame - include/openssl/async.h
Fix typo in CONTRIBUTING.md
[thirdparty/openssl.git] / include / openssl / async.h
CommitLineData
a3667c31 1/*
fecb3aae 2 * Copyright 2015-2022 The OpenSSL Project Authors. All Rights Reserved.
a3667c31 3 *
48f4ad77 4 * Licensed under the Apache License 2.0 (the "License"). You may not use
21dcbebc
RS
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
a3667c31
MC
8 */
9
316fae2a
MC
10#include <stdlib.h>
11
ae4186b0
DMSP
12#ifndef OPENSSL_ASYNC_H
13# define OPENSSL_ASYNC_H
d86167ec
DMSP
14# pragma once
15
16# include <openssl/macros.h>
936c2b9e 17# ifndef OPENSSL_NO_DEPRECATED_3_0
d86167ec
DMSP
18# define HEADER_ASYNC_H
19# endif
a3667c31 20
8d35ceb9 21#if defined(_WIN32)
f1f5ee17
AP
22# if defined(BASETYPES) || defined(_WINDEF_H)
23/* application has to include <windows.h> to use this */
ff75a257
MC
24#define OSSL_ASYNC_FD HANDLE
25#define OSSL_BAD_ASYNC_FD INVALID_HANDLE_VALUE
f1f5ee17 26# endif
2b2c78d4 27#else
ff75a257
MC
28#define OSSL_ASYNC_FD int
29#define OSSL_BAD_ASYNC_FD -1
2b2c78d4 30#endif
52df25cf 31# include <openssl/asyncerr.h>
2b2c78d4
MC
32
33
a3667c31
MC
34# ifdef __cplusplus
35extern "C" {
36# endif
37
38typedef struct async_job_st ASYNC_JOB;
ff75a257 39typedef struct async_wait_ctx_st ASYNC_WAIT_CTX;
9f5a87fd 40typedef int (*ASYNC_callback_fn)(void *arg);
a3667c31
MC
41
42#define ASYNC_ERR 0
252d6d3a
MC
43#define ASYNC_NO_JOBS 1
44#define ASYNC_PAUSE 2
45#define ASYNC_FINISH 3
46
9f5a87fd
PY
47#define ASYNC_STATUS_UNSUPPORTED 0
48#define ASYNC_STATUS_ERR 1
49#define ASYNC_STATUS_OK 2
50#define ASYNC_STATUS_EAGAIN 3
51
68487a9b
MC
52int ASYNC_init_thread(size_t max_size, size_t init_size);
53void ASYNC_cleanup_thread(void);
a3667c31 54
f1f5ee17 55#ifdef OSSL_ASYNC_FD
ff75a257
MC
56ASYNC_WAIT_CTX *ASYNC_WAIT_CTX_new(void);
57void ASYNC_WAIT_CTX_free(ASYNC_WAIT_CTX *ctx);
58int ASYNC_WAIT_CTX_set_wait_fd(ASYNC_WAIT_CTX *ctx, const void *key,
59 OSSL_ASYNC_FD fd,
60 void *custom_data,
61 void (*cleanup)(ASYNC_WAIT_CTX *, const void *,
62 OSSL_ASYNC_FD, void *));
63int ASYNC_WAIT_CTX_get_fd(ASYNC_WAIT_CTX *ctx, const void *key,
64 OSSL_ASYNC_FD *fd, void **custom_data);
65int ASYNC_WAIT_CTX_get_all_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *fd,
66 size_t *numfds);
9f5a87fd
PY
67int ASYNC_WAIT_CTX_get_callback(ASYNC_WAIT_CTX *ctx,
68 ASYNC_callback_fn *callback,
69 void **callback_arg);
70int ASYNC_WAIT_CTX_set_callback(ASYNC_WAIT_CTX *ctx,
71 ASYNC_callback_fn callback,
72 void *callback_arg);
73int ASYNC_WAIT_CTX_set_status(ASYNC_WAIT_CTX *ctx, int status);
74int ASYNC_WAIT_CTX_get_status(ASYNC_WAIT_CTX *ctx);
ff75a257
MC
75int ASYNC_WAIT_CTX_get_changed_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *addfd,
76 size_t *numaddfds, OSSL_ASYNC_FD *delfd,
77 size_t *numdelfds);
78int ASYNC_WAIT_CTX_clear_fd(ASYNC_WAIT_CTX *ctx, const void *key);
f1f5ee17 79#endif
ff75a257 80
667867cc
MC
81int ASYNC_is_capable(void);
82
f6f56f47
ACB
83typedef void *(*ASYNC_stack_alloc_fn)(size_t *num);
84typedef void (*ASYNC_stack_free_fn)(void *addr);
85
86int ASYNC_set_mem_functions(ASYNC_stack_alloc_fn alloc_fn,
87 ASYNC_stack_free_fn free_fn);
88void ASYNC_get_mem_functions(ASYNC_stack_alloc_fn *alloc_fn,
89 ASYNC_stack_free_fn *free_fn);
90
ff75a257
MC
91int ASYNC_start_job(ASYNC_JOB **job, ASYNC_WAIT_CTX *ctx, int *ret,
92 int (*func)(void *), void *args, size_t size);
a3667c31 93int ASYNC_pause_job(void);
a3667c31 94
f4da39d2 95ASYNC_JOB *ASYNC_get_current_job(void);
ff75a257 96ASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job);
e8dfb5bf
MC
97void ASYNC_block_pause(void);
98void ASYNC_unblock_pause(void);
f4da39d2 99
a3667c31 100
0cd0a820 101# ifdef __cplusplus
079a1a90 102}
0cd0a820 103# endif
a3667c31 104#endif