Ticket #19232
Ticket #19232

In parrot.h (revision 1.45 2002-08-07), macros were defined
to eliminate warnings during pointer conversions. See:
        http://rt.perl.org/rt2/Ticket/Display.html?id=16019

The definition of the macros is controlled by the first line of this block:
        #if (INTVAL_SIZE == PTR_SIZE) && (UINTVAL_SIZE == PTR_SIZE)
        #  define INTVAL2PTR(any,d)    (any)(d)
        #  define UINTVAL2PTR(any,d)    (any)(d)
        #else
        #  if PTR_SIZE == LONG_SIZE
        #    define INTVAL2PTR(any,d)    (any)(unsigned long)(d)
        #    define UINTVAL2PTR(any,d)    (any)(unsigned long)(d)
        #  else
        #    define INTVAL2PTR(any,d)    (any)(unsigned int)(d)
        #    define UINTVAL2PTR(any,d)    (any)(unsigned int)(d)
        #  endif
        #endif
        #define PTR2INTVAL(p)    INTVAL2PTR(INTVAL,p)
        #define PTR2UINTVAL(p)    UINTVAL2PTR(UINTVAL,p)
--snip--
        #define D2FPTR(x) UINTVAL2PTR(funcptr_t, PTR2UINTVAL(x))
        #define F2DPTR(x) UINTVAL2PTR(void *, PTR2UINTVAL((funcptr_t) x))

I cannot find a definition for UINTVAL_SIZE anywhere. Being
undefined, it evaluates to 0, and so the #if always fails.
This means that some systems have been getting the wrong
macro definitions.

It would not be difficult to add Configure tests to define
UINTVAL_SIZE, but I think that it is not really needed.
Instead, the attached patch just changes the first line to:
        #if PTR_SIZE == INTVAL_SIZE
( Is there any platform for which sizeof(signed foo) <>
sizeof(unsigned foo)? Would the C spec even allow it? If so,
I will be glad to write the Configure tests. )

I feel confident that this simpler change is the Right
Thing, but it could uncover other bugs, and I have no
esoteric platforms to test it on. Here is a summary of the
patch's effect on different platforms:

1) PTR_SIZE <> INTVAL_SIZE
No change.

2) PTR_SIZE == INTVAL_SIZE == LONG_SIZE (x86 Linux and Win32)
Intermediate casts to (unsigned long) removed, i.e.
        (any)(unsigned long)(d)
becomes
        (any)(d)

3) PTR_SIZE == INTVAL_SIZE <> LONG_SIZE
Intermediate casts to (unsigned int) removed, i.e.
        (any)(unsigned int)(d)
becomes
        (any)(d)


Under MS VC++ for .Net, this patch changes the results of
none of the tests; it only stops the "UINTVAL_SIZE is not
defined as a preprocessor macro" warnings that are given
with the -Wall option.

 -- Bruce Gray


git-svn-id: 6e74a02f85675cec270f5d931b0f6998666294a3@2844 d31e2699-5ff4-0310-a27c-f18f2fbe73fe

fernandobrito/parrot,tkob/parrot,tewk/parrot-select,tkob/parrot,fernandobrito/parrot,fernandobrito/parrot,tewk/parrot-select,gagern/parrot,youprofit/parrot,FROGGS/parrot,youprofit/parrot,youprofit/parrot,youprofit/parrot,gagern/parrot,tkob/parrot,gitster/parrot,fernandobrito/parrot,fernandobrito/parrot,tkob/parrot,tewk/parrot-select,youprofit/parrot,gagern/parrot,gitster/parrot,FROGGS/parrot,parrot/parrot,gitster/parrot,parrot/parrot,gitster/parrot,FROGGS/parrot,fernandobrito/parrot,gagern/parrot,FROGGS/parrot,tkob/parrot,FROGGS/parrot,fernandobrito/parrot,gitster/parrot,youprofit/parrot,tewk/parrot-select,tkob/parrot,youprofit/parrot,gitster/parrot,tewk/parrot-select,FROGGS/parrot,parrot/parrot,gagern/parrot,gitster/parrot,tewk/parrot-select,FROGGS/parrot,parrot/parrot,youprofit/parrot,tewk/parrot-select,tkob/parrot,gagern/parrot,FROGGS/parrot,parrot/parrot,gagern/parrot,tkob/parrot