Skip to content

Guard CPUID/rdtsc for non-x86 and add stubs#182

Open
chemiskyy wants to merge 1 commit intoromeric:masterfrom
3MAH:master
Open

Guard CPUID/rdtsc for non-x86 and add stubs#182
chemiskyy wants to merge 1 commit intoromeric:masterfrom
3MAH:master

Conversation

@chemiskyy
Copy link

Proposed fix for ARM:

Fastor/config/cpuid.h — The CPUID class constructor uses x86 cpuid asm in an unguarded #else. Fix: gate it with #elif defined(x86_64) || defined(i386)
and add an #else that zeros the registers on ARM.

Fastor/util/timeit.h — The rdtsc() / rdtsc_begin() / rdtsc_end() functions use x86 rdtsc/rdtscp asm in an unguarded #else. Fix: same #elif x86 gate, plus ARM
stubs that return 0.

Add explicit x86/x86_64 guards and non-x86 fallbacks for CPUID and rdtsc. In Fastor/config/cpuid.h, avoid using inline asm on non-x86 targets by checking for __x86_64__/__i386__ and provide a safe zeroed fallback for regs otherwise. In Fastor/util/timeit.h, restrict the GCC inline-asm rdtsc implementation to x86 and add ARM/non-x86 stub implementations that return 0. These changes prevent build failures on non-x86 platforms and make the codebase more portable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant