$!
$ perllibs=libs
$!
-$! Are we 64 bit?
$!
-$ IF use64bitint .OR. use64bitint .EQS. "define"
+$ IF archname .NES. "VMS_VAX"
$ THEN
$ d_PRId64 = "define"
$ d_PRIu64 = "define"
$ d_quad = "define"
$ quadtype = "long long"
$ uquadtype = "unsigned long long"
-$ quadkind = "QUAD_IS_LONG_LONG"
+$ quadkind = "3"
+$!
+$ d_frexpl = "define"
+$ d_modfl = "define"
+$ d_modflproto = "define"
$ ELSE
$ d_PRId64 = "undef"
$ d_PRIXU64 = "undef"
$ sPRIu64 = ""
$ sPRIx64 = ""
$ d_quad = "undef"
-$ quadtype = "long"
-$ uquadtype = "unsigned long"
-$ quadkind = "QUAD_IS_LONG"
-$ ENDIF
+$ quadtype = "undef"
+$ uquadtype = "undef"
+$ quadkind = "undef"
$!
-$ IF archname .NES. "VMS_VAX"
-$ THEN
-$ d_frexpl = "define"
-$ d_modfl = "define"
-$ d_modflproto = "define"
-$ ELSE
$ d_frexpl = "undef"
$ d_modfl = "undef"
$ d_modflproto = "undef"
$ nv_preserves_uv_bits = tmp
$ ENDIF
$!
+$ nv_overflows_integers_at = "0"
+$ echo4 "Checking to find the largest integer value your NVs can hold..."
+$ OS
+$ WS "#include <stdio.h>"
+$ WS ""
+$ WS "typedef ''nvtype' NV;"
+$ WS ""
+$ WS "int"
+$ WS "main() {"
+$ WS " NV value = 2;"
+$ WS " int count = 1;"
+$ WS ""
+$ WS " while(count < 256) {"
+$ WS " volatile NV up = value + 1.0;"
+$ WS " volatile NV negated = -value;"
+$ WS " volatile NV down = negated - 1.0;"
+$ WS " volatile NV got_up = up - value;"
+$ WS " int up_good = got_up == 1.0;"
+$ WS " int got_down = down - negated;"
+$ WS " int down_good = got_down == -1.0;"
+$ WS ""
+$ WS " if (down_good != up_good) {"
+$ WS " fprintf(stderr,"
+$ WS " ""Inconsistency - up %d %f; down %d %f; for 2**%d (%.20f)\n"","
+$ WS " up_good, (double) got_up, down_good, (double) got_down,"
+$ WS " count, (double) value);"
+$ WS " return 1;"
+$ WS " }"
+$ WS " if (!up_good) {"
+$ WS " while (1) {"
+$ WS " if (count > 8) {"
+$ WS " count -= 8;"
+$ WS " fputs(""256.0"", stdout);"
+$ WS " } else {"
+$ WS " count--;"
+$ WS " fputs(""2.0"", stdout);"
+$ WS " }"
+$ WS " if (!count) {"
+$ WS " puts("""");"
+$ WS " return 0;"
+$ WS " }"
+$ WS " fputs(""*"", stdout);"
+$ WS " }"
+$ WS " }"
+$ WS " value *= 2;"
+$ WS " ++count;"
+$ WS " }"
+$ WS " fprintf(stderr, ""Cannot overflow integer range, even at 2**%d (%.20f)\n"","
+$ WS " count, (double) value);"
+$ WS " return 1;"
+$ WS "}"
+$ CS
+$ GOSUB compile
+$ IF F$LENGTH(tmp) .GT. 0
+$ THEN
+$ IF F$EXTRACT(0,1,tmp) .EQS. "2"
+$ THEN
+$ echo "The largest integer your NVs can preserve is equal to ''tmp'"
+$ nv_overflows_integers_at = tmp
+$ ELSE
+$ echo "Cannot determine the largest integer value your NVs can hold, unexpected output"
+$ echo "''tmp'"
+$ ENDIF
+$ ELSE
+$ echo "Cannot determine the largest integer value your NVs can hold"
+$ ENDIF
+$!
$! Check for signbit (must already know nvtype)
$!
$ echo4 "Checking to see if you have signbit() available to work on ''nvtype'..."
$ WC "d_nice='define'"
$ WC "d_nl_langinfo='" + d_nl_langinfo + "'"
$ WC "d_nv_preserves_uv='" + d_nv_preserves_uv + "'"
+$ WC "nv_overflows_integers_at='" + nv_overflows_integers_at + "'"
$ WC "nv_preserves_uv_bits='" + nv_preserves_uv_bits + "'"
$ WC "d_nv_zero_is_allbits_zero='define'"
$ WC "d_off64_t='" + d_off64_t + "'"
$ WC "dlsrc='dl_vms.c'"
$ WC "doublesize='" + doublesize + "'"
$ WC "drand01='" + drand01 + "'"
+$ WC "dtrace='" + "'"
$!
$! The extensions symbol may be quite long
$!
$ WC "i8size='" + i8size + "'"
$ WC "i8type='" + i8type + "'"
$ WC "i_arpainet='undef'"
+$ WC "i_assert='define'"
$ WC "i_crypt='undef'"
$ WC "i_db='undef'"
$ WC "i_dbm='undef'"
$ WC "usedefaulttypes='" + usedefaulttypes + "'" ! VMS-specific
$ WC "usecrosscompile='undef'"
$ WC "usedl='" + usedl + "'"
+$ WC "usedtrace='undef'"
$ WC "usefaststdio='" + usefaststdio + "'"
$ WC "useieee='" + useieee + "'" ! VMS-specific
$ WC "useithreads='" + useithreads + "'"