You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by David Jones <os...@gmail.com> on 2007/01/16 22:19:06 UTC
Compile failure in apr/threadproc/unix/thread.c
I am hitting compile problems due to the interaction of Revision 65199 in
apr/threadproc/unix/thread.c and
#define PTHREAD_ATTR_SETDETACHSTATE_ARG2_ADDR.
Problem 1: Line int arg = DETACH_ARG(v); where v is undefined.
patch to use the defined value on instead of undefined v
svn diff apr/threadproc/unix/thread.c
Index: apr/threadproc/unix/thread.c
===================================================================
--- apr/threadproc/unix/thread.c (revision 494820)
+++ apr/threadproc/unix/thread.c (working copy)
@@ -65,7 +65,7 @@
{
apr_status_t stat;
#ifdef PTHREAD_ATTR_SETDETACHSTATE_ARG2_ADDR
- int arg = DETACH_ARG(v);
+ int arg = DETACH_ARG(on);
if ((stat = pthread_attr_setdetachstate(&attr->attr, &arg)) == 0) {
#else
====================================================================
Revision info for reference:
================================================================================
Revision 65199 - (view) (download) (annotate) - [select for diffs]
Modified Mon Jun 14 22:24:56 2004 UTC (2 years, 6 months ago) by jorton
File length: 7792 byte(s)
Diff to previous 65195 (colored)
* threadproc/unix/thread.c (apr_threadattr_detach_set): Fix for Mac OS
X: pass valid arguments to pthread_attr_setdetachstate.
* include/apr_thread_proc.h: Clarify apr_threadattr_detach_{set,get}
interfaces.
PR: 28472
Submitted by: INOUE Seiichiro <inoue ariel-networks.com>
--- apr/apr/trunk/threadproc/unix/thread.c 2004/06/14 15:08:43 65195
+++ apr/apr/trunk/threadproc/unix/thread.c 2004/06/14 22:24:56 65199
@@ -57,18 +57,20 @@
return stat;
}
+#define DETACH_ARG(v) ((v) ? PTHREAD_CREATE_DETACHED :
PTHREAD_CREATE_JOINABLE)
+
APR_DECLARE(apr_status_t) apr_threadattr_detach_set(apr_threadattr_t *attr,
apr_int32_t on)
{
apr_status_t stat;
#ifdef PTHREAD_ATTR_SETDETACHSTATE_ARG2_ADDR
- int arg = on;
+ int arg = DETACH_ARG(v);
if ((stat = pthread_attr_setdetachstate(&attr->attr, &arg)) == 0) {
#else
- if ((stat = pthread_attr_setdetachstate(&attr->attr, on)) == 0) {
+ if ((stat = pthread_attr_setdetachstate(&attr->attr,
+ DETACH_ARG(on))) == 0) {
#endif
-
return APR_SUCCESS;
}
else {
======================================================================================
Problem 2:
Constants PTHREAD_CREATE_DETACHED and PTHREAD_CREATE_JOINABLE are undefined
in zOS, so I get undefines from:
#define DETACH_ARG(v) ((v) ? PTHREAD_CREATE_DETACHED :
PTHREAD_CREATE_JOINABLE)
So add something like this to apr/include/apr_thread_proc.c?:
Index: apr/include/apr_thread_proc.h
===================================================================
--- apr/include/apr_thread_proc.h (revision 494820)
+++ apr/include/apr_thread_proc.h (working copy)
@@ -212,6 +212,13 @@
*/
APR_DECLARE(apr_status_t) apr_threadattr_detach_set(apr_threadattr_t *attr,
apr_int32_t on);
+#ifndef PTHREAD_CREATE_JOINABLE
+#define PTHREAD_CREATE_JOINABLE 0
+#endif
+
+#ifndef PTHREAD_CREATE_DETACHED
+#define PTHREAD_CREATE_DETACHED 1
+#endif
/**
* Get the detach state for this threadattr.
--
David Jones
oscaremma@gmail.com
Re: Compile failure in apr/threadproc/unix/thread.c
Posted by Jeff Trawick <tr...@gmail.com>.
On 1/23/07, David Jones <os...@gmail.com> wrote:
> Yes, +1
>
>
> On 1/16/07, Jeff Trawick <tr...@gmail.com> wrote:
> > We shouldn't be defining PTHREAD_ symbols for applications. For APR,
> > the application passes in zero or non-zero.
> >
> > How about changing thread.c as follows?
> >
> > #if defined(PTHREAD_CREATE_DETACHED)
> > #define DETACH_ARG(v) ((v) ? PTHREAD_CREATE_DETACHED :
> PTHREAD_CREATE_JOINABLE)
> > #else
> > #define DETACH_ARG(v) ((v) ? 1 : 0)
> > #endif
> >
committed to apr trunk and 1.2.x branch
thanks!
Re: Compile failure in apr/threadproc/unix/thread.c
Posted by David Jones <os...@gmail.com>.
Yes, +1
On 1/16/07, Jeff Trawick <tr...@gmail.com> wrote:
>
> On 1/16/07, David Jones <os...@gmail.com> wrote:
>
> > Problem 2:
> > Constants PTHREAD_CREATE_DETACHED and PTHREAD_CREATE_JOINABLE are
> undefined
> > in zOS, so I get undefines from:
> >
> > #define DETACH_ARG(v) ((v) ? PTHREAD_CREATE_DETACHED :
> > PTHREAD_CREATE_JOINABLE)
> >
> > Index: apr/include/apr_thread_proc.h
>
> > +#ifndef PTHREAD_CREATE_JOINABLE
> > +#define PTHREAD_CREATE_JOINABLE 0
> > +#endif
> > +
> > +#ifndef PTHREAD_CREATE_DETACHED
> > +#define PTHREAD_CREATE_DETACHED 1
> > +#endif
>
> We shouldn't be defining PTHREAD_ symbols for applications. For APR,
> the application passes in zero or non-zero.
>
> How about changing thread.c as follows?
>
> #if defined(PTHREAD_CREATE_DETACHED)
> #define DETACH_ARG(v) ((v) ? PTHREAD_CREATE_DETACHED :
> PTHREAD_CREATE_JOINABLE)
> #else
> #define DETACH_ARG(v) ((v) ? 1 : 0)
> #endif
>
Re: Compile failure in apr/threadproc/unix/thread.c
Posted by Jeff Trawick <tr...@gmail.com>.
On 1/16/07, David Jones <os...@gmail.com> wrote:
> Problem 2:
> Constants PTHREAD_CREATE_DETACHED and PTHREAD_CREATE_JOINABLE are undefined
> in zOS, so I get undefines from:
>
> #define DETACH_ARG(v) ((v) ? PTHREAD_CREATE_DETACHED :
> PTHREAD_CREATE_JOINABLE)
>
> Index: apr/include/apr_thread_proc.h
> +#ifndef PTHREAD_CREATE_JOINABLE
> +#define PTHREAD_CREATE_JOINABLE 0
> +#endif
> +
> +#ifndef PTHREAD_CREATE_DETACHED
> +#define PTHREAD_CREATE_DETACHED 1
> +#endif
We shouldn't be defining PTHREAD_ symbols for applications. For APR,
the application passes in zero or non-zero.
How about changing thread.c as follows?
#if defined(PTHREAD_CREATE_DETACHED)
#define DETACH_ARG(v) ((v) ? PTHREAD_CREATE_DETACHED : PTHREAD_CREATE_JOINABLE)
#else
#define DETACH_ARG(v) ((v) ? 1 : 0)
#endif