vtgl

terminal emulator implemented in OpenGL
git clone anongit@rnpnr.xyz:vtgl.git
Log | Files | Refs | Feed | LICENSE

intrinsics.c (567B)


      1 #define FORCE_INLINE inline __attribute__((always_inline))
      2 
      3 #define clz_u32(a) __builtin_clz(a)
      4 #define ctz_u32(a) __builtin_ctz(a)
      5 
      6 #ifdef __ARM_ARCH_ISA_A64
      7 /* TODO? debuggers just loop here forever and need a manual PC increment (jump +1 in gdb) */
      8 #define debugbreak() asm volatile ("brk 0xf000")
      9 
     10 static FORCE_INLINE u64
     11 rdtsc(void)
     12 {
     13 	register u64 cntvct asm("x0");
     14 	asm volatile ("mrs x0, cntvct_el0" : "=x"(cntvct));
     15 	return cntvct;
     16 }
     17 #elif __x86_64__
     18 #include <immintrin.h>
     19 
     20 #define debugbreak() asm volatile ("int3; nop")
     21 
     22 #define rdtsc() __rdtsc()
     23 
     24 #endif