zstd/lib/common/threading.h

61 lines
1.7 KiB
C

/**
* Copyright (c) 2016 Tino Reichardt
* All rights reserved.
*
* You can contact the author at:
* - zstdmt source repository: https://github.com/mcmilk/zstdmt
*
* This source code is licensed under both the BSD-style license (found in the
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
* in the COPYING file in the root directory of this source tree).
* You may select, at your option, one of the above-listed licenses.
*/
#ifndef THREADING_H_938743
#define THREADING_H_938743
#include "debug.h"
#if defined (__cplusplus)
extern "C" {
#endif
#if defined(ZSTD_MULTITHREAD)
/* mutex */
typedef void* ZSTD_pthread_mutex_t;
int ZSTD_pthread_mutex_init(ZSTD_pthread_mutex_t * in);
void ZSTD_pthread_mutex_destroy(ZSTD_pthread_mutex_t* in);
void ZSTD_pthread_mutex_lock(ZSTD_pthread_mutex_t* in);
void ZSTD_pthread_mutex_unlock(ZSTD_pthread_mutex_t* in);
/* condition variable */
typedef void* ZSTD_pthread_cond_t;
int ZSTD_pthread_cond_init(ZSTD_pthread_cond_t* a, ZSTD_pthread_mutex_t* b);
void ZSTD_pthread_cond_wait(ZSTD_pthread_cond_t* a);
void ZSTD_pthread_cond_destroy(ZSTD_pthread_cond_t* a);
void ZSTD_pthread_cond_signal(ZSTD_pthread_cond_t* a);
void ZSTD_pthread_cond_broadcast(ZSTD_pthread_cond_t* a);
/* ZSTD_pthread_create() and ZSTD_pthread_join() */
typedef struct {
void * handle;
void* (*start_routine)(void*);
void* arg;
} ZSTD_pthread_t;
int ZSTD_pthread_create(ZSTD_pthread_t* thread, const void* unused,
void* (*start_routine) (void*), void* arg);
int ZSTD_pthread_join(ZSTD_pthread_t thread, void** value_ptr);
#endif /* ZSTD_MULTITHREAD */
#if defined (__cplusplus)
}
#endif
#endif /* THREADING_H_938743 */