Tor 0.4.9.2-alpha-dev
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
hashx_thread.c
1/* Copyright (c) 2020 tevador <tevador@gmail.com> */
2/* See LICENSE for licensing information */
3
4#include "hashx_thread.h"
5
6hashx_thread hashx_thread_create(hashx_thread_func* func, void* args) {
7#ifdef HASHX_WIN
8 return CreateThread(NULL, 0, func, args, 0, NULL);
9#else
10 hashx_thread thread;
11 if (pthread_create(&thread, NULL, func, args) != 0)
12 {
13 thread = 0;
14 }
15 return thread;
16#endif
17}
18
19void hashx_thread_join(hashx_thread thread) {
20#ifdef HASHX_WIN
21 WaitForSingleObject(thread, INFINITE);
22 CloseHandle(thread);
23#else
24 void* retval;
25 pthread_join(thread, &retval);
26#endif
27}