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: Phillip Gawlowski on 15 Jan 2010 15:07 On 15.01.2010 20:56, Walton Hoops wrote: > 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. If the OS isn't 64 bits itself, it'll run on an x86_64 architecture, but the CPU is in 32 bit mode. The only thing you can really test, is the bit-ness of the OS, not the CPU. After all, how should a 32 bit OS deal with a 64 bit memory address? -- Phillip Gawlowski
From: Paul Mckibbin on 15 Jan 2010 15:12 Walton Hoops wrote: > On 1/15/2010 9:59 AM, Iñaki Baz Castillo wrote: >>> In my server RbConfig::CONFIG['host_os'] = "linux-gnu" so finally it ends >>> if 1.size == 8 >> >> >> >> > 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? Not on this machine cat /proc/cpuinfo | grep lm flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc arch_perfmon pebs bts pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm lahf_lm tpr_shadow flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc arch_perfmon pebs bts pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm lahf_lm tpr_shadow uname -a Linux xxxxxxx 2.6.31-16-generic #53-Ubuntu SMP Tue Dec 8 04:01:29 UTC 2009 i686 GNU/Linux ruby -e "require 'rbconfig'; p(Config::CONFIG['host_cpu'])" "i486" Mac -- Posted via http://www.ruby-forum.com/.
From: Walton Hoops on 15 Jan 2010 15:15 On 1/15/2010 1:10 PM, Luis Lavena wrote: > 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 > > Ah! But this tool doesn't claim to tell me about my address space or runtime enviornment, but rather my _OS_. Just because I'm in a 32-bit app, doesn't mean I may not care that I'm on a 64-bit os.
From: Walton Hoops on 15 Jan 2010 15:20 On 1/15/2010 1:07 PM, Phillip Gawlowski wrote: > On 15.01.2010 20:56, Walton Hoops wrote: > >> 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. If the OS isn't 64 bits itself, it'll run on an x86_64 > architecture, but the CPU is in 32 bit mode. The only thing you can > really test, is the bit-ness of the OS, not the CPU. > > After all, how should a 32 bit OS deal with a 64 bit memory address? > > -- > Phillip Gawlowski > Makes sense, but I don't know enough about low-level OS/hardware to be sure that there isn't a CPU flag exposed that would still allow for an app or the OS to determine the bittedness of the CPU. So I asked and was answered :-)
From: Roger Pack on 15 Jan 2010 15:28
> 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? 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. I also added a .mac? method--if anybody on a mac could try it out [and/or tell me what the RUBY_PLATFORM is for OS X and OS X 64 bit] then I could actually test it. Re: OS.bits on a 32 within a 64...anybody know how you can tell that you're on 64 bit running a 32 bit ruby, on windows [or linux]? Thanks. -r -- Posted via http://www.ruby-forum.com/. |