summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2018-09-19 15:31:34 -0600
committerKarl Williamson <khw@cpan.org>2018-09-20 08:30:45 -0600
commit86477e8975af27133f77fa918070748d5304ae49 (patch)
treec4967e8c9766c92ca69435565025a4af36308d96
parent94b1fc235db3d15b93f78567e32ea87641156e25 (diff)
downloadperl-86477e8975af27133f77fa918070748d5304ae49.tar.gz
Create Ptrdiff_t type
which evaluates to SSize_t in the unlikely event that there isn't a ptrdiff_t on the platform. ptrdiff_t is safer than ssize_t, as the latter need not contain any negative number besides -1.
-rw-r--r--perl.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/perl.h b/perl.h
index 9ba4ea2b38..5e5a15746c 100644
--- a/perl.h
+++ b/perl.h
@@ -1050,11 +1050,20 @@ EXTERN_C int usleep(unsigned int);
# define STRUCT_OFFSET(s,m) offsetof(s,m)
#endif
-/* ptrdiff_t is C11, so undef it under pedantic builds */
+/* ptrdiff_t is C11, so undef it under pedantic builds. (Actually it is
+ * in C89, but apparently there are platforms where it doesn't exist. See
+ * thread beginning at http://nntp.perl.org/group/perl.perl5.porters/251541.)
+ * */
#ifdef PERL_GCC_PEDANTIC
# undef HAS_PTRDIFF_T
#endif
+#ifdef HAS_PTRDIFF_T
+# define Ptrdiff_t ptrdiff_t
+#else
+# define Ptrdiff_t SSize_t
+#endif
+
#ifndef __SYMBIAN32__
# include <string.h>
#endif