Fix bit-fields for VC [was RE: [perl #50386] GIMME_V broken with 5.10.0/GCC and XS?]
authorJan Dubois <jand@activestate.com>
Fri, 1 Feb 2008 13:40:41 +0000 (05:40 -0800)
committerDavid Mitchell <davem@iabyn.com>
Sun, 22 Mar 2009 00:01:08 +0000 (00:01 +0000)
From: "Jan Dubois" <jand@activestate.com>
Message-ID: <02ee01c8651b$17ef72f0$47ce58d0$@com>

p4raw-id: //depot/perl@33292

partially cherry-picked from commit 654eccd594bfe8deab367b0f4cdda726a7796ff3:
The PERL_BITFIELD* macros are merged, but the VC-specific overrride of
their values has been ommited to mainbtain BinCompat, as has the
-mms-bitfields compile option.

op.h
perl.h
sv.h

diff --git a/op.h b/op.h
index 12d3226..41d703a 100644 (file)
--- a/op.h
+++ b/op.h
     OP*                (CPERLscope(*op_ppaddr))(pTHX);         \
     MADPROP_IN_BASEOP                  \
     PADOFFSET  op_targ;                \
-    unsigned   op_type:9;              \
-    unsigned   op_opt:1;               \
-    unsigned   op_latefree:1;          \
-    unsigned   op_latefreed:1;         \
-    unsigned   op_attached:1;          \
-    unsigned   op_spare:3;             \
+    PERL_BITFIELD16 op_type:9;         \
+    PERL_BITFIELD16 op_opt:1;          \
+    PERL_BITFIELD16 op_latefree:1;     \
+    PERL_BITFIELD16 op_latefreed:1;    \
+    PERL_BITFIELD16 op_attached:1;     \
+    PERL_BITFIELD16 op_spare:3;                \
     U8         op_flags;               \
     U8         op_private;
 #endif
diff --git a/perl.h b/perl.h
index 374a61b..e66021c 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -3370,6 +3370,17 @@ struct nexttoken {
 };
 #endif
 
+/* macros to define bit-fields in structs. */
+#ifndef PERL_BITFIELD8
+#  define PERL_BITFIELD8 unsigned
+#endif
+#ifndef PERL_BITFIELD16
+#  define PERL_BITFIELD16 unsigned
+#endif
+#ifndef PERL_BITFIELD32
+#  define PERL_BITFIELD32 unsigned
+#endif
+
 #include "regexp.h"
 #include "sv.h"
 #include "util.h"
diff --git a/sv.h b/sv.h
index 0aa44dc..6b5ba63 100644 (file)
--- a/sv.h
+++ b/sv.h
@@ -113,10 +113,10 @@ struct STRUCT_SV {                /* struct sv { */
     _SV_HEAD(void*);
     _SV_HEAD_UNION;
 #ifdef DEBUG_LEAKING_SCALARS
-    unsigned   sv_debug_optype:9;      /* the type of OP that allocated us */
-    unsigned   sv_debug_inpad:1;       /* was allocated in a pad for an OP */
-    unsigned   sv_debug_cloned:1;      /* was cloned for an ithread */
-    unsigned   sv_debug_line:16;       /* the line where we were allocated */
+    PERL_BITFIELD32 sv_debug_optype:9; /* the type of OP that allocated us */
+    PERL_BITFIELD32 sv_debug_inpad:1;  /* was allocated in a pad for an OP */
+    PERL_BITFIELD32 sv_debug_cloned:1; /* was cloned for an ithread */
+    PERL_BITFIELD32 sv_debug_line:16;  /* the line where we were allocated */
     U32                sv_debug_serial;        /* serial number of sv allocation   */
     char *     sv_debug_file;          /* the file where we were allocated */
 #endif