| 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_READ_WRITE_LOCK_H ) |
| 23 |
#define _LIBCTHREADS_INTERNAL_READ_WRITE_LOCK_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_read_write_lock libcthreads_internal_read_write_lock_t; |
| 47 |
|
| 48 |
struct libcthreads_internal_read_write_lock |
| 49 |
{ |
| 50 |
#if defined( WINAPI ) && ( WINVER >= 0x0600 ) |
| 51 |
|
| 52 |
|
| 53 |
SRWLOCK slim_read_write_lock; |
| 54 |
|
| 55 |
#elif defined( WINAPI ) |
| 56 |
|
| 57 |
|
| 58 |
CRITICAL_SECTION read_critical_section; |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
CRITICAL_SECTION write_critical_section; |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
int number_of_readers; |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
HANDLE no_read_event_handle; |
| 71 |
|
| 72 |
#elif defined( HAVE_PTHREAD_H ) |
| 73 |
|
| 74 |
|
| 75 |
pthread_rwlock_t read_write_lock; |
| 76 |
|
| 77 |
#else |
| 78 |
#error Missing read/write lock type |
| 79 |
#endif |
| 80 |
}; |
| 81 |
|
| 82 |
LIBCTHREADS_EXTERN \ |
| 83 |
int libcthreads_read_write_lock_initialize( |
| 84 |
libcthreads_read_write_lock_t **read_write_lock, |
| 85 |
libcerror_error_t **error ); |
| 86 |
|
| 87 |
LIBCTHREADS_EXTERN \ |
| 88 |
int libcthreads_read_write_lock_free( |
| 89 |
libcthreads_read_write_lock_t **read_write_lock, |
| 90 |
libcerror_error_t **error ); |
| 91 |
|
| 92 |
LIBCTHREADS_EXTERN \ |
| 93 |
int libcthreads_read_write_lock_grab_for_read( |
| 94 |
libcthreads_read_write_lock_t *read_write_lock, |
| 95 |
libcerror_error_t **error ); |
| 96 |
|
| 97 |
LIBCTHREADS_EXTERN \ |
| 98 |
int libcthreads_read_write_lock_grab_for_write( |
| 99 |
libcthreads_read_write_lock_t *read_write_lock, |
| 100 |
libcerror_error_t **error ); |
| 101 |
|
| 102 |
LIBCTHREADS_EXTERN \ |
| 103 |
int libcthreads_read_write_lock_release_for_read( |
| 104 |
libcthreads_read_write_lock_t *read_write_lock, |
| 105 |
libcerror_error_t **error ); |
| 106 |
|
| 107 |
LIBCTHREADS_EXTERN \ |
| 108 |
int libcthreads_read_write_lock_release_for_write( |
| 109 |
libcthreads_read_write_lock_t *read_write_lock, |
| 110 |
libcerror_error_t **error ); |
| 111 |
|
| 112 |
#endif |
| 113 |
|
| 114 |
#if defined( __cplusplus ) |
| 115 |
} |
| 116 |
#endif |
| 117 |
|
| 118 |
#endif |
| 119 |
|