instead of unions use double cast for data pointer <-> function pointer
[p5sagit/p5-mst-13.2.git] / perl.h
diff --git a/perl.h b/perl.h
index d8d3878..3df67eb 100644 (file)
--- a/perl.h
+++ b/perl.h
 #define CALLREG_INTUIT_STRING CALL_FPTR(PL_regint_string)
 #define CALLREGFREE CALL_FPTR(PL_regfree)
 
-#define PERL_UNUSED_DECL __attribute__unused__
+#if defined(SYMBIAN) && defined(__GNUC__)
+#  ifdef __cplusplus
+#    define PERL_UNUSED_DECL
+#  else
+#    define PERL_UNUSED_DECL __attribute__((unused))
+#  endif
+#endif
 
+#ifndef PERL_UNUSED_DECL
+#  ifdef HASATTRIBUTE_UNUSED
+#    define PERL_UNUSED_DECL __attribute__unused__
+#  else
+#    define PERL_UNUSED_DECL
+#  endif
+#endif
 /* gcc -Wall:
  * for silencing unused variables that are actually used most of the time,
- * but we cannot quite get rid of, such `ax' in PPCODE+noargs xsubs
+ * but we cannot quite get rid of, such as "ax" in PPCODE+noargs xsubs
  */
 #define PERL_UNUSED_VAR(var) ((void)var)
 
@@ -306,7 +320,7 @@ register struct op *Perl_op asm(stringify(OP_IN_REGISTER));
  */
 #if !(defined(STMT_START) && defined(STMT_END))
 # if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) && !defined(__cplusplus)
-#   define STMT_START  (void)( /* gcc supports ``({ STATEMENTS; })'' */
+#   define STMT_START  (void)( /* gcc supports "({ STATEMENTS; })" */
 #   define STMT_END    )
 # else
    /* Now which other defined()s do we need here ??? */
@@ -789,6 +803,13 @@ int usleep(unsigned int);
 
 #define MEM_SIZE Size_t
 
+/* Round all values passed to malloc up, by default to a multiple of
+   sizeof(size_t)
+*/
+#ifndef PERL_STRLEN_ROUNDUP_QUANTUM
+#define PERL_STRLEN_ROUNDUP_QUANTUM Size_t_size
+#endif
+
 #if defined(STANDARD_C) && defined(I_STDDEF)
 #   include <stddef.h>
 #   define STRUCT_OFFSET(s,m)  offsetof(s,m)
@@ -1474,6 +1495,19 @@ typedef UVTYPE UV;
 #  define PTR2ul(p)    INT2PTR(unsigned long,p)        
 #endif
 
+/* 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,
+ * first the other pointer to an (unsigned) integer, and then
+ * the integer to the other pointer.  The other way would be
+ * to use unions to "overlay" the pointers.  For an example of
+ * the latter technique, see union dirpu in struct xpvio in sv.h.
+ * The only feasible use is probably temporarily storing
+ * function pointers in a data pointer (such as a void pointer). */
+
+#define DPTR2FPTR(t,p) ((t)PTR2UV(p)) /* data pointer to function pointer */
+#define FPTR2DPTR(t,p) ((t)PTR2UV(p)) /* function pointer to data pointer */
+
 #ifdef USE_LONG_DOUBLE
 #  if defined(HAS_LONG_DOUBLE) && LONG_DOUBLESIZE == DOUBLESIZE
 #      define LONG_DOUBLE_EQUALS_DOUBLE
@@ -2087,7 +2121,6 @@ typedef struct context PERL_CONTEXT;
 typedef struct block BLOCK;
 
 typedef struct magic MAGIC;
-typedef struct xrv XRV;
 typedef struct xpv XPV;
 typedef struct xpviv XPVIV;
 typedef struct xpvuv XPVUV;
@@ -3170,14 +3203,16 @@ Gid_t getegid (void);
 #define PERL_MAGIC_pos           '.' /* pos() lvalue */
 #define PERL_MAGIC_backref       '<' /* for weak ref data */
 #define PERL_MAGIC_symtab        ':' /* extra data for symbol tables */
+#define PERL_MAGIC_rhash         '%' /* extra data for restricted hashes */
+#define PERL_MAGIC_arylen_p      '@' /* to move arylen out of XPVAV */
 #define PERL_MAGIC_ext           '~' /* Available for use by extensions */
 
 
 #ifndef assert  /* <assert.h> might have been included somehow */
 #define assert(what)   PERL_DEB(                                       \
        ((what) ? ((void) 0) :                                          \
-           (Perl_croak(aTHX_ "Assertion " STRINGIFY(what) " failed: file \"%s\", line %d",     \
-               __FILE__, __LINE__),                                    \
+           (Perl_croak(aTHX_ "Assertion %s failed: file \"" __FILE__   \
+                       "\", line %d", STRINGIFY(what), __LINE__),      \
            PerlProc_exit(1),                                           \
            (void) 0)))
 #endif
@@ -3942,8 +3977,8 @@ struct tempsym; /* defined in pp_pack.c */
 #endif
 #undef PERL_CKDEF
 #undef PERL_PPDEF
-#define PERL_CKDEF(s)  OP *s (pTHX_ OP *o);
-#define PERL_PPDEF(s)  OP *s (pTHX);
+#define PERL_CKDEF(s)  PERL_CALLCONV OP *s (pTHX_ OP *o);
+#define PERL_PPDEF(s)  PERL_CALLCONV OP *s (pTHX);
 
 #include "proto.h"
 
@@ -5077,8 +5112,8 @@ extern void moncontrol(int);
  * but also beware since this evaluates its argument twice, so no x++. */
 #define PERL_ABS(x) ((x) < 0 ? -(x) : (x))
 
-#ifdef __osf__
-#pragma message disable (mainparm) /* We have the envp in main(). */
+#if defined(__DECC) && defined(__osf__)
+#pragma message disable (mainparm) /* Perl uses the envp in main(). */
 #endif
 
 /* and finally... */