question about hsc2hs

Jose A. Ortega Ruiz jao at gnu.org
Tue Feb 2 12:24:38 EST 2010


Ross Paterson <ross at soi.city.ac.uk> writes:

> On Tue, Feb 02, 2010 at 03:51:18PM +0100, Jose A. Ortega Ruiz wrote:
>> [...] The problem is that the size and
>> some of the offsets of the C struct statfs computed by hsc2c are wrong:
>> i'm in a 32bit linux system, and i've checked, using a C program, that
>> sizeof(struct statfs) is 64 (hsc2 is giving 84 -- although perhaps
>> Haskell needs additional space for housekeeping?), and that the offsets
>> of f_bfree and f_bavail are, respectively, 12 and 16 (not 16 and 24).
>> Also, i know that 12 and 16 are the right values because putting them by
>> hand gives me the correct statfs values.
>
> If you compile your C program with -D_FILE_OFFSET_BITS=64 you'll get the
> same numbers that hsc2hs does.

But when i use those offsets (16, 24) in my Haskell program (generated
by hsc2hs), i get the wrong values when i inspect the struct filled by
statfs() (via the call performed by Haskell's FFI), while if i put (by
hand this time) the ones (12, 16) given by the C program without
_FILE_OFFSET_BITS defined, the results are correct. So it looks like the
C library, or the generated code, is not using that value for
_FILE_OFFSET_BITS. Do i need to compile my Haskell code using a similar
flag?

(Sorry if i'm missing something obvious.)

Thanks!
jao



More information about the Glasgow-haskell-users mailing list