fixed incorrect test in Win32 pthread wrapper
reported by @Banzai24-yht in #3683
This commit is contained in:
@@ -42,6 +42,7 @@ build-*
|
|||||||
_codelite/
|
_codelite/
|
||||||
_zstdbench/
|
_zstdbench/
|
||||||
.clang_complete
|
.clang_complete
|
||||||
|
compile_flags.txt
|
||||||
*.idea
|
*.idea
|
||||||
*.swp
|
*.swp
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|||||||
@@ -73,10 +73,12 @@ int ZSTD_pthread_create(ZSTD_pthread_t* thread, const void* unused,
|
|||||||
ZSTD_thread_params_t thread_param;
|
ZSTD_thread_params_t thread_param;
|
||||||
(void)unused;
|
(void)unused;
|
||||||
|
|
||||||
|
if (thread==NULL) return -1;
|
||||||
|
*thread = NULL;
|
||||||
|
|
||||||
thread_param.start_routine = start_routine;
|
thread_param.start_routine = start_routine;
|
||||||
thread_param.arg = arg;
|
thread_param.arg = arg;
|
||||||
thread_param.initialized = 0;
|
thread_param.initialized = 0;
|
||||||
*thread = NULL;
|
|
||||||
|
|
||||||
/* Setup thread initialization synchronization */
|
/* Setup thread initialization synchronization */
|
||||||
if(ZSTD_pthread_cond_init(&thread_param.initialized_cond, NULL)) {
|
if(ZSTD_pthread_cond_init(&thread_param.initialized_cond, NULL)) {
|
||||||
@@ -91,7 +93,7 @@ int ZSTD_pthread_create(ZSTD_pthread_t* thread, const void* unused,
|
|||||||
|
|
||||||
/* Spawn thread */
|
/* Spawn thread */
|
||||||
*thread = (HANDLE)_beginthreadex(NULL, 0, worker, &thread_param, 0, NULL);
|
*thread = (HANDLE)_beginthreadex(NULL, 0, worker, &thread_param, 0, NULL);
|
||||||
if (!thread) {
|
if (*thread==NULL) {
|
||||||
ZSTD_pthread_mutex_destroy(&thread_param.initialized_mutex);
|
ZSTD_pthread_mutex_destroy(&thread_param.initialized_mutex);
|
||||||
ZSTD_pthread_cond_destroy(&thread_param.initialized_cond);
|
ZSTD_pthread_cond_destroy(&thread_param.initialized_cond);
|
||||||
return errno;
|
return errno;
|
||||||
@@ -137,6 +139,7 @@ int ZSTD_pthread_join(ZSTD_pthread_t thread)
|
|||||||
|
|
||||||
int ZSTD_pthread_mutex_init(ZSTD_pthread_mutex_t* mutex, pthread_mutexattr_t const* attr)
|
int ZSTD_pthread_mutex_init(ZSTD_pthread_mutex_t* mutex, pthread_mutexattr_t const* attr)
|
||||||
{
|
{
|
||||||
|
assert(mutex != NULL);
|
||||||
*mutex = (pthread_mutex_t*)ZSTD_malloc(sizeof(pthread_mutex_t));
|
*mutex = (pthread_mutex_t*)ZSTD_malloc(sizeof(pthread_mutex_t));
|
||||||
if (!*mutex)
|
if (!*mutex)
|
||||||
return 1;
|
return 1;
|
||||||
@@ -145,6 +148,7 @@ int ZSTD_pthread_mutex_init(ZSTD_pthread_mutex_t* mutex, pthread_mutexattr_t con
|
|||||||
|
|
||||||
int ZSTD_pthread_mutex_destroy(ZSTD_pthread_mutex_t* mutex)
|
int ZSTD_pthread_mutex_destroy(ZSTD_pthread_mutex_t* mutex)
|
||||||
{
|
{
|
||||||
|
assert(mutex != NULL);
|
||||||
if (!*mutex)
|
if (!*mutex)
|
||||||
return 0;
|
return 0;
|
||||||
{
|
{
|
||||||
@@ -156,6 +160,7 @@ int ZSTD_pthread_mutex_destroy(ZSTD_pthread_mutex_t* mutex)
|
|||||||
|
|
||||||
int ZSTD_pthread_cond_init(ZSTD_pthread_cond_t* cond, pthread_condattr_t const* attr)
|
int ZSTD_pthread_cond_init(ZSTD_pthread_cond_t* cond, pthread_condattr_t const* attr)
|
||||||
{
|
{
|
||||||
|
assert(cond != NULL);
|
||||||
*cond = (pthread_cond_t*)ZSTD_malloc(sizeof(pthread_cond_t));
|
*cond = (pthread_cond_t*)ZSTD_malloc(sizeof(pthread_cond_t));
|
||||||
if (!*cond)
|
if (!*cond)
|
||||||
return 1;
|
return 1;
|
||||||
@@ -164,6 +169,7 @@ int ZSTD_pthread_cond_init(ZSTD_pthread_cond_t* cond, pthread_condattr_t const*
|
|||||||
|
|
||||||
int ZSTD_pthread_cond_destroy(ZSTD_pthread_cond_t* cond)
|
int ZSTD_pthread_cond_destroy(ZSTD_pthread_cond_t* cond)
|
||||||
{
|
{
|
||||||
|
assert(cond != NULL);
|
||||||
if (!*cond)
|
if (!*cond)
|
||||||
return 0;
|
return 0;
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user