2 * Argon2 reference source code package - reference C implementations
5 * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves
7 * You may use this work under the terms of a Creative Commons CC0 1.0
8 * License/Waiver or the Apache Public License 2.0, at your option. The terms of
9 * these licenses can be found at:
11 * - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
12 * - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
14 * You should have received a copy of both of these licenses along with this
15 * software. If not, they may be obtained at the above URLs.
18 #if !defined(ARGON2_NO_THREADS)
25 int argon2_thread_create(argon2_thread_handle_t *handle,
26 argon2_thread_func_t func, void *args) {
27 if (NULL == handle || func == NULL) {
31 *handle = _beginthreadex(NULL, 0, func, args, 0, NULL);
32 return *handle != 0 ? 0 : -1;
34 return pthread_create(handle, NULL, func, args);
38 int argon2_thread_join(argon2_thread_handle_t handle) {
40 if (WaitForSingleObject((HANDLE)handle, INFINITE) == WAIT_OBJECT_0) {
41 return CloseHandle((HANDLE)handle) != 0 ? 0 : -1;
45 return pthread_join(handle, NULL);
49 #endif /* ARGON2_NO_THREADS */