[gambit-list] Converting uint32 to scheme object
Alex Silva
asandroq at gmail.com
Wed Jan 6 06:41:07 EST 2016
Hello list,
I am currently writing some FFI code that interfaces with libtiff to
read tags from TIFF image files. The values of these tags have different
C types and using the right type is needed to avoid memory corruption.
For reading tags with uint16 values the code is straightforward:
```
static ___SCMOBJ uint16_tag(TIFF *tiff, ttag_t tag)
{
uint16 val;
int ret = TIFFGetField(tiff, tag, &val);
return ret == 1 ? ___FIX(val) : ___FAL;
}
```
But, since fixnums have less than 32 bits I cannot use the same code. It
seems the solution would be something similar to:
```
static ___SCMOBJ uint32_tag(TIFF *tiff, ttag_t tag)
{
uint32 val;
if(TIFFGetField(tiff, tag, &val) == 1)
{
___SCMOBJ ret;
___U32_to_SCMOBJ(___ps, val, &ret, ___RETURN_POS); <---- ERROR
return ret;
}
else
{
return ___FAL;
}
}
```
except that I don't know how to get hold of the processor state. Can
anybody shed a light here?
Thanks,
-alex
http://unendli.ch/
More information about the Gambit-list
mailing list