diff options
author | Nicholas Clark <nick@ccl4.org> | 2005-05-21 22:46:50 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2005-05-21 22:46:50 +0000 |
commit | e4305a6302fd35f8f8c1a7e612369beaaea58a4a (patch) | |
tree | 6ac771d6994c71db69f780e38918c56d399bdfef /sv.h | |
parent | 0e66cca035ceb727a3ab9256f4ef9b63b31b7c37 (diff) | |
download | perl-e4305a6302fd35f8f8c1a7e612369beaaea58a4a.tar.gz |
Add a union in place of xnv_nv, which allows AVs and HVs to re-use
the memory to store pointers and integers.
(Part 1 - will be reworked to be more efficient when IV or void*
is 64 bit soon)
p4raw-id: //depot/perl@24538
Diffstat (limited to 'sv.h')
-rw-r--r-- | sv.h | 79 |
1 files changed, 72 insertions, 7 deletions
@@ -295,15 +295,35 @@ struct xpvnv { STRLEN xpv_cur; /* length of sv_pv as a C string */ STRLEN xpv_len; /* allocated size */ IV xiv_iv; /* integer value or pv offset */ - NV xnv_nv; /* numeric value, if any */ + union { + NV xnvu_nv; /* numeric value, if any */ + struct { + void *xnv_p1; + union { + void *xnv_p2; + IV xnv_i2; + } xnv_u2; + } xnv_s; + } xnv_u; }; +#define xnv_nv xnv_u.xnvu_nv + /* These structure must match the beginning of struct xpvhv in hv.h. */ struct xpvmg { STRLEN xpv_cur; /* length of sv_pv as a C string */ STRLEN xpv_len; /* allocated size */ IV xiv_iv; /* integer value or pv offset */ - NV xnv_nv; /* numeric value, if any */ + union { + NV xnvu_nv; /* numeric value, if any */ + struct { + void *xnv_p1; + union { + void *xnv_p2; + IV xnv_i2; + } xnv_u2; + } xnv_s; + } xnv_u; MAGIC* xmg_magic; /* linked list of magicalness */ HV* xmg_stash; /* class package */ }; @@ -312,7 +332,16 @@ struct xpvlv { STRLEN xpv_cur; /* length of sv_pv as a C string */ STRLEN xpv_len; /* allocated size */ IV xiv_iv; /* integer value or pv offset */ - NV xnv_nv; /* numeric value, if any */ + union { + NV xnvu_nv; /* numeric value, if any */ + struct { + void *xnv_p1; + union { + void *xnv_p2; + IV xnv_i2; + } xnv_u2; + } xnv_s; + } xnv_u; MAGIC* xmg_magic; /* linked list of magicalness */ HV* xmg_stash; /* class package */ @@ -334,7 +363,16 @@ struct xpvgv { STRLEN xpv_cur; /* length of sv_pv as a C string */ STRLEN xpv_len; /* allocated size */ IV xiv_iv; /* integer value or pv offset */ - NV xnv_nv; /* numeric value, if any */ + union { + NV xnvu_nv; /* numeric value, if any */ + struct { + void *xnv_p1; + union { + void *xnv_p2; + IV xnv_i2; + } xnv_u2; + } xnv_s; + } xnv_u; MAGIC* xmg_magic; /* linked list of magicalness */ HV* xmg_stash; /* class package */ @@ -349,7 +387,16 @@ struct xpvbm { STRLEN xpv_cur; /* length of sv_pv as a C string */ STRLEN xpv_len; /* allocated size */ IV xiv_iv; /* integer value or pv offset */ - NV xnv_nv; /* numeric value, if any */ + union { + NV xnvu_nv; /* numeric value, if any */ + struct { + void *xnv_p1; + union { + void *xnv_p2; + IV xnv_i2; + } xnv_u2; + } xnv_s; + } xnv_u; MAGIC* xmg_magic; /* linked list of magicalness */ HV* xmg_stash; /* class package */ @@ -366,7 +413,16 @@ struct xpvfm { STRLEN xpv_cur; /* length of sv_pv as a C string */ STRLEN xpv_len; /* allocated size */ IV xiv_iv; /* integer value or pv offset */ - NV xnv_nv; /* numeric value, if any */ + union { + NV xnvu_nv; /* numeric value, if any */ + struct { + void *xnv_p1; + union { + void *xnv_p2; + IV xnv_i2; + } xnv_u2; + } xnv_s; + } xnv_u; MAGIC* xmg_magic; /* linked list of magicalness */ HV* xmg_stash; /* class package */ @@ -391,7 +447,16 @@ struct xpvio { STRLEN xpv_cur; /* length of sv_pv as a C string */ STRLEN xpv_len; /* allocated size */ IV xiv_iv; /* integer value or pv offset */ - NV xnv_nv; /* numeric value, if any */ + union { + NV xnvu_nv; /* numeric value, if any */ + struct { + void *xnv_p1; + union { + void *xnv_p2; + IV xnv_i2; + } xnv_u2; + } xnv_s; + } xnv_u; MAGIC* xmg_magic; /* linked list of magicalness */ HV* xmg_stash; /* class package */ |