Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-13 08:31:40

0001 /*
0002  * Copyright 2015-2022 The OpenSSL Project Authors. All Rights Reserved.
0003  *
0004  * Licensed under the Apache License 2.0 (the "License").  You may not use
0005  * this file except in compliance with the License.  You can obtain a copy
0006  * in the file LICENSE in the source distribution or at
0007  * https://www.openssl.org/source/license.html
0008  */
0009 
0010 #include <stdlib.h>
0011 
0012 #ifndef OPENSSL_ASYNC_H
0013 #define OPENSSL_ASYNC_H
0014 #pragma once
0015 
0016 #include <openssl/macros.h>
0017 #ifndef OPENSSL_NO_DEPRECATED_3_0
0018 #define HEADER_ASYNC_H
0019 #endif
0020 
0021 #if defined(_WIN32)
0022 #if defined(BASETYPES) || defined(_WINDEF_H)
0023 /* application has to include <windows.h> to use this */
0024 #define OSSL_ASYNC_FD HANDLE
0025 #define OSSL_BAD_ASYNC_FD INVALID_HANDLE_VALUE
0026 #endif
0027 #else
0028 #define OSSL_ASYNC_FD int
0029 #define OSSL_BAD_ASYNC_FD -1
0030 #endif
0031 #include <openssl/asyncerr.h>
0032 
0033 #ifdef __cplusplus
0034 extern "C" {
0035 #endif
0036 
0037 typedef struct async_job_st ASYNC_JOB;
0038 typedef struct async_wait_ctx_st ASYNC_WAIT_CTX;
0039 typedef int (*ASYNC_callback_fn)(void *arg);
0040 
0041 #define ASYNC_ERR 0
0042 #define ASYNC_NO_JOBS 1
0043 #define ASYNC_PAUSE 2
0044 #define ASYNC_FINISH 3
0045 
0046 #define ASYNC_STATUS_UNSUPPORTED 0
0047 #define ASYNC_STATUS_ERR 1
0048 #define ASYNC_STATUS_OK 2
0049 #define ASYNC_STATUS_EAGAIN 3
0050 
0051 int ASYNC_init_thread(size_t max_size, size_t init_size);
0052 void ASYNC_cleanup_thread(void);
0053 
0054 #ifdef OSSL_ASYNC_FD
0055 ASYNC_WAIT_CTX *ASYNC_WAIT_CTX_new(void);
0056 void ASYNC_WAIT_CTX_free(ASYNC_WAIT_CTX *ctx);
0057 int ASYNC_WAIT_CTX_set_wait_fd(ASYNC_WAIT_CTX *ctx, const void *key,
0058     OSSL_ASYNC_FD fd,
0059     void *custom_data,
0060     void (*cleanup)(ASYNC_WAIT_CTX *, const void *,
0061         OSSL_ASYNC_FD, void *));
0062 int ASYNC_WAIT_CTX_get_fd(ASYNC_WAIT_CTX *ctx, const void *key,
0063     OSSL_ASYNC_FD *fd, void **custom_data);
0064 int ASYNC_WAIT_CTX_get_all_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *fd,
0065     size_t *numfds);
0066 int ASYNC_WAIT_CTX_get_callback(ASYNC_WAIT_CTX *ctx,
0067     ASYNC_callback_fn *callback,
0068     void **callback_arg);
0069 int ASYNC_WAIT_CTX_set_callback(ASYNC_WAIT_CTX *ctx,
0070     ASYNC_callback_fn callback,
0071     void *callback_arg);
0072 int ASYNC_WAIT_CTX_set_status(ASYNC_WAIT_CTX *ctx, int status);
0073 int ASYNC_WAIT_CTX_get_status(ASYNC_WAIT_CTX *ctx);
0074 int ASYNC_WAIT_CTX_get_changed_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *addfd,
0075     size_t *numaddfds, OSSL_ASYNC_FD *delfd,
0076     size_t *numdelfds);
0077 int ASYNC_WAIT_CTX_clear_fd(ASYNC_WAIT_CTX *ctx, const void *key);
0078 #endif
0079 
0080 int ASYNC_is_capable(void);
0081 
0082 typedef void *(*ASYNC_stack_alloc_fn)(size_t *num);
0083 typedef void (*ASYNC_stack_free_fn)(void *addr);
0084 
0085 int ASYNC_set_mem_functions(ASYNC_stack_alloc_fn alloc_fn,
0086     ASYNC_stack_free_fn free_fn);
0087 void ASYNC_get_mem_functions(ASYNC_stack_alloc_fn *alloc_fn,
0088     ASYNC_stack_free_fn *free_fn);
0089 
0090 int ASYNC_start_job(ASYNC_JOB **job, ASYNC_WAIT_CTX *ctx, int *ret,
0091     int (*func)(void *), void *args, size_t size);
0092 int ASYNC_pause_job(void);
0093 
0094 ASYNC_JOB *ASYNC_get_current_job(void);
0095 ASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job);
0096 void ASYNC_block_pause(void);
0097 void ASYNC_unblock_pause(void);
0098 
0099 #ifdef __cplusplus
0100 }
0101 #endif
0102 #endif