Hi, on a 64 bit Windows machine os.uname() erroneously returns machine i686 On the same machine I get under Linux machine x86_64 with both, x86_64-linux and i386-linux binaries. Thus I assume that the keyword 'machine' refers to the hardware, not to how the binaries were compiled (32 vs. 64 bit). The complete output of for k,v in pairs(os.uname()) do print(k,v) end is release build 9200 nodename R804 version 6.02 machine i686 sysname Windows 8 Regards, Reinhard -- ------------------------------------------------------------------ Reinhard Kotucha Phone: +49-511-3373112 Marschnerstr. 25 D-30167 Hannover mailto:reinhard.kotucha@web.de ------------------------------------------------------------------
On Sun, Sep 5, 2021 at 2:22 AM Reinhard Kotucha
Hi, on a 64 bit Windows machine os.uname() erroneously returns
machine i686
On the same machine I get under Linux
machine x86_64
with both, x86_64-linux and i386-linux binaries. Thus I assume that the keyword 'machine' refers to the hardware, not to how the binaries were compiled (32 vs. 64 bit).
The complete output of
for k,v in pairs(os.uname()) do print(k,v) end
is
release build 9200 nodename R804 version 6.02 machine i686 sysname Windows 8
#ifdef _WIN32 # define _UTSNAME_LENGTH 65 /* Structure describing the system and machine. */ struct utsname { char sysname[_UTSNAME_LENGTH]; char nodename[_UTSNAME_LENGTH]; char release[_UTSNAME_LENGTH]; char version[_UTSNAME_LENGTH]; char machine[_UTSNAME_LENGTH]; }; /* * Get name and information about current kernel. */ static int uname(struct utsname *uts) : case WinNT: sprintf(uts->machine, "i%d86", sysinfo.wProcessorLevel); break; I guess that wProcessorLevel gives 6 in your case. -- luigi
On 2021-09-05 at 10:43:10 +0200, luigi scarso wrote:
On Sun, Sep 5, 2021 at 2:22 AM Reinhard Kotucha
wrote: Hi, on a 64 bit Windows machine os.uname() erroneously returns
machine i686
On the same machine I get under Linux
machine x86_64
with both, x86_64-linux and i386-linux binaries. Thus I assume that the keyword 'machine' refers to the hardware, not to how the binaries were compiled (32 vs. 64 bit).
The complete output of
for k,v in pairs(os.uname()) do print(k,v) end
is
release build 9200 nodename R804 version 6.02 machine i686 sysname Windows 8
#ifdef _WIN32 # define _UTSNAME_LENGTH 65
/* Structure describing the system and machine. */ struct utsname { char sysname[_UTSNAME_LENGTH]; char nodename[_UTSNAME_LENGTH]; char release[_UTSNAME_LENGTH]; char version[_UTSNAME_LENGTH]; char machine[_UTSNAME_LENGTH]; };
/* * Get name and information about current kernel. */ static int uname(struct utsname *uts) :
case WinNT: sprintf(uts->machine, "i%d86", sysinfo.wProcessorLevel); break;
I guess that wProcessorLevel gives 6 in your case.
Obviously. But I doubt that wProcessorLevel is what's needed here. Isn't there something like wProcessorArchitecture that distinguishes between 32 and 64 bit? Regards, Reinhard -- ------------------------------------------------------------------ Reinhard Kotucha Phone: +49-511-3373112 Marschnerstr. 25 D-30167 Hannover mailto:reinhard.kotucha@web.de ------------------------------------------------------------------
On Wed, Sep 8, 2021 at 9:56 AM luigi scarso
On Sun, Sep 5, 2021 at 7:48 PM Reinhard Kotucha
wrote: Obviously. But I doubt that wProcessorLevel is what's needed here. Isn't there something like wProcessorArchitecture that distinguishes between 32 and 64 bit?
seems so. I will check this weekend .
-- luigi
It should be fixed, we have now more PROCESSOR_ARCHITECTURE : + case PROCESSOR_ARCHITECTURE_AMD64: + strcpy(uts->machine, "amd64"); + break; + case PROCESSOR_ARCHITECTURE_ARM: + strcpy(uts->machine, "arm"); + break; + case PROCESSOR_ARCHITECTURE_ARM64: + strcpy(uts->machine, "arm64"); + break; + case PROCESSOR_ARCHITECTURE_IA64: + strcpy(uts->machine, "ia64"); + break; -- luigi
On 2021-12-21 at 11:41:37 +0100, luigi scarso wrote:
On Wed, Sep 8, 2021 at 9:56 AM luigi scarso
wrote: On Sun, Sep 5, 2021 at 7:48 PM Reinhard Kotucha
wrote: Obviously. But I doubt that wProcessorLevel is what's needed here. Isn't there something like wProcessorArchitecture that distinguishes between 32 and 64 bit?
seems so. I will check this weekend .
-- luigi
It should be fixed, we have now more PROCESSOR_ARCHITECTURE :
+ case PROCESSOR_ARCHITECTURE_AMD64: + strcpy(uts->machine, "amd64"); + break; + case PROCESSOR_ARCHITECTURE_ARM: + strcpy(uts->machine, "arm"); + break; + case PROCESSOR_ARCHITECTURE_ARM64: + strcpy(uts->machine, "arm64"); + break; + case PROCESSOR_ARCHITECTURE_IA64: + strcpy(uts->machine, "ia64"); + break;
Thank you Luigi! Currently I get "x86_64" on Linux. Will it be sufficient check whether the string ends with '64' in order to determine reliably whether I'm on a 64 bit machine? That would be nice because conditional code or table lookups can be avoided. Regards, Reinhard -- ------------------------------------------------------------------ Reinhard Kotucha Phone: +49-511-3373112 Marschnerstr. 25 D-30167 Hannover mailto:reinhard.kotucha@web.de ------------------------------------------------------------------
On Wed, Dec 22, 2021 at 9:54 PM Reinhard Kotucha
On 2021-12-21 at 11:41:37 +0100, luigi scarso wrote:
On Wed, Sep 8, 2021 at 9:56 AM luigi scarso
wrote: On Sun, Sep 5, 2021 at 7:48 PM Reinhard Kotucha <
reinhard.kotucha@web.de>
wrote:
Obviously. But I doubt that wProcessorLevel is what's needed here. Isn't there something like wProcessorArchitecture that distinguishes between 32 and 64 bit?
seems so. I will check this weekend .
-- luigi
It should be fixed, we have now more PROCESSOR_ARCHITECTURE :
+ case PROCESSOR_ARCHITECTURE_AMD64: + strcpy(uts->machine, "amd64"); + break; + case PROCESSOR_ARCHITECTURE_ARM: + strcpy(uts->machine, "arm"); + break; + case PROCESSOR_ARCHITECTURE_ARM64: + strcpy(uts->machine, "arm64"); + break; + case PROCESSOR_ARCHITECTURE_IA64: + strcpy(uts->machine, "ia64"); + break;
Thank you Luigi!
Currently I get "x86_64" on Linux. Will it be sufficient check whether the string ends with '64' in order to determine reliably whether I'm on a 64 bit machine? That would be nice because conditional code or table lookups can be avoided.
hm, what we have now ( always #ifdef _WIN32 is true ) is : switch (sysinfo.wProcessorArchitecture) { case PROCESSOR_ARCHITECTURE_AMD64: strcpy(uts->machine, "amd64"); break; case PROCESSOR_ARCHITECTURE_ARM: strcpy(uts->machine, "arm"); break; case PROCESSOR_ARCHITECTURE_ARM64: strcpy(uts->machine, "arm64"); break; case PROCESSOR_ARCHITECTURE_IA64: strcpy(uts->machine, "ia64"); break; case PROCESSOR_ARCHITECTURE_PPC: strcpy(uts->machine, "ppc"); break; case PROCESSOR_ARCHITECTURE_ALPHA: strcpy(uts->machine, "alpha"); break; case PROCESSOR_ARCHITECTURE_MIPS: strcpy(uts->machine, "mips"); break; case PROCESSOR_ARCHITECTURE_INTEL: /* * dwProcessorType is only valid in Win95 and Win98 and WinME * wProcessorLevel is only valid in WinNT */ switch (os) { case Win95: case Win98: switch (sysinfo.dwProcessorType) { case PROCESSOR_INTEL_386: case PROCESSOR_INTEL_486: case PROCESSOR_INTEL_PENTIUM: sprintf(uts->machine, "i%ld", sysinfo.dwProcessorType); break; default: strcpy(uts->machine, "i386"); break; } break; case WinNT: sprintf(uts->machine, "i%d86", sysinfo.wProcessorLevel); break; default: strcpy(uts->machine, "unknown"); break; } break; default: strcpy(uts->machine, "unknown"); break; } -- luigi
On 2021-12-22 at 22:30:43 +0100, luigi scarso wrote:
hm, what we have now ( always #ifdef _WIN32 is true ) is :
switch (sysinfo.wProcessorArchitecture) { case PROCESSOR_ARCHITECTURE_AMD64: strcpy(uts->machine, "amd64"); break; case PROCESSOR_ARCHITECTURE_ARM: strcpy(uts->machine, "arm"); break; case PROCESSOR_ARCHITECTURE_ARM64: strcpy(uts->machine, "arm64"); break; case PROCESSOR_ARCHITECTURE_IA64: strcpy(uts->machine, "ia64"); break; case PROCESSOR_ARCHITECTURE_PPC: strcpy(uts->machine, "ppc"); break; case PROCESSOR_ARCHITECTURE_ALPHA: strcpy(uts->machine, "alpha"); break; case PROCESSOR_ARCHITECTURE_MIPS: strcpy(uts->machine, "mips"); break; case PROCESSOR_ARCHITECTURE_INTEL: /* * dwProcessorType is only valid in Win95 and Win98 and WinME * wProcessorLevel is only valid in WinNT */ switch (os) { case Win95: case Win98: switch (sysinfo.dwProcessorType) { case PROCESSOR_INTEL_386: case PROCESSOR_INTEL_486: case PROCESSOR_INTEL_PENTIUM: sprintf(uts->machine, "i%ld", sysinfo.dwProcessorType); break; default: strcpy(uts->machine, "i386"); break; } break; case WinNT: sprintf(uts->machine, "i%d86", sysinfo.wProcessorLevel); break; default: strcpy(uts->machine, "unknown"); break; } break; default: strcpy(uts->machine, "unknown"); break; }
Hi Luigi, I suppose that with "ppc", "alpha", and "mips" you can't derive the register width width from the name. Renaming them doesn't make sense either. It's not important, I just said that it would be nice. No problem at all. Ignore and proceed. Thanks, Reinhard -- ------------------------------------------------------------------ Reinhard Kotucha Phone: +49-511-3373112 Marschnerstr. 25 D-30167 Hannover mailto:reinhard.kotucha@web.de ------------------------------------------------------------------
On Wed, Dec 22, 2021 at 09:54:42PM +0100, Reinhard Kotucha wrote:
Currently I get "x86_64" on Linux. Will it be sufficient check whether the string ends with '64' in order to determine reliably whether I'm on a 64 bit machine? That would be nice because conditional code or table lookups can be avoided.
You can get the bitwidth of the current system by running `string.packsize'T'*8` . (Technically this only gives you the bitwidth of the size_t type, but that should be the same as the native bitwidth on all architectures I am aware of.) Best, Marcel
participants (3)
-
luigi scarso
-
Marcel Fabian Krüger
-
Reinhard Kotucha