arch: architecture-specific interface
The arch module provides non-portable access to CPU information and the floating point environment.
Note that the compiler currently optimizes under the assumption that the floating point environment is never modified. Because of this, you're *strongly* advised to not touch the floating point environment unless you absolutely have to. No compatibility or correctness guarantees are provided if you choose to do so anyway.
// Undocumented types: type arch_jmp_buf; type cpuid_ecxflag; type cpuid_edxflag; type cpuid_vendor; type jmp_buf;
// Undocumented Errors: type cpuid_unknownvendor;
fn cpuid_getvendor() (cpuid_vendor | cpuid_unknownvendor); fn cpuid_hasflags(edx: u32, ecx: u32) bool; // Undocumented functions: fn feclearexcept(ex: uint) void; fn fegetround() uint; fn feraiseexcept(ex: uint) void; fn fesetround(mode: uint) void; fn fetestexcept(ex: uint) uint; fn longjmp(buf: *jmp_buf, n: int) never; fn setjmp(buf: *jmp_buf) int;
type arch_jmp_buf = [8]u64;
type cpuid_ecxflag = enum uint { SSE3 = 1 << 0, AES = 1 << 25, AVX = 1 << 28, };
type cpuid_edxflag = enum uint { SSE = 1 << 25, SSE2 = 1 << 26, };
type cpuid_vendor = enum { AMD, INTEL, WINCHIP, TRANSMETA, CYRIX, CENTAUR, NEXGEN, UMC, SIS, NSC, RISE, VORTEX, VIA, ZHAOXIN, HYGON, MCST_ELBRUS, VMWARE, // Virtual Machines. XENHVM, MICROSOFT_HV, PARALLELS, };
type jmp_buf = struct { __jb: arch_jmp_buf, __fl: size, __ss: [128 / size(size)]size, };
type cpuid_unknownvendor = !void;
fn cpuid_getvendor() (cpuid_vendor | cpuid_unknownvendor);
Figures out cpu vendor using cpuid
fn cpuid_hasflags(edx: u32, ecx: u32) bool;
Checks if cpu has given features. See cpuid_edxflag and cpuid_ecxflag for available options.
fn feclearexcept(ex: uint) void;
fn fegetround() uint;
fn feraiseexcept(ex: uint) void;
fn fesetround(mode: uint) void;
fn fetestexcept(ex: uint) uint;
fn longjmp(buf: *jmp_buf, n: int) never;
fn setjmp(buf: *jmp_buf) int;