summaryrefslogtreecommitdiffstats
path: root/crypto/async
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek.chauhan@gmail.com>2020-07-08 23:10:34 +0530
committerMatt Caswell <matt@openssl.org>2021-01-04 12:01:44 +0000
commitce1119265005bd254fc92395f72490c19adc707c (patch)
tree8323d63ceac70d4aebc2ab86c0ec8710b0fdce9e /crypto/async
parent38b57c4c5268e4db0cad6db6744bf70ce4a0e188 (diff)
crypto/win: Don't use disallowed APIs on UWP
CreateFiber and ConvertThreadToFiber are not allowed in Windows Store (Universal Windows Platform) apps since they have been replaced by their Ex variants which have a new dwFlags parameter. This flag allows the fiber to do floating-point arithmetic in the fiber on x86, which would silently cause corruption otherwise since the floating-point state is not switched by default. Switch to these "new" APIs which were added in Vista. See: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createfiberex#parameters Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12400)
Diffstat (limited to 'crypto/async')
-rw-r--r--crypto/async/arch/async_win.c4
-rw-r--r--crypto/async/arch/async_win.h10
2 files changed, 13 insertions, 1 deletions
diff --git a/crypto/async/arch/async_win.c b/crypto/async/arch/async_win.c
index 0db9efe3c1..72cc27c214 100644
--- a/crypto/async/arch/async_win.c
+++ b/crypto/async/arch/async_win.c
@@ -34,7 +34,11 @@ void async_local_cleanup(void)
int async_fibre_init_dispatcher(async_fibre *fibre)
{
+# if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x600
+ fibre->fibre = ConvertThreadToFiberEx(NULL, FIBER_FLAG_FLOAT_SWITCH);
+# else
fibre->fibre = ConvertThreadToFiber(NULL);
+# endif
if (fibre->fibre == NULL) {
fibre->converted = 0;
fibre->fibre = GetCurrentFiber();
diff --git a/crypto/async/arch/async_win.h b/crypto/async/arch/async_win.h
index 87e661d766..eb61b032e0 100644
--- a/crypto/async/arch/async_win.h
+++ b/crypto/async/arch/async_win.h
@@ -26,8 +26,16 @@ typedef struct async_fibre_st {
# define async_fibre_swapcontext(o,n,r) \
(SwitchToFiber((n)->fibre), 1)
-# define async_fibre_makecontext(c) \
+
+# if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x600
+# define async_fibre_makecontext(c) \
+ ((c)->fibre = CreateFiberEx(0, 0, FIBER_FLAG_FLOAT_SWITCH, \
+ async_start_func_win, 0))
+# else
+# define async_fibre_makecontext(c) \
((c)->fibre = CreateFiber(0, async_start_func_win, 0))
+# endif
+
# define async_fibre_free(f) (DeleteFiber((f)->fibre))
int async_fibre_init_dispatcher(async_fibre *fibre);