2015-02-17 21:30:22 +08:00
|
|
|
/*
|
2020-07-16 20:47:04 +08:00
|
|
|
* Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
|
2015-02-17 21:30:22 +08:00
|
|
|
*
|
2018-12-06 20:18:31 +08:00
|
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-05-18 02:24:46 +08:00
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
2015-02-17 21:30:22 +08:00
|
|
|
*/
|
|
|
|
|
2015-11-22 09:14:43 +08:00
|
|
|
/*
|
|
|
|
* Must do this before including any header files, because on MacOS/X <stlib.h>
|
|
|
|
* includes <signal.h> which includes <ucontext.h>
|
|
|
|
*/
|
|
|
|
#if defined(__APPLE__) && defined(__MACH__) && !defined(_XOPEN_SOURCE)
|
|
|
|
# define _XOPEN_SOURCE /* Otherwise incomplete ucontext_t structure */
|
|
|
|
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
|
|
|
#endif
|
|
|
|
|
2016-06-26 19:40:15 +08:00
|
|
|
#if defined(_WIN32)
|
|
|
|
# include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
2019-09-28 06:45:33 +08:00
|
|
|
#include "crypto/async.h"
|
2015-09-17 00:01:58 +08:00
|
|
|
#include <openssl/crypto.h>
|
2015-02-17 21:30:22 +08:00
|
|
|
|
2015-10-06 18:25:16 +08:00
|
|
|
typedef struct async_ctx_st async_ctx;
|
2015-11-13 23:21:20 +08:00
|
|
|
typedef struct async_pool_st async_pool;
|
2015-02-17 21:30:22 +08:00
|
|
|
|
|
|
|
#include "arch/async_win.h"
|
|
|
|
#include "arch/async_posix.h"
|
2015-02-17 22:14:36 +08:00
|
|
|
#include "arch/async_null.h"
|
2015-02-17 21:30:22 +08:00
|
|
|
|
|
|
|
struct async_ctx_st {
|
2015-10-06 18:25:16 +08:00
|
|
|
async_fibre dispatcher;
|
2015-02-17 21:30:22 +08:00
|
|
|
ASYNC_JOB *currjob;
|
2015-11-12 18:42:08 +08:00
|
|
|
unsigned int blocked;
|
2015-02-17 21:30:22 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct async_job_st {
|
2015-10-06 18:25:16 +08:00
|
|
|
async_fibre fibrectx;
|
2015-02-17 21:30:22 +08:00
|
|
|
int (*func) (void *);
|
|
|
|
void *funcargs;
|
|
|
|
int ret;
|
|
|
|
int status;
|
2016-01-25 23:28:57 +08:00
|
|
|
ASYNC_WAIT_CTX *waitctx;
|
2020-10-15 17:55:50 +08:00
|
|
|
OSSL_LIB_CTX *libctx;
|
2016-01-25 23:28:57 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct fd_lookup_st {
|
|
|
|
const void *key;
|
|
|
|
OSSL_ASYNC_FD fd;
|
|
|
|
void *custom_data;
|
|
|
|
void (*cleanup)(ASYNC_WAIT_CTX *, const void *, OSSL_ASYNC_FD, void *);
|
|
|
|
int add;
|
|
|
|
int del;
|
|
|
|
struct fd_lookup_st *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct async_wait_ctx_st {
|
|
|
|
struct fd_lookup_st *fds;
|
|
|
|
size_t numadd;
|
|
|
|
size_t numdel;
|
2018-11-06 04:41:01 +08:00
|
|
|
ASYNC_callback_fn callback;
|
|
|
|
void *callback_arg;
|
|
|
|
int status;
|
2015-02-17 21:30:22 +08:00
|
|
|
};
|
|
|
|
|
2015-12-28 08:04:33 +08:00
|
|
|
DEFINE_STACK_OF(ASYNC_JOB)
|
2015-09-17 00:01:58 +08:00
|
|
|
|
2015-11-13 23:21:20 +08:00
|
|
|
struct async_pool_st {
|
|
|
|
STACK_OF(ASYNC_JOB) *jobs;
|
|
|
|
size_t curr_size;
|
|
|
|
size_t max_size;
|
|
|
|
};
|
|
|
|
|
2015-11-20 05:44:13 +08:00
|
|
|
void async_local_cleanup(void);
|
2015-10-06 18:25:16 +08:00
|
|
|
void async_start_func(void);
|
2016-03-03 00:15:52 +08:00
|
|
|
async_ctx *async_get_ctx(void);
|
2016-01-25 23:28:57 +08:00
|
|
|
|
|
|
|
void async_wait_ctx_reset_counts(ASYNC_WAIT_CTX *ctx);
|
|
|
|
|