Subject: pkg/12955: unproven-pthread's PTHREAD_COND_INITIALIZER need PTHREAD_KERNEL defined
To: None <gnats-bugs@gnats.netbsd.org>
From: Jaromír <jdolecek@NetBSD.org>
List: netbsd-bugs
Date: 05/16/2001 09:30:36
>Number:         12955
>Category:       pkg
>Synopsis:       unproven-pthread's PTHREAD_COND_INITIALIZER need PTHREAD_KERNEL defined
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed May 16 00:30:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Jaromír Dolecek
>Release:        -current, 2001-05-14
>Organization:
	This time working for Artisys (cz).
>Environment:
	
System: NetBSD saruman.ics.muni.cz 1.5V NetBSD 1.5V (SARUMAN) #55: Mon May 14 10:37:38 CEST 2001 dolecek@saruman.ics.muni.cz:/usr/home/dolecek/soft/netbsd/sys/arch/i386/compile/SARUMAN i386
Architecture: i386
Machine: i386
>Description:
	It's not possible to use PTHREAD_COND_INITIALIZER with unproven-pthreads
	<pthread.h>, since it uses SEMAPHORE_CLEAR, which is only defined
	#ifdef PTHREAD_KERNEL. Workaround is to define it prior of including
	<pthread.h>, but that also makes the code incompilable with
	-Wall -Wwrite-strings -Werror.

	It's possible mit-pthreads also have this bug.
>How-To-Repeat:
	code fragment:

static pthread_cond_t pi_nonempty = PTHREAD_COND_INITIALIZER;

	> make
/usr/pkg/pthreads/bin/pgcc -O2 -g -pipe  -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wno-uninitialized -Wreturn-type -Wcast-qual -Wpointer-arith -Wwrite-strings -Wswitch -Wshadow -Werror   -I/usr/home/dolecek/soft/artisys/art/draked/.. -I/usr/home/dolecek/soft/artisys/art/draked -c /usr/home/dolecek/soft/artisys/art/draked/ptt.c
/usr/home/dolecek/soft/artisys/art/draked/ptt.c:27: `SEMAPHORE_CLEAR' undeclared here (not in a function)
/usr/home/dolecek/soft/artisys/art/draked/ptt.c:27: initializer element for `pi_nonempty.c_lock' is not constant

	with PTHREAD_KERNEL defined:

	> make
/usr/pkg/pthreads/bin/pgcc -O2 -g -pipe  -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wno-uninitialized -Wreturn-type -Wcast-qual -Wpointer-arith -Wwrite-strings -Wswitch -Wshadow -Werror   -I/usr/home/dolecek/soft/artisys/art/draked/.. -I/usr/home/dolecek/soft/artisys/art/draked -c /usr/home/dolecek/soft/artisys/art/draked/ptt.c
cc1: warnings being treated as errors
/usr/pkg/pthreads/include/pthread/machdep.h: In function `machdep_set_thread_timer':
In file included from /usr/pkg/pthreads/include/pthread.h:74,
                 from /usr/home/dolecek/soft/artisys/art/draked/ptt.c:11:
/usr/pkg/pthreads/include/pthread/machdep.h:131: warning: passing arg 1 of `__PANIC' discards `const' from pointer target type
/usr/pkg/pthreads/include/pthread/machdep.h:131: warning: passing arg 3 of `__PANIC' discards `const' from pointer target type
/usr/pkg/pthreads/include/pthread/machdep.h: In function `machdep_unset_thread_timer':
/usr/pkg/pthreads/include/pthread/machdep.h:154: warning: passing arg 1 of `__PANIC' discards `const' from pointer target type
/usr/pkg/pthreads/include/pthread/machdep.h:154: warning: passing arg 3 of `__PANIC' discards `const' from pointer target type
*** Error code 1

Stop.

>Fix:
	Define PTHREAD_COND_INITIALIZER so that it doesn't use stuff which
	is normally not defined.
>Release-Note:
>Audit-Trail:
>Unformatted: