Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Unified Diff: src/untrusted/pthread/pthread.h

Issue 609363003: Add implementation of pthread_rwlock based on NaCl futexs (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/untrusted/pthread/nc_rwlock.c ('k') | src/untrusted/pthread/pthread.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/untrusted/pthread/pthread.h
diff --git a/src/untrusted/pthread/pthread.h b/src/untrusted/pthread/pthread.h
index eb495280aba765a6f5329e9cd36f57b433fd0b8d..18afd25699354c35f0cbb7468d44bc10743027bc 100644
--- a/src/untrusted/pthread/pthread.h
+++ b/src/untrusted/pthread/pthread.h
@@ -129,6 +129,24 @@ typedef struct {
int dummy; /**< Reserved; condition variables don't have attributes */
} pthread_condattr_t;
+/**
+ * A structure representing rwlock attributes. It should be considered an
+ * opaque record.
+ */
+typedef int32_t pthread_rwlockattr_t;
+
+/**
+ * A structure representing a rwlock. It should be considered an
+ * opaque record; the names of the fields can change anytime.
+ */
+typedef struct {
+ volatile int32_t state; /* 0=unlock, -1=writer lock, +n=reader lock */
+ struct __nc_basic_thread_data *volatile writer_thread_id;
+ volatile int32_t pending_readers;
+ volatile int32_t pending_writers;
+ pthread_rwlockattr_t attr;
+} pthread_rwlock_t;
+
/** A value that represents an uninitialized handle. */
#define NC_INVALID_HANDLE -1
@@ -153,7 +171,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. */
@@ -376,6 +395,30 @@ 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,
+ 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. */
« no previous file with comments | « src/untrusted/pthread/nc_rwlock.c ('k') | src/untrusted/pthread/pthread.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698