From: ara.t.howard@... Date: 2006-02-13T00:20:21+09:00 Subject: Re: ruby/dl question On Sun, 12 Feb 2006, 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.) i can pack my own struct easily enough... but knowing the layout is impossible. right now i'm considering a 'configure' setup to my install that requires the compiler to determine the layout of the flock struct and generate ruby code to describe it. that way, if your arch is standard you can use the dl binding with requiring a compiler and you only need one to determine struct layout if it's not. might be too much work though... an extension is what i've already done anyhow (posixlock) but i'd just like to hook into the existing IO::fcntl call with the ability to apply posixlocking. regards. -a -- happiness is not something ready-made. it comes from your own actions. - h.h. the 14th dali lama