diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2005-06-09 11:50:56 +0300 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2005-06-09 07:44:36 +0000 |
commit | 8141890a98cb18fe79a9b720aaed544527266f99 (patch) | |
tree | 05c902bdc760cad3dfc8a67b514d9c285d41a7a6 /perl.h | |
parent | d526390560c1ae208a087ad4d648b08895f79f8f (diff) | |
download | perl-8141890a98cb18fe79a9b720aaed544527266f99.tar.gz |
instead of unions use double cast for data pointer <-> function pointer
Message-ID: <42A7D8C0.1080104@gmail.com>
p4raw-id: //depot/perl@24770
Diffstat (limited to 'perl.h')
-rw-r--r-- | perl.h | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -1495,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 |