}
#endif
-/* These are first defined in Draft 7 */
+/* detachstate appeared in Draft 6, but without manifest constants.
+ * in Draft 7 they were called PTHREAD_CREATE_UNDETACHED and ...DETACHED.
+ * in Draft 8 on, ...UNDETACHED became ...JOINABLE.
+ */
#ifndef PTHREAD_CREATE_JOINABLE
+#ifdef PTHREAD_CREATE_UNDETACHED
+#define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED
+#else
#define PTHREAD_CREATE_JOINABLE 0
#endif
+#endif
#ifndef PTHREAD_CREATE_DETACHED
#define PTHREAD_CREATE_DETACHED 1
{
int rtn;
pthread_attr_t attr;
+
+/* Always create the thread attrs, so we can set stacksize if we need to */
#if HAVE_PTHREADS > 4
pthread_attr_init(&attr);
#else
pthread_attr_setstacksize( &attr, LDAP_PVT_THREAD_STACK_SIZE );
#endif
-#if HAVE_PTHREADS > 4
+#if HAVE_PTHREADS > 5
detach = detach ? PTHREAD_CREATE_DETACHED : PTHREAD_CREATE_JOINABLE;
#if HAVE_PTHREADS == 6
pthread_attr_setdetachstate(&attr, &detach);
pthread_attr_destroy(&attr);
#else
pthread_attr_delete(&attr);
+#endif
+#if HAVE_PTHREADS < 6
if( detach ) {
pthread_detach( thread );
}
{
#if HAVE_PTHREADS > 6
return pthread_kill( thread, signo );
-#elif HAVE_PTHREADS == 6
+#elif HAVE_PTHREADS > 4
if ( pthread_kill( thread, signo ) < 0 ) return errno;
return 0;
#else