line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
/* |
2
|
|
|
|
|
|
|
* Argon2 reference source code package - reference C implementations |
3
|
|
|
|
|
|
|
* |
4
|
|
|
|
|
|
|
* Copyright 2015 |
5
|
|
|
|
|
|
|
* Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves |
6
|
|
|
|
|
|
|
* |
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: |
10
|
|
|
|
|
|
|
* |
11
|
|
|
|
|
|
|
* - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0 |
12
|
|
|
|
|
|
|
* - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0 |
13
|
|
|
|
|
|
|
* |
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. |
16
|
|
|
|
|
|
|
*/ |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#if !defined(ARGON2_NO_THREADS) |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
#include "thread.h" |
21
|
|
|
|
|
|
|
#if defined(_WIN32) |
22
|
|
|
|
|
|
|
#include |
23
|
|
|
|
|
|
|
#endif |
24
|
|
|
|
|
|
|
|
25
|
48
|
|
|
|
|
|
int argon2_thread_create(argon2_thread_handle_t *handle, |
26
|
|
|
|
|
|
|
argon2_thread_func_t func, void *args) { |
27
|
48
|
50
|
|
|
|
|
if (NULL == handle || func == NULL) { |
28
|
|
|
|
|
|
|
return -1; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
#if defined(_WIN32) |
31
|
|
|
|
|
|
|
*handle = _beginthreadex(NULL, 0, func, args, 0, NULL); |
32
|
|
|
|
|
|
|
return *handle != 0 ? 0 : -1; |
33
|
|
|
|
|
|
|
#else |
34
|
48
|
|
|
|
|
|
return pthread_create(handle, NULL, func, args); |
35
|
|
|
|
|
|
|
#endif |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
48
|
|
|
|
|
|
int argon2_thread_join(argon2_thread_handle_t handle) { |
39
|
|
|
|
|
|
|
#if defined(_WIN32) |
40
|
|
|
|
|
|
|
if (WaitForSingleObject((HANDLE)handle, INFINITE) == WAIT_OBJECT_0) { |
41
|
|
|
|
|
|
|
return CloseHandle((HANDLE)handle) != 0 ? 0 : -1; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
return -1; |
44
|
|
|
|
|
|
|
#else |
45
|
48
|
|
|
|
|
|
return pthread_join(handle, NULL); |
46
|
|
|
|
|
|
|
#endif |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
48
|
|
|
|
|
|
void argon2_thread_exit(void) { |
50
|
|
|
|
|
|
|
#if defined(_WIN32) |
51
|
|
|
|
|
|
|
_endthreadex(0); |
52
|
|
|
|
|
|
|
#else |
53
|
48
|
|
|
|
|
|
pthread_exit(NULL); |
54
|
|
|
|
|
|
|
#endif |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
#endif /* ARGON2_NO_THREADS */ |