in reply to Perl XS portable uint32_t

along the perl.h header file installed on you system, you will find config.h (for instance, in my Debian box it is at /usr/lib/perl/5.10.0/CORE/config.h) containing all the information captured by Configure when perl was built.

Specifically it has information about the size of most common C integer types. For instance:

#define INTSIZE 4 /**/ #define LONGSIZE 4 /**/ #define SHORTSIZE 2 /**/
BTW, the same information is available on the Perl side using the Config module.

You could also explicitly discard the upper bits from a possible 64bits word using...

v &= 0xffffffff;
and hope that the optimizer removes the superfluous instructions from the final code on 32 bit architectures