1 |
/* Mutex type. Generic version. |
/* Mutex type. Generic version. |
2 |
Copyright (C) 2000,02 Free Software Foundation, Inc. |
Copyright (C) 2000, 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 |
52 |
/* Initializer for a mutex. N.B. this also happens to be compatible |
/* Initializer for a mutex. N.B. this also happens to be compatible |
53 |
with the cthread mutex initializer. */ |
with the cthread mutex initializer. */ |
54 |
# define __PTHREAD_MUTEX_INITIALIZER \ |
# define __PTHREAD_MUTEX_INITIALIZER \ |
55 |
((struct __pthread_mutex) \ |
{ __SPIN_LOCK_INITIALIZER, __SPIN_LOCK_INITIALIZER, 0, 0, 0, 0, 0, 0 } |
|
{ __SPIN_LOCK_INITIALIZER, __SPIN_LOCK_INITIALIZER, NULL, NULL, NULL, \ |
|
|
NULL, 0, 0 }) |
|
56 |
|
|
57 |
# endif |
# endif |
58 |
#endif /* Not __pthread_mutex_defined. */ |
#endif /* Not __pthread_mutex_defined. */ |
72 |
pthread_mutex_init (struct __pthread_mutex *__mutex, |
pthread_mutex_init (struct __pthread_mutex *__mutex, |
73 |
const pthread_mutexattr_t *attr) |
const pthread_mutexattr_t *attr) |
74 |
{ |
{ |
75 |
|
struct __pthread_mutex initialized_mutex = __PTHREAD_MUTEX_INITIALIZER; |
76 |
|
|
77 |
extern int _pthread_mutex_init (struct __pthread_mutex *, |
extern int _pthread_mutex_init (struct __pthread_mutex *, |
78 |
const pthread_mutexattr_t *); |
const pthread_mutexattr_t *); |
79 |
|
|
80 |
if (attr) |
if (attr) |
81 |
return _pthread_mutex_init (__mutex, attr); |
return _pthread_mutex_init (__mutex, attr); |
82 |
|
|
83 |
*__mutex = __PTHREAD_MUTEX_INITIALIZER; |
*__mutex = initialized_mutex; |
84 |
return 0; |
return 0; |
85 |
} |
} |
86 |
|
|