Go to the documentation of this file.
33 #if (defined(AK_CPU_X86_64) || defined(AK_CPU_X86))
41 #define AK_THREAD_INIT_CODE(_threadProperties) \
42 if (_threadProperties.dwAffinityMask != AK_THREAD_AFFINITY_DEFAULT) \
45 CPU_ZERO(&affinity); \
46 for (AkUInt32 i = 0; i < 32; ++i) { \
47 if (_threadProperties.dwAffinityMask & ( 1 << i )){\
48 CPU_SET(i, &affinity); \
51 sched_setaffinity(0, sizeof(cpu_set_t), &affinity); \
62 struct timespec clockNow;
63 clock_gettime(CLOCK_MONOTONIC, &clockNow);
64 *out_piLastTime = ((clockNow.tv_sec + clockNow.tv_nsec/ 1000000000.0) * CLOCKS_PER_SEC);
71 *out_piFreq = CLOCKS_PER_SEC;
74 template<
class destType,
class srcType>
75 inline size_t AkSimpleConvertString( destType* in_pdDest,
const srcType* in_pSrc,
size_t in_MaxSize,
size_t destStrLen(
const destType *),
size_t srcStrLen(
const srcType *) )
78 size_t lenToCopy = srcStrLen(in_pSrc);
80 lenToCopy = (lenToCopy > in_MaxSize-1) ? in_MaxSize-1 : lenToCopy;
81 for(i = 0; i < lenToCopy; i++)
83 in_pdDest[i] = (destType) in_pSrc[i];
85 in_pdDest[lenToCopy] = (destType)0;
90 #define CONVERT_UTF16_TO_CHAR( _astring_, _charstring_ ) \
91 _charstring_ = (char*)AkAlloca( (1 + AKPLATFORM::AkUtf16StrLen((const AkUtf16*)_astring_)) * sizeof(char) ); \
92 AK_UTF16_TO_CHAR( _charstring_, (const AkUtf16*)_astring_, AKPLATFORM::AkUtf16StrLen((const AkUtf16*)_astring_)+1 )
94 #define AK_UTF16_TO_CHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, strlen, AKPLATFORM::AkUtf16StrLen )
95 #define AK_UTF8_TO_OSCHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, strlen, strlen )
96 #define AK_UTF16_TO_OSCHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, strlen, AKPLATFORM::AkUtf16StrLen )
97 #define AK_UTF16_TO_WCHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, wcslen, AKPLATFORM::AkUtf16StrLen )
98 #define AK_CHAR_TO_UTF16( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, AKPLATFORM::AkUtf16StrLen, strlen )
99 #define AK_OSCHAR_TO_UTF16( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, AKPLATFORM::AkUtf16StrLen, strlen )
100 #define AK_WCHAR_TO_UTF16( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, AKPLATFORM::AkUtf16StrLen, wcslen )
103 #define AkAlloca( _size_ ) __builtin_alloca( _size_ )
105 #if (defined(AK_CPU_X86_64) || defined(AK_CPU_X86))
107 #if defined(__i386__) && defined(__PIC__)
109 #define __ak_cpuid_count(level, count, a, b, c, d) \
110 __asm__ ("xchg{l}\t{%%}ebx, %k1\n\t" \
112 "xchg{l}\t{%%}ebx, %k1\n\t" \
113 : "=a" (a), "=&r" (b), "=c" (c), "=d" (d) \
114 : "0" (level), "2" (count))
115 #elif defined(__x86_64__) && defined(__PIC__)
117 #define __ak_cpuid_count(level, count, a, b, c, d) \
118 __asm__ ("xchg{q}\t{%%}rbx, %q1\n\t" \
120 "xchg{q}\t{%%}rbx, %q1\n\t" \
121 : "=a" (a), "=&r" (b), "=c" (c), "=d" (d) \
122 : "0" (level), "2" (count))
124 #define __ak_cpuid_count(level, count, a, b, c, d) \
125 __asm__ ("cpuid\n\t" \
126 : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \
127 : "0" (level), "2" (count))
131 unsigned int __subleaf,
132 unsigned int *__eax,
unsigned int *__ebx,
133 unsigned int *__ecx,
unsigned int *__edx)
135 unsigned int __max_leaf = __get_cpuid_max(__leaf & 0x80000000, 0);
137 if (__max_leaf == 0 || __max_leaf < __leaf)
147 inline void CPUID(
AkUInt32 in_uLeafOpcode,
AkUInt32 in_uSubLeafOpcode,
unsigned int out_uCPUFeatures[4])
150 &out_uCPUFeatures[0],
151 &out_uCPUFeatures[1],
152 &out_uCPUFeatures[2],
153 &out_uCPUFeatures[3]);
static __inline int __ak_get_cpuid_count(unsigned int __leaf, unsigned int __subleaf, unsigned int *__eax, unsigned int *__ebx, unsigned int *__ecx, unsigned int *__edx)
Platform-dependent helpers.
void CPUID(AkUInt32 in_uLeafOpcode, AkUInt32 in_uSubLeafOpcode, unsigned int out_uCPUFeatures[4])
void PerformanceCounter(AkInt64 *out_piLastTime)
Platform Independent Helper.
void PerformanceFrequency(AkInt64 *out_piFreq)
Platform Independent Helper.
size_t AkSimpleConvertString(destType *in_pdDest, const srcType *in_pSrc, size_t in_MaxSize, size_t destStrLen(const destType *), size_t srcStrLen(const srcType *))
Tell us about your project. We're here to help.
Register your project and we'll help you get started with no strings attached!
Get started with Wwise