From: curt Date: Thu, 23 Jan 2003 15:16:51 +0000 (+0000) Subject: FreeBSD pthread and malloc fixes. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=3f0efc2a6fd5cd9076c78da7a32b119343d8b72e;p=simgear.git FreeBSD pthread and malloc fixes. --- diff --git a/configure.ac b/configure.ac index 4482cdc3..7846a9b4 100644 --- a/configure.ac +++ b/configure.ac @@ -147,6 +147,25 @@ if test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h CXXFLAGS="$CXXFLAGS -D_REENTRANT" CFLAGS="$CFLAGS -D_REENTRANT" fi +if test "x$ac_cv_lib_pthread_pthread_exit" != "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then + dnl FreeBSD: System has pthread.h, but -lpthread library check + dnl fails. See if we need -pthread instead of -lpthread and look + dnl for the functions in libc_r. + save_CXXFLAGS="$CXXFLAGS" + save_CFLAGS="$FLAGS" + CXXFLAGS="-pthread $CXXFLAGS" + CFLAGS="-pthread $FLAGS" + save_LIBS=$LIBS + AC_CHECK_LIB(c_r, pthread_exit) + if test "x$ac_cv_lib_c_r_pthread_exit" != "xyes"; then + CXXFLAGS=$save_CXXFLAGS + CFLAGS=$save_CFLAGS + else + dnl This is cheating a bit. pthread_exit comes with using -pthread, not -lpthread + ac_cv_lib_pthread_pthread_exit="yes" + fi + LIBS=$save_LIBS +fi AM_CONDITIONAL(HAVE_THREADS, test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes") AC_CHECK_LIB(socket, socket) diff --git a/simgear/xgl/xglUtils.c b/simgear/xgl/xglUtils.c index 4af679dc..9fb05be1 100644 --- a/simgear/xgl/xglUtils.c +++ b/simgear/xgl/xglUtils.c @@ -6,7 +6,10 @@ #if !defined( WIN32 ) # if !defined( HAVE_STL_SGI_PORT ) && !defined( __MWERKS__ ) && !defined( __APPLE__ ) // Avoid malloc with STLport and MSL -# include +# ifdef HAVE_MALLOC_H +// Avoid malloc if system doesn't have it. :-) +# include +# endif # endif #endif