Prev: [ANN] os gem: initial release: easier platform management
Next: Building mysql extension/gem with MinGW (was Re: Gem build issuesUbuntu 9.10 64 bit)
From: Seebs on 15 Jan 2010 12:32 On 2010-01-15, I�aki Baz Castillo <ibc(a)aliax.net> wrote: > When the app runs it tries to create a posix mqueue with maxmsg=5000 and > msgsize=1024. The user running the application could have not permissions to > create such posix mqueue due to system limits ("ulimit -q"). Ahh. > The algorimth to know such amount of required bytes is: > queue.attr.mq_maxmsg * sizeof(struct msg_msg *) + > queue.attr.mq_maxmsg * queue.attr.mq_msgsize > In 32 bits sizeof(struct msg_msg *) is 4 bytes while in 64 it's 8 bytes, so > the total ammount of bytes changes. This means that "ulimit -q" must be > different depending on the system architecture (32/64 bits). Ahh, yes. Although to be picky, you're now into one of the areas where, if you ever end up on stranger hardware, the answer may be ill-defined; it appears you care specifically about pointer sizes. There are some systems where "pointer size" is not the same as "integer size", and so on... So you could get some surprises. I suspect Ruby tries to get a 64-bit fixnum if it can, so you're probably set. -s -- Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam(a)seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
From: Iñaki Baz Castillo on 15 Jan 2010 12:52 El Viernes, 15 de Enero de 2010, Seebs escribió: > > The algorimth to know such amount of required bytes is: > > > > queue.attr.mq_maxmsg * sizeof(struct msg_msg *) + > > queue.attr.mq_maxmsg * queue.attr.mq_msgsize > > > > In 32 bits sizeof(struct msg_msg *) is 4 bytes while in 64 it's 8 bytes, > > so the total ammount of bytes changes. This means that "ulimit -q" must > > be different depending on the system architecture (32/64 bits). > > Ahh, yes. Although to be picky, you're now into one of the areas where, if > you ever end up on stranger hardware, the answer may be ill-defined; it > appears you care specifically about pointer sizes. There are some systems > where "pointer size" is not the same as "integer size", and so on... So > you could get some surprises. Yes, for now I use 1.size to determine if I'm under 32 or 64 bits but it's just a hack. Most probably I will code a small C extension method with returns the exact value of sizeof(struct msg_msg *). Then the calculated valued would be exact for any kinf of strange architecture (I hope). Regards. -- Iñaki Baz Castillo <ibc(a)aliax.net>
From: Seebs on 15 Jan 2010 14:12 On 2010-01-15, I�aki Baz Castillo <ibc(a)aliax.net> wrote: > Most probably I will code a small C extension method with returns > the exact value of sizeof(struct msg_msg *). Then the calculated valued would > be exact for any kinf of strange architecture (I hope). That seems like it should work. -s -- Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam(a)seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
From: Walton Hoops on 15 Jan 2010 14:56 On 1/15/2010 9:59 AM, Iñaki Baz Castillo wrote: > El Viernes, 15 de Enero de 2010, Iñaki Baz Castillo escribió: > > >> Note that to know the bits it uses "rbconfig" gem, and them: >> > Well, "rbconfig" is not a gem but a Ruby built in library. > > > > >> In my server RbConfig::CONFIG['host_os'] = "linux-gnu" so finally it ends >> doing: >> >> if (1<<32).class == Fixnum >> 64 >> else >> 32 >> end >> >> Which is basically the same as doing >> >> if 1.size == 8 >> 64 >> else >> 32 >> end >> >> > > Definitively I don't like "os" gem at all. It could use > RbConfig::CONFIG['host_cpu'] rather than the not reliable > RbConfig::CONFIG['host_os']: > > > a) 32 bits host: > > RbConfig::CONFIG['host_os'] => "linux-gnu" > RbConfig::CONFIG['host_cpu'] => "i486" > > b) 64 bits host: > > RbConfig::CONFIG['host_os'] => "linux-gnu" > RbConfig::CONFIG['host_cpu'] => "x86_64" > > > submit a bug! http://github.com/rdp/os My main concern with that though: Would RbConfig::CONFIG['host_cpu'] return "x86_64" if I'm running 32-bit Linux on a 64-bit CPU?
From: Luis Lavena on 15 Jan 2010 15:05
On Jan 15, 1:40 pm, Walton Hoops <wal...(a)vyper.hopto.org> wrote: > On 1/15/2010 9:36 AM, Walton Hoops wrote: > > > > > On 1/14/2010 4:12 PM, Iñaki Baz Castillo wrote: > >> Hi, is there a reliable way under Ruby to know the OS architecture > >> (32 or 64 > >> bits)? > > >> I've just found RUBY_PLATFORM constant which returns "x86_64-linux" > >> under 64 > >> bits, however it doesn't send very reliable for me. > > >> I need a way working under Linux and BSD. Thanks for any suggestion. > > > I can't vouch for how accurate it is, but an OS gem was recently > > announced on this list. > > gem install os > > > irb(main):001:0> require 'os' > > => true > > irb(main):002:0> OS.bits > > => 64 > > irb(main):004:0> OS.posix? > > => true > > irb(main):005:0> > > Hmm.. it does not appear to deal with 32-bit ruby running on a 64 bit > system though. > On my Windows 7 x64 (with 32-bit ruby): > irb(main):005:0> OS.bits > => 32 > irb(main):006:0> 1.size > => 4 > irb(main):007:0> No matter how many bits the OS has, as long the compiled interpreter is 32 bits, the returned values is going to be 32 bits. Windows can run 32bits applications along with 64bits ones, but that doesn't mean you can access 64bits address space or tools from 32bits applications. -- Luis Lavena |