From: "Iñaki Baz Castillo" Date: 2010-01-16T06:31:26+09:00 Subject: Re: How to know the OS architecture (32 or 64 bits)? 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