dec has asked for the wisdom of the Perl Monks concerning the following question:
Recognising that this could have been an issue, I made sure to declare all the particular word sizes (1, 2 and 4-byte words) as typedefs in my C code, and made mention that these might need to be changed in the header files. However, as these are automated tests, nobody is looking at the header file to see what what might need to be changed in order to get the code to compile and run cleanly. So, what I'm looking for is an easy way to figure out which native C types have 8, 16 and 32 bits apiece at compilation time and to have my C/XS code use those data types. Can anyone help me?
There are a few more details I can add. First, I've noticed that if I define my XS prototypes using my user-defined data types (gf2_u8, gf2_u16 and gf2_u32) then the program won't compile correctly (I've tried using both typedefs and #defines). So at the moment I'm reduced to using my user-defined types for internal function calls and data structures, but having to use types like unsigned long for any function prototype that I want to be visible from Perl. Obviously this isn't ideal, as someone wanting to compile the code has to change all the typedefs and all the function prototypes that are meant to be visible to the Perl interpreter.
Second, I thought it should probably be possible to do this using typemaps, but my limited searching didn't turn up any information on doing something like I want.
The third and final bit of extra information is that I'm fairly used to using C-based configure scripts to figure out things like this and create header files based on the local configuration. I must admit that I'm only getting to grips with the MakeMaker system and the XS system in general, so I'm not even sure how to make my configuration script happen before the compilation proper. I hope you be mindful of my inexperience if you have a solution to offer.
Thank you, oh worthy ones!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: A clean way to account for machine word sizes in XS code?
by syphilis (Archbishop) on Aug 14, 2009 at 01:39 UTC | |
by DrHyde (Prior) on Aug 14, 2009 at 09:41 UTC | |
Re: A clean way to account for machine word sizes in XS code?
by tonyc (Friar) on Aug 14, 2009 at 01:50 UTC | |
Re: A clean way to account for machine word sizes in XS code?
by syphilis (Archbishop) on Aug 14, 2009 at 09:37 UTC | |
Success! (more words)
by dec (Beadle) on Aug 14, 2009 at 22:35 UTC | |
Re: A clean way to account for machine word sizes in XS code?
by dec (Beadle) on Aug 14, 2009 at 17:44 UTC |