#x86 machine code, 12 bytes
x86 machine code, 12 bytes
8c c8 83 f8 23 b0 20 75 02 00 c0 c3
Ungolfed:
getKernelBitness:
mov eax,cs
cmp eax,0x23 ; 32 bit process on 64 bit kernel has this selector in CS
mov al,32
jne kernelIs32Bit
add al,al ; return value in eax
kernelIs32Bit:
ret
This function works in Linux when used in ELF32, following i386 SysV ABI, as well as in Windows/Wine when used in PE32, following stdcall
calling convention.