2015-02-17 13:30:22 +00:00
|
|
|
/*
|
2016-05-17 18:24:46 +00:00
|
|
|
* Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
|
2015-02-17 13:30:22 +00:00
|
|
|
*
|
2016-05-17 18:24:46 +00:00
|
|
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
|
|
|
* 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 13:30:22 +00:00
|
|
|
*/
|
|
|
|
|
2015-11-22 01:14:43 +00: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 11:40:15 +00:00
|
|
|
#if defined(_WIN32)
|
|
|
|
# include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
2017-08-22 12:35:43 +00:00
|
|
|
#include "internal/async.h"
|
2015-09-16 16:01:58 +00:00
|
|
|
#include <openssl/crypto.h>
|
2015-02-17 13:30:22 +00:00
|
|
|
|
2015-10-06 10:25:16 +00:00
|
|
|
typedef struct async_ctx_st async_ctx;
|
2015-11-13 15:21:20 +00:00
|
|
|
typedef struct async_pool_st async_pool;
|
2015-02-17 13:30:22 +00:00
|
|
|
|
|
|
|
#include "arch/async_win.h"
|
|
|
|
#include "arch/async_posix.h"
|
2015-02-17 14:14:36 +00:00
|
|
|
#include "arch/async_null.h"
|
2015-02-17 13:30:22 +00:00
|
|
|
|
|
|
|
struct async_ctx_st {
|
2015-10-06 10:25:16 +00:00
|
|
|
async_fibre dispatcher;
|
2015-02-17 13:30:22 +00:00
|
|
|
ASYNC_JOB *currjob;
|
2015-11-12 10:42:08 +00:00
|
|
|
unsigned int blocked;
|
2015-02-17 13:30:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct async_job_st {
|
2015-10-06 10:25:16 +00:00
|
|
|
async_fibre fibrectx;
|
2015-02-17 13:30:22 +00:00
|
|
|
int (*func) (void *);
|
|
|
|
void *funcargs;
|
|
|
|
int ret;
|
|
|
|
int status;
|
2016-01-25 15:28:57 +00:00
|
|
|
ASYNC_WAIT_CTX *waitctx;
|
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
2015-02-17 13:30:22 +00:00
|
|
|
};
|
|
|
|
|
2015-12-28 00:04:33 +00:00
|
|
|
DEFINE_STACK_OF(ASYNC_JOB)
|
2015-09-16 16:01:58 +00:00
|
|
|
|
2015-11-13 15:21:20 +00:00
|
|
|
struct async_pool_st {
|
|
|
|
STACK_OF(ASYNC_JOB) *jobs;
|
|
|
|
size_t curr_size;
|
|
|
|
size_t max_size;
|
|
|
|
};
|
|
|
|
|
2015-11-19 21:44:13 +00:00
|
|
|
void async_local_cleanup(void);
|
2015-10-06 10:25:16 +00:00
|
|
|
void async_start_func(void);
|
2016-03-02 16:15:52 +00:00
|
|
|
async_ctx *async_get_ctx(void);
|
2016-01-25 15:28:57 +00:00
|
|
|
|
|
|
|
void async_wait_ctx_reset_counts(ASYNC_WAIT_CTX *ctx);
|
|
|
|
|