1e71b7053SJung-uk Kim /* 2*b077aed3SPierre Pronchery * Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved. 3e71b7053SJung-uk Kim * 4*b077aed3SPierre Pronchery * Licensed under the Apache License 2.0 (the "License"). You may not use 5e71b7053SJung-uk Kim * this file except in compliance with the License. You can obtain a copy 6e71b7053SJung-uk Kim * in the file LICENSE in the source distribution or at 7e71b7053SJung-uk Kim * https://www.openssl.org/source/license.html 8e71b7053SJung-uk Kim */ 9e71b7053SJung-uk Kim 10e71b7053SJung-uk Kim /* 11e71b7053SJung-uk Kim * This is the same detection used in cryptlib to set up the thread local 12e71b7053SJung-uk Kim * storage that we depend on, so just copy that 13e71b7053SJung-uk Kim */ 14e71b7053SJung-uk Kim #if defined(_WIN32) && !defined(OPENSSL_NO_ASYNC) 15e71b7053SJung-uk Kim #include <openssl/async.h> 16e71b7053SJung-uk Kim # define ASYNC_WIN 17e71b7053SJung-uk Kim # define ASYNC_ARCH 18e71b7053SJung-uk Kim 19e71b7053SJung-uk Kim # include <windows.h> 20e71b7053SJung-uk Kim # include "internal/cryptlib.h" 21e71b7053SJung-uk Kim 22e71b7053SJung-uk Kim typedef struct async_fibre_st { 23e71b7053SJung-uk Kim LPVOID fibre; 24e71b7053SJung-uk Kim int converted; 25e71b7053SJung-uk Kim } async_fibre; 26e71b7053SJung-uk Kim 27e71b7053SJung-uk Kim # define async_fibre_swapcontext(o,n,r) \ 28e71b7053SJung-uk Kim (SwitchToFiber((n)->fibre), 1) 29*b077aed3SPierre Pronchery 30*b077aed3SPierre Pronchery # if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x600 31*b077aed3SPierre Pronchery # define async_fibre_makecontext(c) \ 32*b077aed3SPierre Pronchery ((c)->fibre = CreateFiberEx(0, 0, FIBER_FLAG_FLOAT_SWITCH, \ 33*b077aed3SPierre Pronchery async_start_func_win, 0)) 34*b077aed3SPierre Pronchery # else 35e71b7053SJung-uk Kim # define async_fibre_makecontext(c) \ 36e71b7053SJung-uk Kim ((c)->fibre = CreateFiber(0, async_start_func_win, 0)) 37*b077aed3SPierre Pronchery # endif 38*b077aed3SPierre Pronchery 39e71b7053SJung-uk Kim # define async_fibre_free(f) (DeleteFiber((f)->fibre)) 40e71b7053SJung-uk Kim 41e71b7053SJung-uk Kim int async_fibre_init_dispatcher(async_fibre *fibre); 42e71b7053SJung-uk Kim VOID CALLBACK async_start_func_win(PVOID unused); 43e71b7053SJung-uk Kim 44e71b7053SJung-uk Kim #endif 45