File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / TSRM / threads.m4
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:47:52 2012 UTC (12 years, 4 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_17p0, v5_3_10, HEAD
php

    1: dnl  Copyright (c) 1999, 2000 Sascha Schumann. All rights reserved.
    2: dnl 
    3: dnl  Redistribution and use in source and binary forms, with or without
    4: dnl  modification, are permitted provided that the following conditions
    5: dnl  are met:
    6: dnl 
    7: dnl  1. Redistributions of source code must retain the above copyright
    8: dnl     notice, this list of conditions and the following disclaimer.
    9: dnl 
   10: dnl  2. Redistributions in binary form must reproduce the above copyright
   11: dnl     notice, this list of conditions and the following disclaimer in
   12: dnl     the documentation and/or other materials provided with the
   13: dnl     distribution.
   14: dnl 
   15: dnl  THIS SOFTWARE IS PROVIDED BY SASCHA SCHUMANN ``AS IS'' AND ANY
   16: dnl  EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   17: dnl  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   18: dnl  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL SASCHA SCHUMANN OR
   19: dnl  HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   20: dnl  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   21: dnl  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   22: dnl  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   23: dnl  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   24: dnl  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   25: dnl  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   26: dnl  OF THE POSSIBILITY OF SUCH DAMAGE.
   27: 
   28: dnl
   29: dnl PTHREADS_FLAGS
   30: dnl
   31: dnl Set some magic defines to achieve POSIX threads conformance
   32: dnl
   33: AC_DEFUN([PTHREADS_FLAGS],[
   34:   if test -z "$host_alias" && test -n "$host"; then
   35:     host_alias=$host
   36:   fi
   37:   if test -z "$host_alias"; then
   38:     AC_MSG_ERROR(host_alias is not set. Make sure to run config.guess)
   39:   fi
   40:   case $host_alias in
   41:   *solaris*)
   42:     PTHREAD_FLAGS="-D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT";;
   43:   *freebsd*)
   44:     PTHREAD_FLAGS="-D_REENTRANT -D_THREAD_SAFE";;
   45:   *linux*)
   46:     PTHREAD_FLAGS=-D_REENTRANT;;
   47:   *aix*)
   48:     PTHREAD_FLAGS=-D_THREAD_SAFE;;
   49:   *irix*)
   50:     PTHREAD_FLAGS=-D_POSIX_THREAD_SAFE_FUNCTIONS;;
   51:   *hpux*)
   52:     PTHREAD_FLAGS=-D_REENTRANT;;
   53:   *sco*)
   54:     PTHREAD_FLAGS=-D_REENTRANT;;
   55: dnl Solves sigwait() problem, creates problems with u_long etc.
   56: dnl    PTHREAD_FLAGS="-D_REENTRANT -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=199506 -D_XOPEN_SOURCE_EXTENDED=1";;
   57:   esac
   58: 
   59:   if test -n "$PTHREAD_FLAGS"; then
   60:     CPPFLAGS="$CPPFLAGS $PTHREAD_FLAGS"
   61:   fi
   62: ])dnl
   63: dnl
   64: dnl PTHREADS_CHECK_COMPILE
   65: dnl
   66: dnl Check whether the current setup can use POSIX threads calls
   67: dnl
   68: AC_DEFUN([PTHREADS_CHECK_COMPILE], [
   69: AC_TRY_RUN( [
   70: #include <pthread.h>
   71: #include <stddef.h>
   72: 
   73: void *thread_routine(void *data) {
   74:     return data;
   75: }
   76: 
   77: int main() {
   78:     pthread_t thd;
   79:     pthread_mutexattr_t mattr;
   80:     int data = 1;
   81:     pthread_mutexattr_init(&mattr);
   82:     return 0;
   83: } ], [
   84:   pthreads_working=yes
   85:   ], [
   86:   pthreads_working=no
   87:   ], [
   88:   dnl For cross compiling running this test is of no use. NetWare supports pthreads
   89:   pthreads_working=no
   90:   case $host_alias in
   91:   *netware*)
   92:     pthreads_working=yes
   93:   esac
   94: ]
   95: ) ] )dnl
   96: dnl
   97: dnl PTHREADS_CHECK()
   98: dnl
   99: dnl Try to find a way to enable POSIX threads
  100: dnl
  101: dnl  Magic flags
  102: dnl  -kthread          gcc (FreeBSD)
  103: dnl  -Kthread          UDK cc (UnixWare)
  104: dnl  -mt               WorkShop cc (Solaris)
  105: dnl  -mthreads         gcc (AIX)
  106: dnl  -pthread          gcc (Linux, FreeBSD, NetBSD, OpenBSD)
  107: dnl  -pthreads         gcc (Solaris) 
  108: dnl  -qthreaded        AIX cc V5
  109: dnl  -threads          gcc (HP-UX)
  110: dnl
  111: AC_DEFUN([PTHREADS_CHECK],[
  112: 
  113: if test "$beos_threads" = "1"; then
  114:   pthreads_working="yes"
  115:   ac_cv_pthreads_cflags=""
  116: else
  117:   save_CFLAGS=$CFLAGS
  118:   save_LIBS=$LIBS
  119:   PTHREADS_ASSIGN_VARS
  120:   PTHREADS_CHECK_COMPILE
  121:   LIBS=$save_LIBS
  122:   CFLAGS=$save_CFLAGS
  123: 
  124:   AC_CACHE_CHECK(for pthreads_cflags,ac_cv_pthreads_cflags,[
  125:   ac_cv_pthreads_cflags=
  126:   if test "$pthreads_working" != "yes"; then
  127:     for flag in -kthread -pthread -pthreads -mthreads -Kthread -threads -mt -qthreaded; do 
  128:       ac_save=$CFLAGS
  129:       CFLAGS="$CFLAGS $flag"
  130:       PTHREADS_CHECK_COMPILE
  131:       CFLAGS=$ac_save
  132:       if test "$pthreads_working" = "yes"; then
  133:         ac_cv_pthreads_cflags=$flag
  134:         break
  135:       fi
  136:     done
  137:   fi
  138: fi
  139: ])
  140: 
  141: AC_CACHE_CHECK(for pthreads_lib, ac_cv_pthreads_lib,[
  142: ac_cv_pthreads_lib=
  143: if test "$pthreads_working" != "yes"; then
  144:   for lib in pthread pthreads c_r; do
  145:     ac_save=$LIBS
  146:     LIBS="$LIBS -l$lib"
  147:     PTHREADS_CHECK_COMPILE
  148:     LIBS=$ac_save
  149:     if test "$pthreads_working" = "yes"; then
  150:       ac_cv_pthreads_lib=$lib
  151:       break
  152:     fi
  153:   done
  154: fi
  155: ])
  156: 
  157: if test "$pthreads_working" = "yes"; then
  158:   threads_result="POSIX-Threads found"
  159: else
  160:   threads_result="POSIX-Threads not found"
  161: fi
  162: ])dnl
  163: dnl
  164: dnl
  165: AC_DEFUN([PTHREADS_ASSIGN_VARS],[
  166: if test -n "$ac_cv_pthreads_lib"; then
  167:   LIBS="$LIBS -l$ac_cv_pthreads_lib"
  168: fi
  169: 
  170: if test -n "$ac_cv_pthreads_cflags"; then
  171:   CFLAGS="$CFLAGS $ac_cv_pthreads_cflags"
  172: fi
  173: ])dnl
  174: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>