1 |
/* Lock a mutex with a timeout. Generic version. |
/* Lock a mutex with a timeout. 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 |
24 |
|
|
25 |
#define LOSE do { * (int *) 0 = 0; } while (1) |
#define LOSE do { * (int *) 0 = 0; } while (1) |
26 |
|
|
|
int |
|
|
pthread_mutex_timedlock (struct __pthread_mutex *mutex, |
|
|
const struct timespec *abstime) |
|
|
{ |
|
|
return __pthread_mutex_timedlock_internal (mutex, abstime); |
|
|
} |
|
|
|
|
27 |
/* Try to lock MUTEX, block until *ABSTIME if it is already held. As |
/* Try to lock MUTEX, block until *ABSTIME if it is already held. As |
28 |
a GNU extension, if TIMESPEC is NULL then wait forever. */ |
a GNU extension, if TIMESPEC is NULL then wait forever. */ |
29 |
int |
int |
89 |
} |
} |
90 |
} |
} |
91 |
|
|
92 |
|
if (abstime && (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)) |
93 |
|
return EINVAL; |
94 |
|
|
95 |
/* Add ourselves to the queue. */ |
/* Add ourselves to the queue. */ |
96 |
__pthread_enqueue (&mutex->__queue, self); |
__pthread_enqueue (&mutex->__queue, self); |
97 |
__pthread_spin_unlock (&mutex->__lock); |
__pthread_spin_unlock (&mutex->__lock); |
142 |
|
|
143 |
return 0; |
return 0; |
144 |
} |
} |
145 |
|
|
146 |
|
int |
147 |
|
pthread_mutex_timedlock (struct __pthread_mutex *mutex, |
148 |
|
const struct timespec *abstime) |
149 |
|
{ |
150 |
|
return __pthread_mutex_timedlock_internal (mutex, abstime); |
151 |
|
} |