async_win.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. /* This must be the first #include file */
  10. #include "../async_local.h"
  11. #ifdef ASYNC_WIN
  12. # include <windows.h>
  13. # include "internal/cryptlib.h"
  14. int ASYNC_is_capable(void)
  15. {
  16. return 1;
  17. }
  18. void async_local_cleanup(void)
  19. {
  20. async_ctx *ctx = async_get_ctx();
  21. if (ctx != NULL) {
  22. async_fibre *fibre = &ctx->dispatcher;
  23. if (fibre != NULL && fibre->fibre != NULL && fibre->converted) {
  24. ConvertFiberToThread();
  25. fibre->fibre = NULL;
  26. }
  27. }
  28. }
  29. int async_fibre_init_dispatcher(async_fibre *fibre)
  30. {
  31. fibre->fibre = ConvertThreadToFiber(NULL);
  32. if (fibre->fibre == NULL) {
  33. fibre->converted = 0;
  34. fibre->fibre = GetCurrentFiber();
  35. if (fibre->fibre == NULL)
  36. return 0;
  37. } else {
  38. fibre->converted = 1;
  39. }
  40. return 1;
  41. }
  42. VOID CALLBACK async_start_func_win(PVOID unused)
  43. {
  44. async_start_func();
  45. }
  46. #endif