1 |
/* Initialize a rwlock. Generic version. |
/* Initialize a rwlock. Generic version. |
2 |
Copyright (C) 2002 Free Software Foundation, Inc. |
Copyright (C) 2002, 2005 Free Software Foundation, Inc. |
3 |
This file is part of the GNU C Library. |
This file is part of the GNU C Library. |
4 |
|
|
5 |
The GNU C Library is free software; you can redistribute it and/or |
The GNU C Library is free software; you can redistribute it and/or |
18 |
Boston, MA 02111-1307, USA. */ |
Boston, MA 02111-1307, USA. */ |
19 |
|
|
20 |
#include <pthread.h> |
#include <pthread.h> |
21 |
|
#include <string.h> |
22 |
#include <pt-internal.h> |
#include <pt-internal.h> |
23 |
|
|
24 |
int |
int |
25 |
_pthread_rwlock_init (pthread_rwlock_t *rwlock, |
_pthread_rwlock_init (pthread_rwlock_t *rwlock, |
26 |
const pthread_rwlockattr_t *attr) |
const pthread_rwlockattr_t *attr) |
27 |
{ |
{ |
28 |
*rwlock = __PTHREAD_RWLOCK_INITIALIZER; |
*rwlock = (pthread_rwlock_t) __PTHREAD_RWLOCK_INITIALIZER; |
29 |
|
|
30 |
|
if (! attr |
31 |
|
|| memcmp (attr, &__pthread_default_rwlockattr, sizeof (*attr) == 0)) |
32 |
|
/* Use the default attributes. */ |
33 |
|
return 0; |
34 |
|
|
35 |
|
/* Non-default attributes. */ |
36 |
|
|
37 |
|
rwlock->__attr = malloc (sizeof *attr); |
38 |
|
if (! rwlock->__attr) |
39 |
|
return ENOMEM; |
40 |
|
|
41 |
|
*rwlock->__attr = *attr; |
42 |
return 0; |
return 0; |
43 |
} |
} |
44 |
|
|