2 * Copyright 2021 The OpenSSL Project Authors. All Rights Reserved.
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
17 #if !defined(OPENSSL_THREADS) || defined(CRYPTO_TDEBUG)
19 typedef unsigned int thread_t;
21 static int run_thread(thread_t *t, void (*f)(void))
27 static int wait_for_thread(thread_t thread)
32 #elif defined(OPENSSL_SYS_WINDOWS)
34 typedef HANDLE thread_t;
36 static DWORD WINAPI thread_run(LPVOID arg)
40 *(void **) (&f) = arg;
46 static int run_thread(thread_t *t, void (*f)(void))
48 *t = CreateThread(NULL, 0, thread_run, *(void **) &f, 0, NULL);
52 static int wait_for_thread(thread_t thread)
54 return WaitForSingleObject(thread, INFINITE) == 0;
59 typedef pthread_t thread_t;
61 static void *thread_run(void *arg)
65 *(void **) (&f) = arg;
71 static int run_thread(thread_t *t, void (*f)(void))
73 return pthread_create(t, NULL, thread_run, *(void **) &f) == 0;
76 static int wait_for_thread(thread_t thread)
78 return pthread_join(thread, NULL) == 0;