[kaffe] unix-pthreads broken on sunos

Dalibor Topic robilad at kaffe.org
Mon May 31 10:46:02 PDT 2004

Ciao Riccardo,

thanks for the bug report.

Riccardo wrote:
> Building kaffe with pthreads on solaris (sunos 5.6) fails:
> In file included from ../../../../../kaffe/kaffe/kaffevm/systems/unix-
> pthreads/syscalls.c:21:
> <cut>
> ./../../../../kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c: 
> At top level:
> ./../../../../kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:
> 207: warning: no previous prototype for `tDump'
> ./../../../../kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:
> 249: warning: no previous prototype for `dump_signal_handler'
> <cut>
> ./../../../../kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c: 
> In function `tRun':
> ./../../../../kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:
> 594: error: `PTHREAD_THREADS_MAX' undeclared (first use in this function)

Ouch, it seems like Solaris is not POSIX[1] conforming there. Oh well. 
It should be in limits.h, according to the POSIX standard. But judging 
by [2] it seems like solaris does its own thing. Own thing being that 
solaris has no limit in theory, but it has one practice. Nevertheless, 
it doesn't want to provide the programmer with useful information 
regarding such limits, so our best bet is to use 
_POSIX_THREAD_THREADS_MAX [3] for systems that don't define 
`PTHREAD_THREADS_MAX'. It's the minimum value, though.

On the other hand, I'm wondering why we have to check for the pthread 
max anyway, since my understanding of pthread_create [4] is that it will 
return EAGAIN on failure, so we could simply use that on all systems, no?

I'll write a patch that does that, and give it a spin on linux.

dalibor topic

[1] http://www.opengroup.org/onlinepubs/009695399/basedefs/limits.h.html
[2] http://www.netsys.com/cgi-bin/solaris9?sysconf(3C)
[3] Keep off the '_', POSIX. Someone on the POSIX standards body should 
read http://oakroadsystems.com/tech/c-predef.htm.
[4] http://www.opengroup.org/onlinepubs/007908799/xsh/pthread_create.html

More information about the kaffe mailing list