summaryrefslogtreecommitdiff
path: root/perl.h
diff options
context:
space:
mode:
Diffstat (limited to 'perl.h')
-rw-r--r--perl.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/perl.h b/perl.h
index 2deb1d4f0c..2d3e1f769d 100644
--- a/perl.h
+++ b/perl.h
@@ -1754,6 +1754,19 @@ typedef UVTYPE UV;
#define PTR2NV(p) NUM2PTR(NV,p)
#define PTR2nat(p) (PTRV)(p) /* pointer to integer of PTRSIZE */
+
+#if PTRSIZE == 8
+# define PTRSIZELOG2 3
+#elif PTRSIZE == 4
+# define PTRSIZELOG2 2
+# else
+# error unknown pointer size
+# endif
+
+/* idx = PTRPTR2IDX(offset)
+ -turn an offset into array of void *s into an index into the array */
+#define PTRPTR2IDX(offset) ((offset) >> PTRSIZELOG2)
+
/* According to strict ANSI C89 one cannot freely cast between
* data pointers and function (code) pointers. There are at least
* two ways around this. One (used below) is to do two casts,