Re: [racket] FFI question: 0 microseconds returned from gettimeofday call

2011-07-17 Thread keyd...@gmx.de
Hi Thomas, thanks again for your "lecture in c thinking", this is very helpful for someone who made her way into programming, and IT in general, starting with Java 5 and Racket (pardon me, it used to be called scheme then :-; ) :-) >> > > Correct, the caller has to provide a storage location

Re: [racket] FFI question: 0 microseconds returned from gettimeofday call

2011-07-17 Thread keyd...@gmx.de
Hi Jon, thanks a lot for your "find-out-yourself" code - not only will I remember this method for application to future problems, but also did it really solve my problem! In fact the result was _int64 for the seconds and _int32 for the microseconds, which left me wondering why my code didn't w

Re: [racket] FFI question: 0 microseconds returned from gettimeofday call

2011-07-15 Thread Thomas Chust
keyd...@gmx.de wrote: > [...] > Well in this case in fact, I was happy with the result, the 1 looked fine > given we're having daylight saving time :-; > [...] Hello Sigrid, sure the one is fine, but I think this field really never contains anything else than 1 when DST is in effect or 0 when it

Re: [racket] FFI question: 0 microseconds returned from gettimeofday call

2011-07-15 Thread Jon Zeppieri
On Fri, Jul 15, 2011 at 8:40 PM, Jon Zeppieri wrote: > > I *think* it's fairly > safe; it should always err on the side of passing in too large a chunk > of memory, so it shouldn't start stomping on random addresses. Just to be clear: the code isn't safe if the tolerances are too narrow. The code

Re: [racket] FFI question: 0 microseconds returned from gettimeofday call

2011-07-15 Thread Jon Zeppieri
On Fri, Jul 15, 2011 at 4:28 PM, keyd...@gmx.de wrote: [snip] >> >> There is, however, a PLaneT package (planet dherman/c:4:0) providing the >> facilities to parse header files and extract structure layout >> information like that required here using the system's C compiler. > > > Thanks for the

Re: [racket] FFI question: 0 microseconds returned from gettimeofday call

2011-07-15 Thread keyd...@gmx.de
Hi Thomas, thanks a lot for your quick answer! > :-/ Perhaps _long or _intptr would be a better choice than _int, since > they would adapt to the system's word size, which is more likely to be > right everywhere than _int that is always 32 bits wide, according to the > Racket documentation, but

Re: [racket] FFI question: 0 microseconds returned from gettimeofday call

2011-07-14 Thread Thomas Chust
keyd...@gmx.de wrote: > [...] > In fact I'd assume that using _int for suseconds_t should work fine, too, > given that man even tells us that > > "The values in timeval are opaque types whose length may vary on different > machines; depending on > them to have any given length may lead to e

[racket] FFI question: 0 microseconds returned from gettimeofday call

2011-07-14 Thread keyd...@gmx.de
Hi, I am kind of stuck trying to get the current microsecond from gettimeofday... and I wonder how best to systematically approach the question of what racket datatype to choose when defining a FFI function. From the man page I see that timeval is defined as struct timeval { time_