apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig Rodrigues <rodr...@crodrigues.org>
Subject FreeBSD APR patch for threads
Date Fri, 02 Jul 2004 19:43:54 GMT
Hi,

I maintain the port for apr in the FreeBSD ports collection.


The latest version of FreeBSD's implementation of threads is *MUCH*
more stable than in earlier versions of FreeBSD.  To compile a program
for threads, all you need to do is link with -lpthread.  -D_REENTRANT
and -D_THREAD_SAFE are no longer needed and have been entirely removed
from FreeBSD header files.

I have been maintaining a variation of this patch which I would
like to submit back to the APR repository.

This patch basically does the following:
 - for the latest versions of FreeBSD, puts in the correct flags for
   linking in threads
 - for older versions of FreeBSD, i.e FreeBSD 4.x, disables threads by 
   default (which is what APR does right now)   

I've been testing this patch for some time now.
Would it be possible to go in for APR 1.0?



Index: apr_hints.m4
===================================================================
RCS file: /home/cvspublic/apr/build/apr_hints.m4,v
retrieving revision 1.63
diff -u -r1.63 apr_hints.m4
--- apr_hints.m4	14 Jun 2004 21:16:40 -0000	1.63
+++ apr_hints.m4	2 Jul 2004 19:42:55 -0000
@@ -136,14 +136,15 @@
 	APR_ADDTO(CPPFLAGS, [-DNETBSD])
 	;;
     *-freebsd*)
-	case $host in
-	    *freebsd[[2345]]*)
-		APR_ADDTO(CFLAGS, [-funsigned-char])
-		;;
-	esac
-	APR_SETIFNULL(enable_threads, [no])
         APR_SETIFNULL(apr_lock_method, [USE_FLOCK_SERIALIZE])
-	APR_ADDTO(CPPFLAGS, [-D_REENTRANT -D_THREAD_SAFE])
+	os_version=`sysctl -n kern.osreldate`
+	if test $os_version -ge "502102"; then
+		apr_cv_pthreads_cflags="none"
+		apr_cv_pthreads_lib="-lpthread"
+	else
+		apr_cv_pthreads_cflags="-D_THREAD_SAFE -D_REENTRANT"
+		APR_SETIFNULL(enable_threads, [no])
+	fi
 	;;
     *-next-nextstep*)
 	APR_SETIFNULL(CFLAGS, [-O])



-- 
Craig Rodrigues        
http://crodrigues.org
rodrigc@crodrigues.org

Mime
View raw message