develooper Front page | perl.perl5.porters | Postings from July 2001

[PATCH] pthread_atfork on FreeBSD - Part 1: #ifdef HAS_PTHREAD_ATFORK

Thread Next
From:
coral
Date:
July 12, 2001 16:18
Subject:
[PATCH] pthread_atfork on FreeBSD - Part 1: #ifdef HAS_PTHREAD_ATFORK
Message ID:
200107122316.f6CNGoq09171@moonlight.crystalflame.net
./Configure needs to check for the presence of pthread_atfork() and define
HAS_PTHREAD_ATFORK if it is present.  If it is not present, the following
patch makes PTHREAD_ATFORK into a nullop so that perl under -Duseithreads
can compile on systems without pthread_atfork().

Part 2 of this patch should be a patch to Configure.sh that detects the
existence of pthread_atfork().  The thread section of Configure is rather
hairy for my severely limited tuits at this moment, so I'm submitting this
patch so that we can use ithreads on ALL platforms again (instead of
platforms that have a pthread_atfork function, which apparently excludes
FreeBSD 4-current).

The only issue I see with this patch is that it makes PTHREAD_ATFORK a
nullop on platforms that have pthread_atfork(), as Configure does not
currently detect and set HAS_PTHREAD_ATFORK properly, or in fact at all. 
This is not of great concern to me, as I'd rather that we include this patch
instead of (a) backing out pthread_atfork or (b) assuming that anyone who
says -Duseithreads will have a pthread_atfork.

Gurusamy, thank you for discovering and adding this function - I do
recognize that it is helpful to us, which may not be apparent in the message
above.

R.

--- thread.h.orig	Thu Jul 12 15:51:49 2001
+++ thread.h	Thu Jul 12 15:53:11 2001
@@ -306,8 +306,12 @@
 void Perl_atfork_unlock(void);
 
 #ifndef PTHREAD_ATFORK
-#  define PTHREAD_ATFORK(prepare,parent,child)			\
-    pthread_atfork(prepare,parent,child)
+#  ifdef HAS_PTHREAD_ATFORK
+#    define PTHREAD_ATFORK(prepare,parent,child)		\
+      pthread_atfork(prepare,parent,child)
+#  else
+#    define PTHREAD_ATFORK(prepare,parent,child)
+#  endif
 #endif
 
 #ifndef THREAD_RET_TYPE

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About