This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
USHRT range limit macros
authorCharles Bailey <bailey@newman.upenn.edu>
Mon, 2 Mar 1998 01:41:41 +0000 (20:41 -0500)
committerMalcolm Beattie <mbeattie@sable.ox.ac.uk>
Thu, 5 Mar 1998 18:53:13 +0000 (18:53 +0000)
p4raw-id: //depot/perl@778

perl.h

diff --git a/perl.h b/perl.h
index 49032b5..2c4ee91 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -784,7 +784,11 @@ Free_t   Perl_free _((Malloc_t where));
 #  ifdef MAXUSHORT
 #    define PERL_USHORT_MAX ((unsigned short)MAXUSHORT)
 #  else
-#    define PERL_USHORT_MAX       ((unsigned short)~(unsigned)0)
+#    ifdef USHRT_MAX
+#      define PERL_USHORT_MAX ((unsigned short)USHRT_MAX)
+#    else
+#      define PERL_USHORT_MAX       ((unsigned short)~(unsigned)0)
+#    endif
 #  endif
 #endif
 
@@ -794,7 +798,11 @@ Free_t   Perl_free _((Malloc_t where));
 #  ifdef MAXSHORT    /* Often used in <values.h> */
 #    define PERL_SHORT_MAX ((short)MAXSHORT)
 #  else
-#    define PERL_SHORT_MAX      ((short) (PERL_USHORT_MAX >> 1))
+#    ifdef SHRT_MAX
+#      define PERL_SHORT_MAX ((short)SHRT_MAX)
+#    else
+#      define PERL_SHORT_MAX      ((short) (PERL_USHORT_MAX >> 1))
+#    endif
 #  endif
 #endif
 
@@ -804,7 +812,11 @@ Free_t   Perl_free _((Malloc_t where));
 #  ifdef MINSHORT
 #    define PERL_SHORT_MIN ((short)MINSHORT)
 #  else
-#    define PERL_SHORT_MIN        (-PERL_SHORT_MAX - ((3 & -1) == 3))
+#    ifdef SHRT_MIN
+#      define PERL_SHORT_MIN ((short)SHRT_MIN)
+#    else
+#      define PERL_SHORT_MIN        (-PERL_SHORT_MAX - ((3 & -1) == 3))
+#    endif
 #  endif
 #endif