i have a bit of code that packs an flock struct
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) */
...
};
using 'ssqqi' (thanks to matz for this tip). this works for linux, but i'm
sure it won't for other *nixes with different flock layouts. if i understand
ruby dl there is no way to portably set the fields of a struct unless you
already know it's layout, so packing is just as good in this case (please
correct me if i'm wrong). what i'm asking for people on various *nixes to
post their struct flock definitions so i can add appropriate pack templates
for those.
this output of
ruby -r rbconfig -e 'p Config::CONFIG["arch"]'
would also be useful
if there is an easier way to do this - some online resource where i could find
this info - please let me know
thanks alot.
-a
···
--
EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
A flower falls, even though we love it;
and a weed grows, even though we do not love it. --Dogen
===============================================================================
The output is from my DragonFlyBSD systems. It is the
same in FreeBSD4.x
ruby -r rbconfig -e 'p Config::CONFIG["arch"]'
"i386-dragonfly1.1"
struct flock {
off_t l_start; /* starting offset */
off_t l_len; /* len = 0 means until
end of file */
pid_t l_pid; /* lock owner */
short l_type; /* lock type:
read/write, etc. */
short l_whence; /* type of l_start */
};
···
--- "Ara.T.Howard" <Ara.T.Howard@noaa.gov> wrote:
i have a bit of code that packs an flock struct
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) */
...
};
using 'ssqqi' (thanks to matz for this tip). this
works for linux, but i'm
sure it won't for other *nixes with different flock
layouts. if i understand
ruby dl there is no way to portably set the fields
of a struct unless you
already know it's layout, so packing is just as good
in this case (please
correct me if i'm wrong). what i'm asking for
people on various *nixes to
post their struct flock definitions so i can add
appropriate pack templates
for those.
this output of
ruby -r rbconfig -e 'p Config::CONFIG["arch"]'
would also be useful
if there is an easier way to do this - some online
resource where i could find
this info - please let me know
thanks alot.
-a
--
===============================================================================
> EMAIL :: Ara [dot] T [dot] Howard [at] noaa
[dot] gov
> PHONE :: 303.497.6469
> A flower falls, even though we love it;
> and a weed grows, even though we do not love it.
> --Dogen
===============================================================================
__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail
Is there any difference between
ruby -r rbconfig -e 'p Config::CONFIG["arch"]'
and
ruby -e 'p PLATFORM'
Thanks,
Nick
Ara.T.Howard wrote:
···
i have a bit of code that packs an flock struct
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) */
...
};
using 'ssqqi' (thanks to matz for this tip). this works for linux, but i'm
sure it won't for other *nixes with different flock layouts. if i understand
ruby dl there is no way to portably set the fields of a struct unless you
already know it's layout, so packing is just as good in this case (please
correct me if i'm wrong). what i'm asking for people on various *nixes to
post their struct flock definitions so i can add appropriate pack templates
for those.
this output of
ruby -r rbconfig -e 'p Config::CONFIG["arch"]'
would also be useful
if there is an easier way to do this - some online resource where i could find
this info - please let me know
thanks alot.
-a
--
> EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
> PHONE :: 303.497.6469
> A flower falls, even though we love it;
> and a weed grows, even though we do not love it. | --Dogen
wow - they just do it backwards (or linux does) - why can't they all just get
along ;-(
thanks - i'll add this one in!
-a
···
On Tue, 3 Aug 2004, David Ross wrote:
The output is from my DragonFlyBSD systems. It is the
same in FreeBSD4.x
ruby -r rbconfig -e 'p Config::CONFIG["arch"]'
"i386-dragonfly1.1"
struct flock {
off_t l_start; /* starting offset */
off_t l_len; /* len = 0 means until
end of file */
pid_t l_pid; /* lock owner */
short l_type; /* lock type:
read/write, etc. */
short l_whence; /* type of l_start */
};
--
EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
A flower falls, even though we love it;
and a weed grows, even though we do not love it. --Dogen
===============================================================================
Hi,
At Thu, 5 Aug 2004 13:25:54 +0900,
Nicholas Van Weerdenburg wrote in [ruby-talk:108359]:
Is there any difference between
ruby -r rbconfig -e 'p Config::CONFIG["arch"]'
and
ruby -e 'p PLATFORM'
Almostly equal. But they can be different while cross
compiling.
Although many extension libraries (even ext/extmk.rb and
lib/mkmf.rb) uses RUBY_PLATFORM in their extconf.rb to determin
the target platform, I consider it shouldn't.
Moreover, PLATFORM, VERSION and RELEASE_DATE have been
deprecated long ago, so never use them.
···
--
Nobu Nakada
Its been like that since 1994 in FreeBSD 
OpenBSD and NetBSD should have the same.. lemme
check..
NetBSD.. checked
OpenBSD. checked
They are all the same 
--David Ross
···
--- "Ara.T.Howard" <ahoward@noaa.gov> wrote:
On Tue, 3 Aug 2004, David Ross wrote:
>
>
> The output is from my DragonFlyBSD systems. It is
the
> same in FreeBSD4.x
>
>
>> ruby -r rbconfig -e 'p Config::CONFIG["arch"]'
> "i386-dragonfly1.1"
>
>
> struct flock {
> off_t l_start; /* starting offset
*/
> off_t l_len; /* len = 0 means
until
> end of file */
> pid_t l_pid; /* lock owner */
> short l_type; /* lock type:
> read/write, etc. */
> short l_whence; /* type of l_start
*/
> };
wow - they just do it backwards (or linux does) -
why can't they all just get
along ;-(
thanks - i'll add this one in!
-a
--
===============================================================================
> EMAIL :: Ara [dot] T [dot] Howard [at] noaa
[dot] gov
> PHONE :: 303.497.6469
> A flower falls, even though we love it;
> and a weed grows, even though we do not love it.
> --Dogen
===============================================================================
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail
Thanks.
How would I normally determine if something is deprecated in ruby? After your email, I tried "ruby -w -e 'p PLATFORM'" but didn't see any warnings of deprecation (if that would be one way to check).
Thanks,
Nick
···
nobu.nokada@softhome.net wrote:
Hi,
At Thu, 5 Aug 2004 13:25:54 +0900,
Nicholas Van Weerdenburg wrote in [ruby-talk:108359]:
Is there any difference between
ruby -r rbconfig -e 'p Config::CONFIG["arch"]'
and
ruby -e 'p PLATFORM'
Almostly equal. But they can be different while cross
compiling.
Although many extension libraries (even ext/extmk.rb and
lib/mkmf.rb) uses RUBY_PLATFORM in their extconf.rb to determin
the target platform, I consider it shouldn't.
Moreover, PLATFORM, VERSION and RELEASE_DATE have been
deprecated long ago, so never use them.
so you reccomend using CONFIG['arch']? how about for #ifdefs in extenstions?
-a
···
On Thu, 5 Aug 2004 nobu.nokada@softhome.net wrote:
Hi,
At Thu, 5 Aug 2004 13:25:54 +0900,
Nicholas Van Weerdenburg wrote in [ruby-talk:108359]:
Is there any difference between
ruby -r rbconfig -e 'p Config::CONFIG["arch"]'
and
ruby -e 'p PLATFORM'
Almostly equal. But they can be different while cross
compiling.
Although many extension libraries (even ext/extmk.rb and
lib/mkmf.rb) uses RUBY_PLATFORM in their extconf.rb to determin
the target platform, I consider it shouldn't.
Moreover, PLATFORM, VERSION and RELEASE_DATE have been
deprecated long ago, so never use them.
--
Nobu Nakada
--
EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
A flower falls, even though we love it;
and a weed grows, even though we do not love it. --Dogen
===============================================================================
lothar-
never knew about offset_of... nice macro. however, if i were writing it in C
i could just use the stuct members couldn't i? am i missing something here?
this should compile on any posix system:
struct flock flock;
flock.l_type = F_RDLCK;
flock.l_whence = SEEK_SET;
flock.l_start = 0;
flock.l_len = 0;
etc. since posix stipultes these members must exist (it just doesn't say where
or if there are others before or after!)
am i missing something?
regards.
-a
···
On Wed, 4 Aug 2004, Lothar Scholz wrote:
Why don't you write a small C level function with "offset_of" to access the
values. You will always run in problems with different datasizes, different
compiler alignments, different struct's.
--
EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
A flower falls, even though we love it;
and a weed grows, even though we do not love it. --Dogen
===============================================================================
Hi,
At Thu, 5 Aug 2004 22:02:48 +0900,
Nicholas Van Weerdenburg wrote in [ruby-talk:108380]:
How would I normally determine if something is deprecated in ruby? After
your email, I tried "ruby -w -e 'p PLATFORM'" but didn't see any
warnings of deprecation (if that would be one way to check).
Constants are not accessed with a method, so we don't have a
way to check about it. Only I think out is a trick using
const_missing.
class Object
class << self
depr = [:VERSION, :PLATFORM, :RELEASE_DATE]
define_method(:const_missing) do |i|
if depr.include?(i)
warn "#{caller(2)[0]}: #{i} is deprecated, use RUBY_#{i}"
const_get("RUBY_#{i}")
else
begin
super(i)
rescue NameError
$@[0,2] = nil
raise
end
end
end
depr
end.each(&method(:remove_const))
end
···
--
Nobu Nakada
Hi,
At Thu, 5 Aug 2004 22:51:36 +0900,
Ara.T.Howard wrote in [ruby-talk:108383]:
so you reccomend using CONFIG['arch']? how about for #ifdefs in extenstions?
Platform/compiler specific macros are not concerned with ruby.
However, I'd prefer to test per feature in extconf.rb.
···
--
Nobu Nakada