Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add pthread_rwlockattr_setpshared

  • Loading branch information...
commit 20f08bd347b301d58f5881e300a69adb0feec7dc 1 parent 615a374
Shinichiro Hamaji authored
Showing with 35 additions and 15 deletions.
  1. +13 −6 libmac/mac.c
  2. +20 −8 mach/pthread.c
  3. +2 −1  rename.tab
19 libmac/mac.c
View
@@ -948,19 +948,26 @@ int __darwin_pthread_mutexattr_settype(pthread_mutexattr_t* attr, int kind) {
#define __DARWIN_PTHREAD_PROCESS_SHARED 1
#define __DARWIN_PTHREAD_PROCESS_PRIVATE 2
-int __darwin_pthread_mutexattr_setpshared(pthread_mutexattr_t* attr,
- int pshared) {
+static int __translate_pshared(int pshared) {
switch (pshared) {
case __DARWIN_PTHREAD_PROCESS_SHARED:
- pshared = PTHREAD_PROCESS_SHARED;
- break;
+ return PTHREAD_PROCESS_SHARED;
case __DARWIN_PTHREAD_PROCESS_PRIVATE:
- pshared = PTHREAD_PROCESS_PRIVATE;
- break;
+ return PTHREAD_PROCESS_PRIVATE;
default:
fprintf(stderr, "Unknown pthread_mutexattr_setpshared pshared: %d\n",
pshared);
+ return pshared;
}
+}
+int __darwin_pthread_mutexattr_setpshared(pthread_mutexattr_t* attr,
+ int pshared) {
+ pshared = __translate_pshared(pshared);
+ return pthread_mutexattr_setpshared(attr, pshared);
+}
+int __darwin_pthread_rwlockattr_setpshared(pthread_rwlockattr_t* attr,
+ int pshared) {
+ pshared = __translate_pshared(pshared);
return pthread_mutexattr_setpshared(attr, pshared);
}
28 mach/pthread.c
View
@@ -6,15 +6,27 @@
pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER;
int main() {
- pthread_mutexattr_t attr;
- if (pthread_mutexattr_init(&attr) != 0) {
- abort();
- }
- if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL) != 0) {
- abort();
+ {
+ pthread_mutexattr_t attr;
+ if (pthread_mutexattr_init(&attr) != 0) {
+ abort();
+ }
+ if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL) != 0) {
+ abort();
+ }
+ if (pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_PRIVATE) != 0) {
+ abort();
+ }
}
- if (pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_PRIVATE) != 0) {
- abort();
+
+ {
+ pthread_rwlockattr_t attr;
+ if (pthread_rwlockattr_init(&attr) != 0) {
+ abort();
+ }
+ if (pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_PRIVATE) != 0) {
+ abort();
+ }
}
// TODO(hamaji): PTHREAD_MUTEX_INITIALIZER has a different implementation...
3  rename.tab
View
@@ -120,6 +120,7 @@ RENAME(__moddi3, __modti3)
RENAME(__udivdi3, __udivti3)
RENAME(__umoddi3, __umodti3)
-// TODO(hamaji): pthread_mutexattr_gettype and pthread_mutexattr_getpshared
+// TODO(hamaji): *attr_gettype and *attr_getpshared
WRAP(pthread_mutexattr_settype)
WRAP(pthread_mutexattr_setpshared)
+WRAP(pthread_rwlockattr_setpshared)
Please sign in to comment.
Something went wrong with that request. Please try again.