|
From: <sv...@va...> - 2008-02-28 07:36:03
|
Author: bart
Date: 2008-02-28 07:36:04 +0000 (Thu, 28 Feb 2008)
New Revision: 7496
Log:
Should compile again with linuxthreads header files.
Modified:
trunk/exp-drd/drd_intercepts.c
Modified: trunk/exp-drd/drd_intercepts.c
===================================================================
--- trunk/exp-drd/drd_intercepts.c 2008-02-28 01:36:38 UTC (rev 7495)
+++ trunk/exp-drd/drd_intercepts.c 2008-02-28 07:36:04 UTC (rev 7496)
@@ -116,7 +116,17 @@
static MutexT mutex_type(pthread_mutex_t* mutex)
{
- return pthread_to_drd_mutex_type(mutex->__data.__kind);
+#if defined(_PTHREAD_DESCR_DEFINED)
+ // Linuxthreads.
+ const int kind = mutex->__m_kind;
+#elif defined(__SIZEOF_PTHREAD_MUTEX_T)
+ // NPTL.
+ const int kind = mutex->__data.__kind;
+#else
+ // Another POSIX threads implementation. Regression tests will fail.
+ const int kind = PTHREAD_MUTEX_DEFAULT;
+#endif
+ return pthread_to_drd_mutex_type(kind);
}
static void vg_start_suppression(const void* const p, size_t const size)
|
|
From: Nicholas N. <nj...@cs...> - 2008-02-29 08:36:17
|
On Thu, 28 Feb 2008 sv...@va... wrote:
> Author: bart
> Date: 2008-02-28 07:36:04 +0000 (Thu, 28 Feb 2008)
> New Revision: 7496
>
> Log:
> Should compile again with linuxthreads header files.
>
> Modified:
> trunk/exp-drd/drd_intercepts.c
>
>
> Modified: trunk/exp-drd/drd_intercepts.c
> ===================================================================
> --- trunk/exp-drd/drd_intercepts.c 2008-02-28 01:36:38 UTC (rev 7495)
> +++ trunk/exp-drd/drd_intercepts.c 2008-02-28 07:36:04 UTC (rev 7496)
> @@ -116,7 +116,17 @@
>
> static MutexT mutex_type(pthread_mutex_t* mutex)
> {
> - return pthread_to_drd_mutex_type(mutex->__data.__kind);
> +#if defined(_PTHREAD_DESCR_DEFINED)
> + // Linuxthreads.
> + const int kind = mutex->__m_kind;
> +#elif defined(__SIZEOF_PTHREAD_MUTEX_T)
> + // NPTL.
> + const int kind = mutex->__data.__kind;
> +#else
> + // Another POSIX threads implementation. Regression tests will fail.
> + const int kind = PTHREAD_MUTEX_DEFAULT;
> +#endif
> + return pthread_to_drd_mutex_type(kind);
> }
I'd be inclined to make the 'else' case abort -- if you don't know what it
is, don't pretend to know...
Nick
|
|
From: Bart V. A. <bar...@gm...> - 2008-02-29 10:45:26
|
On Fri, Feb 29, 2008 at 9:36 AM, Nicholas Nethercote
<nj...@cs...> wrote:
> On Thu, 28 Feb 2008 sv...@va... wrote:
>
> > Modified: trunk/exp-drd/drd_intercepts.c
> > ===================================================================
> > --- trunk/exp-drd/drd_intercepts.c 2008-02-28 01:36:38 UTC (rev 7495)
> > +++ trunk/exp-drd/drd_intercepts.c 2008-02-28 07:36:04 UTC (rev 7496)
> > @@ -116,7 +116,17 @@
> >
> > static MutexT mutex_type(pthread_mutex_t* mutex)
> > {
> > - return pthread_to_drd_mutex_type(mutex->__data.__kind);
> > +#if defined(_PTHREAD_DESCR_DEFINED)
> > + // Linuxthreads.
> > + const int kind = mutex->__m_kind;
> > +#elif defined(__SIZEOF_PTHREAD_MUTEX_T)
> > + // NPTL.
> > + const int kind = mutex->__data.__kind;
> > +#else
> > + // Another POSIX threads implementation. Regression tests will fail.
> > + const int kind = PTHREAD_MUTEX_DEFAULT;
> > +#endif
> > + return pthread_to_drd_mutex_type(kind);
> > }
>
> I'd be inclined to make the 'else' case abort -- if you don't know what it
> is, don't pretend to know...
I'm not entirely happy myself with the above code -- there is e.g. no
standard that guarantees that if the macro _PTHREAD_DESCR_DEFINED is
defined, that pthread_mutex_t has a data member with the name
__m_kind. And in the code above the name PTHREAD_MUTEX_ADAPTIVE_NP is
used, which also may cause portability issues. One possible solution
is that I add configure test that check for the following:
* If the expression &((pthread_mutex_t*)0)->__m_kind compiles, define
HAVE_PTHREAD_MUTEX_T__M_KIND.
* If the expression &((pthread_mutex_t*)0)->__data.__kind compiles,
define HAVE_PTHREAD_MUTEX_T__DATA__KIND.
* If the expression PTHREAD_MUTEX_ADAPTIVE_NP compiles, define
HAVE_PTHREAD_MUTEX_ADAPTIVE_NP.
Since the above tests only test whether or not compilation succeeds,
these tests should also work fine when cross-compiling Valgrind.
Bart.
|