From: Jarkko Hietaniemi Date: Tue, 15 Apr 2003 14:09:31 +0000 (+0000) Subject: Big patch from Alan Burlison to make Solaris long doubles work. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=55954f198635e48806cb76596014125260048264;p=p5sagit%2Fp5-mst-13.2.git Big patch from Alan Burlison to make Solaris long doubles work. (Also spreads more joy.) Needs backporting to metaconfig units and introducing the new symbols to non-Configure lands. p4raw-id: //depot/perl@19218 --- diff --git a/Configure b/Configure index 75b4ca6..cb8082a 100755 --- a/Configure +++ b/Configure @@ -334,6 +334,7 @@ cppstdin='' d__fwalk='' d_access='' d_accessx='' +d_aintl='' d_alarm='' asctime_r_proto='' d_asctime_r='' @@ -352,6 +353,7 @@ d_closedir='' d_void_closedir='' d_cmsghdr_s='' d_const='' +d_copysign='' cryptlib='' d_crypt='' crypt_r_proto='' @@ -510,6 +512,7 @@ d_gnulibc='' gnulibc_version='' d_hasmntopt='' d_htonl='' +d_ilogbl='' d_inetaton='' d_int64_t='' d_isascii='' @@ -599,6 +602,7 @@ d_safebcpy='' d_safemcpy='' d_sanemcmp='' d_sbrkproto='' +d_scalbnl='' d_select='' d_sem='' d_semctl='' @@ -4512,6 +4516,50 @@ case "$firstmakefile" in '') firstmakefile='makefile';; esac +case "$ccflags" in +*-DUSE_LONG_DOUBLE*|*-DUSE_MORE_BITS*) uselongdouble="$define" ;; +esac + +case "$uselongdouble" in +$define|true|[yY]*) dflt='y';; +*) dflt='n';; +esac +cat <&4 @@ -4859,7 +4907,7 @@ echo " " echo "Checking your choice of C compiler and flags for coherency..." >&4 $cat > try.c <<'EOF' #include -int main() { printf("Ok\n"); exit(0); } +int main() { printf("Ok\n"); return(0); } EOF set X $cc -o try $optimize $ccflags $ldflags try.c $libs shift @@ -6137,6 +6185,14 @@ esac set modfl d_modfl eval $inlibc +: see if aintl exists - used along with copysignl if modfl is missing +set aintl d_aintl +eval $inlibc + +: see if copysignl exists - used along with aintl if modfl is missing +set copysign d_copysignl +eval $inlibc + : see if prototype for modfl is available echo " " set d_modflproto modfl math.h @@ -6205,67 +6261,28 @@ EOCP ;; esac -case "$ccflags" in -*-DUSE_LONG_DOUBLE*|*-DUSE_MORE_BITS*) uselongdouble="$define" ;; -esac - -case "$uselongdouble" in -$define|true|[yY]*) dflt='y';; -*) dflt='n';; -esac -cat <&4 *** You requested the use of long doubles but you do not seem to have @@ -6276,6 +6293,7 @@ if $test "$message" != X; then EOM uselongdouble=$undef + fi fi : determine the architecture name @@ -7290,7 +7308,11 @@ eval $setvar : Cruising for prototypes echo " " echo "Checking out function prototypes..." >&4 -$cat >prototype.c <<'EOCP' +$cat >prototype.c < +#endif int main(int argc, char *argv[]) { exit(0);} EOCP @@ -7726,10 +7748,13 @@ while other systems (such as those using ELF) use $cc. EOM case "$ld" in - '') $cat >try.c <<'EOM' + '') $cat >try.c < +#$i_stdlib I_STDLIB +#ifdef I_STDLIB #include +#endif int main() { char b[4]; int i = open("a.out",O_RDONLY); @@ -8993,8 +9018,6 @@ else fpossize="$ans" fi - - # Backward compatibility (uselfs is deprecated). case "$uselfs" in "$define"|true|[yY]*) @@ -9072,6 +9095,10 @@ EOCP $cat > try.c < #include +#$i_stdlib I_STDLIB +#ifdef I_STDLIB +#include +#endif int main() { printf("%d\n", (int)sizeof($fpostype)); return(0); @@ -9534,7 +9561,7 @@ eval $inlibc case "$d_access" in "$define") echo " " - $cat >access.c <<'EOCP' + $cat >access.c < #ifdef I_FCNTL #include @@ -9545,6 +9572,10 @@ case "$d_access" in #ifdef I_UNISTD #include #endif +#$i_stdlib I_STDLIB +#ifdef I_STDLIB +#include +#endif int main() { exit(R_OK); } @@ -9663,7 +9694,7 @@ echo " " if test "X$timeincl" = X; then echo "Testing to see if we should include , or both." >&4 $echo $n "I'm now running the test program...$c" - $cat >try.c <<'EOCP' + $cat >try.c < #ifdef I_TIME #include @@ -9677,6 +9708,10 @@ if test "X$timeincl" = X; then #ifdef I_SYSSELECT #include #endif +#$i_stdlib I_STDLIB +#ifdef I_STDLIB +#include +#endif int main() { struct tm foo; @@ -9886,6 +9921,10 @@ case "$d_getpgrp" in #ifdef I_UNISTD # include #endif +#$i_stdlib I_STDLIB +#ifdef I_STDLIB +#include +#endif int main() { if (getuid() == 0) { @@ -9948,6 +9987,10 @@ case "$d_setpgrp" in #ifdef I_UNISTD # include #endif +#$i_stdlib I_STDLIB +#ifdef I_STDLIB +#include +#endif int main() { if (getuid() == 0) { @@ -10211,8 +10254,12 @@ echo " " if set vprintf val -f d_vprintf; eval $csym; $val; then echo 'vprintf() found.' >&4 val="$define" - $cat >try.c <<'EOF' + $cat >try.c < +#$i_stdlib I_STDLIB +#ifdef I_STDLIB +#include +#endif int main() { xxx("foo"); } @@ -10751,6 +10798,10 @@ eval $inhdr echo " " $cat >dirfd.c < +#$i_stdlib I_STDLIB +#ifdef I_STDLIB +#include +#endif #$i_dirent I_DIRENT /**/ #$i_sysdir I_SYS_DIR /**/ #$i_sysndir I_SYS_NDIR /**/ @@ -10843,6 +10894,10 @@ EOM $cat >fred.c< +#$i_stdlib I_STDLIB +#ifdef I_STDLIB +#include +#endif #$i_dlfcn I_DLFCN #ifdef I_DLFCN #include /* the dynamic linker include file for SunOS/Solaris */ @@ -11380,7 +11435,7 @@ esac : Locate the flags for 'open()' echo " " -$cat >try.c <<'EOCP' +$cat >try.c < #ifdef I_FCNTL #include @@ -11388,6 +11443,10 @@ $cat >try.c <<'EOCP' #ifdef I_SYS_FILE #include #endif +#$i_stdlib I_STDLIB +#ifdef I_STDLIB +#include +#endif int main() { if(O_RDONLY); #ifdef O_TRUNC @@ -11520,7 +11579,10 @@ case "$o_nonblock" in $cat head.c > try.c $cat >>try.c < +#$i_stdlib I_STDLIB +#ifdef I_STDLIB #include +#endif #$i_fcntl I_FCNTL #ifdef I_FCNTL #include @@ -11566,7 +11628,10 @@ case "$eagain" in #include #include #include -#include +#$i_stdlib I_STDLIB +#ifdef I_STDLIB +#include +#endif #$i_fcntl I_FCNTL #ifdef I_FCNTL #include @@ -11726,7 +11791,10 @@ eval $inlibc echo " " : See if fcntl-based locking works. $cat >try.c < +#endif #include #include #include @@ -11793,6 +11861,10 @@ $cat <try.c < +#endif #$i_systime I_SYS_TIME #$i_sysselct I_SYS_SELECT #$d_socket HAS_SOCKET @@ -11937,6 +12009,14 @@ eval $setvar set frexpl d_frexpl eval $inlibc +: see if ilogbl exists - used along with scalbnl if frexpl is missing +set ilogbl d_ilogbl +eval $inlibc + +: see if scalbnl exists - used along with ilogbl if frexpl is missing +set scalbnl d_scalbnl +eval $inlibc + : see if this is a sys/param system set sys/param.h i_sysparam eval $inhdr @@ -13484,6 +13564,10 @@ echo " " $cat >isascii.c <<'EOCP' #include #include +#$i_stdlib I_STDLIB +#ifdef I_STDLIB +#include +#endif int main() { int c = 'A'; if (isascii(c)) @@ -14077,6 +14161,10 @@ if test X"$d_volatile" = X"$define"; then fi $cat <try.c #include +#$i_stdlib I_STDLIB +#ifdef I_STDLIB +#include +#endif #include #include #ifdef SIGFPE @@ -14714,7 +14802,7 @@ EOCP # include #endif #ifdef I_STDLIB -# include +#include #endif #ifdef I_STRING # include @@ -15865,6 +15953,10 @@ fi echo "Checking how std your stdio is..." >&4 $cat >try.c < +#$i_stdlib I_STDLIB +#ifdef I_STDLIB +#include +#endif #define FILE_ptr(fp) $stdio_ptr #define FILE_cnt(fp) $stdio_cnt int main() { @@ -15942,6 +16034,10 @@ $cat >try.c < +#endif #define FILE_ptr(fp) $stdio_ptr #define FILE_cnt(fp) $stdio_cnt #include @@ -16023,6 +16119,10 @@ case "$d_stdstdio" in $define) $cat >try.c < +#$i_stdlib I_STDLIB +#ifdef I_STDLIB +#include +#endif #define FILE_base(fp) $stdio_base #define FILE_bufsiz(fp) $stdio_bufsiz int main() { @@ -16682,6 +16782,10 @@ I'm now running the test program... EOM $cat >try.c < +#$i_stdlib I_STDLIB +#ifdef I_STDLIB +#include +#endif #include typedef $uvtype UV; int main() @@ -17099,6 +17203,10 @@ $define) #endif #include #include +#$i_stdlib I_STDLIB +#ifdef I_STDLIB +#include +#endif #include int main(int argc, char *argv[]) { @@ -17437,6 +17545,10 @@ sunos) $echo '#define PERL_FFLUSH_ALL_FOPEN_MAX 32' > try.c ;; esac $cat >>try.c < +#$i_stdlib I_STDLIB +#ifdef I_STDLIB +#include +#endif #$i_unistd I_UNISTD #ifdef I_UNISTD # include @@ -18467,7 +18579,11 @@ echo " " echo "Checking how to generate random libraries on your machine..." >&4 echo 'int bar1() { return bar2(); }' > bar1.c echo 'int bar2() { return 2; }' > bar2.c -$cat > foo.c <<'EOP' +$cat > foo.c < +#endif int main() { printf("%d\n", bar1()); exit(0); } EOP $cc $ccflags -c bar1.c >/dev/null 2>&1 @@ -18698,9 +18814,13 @@ xxx="$xxx SYS TERM THAW TRAP TSTP TTIN TTOU URG USR1 USR2" xxx="$xxx USR3 USR4 VTALRM WAITING WINCH WIND WINDOW XCPU XFSZ" : generate a few handy files for later -$cat > signal.c <<'EOCP' +$cat > signal.c < #include +#$i_stdlib I_STDLIB +#ifdef I_STDLIB +#include +#endif #include int main() { @@ -20260,6 +20380,7 @@ d_SCNfldbl='$d_SCNfldbl' d__fwalk='$d__fwalk' d_access='$d_access' d_accessx='$d_accessx' +d_aintl='$d_aintl' d_alarm='$d_alarm' d_archlib='$d_archlib' d_asctime_r='$d_asctime_r' @@ -20282,6 +20403,7 @@ d_class='$d_class' d_closedir='$d_closedir' d_cmsghdr_s='$d_cmsghdr_s' d_const='$d_const' +d_copysignl='$d_copysignl' d_crypt='$d_crypt' d_crypt_r='$d_crypt_r' d_csh='$d_csh' @@ -20406,6 +20528,7 @@ d_gnulibc='$d_gnulibc' d_grpasswd='$d_grpasswd' d_hasmntopt='$d_hasmntopt' d_htonl='$d_htonl' +d_ilogbl='$d_ilogbl' d_index='$d_index' d_inetaton='$d_inetaton' d_int64_t='$d_int64_t' @@ -20502,6 +20625,7 @@ d_safebcpy='$d_safebcpy' d_safemcpy='$d_safemcpy' d_sanemcmp='$d_sanemcmp' d_sbrkproto='$d_sbrkproto' +d_scalbnl='$d_scalbnl' d_sched_yield='$d_sched_yield' d_scm_rights='$d_scm_rights' d_seekdir='$d_seekdir' diff --git a/config_h.SH b/config_h.SH index d731579..dc54456 100644 --- a/config_h.SH +++ b/config_h.SH @@ -2462,6 +2462,17 @@ sed <$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un */ #$d_frexpl HAS_FREXPL /**/ +/* HAS_ILOGBL + * This symbol, if defined, indicates that the ilogbl function is + * available. If scalbnl is also present we can emulate frexpl + */ +/* HAS_SCALBNL + * This symbol, if defined, indicates that the scalbnl function is + * available. If ilogbl is also present we can emulate frexpl + */ +#$d_ilogbl HAS_ILOGBL /**/ +#$d_scalbnl HAS_SCALBNL /**/ + /* HAS_STRUCT_FS_DATA: * This symbol, if defined, indicates that the struct fs_data * to do statfs() is supported. @@ -2626,6 +2637,17 @@ sed <$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un #$d_modflproto HAS_MODFL_PROTO /**/ #$d_modfl_pow32_bug HAS_MODFL_POW32_BUG /**/ +/* HAS_AINTL + * This symbol, if defined, indicates that the aintl function is + * available. If copysignl is also present we can emulate modfl + */ +/* HAS_COPYSIGNL + * This symbol, if defined, indicates that the copysignl function is + * available. If aintl is also present we can emulate modfl + */ +#$d_aintl HAS_AINTL /**/ +#$d_copysignl HAS_COPYSIGNL /**/ + /* HAS_MPROTECT: * This symbol, if defined, indicates that the mprotect system call is * available to modify the access protection of a memory mapped file. diff --git a/hints/solaris_2.sh b/hints/solaris_2.sh index 2155e49..b3f2cd3 100644 --- a/hints/solaris_2.sh +++ b/hints/solaris_2.sh @@ -1,12 +1,7 @@ # hints/solaris_2.sh -# Last modified: Mon Jan 29 12:52:28 2001 -# Lupe Christoph -# Based on version by: -# Andy Dougherty -# Which was based on input from lots of folks, especially -# Dean Roehrich -# Additional input from Alan Burlison, Jarkko Hietaniemi, -# and Richard Soderberg. +# Contributions by (in alphabetical order) Alan Burlison, Andy Dougherty, +# Dean Roehrich, Jarkko Hietaniemi, Lupe Christoph, Richard Soderberg and +# many others. # # See README.solaris for additional information. # @@ -25,9 +20,6 @@ # gcc will occasionally emit warnings about "unused prefix", but # these ought to be harmless. See below for more details. -# See man vfork. -usevfork=${usevfork:-false} - # Solaris has secure SUID scripts d_suidsafe=${d_suidsafe:-define} @@ -65,34 +57,18 @@ case "$archname" in ;; esac -cat > UU/workshoplibpth.cbu << 'EOCBU' -# This script UU/workshoplibpth.cbu will get 'called-back' -# by other CBUs this script creates. -case "$workshoplibpth_done" in - '') if test `uname -p` = "sparc"; then - case "$use64bitall" in - "$define"|true|[yY]*) - # add SPARC-specific 64 bit libraries - loclibpth="$loclibpth /usr/lib/sparcv9" - if test -n "$workshoplibs"; then - loclibpth=`echo $loclibpth | sed -e "s% $workshoplibs%%" ` - for lib in $workshoplibs; do - # Logically, it should be sparcv9. - # But the reality fights back, it's v9. - loclibpth="$loclibpth $lib/sparcv9 $lib/v9" - done - fi - ;; - *) loclibpth="$loclibpth $workshoplibs" - ;; - esac - else - loclibpth="$loclibpth $workshoplibs" - fi - workshoplibpth_done="$define" - ;; -esac -EOCBU +# +# This extracts the library directories that will be searched by the Sun +# Workshop compiler, given the command-line supplied in $tryworkshopcc. +# Use thusly: loclibpth="`$getworkshoplibs` $loclibpth" +# + getworkshoplibs=`cat <<'END' +eval $tryworkshopcc -### 2>&1 | \ +sed -n '/ -Y /s!.* -Y "P,\([^"]*\)".*!\1!p' | tr ':' ' ' | \ +sed -e 's!/usr/lib/sparcv9!!' -e 's!/usr/ccs/lib/sparcv9!!' \ + -e 's!/usr/lib!!g' -e 's!/usr/ccs/lib!!g' +END +` case "$cc" in '') if test -f /opt/SUNWspro/bin/cc; then @@ -134,7 +110,7 @@ esac # Check that /dev/fd is mounted. If it is not mounted, let the # user know that suid scripts may not work. -df /dev/fd 2>&1 > /dev/null +mount | grep '^/dev/fd ' 2>&1 > /dev/null case $? in 0) ;; *) @@ -223,7 +199,7 @@ cat > UU/cc.cbu <<'EOCBU' # Tue Apr 13 17:19:43 EDT 1999 # Get gcc to share its secrets. -echo 'main() { return 0; }' > try.c +echo 'int main() { return 0; }' > try.c # Indent to avoid propagation to config.sh verbose=`${cc:-cc} -v -o try try.c 2>&1` @@ -231,6 +207,7 @@ if echo "$verbose" | grep '^Reading specs from' >/dev/null 2>&1; then # # Using gcc. # + ccversion='gcc' # See if as(1) is GNU as(1). GNU as(1) might not work for this job. if echo "$verbose" | grep ' /usr/ccs/bin/as ' >/dev/null 2>&1; then @@ -301,23 +278,24 @@ else # # Not using gcc. # - - ccversion="`${cc:-cc} -V 2>&1|sed -n -e '1s/^cc: //p'`" - case "$ccversion" in - *WorkShop*) ccname=workshop ;; - *) ccversion='' ;; - esac - - case "$ccname" in - workshop) - cat >try.c < -int main() { return(0); } + cat > try.c << 'EOM' +#include +int main() { +#ifdef __SUNPRO_C + printf("workshop\n"); +#else + printf("\n"); +#endif +return(0); +} EOM - workshoplibs=`cc -### try.c -lsunmath -o try 2>&1|sed -n '/ -Y /s%.* -Y "P,\(.*\)".*%\1%p'|tr ':' '\n'|grep '/SUNWspro/'` - . ./workshoplibpth.cbu - ;; - esac + tryworkshopcc="${cc:-cc} try.c -o try" + if $tryworkshopcc >/dev/null 2>&1; then + ccversion=`./try` + if test "$ccversion" = "workshop" -a ! "$use64bitall_done"; then + loclibpth="/usr/lib /usr/ccs/lib `$getworkshoplibs` $loclibpth" + fi + fi # See if as(1) is GNU as(1). GNU might not work for this job. case `as --version < /dev/null 2>&1` in @@ -348,14 +326,9 @@ to the beginning of your PATH. END fi - fi - # as --version or ld --version might dump core. -rm -f try try.c -rm -f core - -# XXX +rm -f try try.c core EOCBU cat > UU/usethreads.cbu <<'EOCBU' @@ -385,7 +358,7 @@ $define|true|[yY]*) /* Test for sig(set|long)jmp bug. */ #include - main() + int main() { sigjmp_buf env; int ret; @@ -520,10 +493,9 @@ Cannot continue, aborting. EOM exit 1 fi - . ./workshoplibpth.cbu case "$cc -v 2>/dev/null" in *gcc*) - echo 'main() { return 0; }' > try.c + echo 'int main() { return 0; }' > try.c case "`${cc:-cc} -mcpu=v9 -m64 -S try.c 2>&1 | grep 'm64 is not supported by this configuration'`" in *"m64 is not supported"*) cat >&4 </dev/null` != X; then ccflags="$ccflags -Wa,`getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null`" @@ -553,12 +526,11 @@ EOM ccflags="$ccflags `getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null`" ldflags="$ldflags `getconf XBS5_LP64_OFF64_LDFLAGS 2>/dev/null`" lddlflags="$lddlflags -G `getconf XBS5_LP64_OFF64_LDFLAGS 2>/dev/null`" + echo "int main() { return(0); } " > try.c + tryworkshopcc="${cc:-cc} try.c -o try $ccflags" + loclibpth="/usr/lib/sparcv9 /usr/ccs/lib/sparcv9 `$getworkshoplibs` $loclibpth" ;; esac - libscheck='case "`/usr/bin/file $xxx`" in -*64-bit*|*SPARCV9*) ;; -*) xxx=/no/64-bit$xxx ;; -esac' use64bitall_done=yes ;; @@ -580,19 +552,20 @@ cat > UU/uselongdouble.cbu <<'EOCBU' # after it has prompted the user for whether to use long doubles. case "$uselongdouble" in "$define"|true|[yY]*) - if test -f /opt/SUNWspro/lib/libsunmath.so; then - # Unfortunately libpth has already been set and - # searched, so we need to add in everything manually. - libpth="$libpth /opt/SUNWspro/lib" - libs="$libs -lsunmath" - ldflags="$ldflags -L/opt/SUNWspro/lib -R/opt/SUNWspro/lib" - d_sqrtl=define + if test "$ccversion" = "workshop"; then + cat > try.c << 'EOM' +#include +int main() { (void) powl(2, 256); return(0); } +EOM + if cc try.c -lsunmath -o try > /dev/null 2>&1 && ./try; then + libswanted="$libswanted sunmath" + fi else cat >&4 < (NV)IV_MIN - 0.5) { SETi(I_V(value)); } else { -#if defined(HAS_MODFL) || defined(LONG_DOUBLE_EQUALS_DOUBLE) -# ifdef HAS_MODFL_POW32_BUG +#if defined(SPARC64_MODF_WORKAROUND) + (void)sparc64_workaround_modf(-value, &value); +#elif defined(HAS_MODFL_POW32_BUG) /* some versions of glibc split (i + d) into (i-1, d+1) for 2^32 <= i < 2^64 */ - { - NV offset = Perl_modf(-value, &value); - (void)Perl_modf(offset, &offset); - value += offset; - } -# else - (void)Perl_modf(-value, &value); -# endif - value = -value; + NV offset = Perl_modf(-value, &value); + (void)Perl_modf(offset, &offset); + value += offset; #else - double tmp = (double)value; - (void)Perl_modf(-tmp, &tmp); - value = -(NV)tmp; + (void)Perl_modf(-value, &value); #endif - SETn(value); + SETn(-value); } } }