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: Iñaki Baz Castillo on 15 Jan 2010 16:31 El Viernes, 15 de Enero de 2010, Walton Hoops escribió: > 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? No, I've tested it in a 64 bits server running Linux 32 bits: RbConfig::CONFIG['host_os'] => "linux-gnu" RbConfig::CONFIG['host_cpu'] => "i486" 1.size => 4 -- Iñaki Baz Castillo <ibc(a)aliax.net>
From: Iñaki Baz Castillo on 15 Jan 2010 16:36 El Viernes, 15 de Enero de 2010, Walton Hoops escribió: > submit a bug! http://github.com/rdp/os I was to submit a report but Roger has already improved it :) -- Iñaki Baz Castillo <ibc(a)aliax.net>
From: Rick DeNatale on 15 Jan 2010 19:48 On Fri, Jan 15, 2010 at 4:31 PM, Iñaki Baz Castillo <ibc(a)aliax.net> wrote: > No, I've tested it in a 64 bits server running Linux 32 bits: > > RbConfig::CONFIG['host_os'] => "linux-gnu" > RbConfig::CONFIG['host_cpu'] => "i486" > 1.size => 4 I think that the value of 1.size depends not on what platform Ruby is running on but how it was configured when Ruby was compiled. You can have a version of Ruby compiled for 32-bits which runs on a 64-bit platform. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale
From: Charles Oliver Nutter on 15 Jan 2010 19:48 On Fri, Jan 15, 2010 at 2:28 PM, Roger Pack <rogerpack2005(a)gmail.com> wrote: > At least within a 32-bit OS (in a VM) it appears to be i686-linux so I > think we're safe there. > > Also, thanks for the hint on 1.size I didn't know that one--it's > integrated now [v 0.6.1]. Â That wouldn't work for jruby (which always > returns 8), but should work fine for MRI, and I think we handle jruby > ok. If you really want to know if you're running on a 32 or 64-bit JVM (at least for Hotspot) you can use this property: ~/projects/jruby â jruby -v -e "p ENV_JAVA['sun.arch.data.model']" jruby 1.5.0.dev (ruby 1.8.7 patchlevel 174) (2010-01-15 6586) (Java HotSpot(TM) Client VM 1.5.0_19) [i386-java] "32" ~/projects/jruby â (pickjdk 3 ; jruby -v -e "p ENV_JAVA['sun.arch.data.model']") New JDK: 1.6.0 jruby 1.5.0.dev (ruby 1.8.7 patchlevel 174) (2010-01-15 6586) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_17) [x86_64-java] "64" ~/projects/jruby â (pickjdk 3 ; jruby -v -J-d32 -e "p ENV_JAVA['sun.arch.data.model']") New JDK: 1.6.0 jruby 1.5.0.dev (ruby 1.8.7 patchlevel 174) (2010-01-15 6586) (Java HotSpot(TM) Client VM 1.6.0_17) [i386-java] "32" There's probably something similar (or identical) for JRockit and J9. - Charlie
From: Roger Pack on 15 Jan 2010 22:52
Charles Nutter wrote: ENV_JAVA['sun.arch.data.model'] Thanks I've included that. @Trans "why this isn't in core" I'm really not sure :P -r -- Posted via http://www.ruby-forum.com/. |