I’m writing a program in gcc that has asm language for performance-critical sections, and I want to ensure at run-time the program is running on the correct architecture. In particular, I need to differentiate ia64 (Itanium) and x86_64 on Linux.
Do I just read /proc/cpuinfo? Seems clunky, but I can’t find an appropriate kernel call.
IA64 and x86_64 are entirely different architectures. A program built for one will simply not run on the other, so your question doesn’t make sense (in fact, incompatibility with the x86 instruction set is one of the reasons for IA64’s lackluster market penetration, because IA64-based systems couldn’t run the wide array of existing, legacy 32-bit x86-based applicaitons).
The best you could do is compile two different versions of the program, and then use a wrapper script to select the appropriate binary when the user invokes the program.