summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/POSIX/POSIX.xs12
-rw-r--r--mg.c2
-rw-r--r--perl.h19
3 files changed, 22 insertions, 11 deletions
diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs
index 26d5e20695..79aa58d1a5 100644
--- a/ext/POSIX/POSIX.xs
+++ b/ext/POSIX/POSIX.xs
@@ -1347,7 +1347,9 @@ sigaction(sig, optaction, oldaction = 0)
/* Get back whether the old handler used safe signals. */
svp = hv_fetch(oldaction, "SAFE", 4, TRUE);
- sv_setiv(*svp, oact.sa_handler == PL_csighandlerp);
+ sv_setiv(*svp,
+ /* compare incompatible pointers by casting to integer */
+ PTR2nat(oact.sa_handler) == PTR2nat(PL_csighandlerp));
}
if (action) {
@@ -1355,8 +1357,12 @@ sigaction(sig, optaction, oldaction = 0)
PL_sighandlerp pointer when it's safe to do so.
(BTW, "csighandler" is very different from "sighandler".) */
svp = hv_fetch(action, "SAFE", 4, FALSE);
- act.sa_handler = (*svp && SvTRUE(*svp))
- ? PL_csighandlerp : PL_sighandlerp;
+ act.sa_handler =
+ DPTR2FPTR(
+ void (*)(),
+ (*svp && SvTRUE(*svp))
+ ? PL_csighandlerp : PL_sighandlerp
+ );
/* Vector new Perl handler through %SIG.
(The core signal handlers read %SIG to dispatch.) */
diff --git a/mg.c b/mg.c
index fe78c208ce..3c691ea8f3 100644
--- a/mg.c
+++ b/mg.c
@@ -2069,7 +2069,7 @@ Perl_magic_killbackrefs(pTHX_ SV *sv, MAGIC *mg)
} else {
Perl_croak(aTHX_
"panic: magic_killbackrefs (flags=%"UVxf")",
- SvFLAGS(referrer));
+ (UV)SvFLAGS(referrer));
}
*svp = Nullsv;
diff --git a/perl.h b/perl.h
index 63eba706a1..73979b6bf9 100644
--- a/perl.h
+++ b/perl.h
@@ -1497,20 +1497,25 @@ typedef UVTYPE UV;
#else
# if PTRSIZE == LONGSIZE
# define PTRV unsigned long
+# define PTR2ul(p) (unsigned long)(p)
# else
# define PTRV unsigned
# endif
+#endif
+
+#ifndef INT2PTR
# define INT2PTR(any,d) (any)(PTRV)(d)
#endif
+
+#ifndef PTR2ul
+# define PTR2ul(p) INT2PTR(unsigned long,p)
+#endif
+
#define NUM2PTR(any,d) (any)(PTRV)(d)
#define PTR2IV(p) INT2PTR(IV,p)
#define PTR2UV(p) INT2PTR(UV,p)
#define PTR2NV(p) NUM2PTR(NV,p)
-#if PTRSIZE == LONGSIZE
-# define PTR2ul(p) (unsigned long)(p)
-#else
-# define PTR2ul(p) INT2PTR(unsigned long,p)
-#endif
+#define PTR2nat(p) (PTRV)(p) /* pointer to integer of PTRSIZE */
/* According to strict ANSI C89 one cannot freely cast between
* data pointers and function (code) pointers. There are at least
@@ -1522,8 +1527,8 @@ typedef UVTYPE UV;
* The only feasible use is probably temporarily storing
* function pointers in a data pointer (such as a void pointer). */
-#define DPTR2FPTR(t,p) ((t)(PTRV)(p)) /* data pointer to function pointer */
-#define FPTR2DPTR(t,p) ((t)(PTRV)(p)) /* function pointer to data pointer */
+#define DPTR2FPTR(t,p) ((t)PTR2nat(p)) /* data pointer to function pointer */
+#define FPTR2DPTR(t,p) ((t)PTR2nat(p)) /* function pointer to data pointer */
#ifdef USE_LONG_DOUBLE
# if defined(HAS_LONG_DOUBLE) && LONG_DOUBLESIZE == DOUBLESIZE