Chromium Code Reviews| Index: src/untrusted/pthread/pthread.h |
| diff --git a/src/untrusted/pthread/pthread.h b/src/untrusted/pthread/pthread.h |
| index 00eee7ba8d13f7d5eb8e557a29132f482e81471e..11eeaf81a78e68141dcc697c08a69ea34124d45b 100644 |
| --- a/src/untrusted/pthread/pthread.h |
| +++ b/src/untrusted/pthread/pthread.h |
| @@ -129,6 +129,27 @@ typedef struct { |
| int dummy; /**< Reserved; condition variables don't have attributes */ |
| } pthread_condattr_t; |
| +/** |
| + * A structure representing a rwlock. It should be considered an |
| + * opaque record; the names of the fields can change anytime. |
| + */ |
| +typedef struct { |
| + pthread_mutex_t mutex; /* mutex for all values in the structure */ |
| + int reader_count; |
| + int writers_waiting; |
| + struct __nc_basic_thread_data *writer_thread_id; |
| + pthread_cond_t read_possible; |
| + pthread_cond_t write_possible; |
| +} pthread_rwlock_t; |
| + |
| +/** |
| + * A structure representing rwlock attributes. It should be considered an |
| + * opaque record. |
| + */ |
| +typedef struct { |
| + int type; |
| +} pthread_rwlockattr_t; |
| + |
| /** A value that represents an uninitialized handle. */ |
| #define NC_INVALID_HANDLE -1 |
| @@ -153,6 +174,8 @@ typedef struct { |
| /** Statically initializes a condition variable (pthread_cond_t). */ |
| #define PTHREAD_COND_INITIALIZER {0, NC_INVALID_HANDLE} |
| +#define PTHREAD_PROCESS_PRIVATE 0 |
| +#define PTHREAD_PROCESS_SHARED 1 |
| /* Functions for mutex handling. */ |
| @@ -353,7 +376,7 @@ int pthread_cond_timedwait_abs(pthread_cond_t *cond, |
| pthread_mutex_t *mutex, |
| const struct timespec *abstime); |
| - /** @nqPosix |
| +/** @nqPosix |
| * Waits for condition variable cond to be signaled or broadcast; wait time is |
| * limited by reltime. |
| * |
| @@ -376,6 +399,31 @@ int pthread_cond_timedwait_rel(pthread_cond_t *cond, |
| */ |
| #define pthread_cond_timedwait pthread_cond_timedwait_abs |
| +/* Functions for rwlock handling. */ |
| + |
| +int pthread_rwlockattr_init(pthread_rwlockattr_t *attr); |
| +int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *attr, |
|
Mark Seaborn
2015/01/05 16:58:53
There's no implementation of get/setpshared in thi
Sam Clegg
2015/01/06 19:06:25
Done. Add added test code.
|
| + int *pshared); |
| +int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr, int pshared); |
| +int pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr); |
| + |
| +int pthread_rwlock_init(pthread_rwlock_t *rwlock, |
| + const pthread_rwlockattr_t *attr); |
| + |
| +int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock); |
| +int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock); |
| +int pthread_rwlock_timedrdlock(pthread_rwlock_t *rwlock, |
| + const struct timespec *abstime); |
| + |
| + |
| +int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock); |
| +int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock); |
| +int pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, |
| + const struct timespec *abstime); |
| + |
| +int pthread_rwlock_unlock(pthread_rwlock_t *rwlock); |
| +int pthread_rwlock_destroy(pthread_rwlock_t *rwlock); |
| + |
| /* Threads */ |
| /** Thread entry function type. */ |
| @@ -499,6 +547,7 @@ extern int pthread_kill(pthread_t thread_id, |
| int sig); |
| /* Functions for handling thread attributes. */ |
| + |
| /** @nqPosix |
| * Initializes thread attributes structure attr with default attributes |
| * (detachstate is PTHREAD_CREATE_JOINABLE). |