e576bb2002-10-11Martin Nilsson /* || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. */
1b10db2002-10-08Martin Nilsson 
e83eb92001-03-22Fredrik Hübinette (Hubbe) #ifndef PIKE_CPULIB_H #define PIKE_CPULIB_H
de9dee2016-01-25Martin Nilsson #define bit_SSE4_2 (1<<20) #define bit_RDRND_2 (1<<30)
fcca612016-02-11Martin Nilsson #ifdef __GNUC__ # ifdef __i386__
d6ea432010-10-17Martin Stjernholm # define HAVE_X86_ASM # define HAVE_IA32_ASM # define GCC_X86_ASM_STYLE # define GCC_IA32_ASM_STYLE # elif defined (__amd64__) || defined (__x86_64__) # define HAVE_X86_ASM # define HAVE_X86_64_ASM # define GCC_X86_ASM_STYLE # define GCC_X86_64_ASM_STYLE # endif #elif defined (_MSC_VER)
fcca612016-02-11Martin Nilsson # ifdef _M_IX86
d6ea432010-10-17Martin Stjernholm # define HAVE_X86_ASM # define HAVE_IA32_ASM # define CL_X86_ASM_STYLE # define CL_IA32_ASM_STYLE # elif defined (_M_X64) # define HAVE_X86_ASM # define HAVE_X86_64_ASM # define CL_X86_ASM_STYLE # define CL_X86_64_ASM_STYLE # endif #endif #ifdef HAVE_X86_ASM PMOD_EXPORT void x86_get_cpuid(int oper, INT32 *cpuid_ptr); #endif
92ec352010-10-23Martin Stjernholm #ifdef HAVE_RDTSC #ifdef GCC_X86_ASM_STYLE #define RDTSC(v) do { \
6d41792010-10-30Martin Stjernholm  unsigned INT32 __l, __h; \
92ec352010-10-23Martin Stjernholm  __asm__ __volatile__ ("rdtsc" : "=a" (__l), "=d" (__h)); \ (v)= __l | (((INT64)__h)<<32); \ } while (0) #endif
6d41792010-10-30Martin Stjernholm #ifdef CL_X86_ASM_STYLE #define RDTSC(v) do { \ unsigned INT32 l, h; \ __asm {rdtsc} \ __asm {mov l, eax} \ __asm {mov h, edx} \ v = l | ((INT64) h << 32); \ } while (0) #endif
92ec352010-10-23Martin Stjernholm #endif
99218e2017-11-06Martin Nilsson PMOD_EXPORT int my_log2(UINT64 x) ATTRIBUTE((const));
aad99b2001-03-28Fredrik Hübinette (Hubbe) #endif /* PIKE_CPULIB_H */