* [PATCH] Fix old pthread_cond_init
@ 2005-04-15 22:08 Jakub Jelinek
2005-04-15 22:19 ` Roland McGrath
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2005-04-15 22:08 UTC (permalink / raw)
To: Ulrich Drepper, Roland McGrath; +Cc: Glibc hackers
Hi!
The pre-GLIBC_2.3.2 pthread_cond_* functions can't support
process shared condvars, nor special clocks.
pshared condvars can't work, because all that is really
ensured to be process shared is the pointer to the full size
pthread_cond_t, but that structure is malloced and generally
not ensured to be shared among processes.
The comment in the new pthread_cond_init is bogus now that we
actually differentiate between process private and process
shared condvars - the former can use FUTEX_REQUEUE* while
the latter can't (well, they could iff both condvar and
mutex are on the same page).
2005-04-15 Jakub Jelinek <jakub@redhat.com>
* old_pthread_cond_init.c: Include errno.h.
(__pthread_cond_init_2_0): Fail with EINVAL if COND_ATTR is
process shared or uses clock other than CLOCK_REALTIME.
* pthread_cond_init.c (__pthread_cond_init): Remove bogus
comment.
--- libc/nptl/pthread_cond_init.c.jj 2004-09-02 23:27:05.000000000 +0200
+++ libc/nptl/pthread_cond_init.c 2005-04-15 23:41:47.000000000 +0200
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -26,8 +26,6 @@ __pthread_cond_init (cond, cond_attr)
pthread_cond_t *cond;
const pthread_condattr_t *cond_attr;
{
- /* Note that we don't need the PSHARED information from COND-ATTR.
- Conditional variables are always usable in multiple processes. */
struct pthread_condattr *icond_attr = (struct pthread_condattr *) cond_attr;
cond->__data.__lock = LLL_MUTEX_LOCK_INITIALIZER;
--- libc/nptl/old_pthread_cond_init.c.jj 2003-01-03 20:13:08.000000000 +0100
+++ libc/nptl/old_pthread_cond_init.c 2005-04-16 00:00:37.000000000 +0200
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -17,6 +17,7 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+#include <errno.h>
#include "pthreadP.h"
#include <shlib-compat.h>
@@ -27,15 +28,18 @@ __pthread_cond_init_2_0 (cond, cond_attr
pthread_cond_2_0_t *cond;
const pthread_condattr_t *cond_attr;
{
- /* Note that we don't need the COND-ATTR. It contains only the
- PSHARED flag which is unimportant here since conditional
- variables are always usable in multiple processes. */
+ struct pthread_condattr *icond_attr = (struct pthread_condattr *) cond_attr;
/* The type of the first argument is actually that of the old, too
small pthread_cond_t. We use only the first word of it, as a
pointer. */
cond->cond = NULL;
+ /* We can't support PSHARED condvars in the old pthread_cond_*
+ functions and neither clocks other than CLOCK_REALTIME. */
+ if (icond_attr != NULL && icond_attr->value)
+ return EINVAL;
+
return 0;
}
compat_symbol (libpthread, __pthread_cond_init_2_0, pthread_cond_init,
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix old pthread_cond_init
2005-04-15 22:08 [PATCH] Fix old pthread_cond_init Jakub Jelinek
@ 2005-04-15 22:19 ` Roland McGrath
0 siblings, 0 replies; 2+ messages in thread
From: Roland McGrath @ 2005-04-15 22:19 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Ulrich Drepper, Glibc hackers
> 2005-04-15 Jakub Jelinek <jakub@redhat.com>
>
> * old_pthread_cond_init.c: Include errno.h.
> (__pthread_cond_init_2_0): Fail with EINVAL if COND_ATTR is
> process shared or uses clock other than CLOCK_REALTIME.
> * pthread_cond_init.c (__pthread_cond_init): Remove bogus
> comment.
I put this in.
Thanks,
Roland
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-04-15 22:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-15 22:08 [PATCH] Fix old pthread_cond_init Jakub Jelinek
2005-04-15 22:19 ` Roland McGrath
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).