--- SheepShaver/src/Unix/configure.ac 2005/06/14 06:35:00 1.25 +++ SheepShaver/src/Unix/configure.ac 2005/07/01 06:16:00 1.31 @@ -185,17 +185,17 @@ no:linux*|no:netbsd*) AC_CHECK_LIB(pthread, pthread_create, , [ AC_CHECK_LIB(c_r, pthread_create, , [ AC_CHECK_LIB(PTL, pthread_create, , [ - AC_MSG_ERROR([You need pthreads to run Basilisk II.]) + dnl XXX remove when no pthreads case is merged + AC_MSG_ERROR([You need pthreads to run SheepShaver.]) + HAVE_PTHREADS=no ]) ]) ]) AC_CHECK_FUNCS(pthread_cancel) + AC_CHECK_FUNCS(pthread_cond_init) AC_CHECK_FUNCS(pthread_mutexattr_setprotocol) AC_CHECK_FUNCS(pthread_mutexattr_settype) AC_CHECK_FUNCS(pthread_mutexattr_setpshared) - if [[ "x$HAVE_PTHREADS" = "xyes" ]]; then - AC_DEFINE(HAVE_PTHREADS, 1, [Define if pthreads are available.]) - fi dnl If POSIX.4 semaphores are not available, we emulate them with pthread mutexes. SEMSRC= AC_CHECK_FUNCS(sem_init, , [ @@ -205,6 +205,9 @@ no:linux*|no:netbsd*) ]) ;; esac +if [[ "x$HAVE_PTHREADS" = "xyes" ]]; then + AC_DEFINE(HAVE_PTHREADS, 1, [Define if pthreads are available.]) +fi dnl We use FBDev DGA if possible. if [[ "x$WANT_FBDEV_DGA" = "xyes" ]]; then @@ -295,7 +298,7 @@ AC_SYS_LARGEFILE dnl Checks for header files. AC_HEADER_STDC AC_HEADER_SYS_WAIT -AC_CHECK_HEADERS(malloc.h) +AC_CHECK_HEADERS(malloc.h stdint.h) AC_CHECK_HEADERS(mach/vm_map.h mach/mach_init.h sys/mman.h) AC_CHECK_HEADERS(sys/time.h sys/times.h sys/socket.h) AC_CHECK_HEADERS(unistd.h fcntl.h byteswap.h dirent.h) @@ -346,8 +349,8 @@ AC_CHECK_FUNCS(nanosleep) AC_CHECK_FUNCS(sigaction signal) AC_CHECK_FUNCS(mmap mprotect munmap) AC_CHECK_FUNCS(vm_allocate vm_deallocate vm_protect) -AC_CHECK_FUNCS(posix_memalign memalign valloc) -AC_CHECK_FUNCS(exp2f log2f exp2 log2 trunc) +AC_CHECK_FUNCS(exp2f log2f exp2 log2) +AC_CHECK_FUNCS(floorf roundf ceilf truncf floor round ceil trunc) dnl Darwin seems to define mach_task_self() instead of task_self(). AC_CHECK_FUNCS(mach_task_self task_self) @@ -999,6 +1002,146 @@ EOF fi AC_MSG_RESULT($WANT_ADDRESSING_MODE) +dnl Utility macro used by next two tests. +dnl AC_EXAMINE_OBJECT(C source code, +dnl commands examining object file, +dnl [commands to run if compile failed]): +dnl +dnl Compile the source code to an object file; then convert it into a +dnl printable representation. All unprintable characters and +dnl asterisks (*) are replaced by dots (.). All white space is +dnl deleted. Newlines (ASCII 0x10) in the input are preserved in the +dnl output, but runs of newlines are compressed to a single newline. +dnl Finally, line breaks are forcibly inserted so that no line is +dnl longer than 80 columns and the file ends with a newline. The +dnl result of all this processing is in the file conftest.dmp, which +dnl may be examined by the commands in the second argument. +dnl +AC_DEFUN([gcc_AC_EXAMINE_OBJECT], +[AC_LANG_SAVE +AC_LANG_C +dnl Next bit cribbed from AC_TRY_COMPILE. +cat > conftest.$ac_ext < conftest.dmp + $2 +ifelse($3, , , else + $3 +)dnl +fi +rm -rf conftest* +AC_LANG_RESTORE]) + +dnl Floating point format probe. +dnl The basic concept is the same as the above: grep the object +dnl file for an interesting string. We have to watch out for +dnl rounding changing the values in the object, however; this is +dnl handled by ignoring the least significant byte of the float. +dnl +dnl Does not know about VAX G-float or C4x idiosyncratic format. +dnl It does know about PDP-10 idiosyncratic format, but this is +dnl not presently supported by GCC. S/390 "binary floating point" +dnl is in fact IEEE (but maybe we should have that in EBCDIC as well +dnl as ASCII?) +dnl +AC_DEFUN([gcc_AC_C_FLOAT_FORMAT], +[AC_CACHE_CHECK(floating point format, ac_cv_c_float_format, +[gcc_AC_EXAMINE_OBJECT( +[/* This will not work unless sizeof(double) == 8. */ +extern char sizeof_double_must_be_8 [sizeof(double) == 8 ? 1 : -1]; + +/* This structure must have no internal padding. */ +struct possibility { + char prefix[8]; + double candidate; + char postfix[8]; +}; + +#define C(cand) { "\nformat:", cand, ":tamrof\n" } +struct possibility table [] = +{ + C( 3.25724264705901305206e+01), /* @@IEEEFP - IEEE 754 */ + C( 3.53802595280598432000e+18), /* D__float - VAX */ + C( 5.32201830133125317057e-19), /* D.PDP-10 - PDP-10 - the dot is 0x13a */ + C( 1.77977764695171661377e+10), /* IBMHEXFP - s/390 format, ascii */ + C(-5.22995989424860458374e+10) /* IBMHEXFP - s/390 format, EBCDIC */ +};], + [if grep 'format:.@IEEEF.:tamrof' conftest.dmp >/dev/null 2>&1; then + ac_cv_c_float_format='IEEE (big-endian)' + elif grep 'format:.I@@PFE.:tamrof' conftest.dmp >/dev/null 2>&1; then + ac_cv_c_float_format='IEEE (big-endian)' + elif grep 'format:.FEEEI@.:tamrof' conftest.dmp >/dev/null 2>&1; then + ac_cv_c_float_format='IEEE (little-endian)' + elif grep 'format:.EFP@@I.:tamrof' conftest.dmp >/dev/null 2>&1; then + ac_cv_c_float_format='IEEE (little-endian)' + elif grep 'format:.__floa.:tamrof' conftest.dmp >/dev/null 2>&1; then + ac_cv_c_float_format='VAX D-float' + elif grep 'format:..PDP-1.:tamrof' conftest.dmp >/dev/null 2>&1; then + ac_cv_c_float_format='PDP-10' + elif grep 'format:.BMHEXF.:tamrof' conftest.dmp >/dev/null 2>&1; then + ac_cv_c_float_format='IBM 370 hex' + else + AC_MSG_ERROR(Unknown floating point format) + fi], + [AC_MSG_ERROR(compile failed)]) +]) +# IEEE is the default format. If the float endianness isn't the same +# as the integer endianness, we have to set FLOAT_WORDS_BIG_ENDIAN +# (which is a tristate: yes, no, default). This is only an issue with +# IEEE; the other formats are only supported by a few machines each, +# all with the same endianness. +format=IEEE_FLOAT_FORMAT +fbigend= +case $ac_cv_c_float_format in + 'IEEE (big-endian)' ) + if test $ac_cv_c_bigendian = no; then + fbigend=1 + fi + ;; + 'IEEE (little-endian)' ) + if test $ac_cv_c_bigendian = yes; then + fbigend=0 + fi + ;; + 'VAX D-float' ) + format=VAX_FLOAT_FORMAT + ;; + 'PDP-10' ) + format=PDP10_FLOAT_FORMAT + ;; + 'IBM 370 hex' ) + format=IBM_FLOAT_FORMAT + ;; +esac +AC_DEFINE_UNQUOTED(HOST_FLOAT_FORMAT, $format, + [Define to the floating point format of the host machine.]) +if test -n "$fbigend"; then + AC_DEFINE_UNQUOTED(HOST_FLOAT_WORDS_BIG_ENDIAN, $fbigend, + [Define to 1 if the host machine stores floating point numbers in + memory with the word containing the sign bit at the lowest address, + or to 0 if it does it the other way around. + + This macro should not be defined if the ordering is the same as for + multi-word integers.]) +fi +]) + +dnl Check for host float format +gcc_AC_C_FLOAT_FORMAT + dnl Platform specific binary postprocessor AC_PATH_PROG(BLESS, "true") if [[ "x$ac_cv_pagezero_hack" = "xyes" ]]; then @@ -1053,10 +1196,26 @@ AC_CACHE_CHECK([the format of compiler g rm -rf conftest* ]) +dnl Add -mdynamic-no-pic for MacOS X +if [[ "x$HAVE_GCC30" = "xyes" ]]; then + SAVED_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -mdynamic-no-pic" + AC_CACHE_CHECK([whether the compiler supports -mdynamic-no-pic], + ac_cv_gcc_mdynamic_no_pic, [ + AC_TRY_COMPILE([],[],[ac_cv_gcc_mdynamic_no_pic=yes],[ac_cv_gcc_mdynamic_no_pic=no]) + ]) + if [[ "x$ac_cv_gcc_mdynamic_no_pic" = "xyes" ]]; then + CXXFLAGS="$CXXFLAGS -mdynamic-no-pic" + else + CFLAGS="$SAVED_CFLAGS" + fi +fi + dnl CPU emulator sources if [[ "x$EMULATED_PPC" = "xyes" ]]; then CPUSRCS="\ ../kpx_cpu/src/mathlib/ieeefp.cpp \ + ../kpx_cpu/src/mathlib/mathlib.cpp \ ../kpx_cpu/src/cpu/ppc/ppc-cpu.cpp \ ../kpx_cpu/src/cpu/ppc/ppc-decode.cpp \ ../kpx_cpu/src/cpu/ppc/ppc-execute.cpp \ @@ -1097,7 +1256,7 @@ if [[ "x$EMULATED_PPC" = "xyes" ]]; then done fi fi - if [[ -z "$DYNGEN_CC" ]] || ! { echo '#include ' | $DYNGEN_CC -xc++ -c -o /dev/null - >& /dev/null; }; then + if [[ -z "$DYNGEN_CC" ]]; then ac_cv_use_dyngen=no fi ])