This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Configure: add doublekind for the format of double.
authorJarkko Hietaniemi <jhi@iki.fi>
Sun, 2 Nov 2014 15:48:43 +0000 (10:48 -0500)
committerJarkko Hietaniemi <jhi@iki.fi>
Sun, 2 Nov 2014 18:59:54 +0000 (13:59 -0500)
17 files changed:
Configure
Cross/config.sh-arm-linux
NetWare/config.wc
Porting/Glossary
Porting/config.sh
config_h.SH
configure.com
metaconfig.h
myconfig.SH
plan9/config_sh.sample
symbian/config.sh
uconfig.h
uconfig.sh
uconfig64.sh
win32/config.ce
win32/config.gc
win32/config.vc

index 03c9a99..a12eba5 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -875,6 +875,7 @@ ld=''
 ld_can_script=''
 lddlflags=''
 usedl=''
+doublekind=''
 doublesize=''
 ebcdic=''
 fflushNULL=''
@@ -6788,6 +6789,78 @@ $rm_try
 set float.h i_float
 eval $inhdr
 
+$echo "Checking the kind of doubles you have..." >&4
+$cat <<EOP >try.c
+#$i_stdlib I_STDLIB
+#define DOUBLESIZE $doublesize
+#ifdef I_STDLIB
+#include <stdlib.h>
+#endif
+#include <stdio.h>
+static const double d = -0.1;
+int main() {
+  unsigned const char* b = (unsigned const char*)(&d);
+#if DOUBLESIZE == 4
+  if (b[0] == 0xCD || b[3] == 0xBD) {
+    /* IEEE 754 32-bit little-endian */
+    printf("1\n");
+    exit(0);
+  }
+  if (b[0] == 0xBD || b[3] == 0xCD) {
+    /* IEEE 754 32-bit big-endian */
+    printf("2\n");
+    exit(0);
+  }
+#endif
+#if DOUBLESIZE == 8
+  if (b[0] == 0x9A || b[7] == 0xBD) {
+    /* IEEE 754 64-bit little-endian */
+    printf("3\n");
+    exit(0);
+  }
+  if (b[0] == 0x9A || b[7] == 0xCD) {
+    /* IEEE 754 64-bit big-endian */
+    printf("4\n");
+    exit(0);
+  }
+#endif
+#if DOUBLESIZE == 16
+  if (b[0] == 0x9A || b[15] == 0xBD) {
+    /* IEEE 754 128-bit little-endian */
+    printf("5\n");
+    exit(0);
+  }
+  if (b[0] == 0x9A || b[15] == 0xCD) {
+    /* IEEE 754 128-bit big-endian */
+    printf("6\n");
+    exit(0);
+  }
+#endif
+  /* Rumoredly some old ARM processors have 'mixed endian' doubles,
+   * two 32-bit little endians stored in big-endian order. */
+  /* Then there are old mainframe/miniframe formats like VAX, IBM, and CRAY.
+   * Whether those environments can still build Perl is debatable. */
+  printf("-1\n"); /* unknown */
+  exit(0);
+}
+EOP
+set try
+if eval $compile; then
+    doublekind=`$run ./try`
+else
+    doublekind=-1
+fi
+case "$doublekind" in
+1) echo "You have IEEE 754 32-bit little endian doubles." >&4 ;;
+2) echo "You have IEEE 754 32-bit big endian doubles." >&4 ;;
+3) echo "You have IEEE 754 64-bit little endian doubles." >&4 ;;
+4) echo "You have IEEE 754 64-bit big endian doubles." >&4 ;;
+5) echo "You have IEEE 754 128-bit little endian doubles." >&4 ;;
+6) echo "You have IEEE 754 128-bit big endian doubles." >&4 ;;
+*) echo "Cannot figure out your double.  You VAX, or something?" >&4 ;;
+esac
+$rm_try
+
 : check for long doubles
 echo " "
 echo "Checking to see if you have long double..." >&4
@@ -23946,6 +24019,7 @@ db_version_patch='$db_version_patch'
 direntrytype='$direntrytype'
 dlext='$dlext'
 dlsrc='$dlsrc'
+doublekind='$doublekind'
 doublesize='$doublesize'
 drand01='$drand01'
 drand48_r_proto='$drand48_r_proto'
index 1cd270b..9c565f8 100644 (file)
@@ -570,6 +570,7 @@ db_version_patch=''
 direntrytype='struct dirent'
 dlext='so'
 dlsrc='dl_dlopen.xs'
+doublekind='3'
 doublesize='8'
 drand01='Perl_drand48()'
 drand48_r_proto='0'
index 6e19e53..171e71c 100644 (file)
@@ -561,6 +561,7 @@ def_temp='sys:\perl\temp'
 direntrytype='DIR'
 dlext='nlm'
 dlsrc='dl_netware.xs'
+doublekind='3'
 doublesize='8'
 drand01='Perl_drand48()'
 drand48_r_proto='0'
index e56c6e1..1a9d770 100644 (file)
@@ -2639,6 +2639,16 @@ dlsrc (dlsrc.U):
        This variable contains the name of the dynamic loading file that
        will be used with the package.
 
+doublekind (doublekind.U):
+       This variable, if defined, encodes the type of a double:
+       1 = IEEE 754 32-bit big little endian,
+       2 = IEEE 754 32-bit big big endian,
+       3 = IEEE 754 64-bit big little endian,
+       4 = IEEE 754 64-bit big big endian,
+       5 = IEEE 754 128-bit big little endian,
+       6 = IEEE 754 128-bit big big endian,
+       -1 = unknown format.
+
 doublesize (doublesize.U):
        This variable contains the value of the DOUBLESIZE symbol, which
        indicates to the C program how many bytes there are in a double.
index 5323e3e..4ecb289 100644 (file)
@@ -581,6 +581,7 @@ db_version_patch='30'
 direntrytype='struct dirent'
 dlext='so'
 dlsrc='dl_dlopen.xs'
+doublekind='3'
 doublesize='8'
 drand01='Perl_drand48()'
 drand48_r_proto='0'
index b78c57f..3e6e5d2 100755 (executable)
@@ -2704,6 +2704,25 @@ sed <<!GROK!THIS! >$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un
  */
 #define DOUBLESIZE $doublesize         /**/
 
+/* DOUBLEKIND:
+ *     DOUBLEKIND will be one of
+ *     DOUBLE_IS_IEEE_754_32_BIT_LITTLE_ENDIAN
+ *     DOUBLE_IS_IEEE_754_32_BIT_BIG_ENDIAN
+ *     DOUBLE_IS_IEEE_754_64_BIT_LITTLE_ENDIAN
+ *     DOUBLE_IS_IEEE_754_64_BIT_BIG_ENDIAN
+ *     DOUBLE_IS_IEEE_754_128_BIT_LITTLE_ENDIAN
+ *     DOUBLE_IS_IEEE_754_128_BIT_BIG_ENDIAN
+ *     DOUBLE_IS_UNKNOWN_FORMAT
+ */
+#define DOUBLEKIND $doublekind         /**/
+#define DOUBLE_IS_IEEE_754_32_BIT_LITTLE_ENDIAN        1
+#define DOUBLE_IS_IEEE_754_32_BIT_BIG_ENDIAN   2
+#define DOUBLE_IS_IEEE_754_64_BIT_LITTLE_ENDIAN        3
+#define DOUBLE_IS_IEEE_754_64_BIT_BIG_ENDIAN   4
+#define DOUBLE_IS_IEEE_754_128_BIT_LITTLE_ENDIAN       5
+#define DOUBLE_IS_IEEE_754_128_BIT_BIG_ENDIAN  6
+#define DOUBLE_IS_UNKNOWN_FORMAT               -1
+
 /* EBCDIC:
  *     This symbol, if defined, indicates that this system uses
  *     EBCDIC encoding.
index be93b10..b441816 100644 (file)
@@ -6369,6 +6369,7 @@ $ WC "direntrytype='struct dirent'"
 $ WC "dlext='" + dlext + "'"
 $ WC "dlobj='" + dlobj + "'"
 $ WC "dlsrc='dl_vms.xs'"
+$ WC "doublekind='3'"
 $ WC "doublesize='" + doublesize + "'"
 $ WC "drand01='" + drand01 + "'"
 $ WC "dtrace='" + "'"
index 8c32690..bf6ae7c 100644 (file)
@@ -11,6 +11,7 @@
  * in Configure, this is the way to force them into availability.
  *
  * BOOTSTRAP_CHARSET
+ * DOUBLEKIND
  * HAS_ACOSH
  * HAS_ASCTIME64
  * HAS_CTIME64
index 6233188..c5a9537 100755 (executable)
@@ -44,7 +44,7 @@ Summary of my $package (revision $revision $version_patchlevel_string) configura
     optimize='$optimize',
     cppflags='$cppflags'
     ccversion='$ccversion', gccversion='$gccversion', gccosandvers='$gccosandvers'
-    intsize=$intsize, longsize=$longsize, ptrsize=$ptrsize, doublesize=$doublesize, byteorder=$byteorder
+    intsize=$intsize, longsize=$longsize, ptrsize=$ptrsize, doublesize=$doublesize, byteorder=$byteorder, doublekind=$doublekind
     d_longlong=$d_longlong, longlongsize=$longlongsize, d_longdbl=$d_longdbl, longdblsize=$longdblsize, longdblkind=$longdblkind
     ivtype='$ivtype', ivsize=$ivsize, nvtype='$nvtype', nvsize=$nvsize, Off_t='$lseektype', lseeksize=$lseeksize
     alignbytes=$alignbytes, prototype=$prototype
index 3583b5d..fe933c2 100644 (file)
@@ -569,6 +569,7 @@ db_version_patch=''
 direntrytype='struct dirent'
 dlext='none'
 dlsrc='dl_none.xs'
+doublekind='3'
 doublesize='8'
 drand01='(rand() / (double) ((unsigned long)1 << 15))'
 drand48_r_proto='0'
index 7496ae9..cd9f454 100644 (file)
@@ -516,6 +516,7 @@ db_version_patch='0'
 direntrytype='struct dirent'
 dlext='dll'
 dlsrc='dl_symbian.xs'
+doublekind='4'
 doublesize='8'
 drand01="((rand() & 0x7FFF) / (double) ((unsigned long)1 << 15))"
 drand48_r_proto='0'
index d2b10c9..98fc7ea 100644 (file)
--- a/uconfig.h
+++ b/uconfig.h
  */
 #define DOUBLESIZE 8           /**/
 
+/* DOUBLEKIND:
+ *     DOUBLEKIND will be one of
+ *     DOUBLE_IS_IEEE_754_32_BIT_LITTLE_ENDIAN
+ *     DOUBLE_IS_IEEE_754_32_BIT_BIG_ENDIAN
+ *     DOUBLE_IS_IEEE_754_64_BIT_LITTLE_ENDIAN
+ *     DOUBLE_IS_IEEE_754_64_BIT_BIG_ENDIAN
+ *     DOUBLE_IS_IEEE_754_128_BIT_LITTLE_ENDIAN
+ *     DOUBLE_IS_IEEE_754_128_BIT_BIG_ENDIAN
+ *     DOUBLE_IS_UNKNOWN_FORMAT
+ */
+#define DOUBLEKIND 3           /**/
+#define DOUBLE_IS_IEEE_754_32_BIT_LITTLE_ENDIAN        1
+#define DOUBLE_IS_IEEE_754_32_BIT_BIG_ENDIAN   2
+#define DOUBLE_IS_IEEE_754_64_BIT_LITTLE_ENDIAN        3
+#define DOUBLE_IS_IEEE_754_64_BIT_BIG_ENDIAN   4
+#define DOUBLE_IS_IEEE_754_128_BIT_LITTLE_ENDIAN       5
+#define DOUBLE_IS_IEEE_754_128_BIT_BIG_ENDIAN  6
+#define DOUBLE_IS_UNKNOWN_FORMAT               -1
+
 /* EBCDIC:
  *     This symbol, if defined, indicates that this system uses
  *     EBCDIC encoding.
 #endif
 
 /* Generated from:
- * 60aff40735c73cdf11d3fbae8088eadf73c0b45413be5bd8480ec5ec481066da config_h.SH
- * 35023b2d9244ad2dc3abea4bb5174a7f66398b60266231cb9a2c3bfc8df867cf uconfig.sh
+ * 3d5c0424ad00f8e220ee942aac53a86c34751e4160f3c47b3771901f9ce87692 config_h.SH
+ * 141d5cd6c8f9074f7d171b61583becedadab81b8ef0b12a8fbda7eb14da72ed6 uconfig.sh
  * ex: set ro: */
index d4199cd..b16ca20 100644 (file)
@@ -505,6 +505,7 @@ db_version_major='0'
 db_version_minor='0'
 db_version_patch='0'
 direntrytype='struct dirent'
+doublekind='3'
 doublesize='8'
 drand01="Perl_drand48()"
 drand48_r_proto='0'
index c575a4e..8ae6326 100644 (file)
@@ -506,6 +506,7 @@ db_version_major='0'
 db_version_minor='0'
 db_version_patch='0'
 direntrytype='struct dirent'
+doublekind='3'
 doublesize='8'
 drand01="((rand() & 0x7FFF) / (double) ((unsigned long)1 << 15))"
 drand48_r_proto='0'
index d63df39..8cae13b 100644 (file)
@@ -557,6 +557,7 @@ db_version_patch='0'
 direntrytype='struct direct'
 dlext='dll'
 dlsrc='dl_win32.xs'
+doublekind='3'
 doublesize='8'
 drand01='Perl_drand48()'
 drand48_r_proto='0'
index 3451f11..b57a243 100644 (file)
@@ -559,6 +559,7 @@ direntrytype='struct direct'
 dlext='dll'
 dlltool='~ARCHPREFIX~dlltool'
 dlsrc='dl_win32.xs'
+doublekind='3'
 doublesize='8'
 drand01='Perl_drand48()'
 drand48_r_proto='0'
index 7819916..4f8375c 100644 (file)
@@ -558,6 +558,7 @@ db_version_patch='0'
 direntrytype='struct direct'
 dlext='dll'
 dlsrc='dl_win32.xs'
+doublekind='3'
 doublesize='8'
 drand01='Perl_drand48()'
 drand48_r_proto='0'