summaryrefslogtreecommitdiff
path: root/sysdeps/generic/pt-rwlock-init.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/generic/pt-rwlock-init.c')
-rw-r--r--sysdeps/generic/pt-rwlock-init.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/sysdeps/generic/pt-rwlock-init.c b/sysdeps/generic/pt-rwlock-init.c
index 8fe87644..8aa495ec 100644
--- a/sysdeps/generic/pt-rwlock-init.c
+++ b/sysdeps/generic/pt-rwlock-init.c
@@ -1,5 +1,5 @@
/* Initialize a rwlock. Generic version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -18,14 +18,28 @@
Boston, MA 02111-1307, USA. */
#include <pthread.h>
+#include <string.h>
#include <pt-internal.h>
int
_pthread_rwlock_init (pthread_rwlock_t *rwlock,
const pthread_rwlockattr_t *attr)
{
- *rwlock = __PTHREAD_RWLOCK_INITIALIZER;
+ *rwlock = (pthread_rwlock_t) __PTHREAD_RWLOCK_INITIALIZER;
+
+ if (! attr
+ || memcmp (attr, &__pthread_default_rwlockattr, sizeof (*attr) == 0))
+ /* Use the default attributes. */
+ return 0;
+
+ /* Non-default attributes. */
+
+ rwlock->__attr = malloc (sizeof *attr);
+ if (! rwlock->__attr)
+ return ENOMEM;
+
+ *rwlock->__attr = *attr;
return 0;
}
-weak_alias (_pthread_rwlock_init, pthread_rwlock_init);
+strong_alias (_pthread_rwlock_init, pthread_rwlock_init);