summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorAndy Dougherty <doughera@lafcol.lafayette.edu>1995-04-14 22:32:18 +0000
committerAndy Dougherty <doughera@lafcol.lafayette.edu>1995-04-14 22:32:18 +0000
commit5d94fbed3754780f11eb4db2d2379544cacb60e1 (patch)
tree9d1c81cc2141769c76b61c272f84155723edb002 /util.c
parent232e078e289220085e912e3d740ae77767611478 (diff)
downloadperl-5d94fbed3754780f11eb4db2d2379544cacb60e1.tar.gz
perl5.001 patch.1d
This is my patch patch.1d for perl5.001. A complete description is given below, but here are the basic changes. 1. Linux: more tweaks so dynamic loading works under ELF or (maybe) under dld. There are so many different dld versions and so many different tool sets, it's hard to be more specific. 2. perl -e '$v=1e19+0' no longer dumps core on Intel x86 processors. 3. pod stuff: a. Wrapped pod2* translators in a 'SH' wrapper so that they have the proper path to perl at the top. b. Fixed pod/ Makefile to call the pod2html translator correctly. (Why do pod2man and pod2html work differently?) c. Include latest (Feb 2, 1995) version of pod2html, fresh from ftp.metronet.com. 4. MakeMaker 4.093. 5. GIMME and installperl patches from Tim Bunce. 6. Miscellaneous hint file updates. Configure Allow ' ' to mean 'none' in a few more places. This provides a way for hint files to set something to an empty value and to ensure that the empty value will be maintained when config.sh is reused. Fix silly ld typo that prevented hint file from actually setting $ld. MANIFEST Now has pod/pod2*.SH. Makefile.SH Remove old libperl.a instead of blindly adding to it. Failure to do this causes a problem if you originally used perl's malloc but later changed your mind. The old malloc.o would still be in libperl.a ext/DynaLoader/dl_dlopen.xs Use strerror(errno) instead of dlerror for NetBSD. handy.h Clarify & rework HAS_BOOL comments and code. No functionality is changed, but I hope this is easier to follow. hints/freebsd.sh hints/isc.sh hints/linux.sh hints/netbsd.sh hints/next_3_0.sh hints/next_3_2.sh hints/sco_3.sh Miscellaneous updates. See the individual comments in the patches. installperl Run ranlib on installed .a libraries. unlink() old versions of files before installing new ones, in case the old ones are are write-protected. lib/ExtUtils/MakeMaker.pm Updated to 4.092 by Andreas Koenig. This features better selection of shared library versions and shorter command lines for static linking of new extensions. It is also more robust against broken csh on Linux. (There's still a glob in the library selection loop, however.) I further updated it to 4.093 because I didn't like the distclean target :-). It's just a sloppy quick fix, but that's all I have time for now. I've also worked on the library version selection stuff and the $(CC) command stuff a little more. lib/TieHash.pm Overdue removal of ambiguous ${pack} construction. perl.h New U_V macro to cast to the UV type (usually unsigned long). pod/Makefile Updated. pod/pod2html.SH Updated. Converted to 'SH' wrapper so correct #!/path/to/perl gets used. pod/pod2latex.SH pod/pod2man.SH Converted to 'SH' wrapper so correct #!/path/to/perl gets used. pp_hot.c GIMME patch from Tim Bunce. pp_sys.c Allow use of F_FREESP fcntl() directive to truncate files. If HAS_MKDIR is not defined, the stat() call to check the result of the system "mkdir" call was failing because the filename pointer no longer pointed to the right location. sv.c Protect some (UV) casts by the new U_V() macro. util.c New cast_uv() function to support the U_V() macro, if needed. cast_iv() and cast_uv() no longer assume 32-bit longs. The various cast_() functions have also been simplified.
Diffstat (limited to 'util.c')
-rw-r--r--util.c77
1 files changed, 60 insertions, 17 deletions
diff --git a/util.c b/util.c
index 4a45c5ef99..9b3dd87896 100644
--- a/util.c
+++ b/util.c
@@ -29,6 +29,10 @@
# include <vfork.h>
#endif
+#ifdef I_LIMITS /* Needed for cast_xxx() functions below. */
+# include <limits.h>
+#endif
+
/* Put this after #includes because fork and vfork prototypes may
conflict.
*/
@@ -1575,36 +1579,75 @@ double f;
#endif
#ifndef CASTI32
+
+/* Look for MAX and MIN integral values. If we can't find them,
+ we'll use 32-bit two's complement defaults.
+*/
+#ifndef LONG_MAX
+# ifdef MAXLONG /* Often used in <values.h> */
+# define LONG_MAX MAXLONG
+# else
+# define LONG_MAX 2147483647L
+# endif
+#endif
+
+#ifndef LONG_MIN
+# define LONG_MIN (-LONG_MAX - 1)
+#endif
+
+#ifndef ULONG_MAX
+# ifdef MAXULONG
+# define LONG_MAX MAXULONG
+# else
+# define ULONG_MAX 4294967295L
+# endif
+#endif
+
+/* Unfortunately, on some systems the cast_uv() function doesn't
+ work with the system-supplied definition of ULONG_MAX. The
+ comparison (f >= ULONG_MAX) always comes out true. It must be a
+ problem with the compiler constant folding.
+
+ In any case, this workaround should be fine on any two's complement
+ system. If it's not, supply a '-DMY_ULONG_MAX=whatever' in your
+ ccflags.
+ --Andy Dougherty <doughera@lafcol.lafayette.edu>
+*/
+#ifndef MY_ULONG_MAX
+# define MY_ULONG_MAX ((UV)LONG_MAX * (UV)2 + (UV)1)
+#endif
+
I32
cast_i32(f)
double f;
{
-# define BIGDOUBLE 2147483647.0 /* Assume 32 bit int's ! */
-# define BIGNEGDOUBLE (-2147483648.0)
- if (f >= BIGDOUBLE)
- return (I32) BIGDOUBLE;
- if (f <= BIGNEGDOUBLE)
- return (I32) BIGNEGDOUBLE;
+ if (f >= LONG_MAX)
+ return (I32) LONG_MAX;
+ if (f <= LONG_MIN)
+ return (I32) LONG_MIN;
return (I32) f;
}
-# undef BIGDOUBLE
-# undef BIGNEGDOUBLE
IV
cast_iv(f)
double f;
{
- /* XXX This should be fixed. It assumes 32 bit IV's. */
-# define BIGDOUBLE 2147483647.0 /* Assume 32 bit IV's ! */
-# define BIGNEGDOUBLE (-2147483648.0)
- if (f >= BIGDOUBLE)
- return (IV) BIGDOUBLE;
- if (f <= BIGNEGDOUBLE)
- return (IV) BIGNEGDOUBLE;
+ if (f >= LONG_MAX)
+ return (IV) LONG_MAX;
+ if (f <= LONG_MIN)
+ return (IV) LONG_MIN;
return (IV) f;
}
-# undef BIGDOUBLE
-# undef BIGNEGDOUBLE
+
+UV
+cast_uv(f)
+double f;
+{
+ if (f >= MY_ULONG_MAX)
+ return (UV) MY_ULONG_MAX;
+ return (UV) f;
+}
+
#endif
#ifndef HAS_RENAME