I am right now testing Device::CDROM
on a NetBSD machine. The tests that worked so splendidly on my Linux box kept
failing there.
The source of the problem is the fact that BSDs use big-endian format for LBA-addressing on CDs (unlike Linux which uses host-byteorder). That means that I have defined some macros that do the necessary byte-swapping. In code this looks like this:
int
minute (self)
CDROM_ADDR *self;
PREINIT:
int lba;
char min, sec, frame;
CODE:
{
lba = self->ADDRaddr.lba;
#if _BSDISH__
LE32_CPU(lba);
#endif
lba_to_msf(lba, &min, &sec, &frame);
RETVAL = min;
}
OUTPUT:
RETVAL
I couldn't the hell figure out why it didn't work on BSD until I spotted a subtle but disastrous typo: It is supposed to be __BSDISH__
and not _BSDISH__
. So in this particular XSUB the byte-swapping never happened.
I really wish there were strictures for the C preprocessor directives!