/* 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) {
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.) */
#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
* 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