| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
#if !defined( _LIBCTHREADS_INTERNAL_CONDITION_H ) |
| 23 |
#define _LIBCTHREADS_INTERNAL_CONDITION_H |
| 24 |
|
| 25 |
#include <common.h> |
| 26 |
#include <types.h> |
| 27 |
|
| 28 |
#if defined( _MSC_VER ) && defined( WINAPI ) && ( WINVER >= 0x0602 ) |
| 29 |
#include <Synchapi.h> |
| 30 |
#endif |
| 31 |
|
| 32 |
#if defined( HAVE_PTHREAD_H ) && !defined( WINAPI ) |
| 33 |
#include <pthread.h> |
| 34 |
#endif |
| 35 |
|
| 36 |
#include "libcthreads_extern.h" |
| 37 |
#include "libcthreads_libcerror.h" |
| 38 |
#include "libcthreads_types.h" |
| 39 |
|
| 40 |
#if defined( __cplusplus ) |
| 41 |
extern "C" { |
| 42 |
#endif |
| 43 |
|
| 44 |
#if !defined( HAVE_LOCAL_LIBCTHREADS ) || defined( HAVE_MULTI_THREAD_SUPPORT ) |
| 45 |
|
| 46 |
typedef struct libcthreads_internal_condition libcthreads_internal_condition_t; |
| 47 |
|
| 48 |
struct libcthreads_internal_condition |
| 49 |
{ |
| 50 |
|
| 51 |
#if defined( WINAPI ) && ( WINVER >= 0x0600 ) |
| 52 |
|
| 53 |
|
| 54 |
CONDITION_VARIABLE condition_variable; |
| 55 |
|
| 56 |
#elif defined( WINAPI ) |
| 57 |
|
| 58 |
|
| 59 |
int number_of_waiting_threads; |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
CRITICAL_SECTION wait_critical_section; |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
HANDLE signal_semaphore_handle; |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
HANDLE signal_event_handle; |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
uint8_t signal_is_broadcast; |
| 76 |
|
| 77 |
#elif defined( HAVE_PTHREAD_H ) |
| 78 |
|
| 79 |
|
| 80 |
pthread_cond_t condition; |
| 81 |
|
| 82 |
#else |
| 83 |
#error Missing condition type |
| 84 |
#endif |
| 85 |
}; |
| 86 |
|
| 87 |
LIBCTHREADS_EXTERN \ |
| 88 |
int libcthreads_condition_initialize( |
| 89 |
libcthreads_condition_t **condition, |
| 90 |
libcerror_error_t **error ); |
| 91 |
|
| 92 |
LIBCTHREADS_EXTERN \ |
| 93 |
int libcthreads_condition_free( |
| 94 |
libcthreads_condition_t **condition, |
| 95 |
libcerror_error_t **error ); |
| 96 |
|
| 97 |
LIBCTHREADS_EXTERN \ |
| 98 |
int libcthreads_condition_broadcast( |
| 99 |
libcthreads_condition_t *condition, |
| 100 |
libcerror_error_t **error ); |
| 101 |
|
| 102 |
LIBCTHREADS_EXTERN \ |
| 103 |
int libcthreads_condition_signal( |
| 104 |
libcthreads_condition_t *condition, |
| 105 |
libcerror_error_t **error ); |
| 106 |
|
| 107 |
LIBCTHREADS_EXTERN \ |
| 108 |
int libcthreads_condition_wait( |
| 109 |
libcthreads_condition_t *condition, |
| 110 |
libcthreads_mutex_t *mutex, |
| 111 |
libcerror_error_t **error ); |
| 112 |
|
| 113 |
#endif |
| 114 |
|
| 115 |
#if defined( __cplusplus ) |
| 116 |
} |
| 117 |
#endif |
| 118 |
|
| 119 |
#endif |
| 120 |
|