From: Lou Vanek Date: 2006-02-12T22:47:08+09:00 Subject: Re: ruby/dl question Eric Hodel wrote: > On Feb 10, 2006, at 7:30 PM, ara.t.howard@noaa.gov wrote: > >> if one has: >> >> struct flock { >> ... >> short l_type; /* Type of lock: F_RDLCK, >> F_WRLCK, F_UNLCK */ >> short l_whence; /* How to interpret l_start: >> SEEK_SET, SEEK_CUR, SEEK_END */ >> off_t l_start; /* Starting offset for lock */ >> off_t l_len; /* Number of bytes to lock */ >> pid_t l_pid; /* PID of process blocking our lock >> (F_GETLK only) */ >> ... >> }; >> >> can this structure be desribed using ruby/dl? i'm worried that the >> struct >> method assumes the fields are in order which, in the case of the flock >> structure, they may not be. > > > You have a bigger problem, off_t is usually 8 bytes and the built-in dl > can only handle 4 byte types. (Or, if it can handle 8 byte types, I > couldn't figure out how.) good pickup. I would expect the higher-order word to be 0 in 99% of cases. You could treat an 8-byte off_t field as two separate unsigned longs and extract the two longs separately and then add them together if the higher-order word is indeed anything but 0.