Go to the documentation of this file.
31 #include <hilog/log.h>
33 #if (defined(AK_CPU_X86_64) || defined(AK_CPU_X86))
39 #define AK_THREAD_INIT_CODE(_threadProperties) syscall(__NR_sched_setaffinity, 0, sizeof(_threadProperties.dwAffinityMask), &_threadProperties.dwAffinityMask)
40 #define AK_SEC_TO_NANOSEC 1000000000ULL
52 #include <AK/Tools/POSIX/AkPlatformFuncs.h>
55 #define AkAlloca( _size_ ) __builtin_alloca( _size_ )
61 #if defined(AK_OPTIMIZED)
64 template <
int MaxSize = 0>
69 OH_LOG_Print(LOG_APP, LOG_DEBUG, LOG_DOMAIN,
"Wwise",
"%{public}s", in_pszMsg);
73 template <
int MaxSize = 256>
79 va_start(args, in_pszFmt);
80 vsnprintf(msg, MaxSize, in_pszFmt, args);
82 OH_LOG_Print(LOG_APP, LOG_DEBUG, LOG_DOMAIN,
"Wwise",
"%{public}s", msg);
93 struct timespec clockNow;
94 clock_gettime(CLOCK_MONOTONIC, &clockNow);
100 template<
class destType,
class srcType>
101 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 *) )
104 size_t lenToCopy = srcStrLen(in_pSrc);
106 lenToCopy = (lenToCopy > in_MaxSize-1) ? in_MaxSize-1 : lenToCopy;
107 for(i = 0; i < lenToCopy; i++)
109 in_pdDest[i] = (destType) in_pSrc[i];
111 in_pdDest[lenToCopy] = (destType)0;
116 #define CONVERT_UTF16_TO_CHAR( _astring_, _charstring_ ) \
117 _charstring_ = (char*)AkAlloca( (1 + AKPLATFORM::AkUtf16StrLen((const AkUtf16*)_astring_)) * sizeof(char) ); \
118 AK_UTF16_TO_CHAR( _charstring_, (const AkUtf16*)_astring_, AKPLATFORM::AkUtf16StrLen((const AkUtf16*)_astring_)+1 )
120 #define AK_UTF8_TO_OSCHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, strlen, strlen )
121 #define AK_UTF16_TO_OSCHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, strlen, AKPLATFORM::AkUtf16StrLen )
122 #define AK_UTF16_TO_CHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, strlen, AKPLATFORM::AkUtf16StrLen )
123 #define AK_CHAR_TO_UTF16( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, AKPLATFORM::AkUtf16StrLen, strlen)
124 #define AK_OSCHAR_TO_UTF16( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, AKPLATFORM::AkUtf16StrLen, strlen)
126 #if __BIGGEST_ALIGNMENT__ < AK_SIMD_ALIGNMENT
127 #define AkAllocaSIMD( _size_ ) __builtin_alloca_with_align( _size_, AK_SIMD_ALIGNMENT*8 )
143 AKVERIFY(!pthread_attr_init(&attr));
147 AKVERIFY(!pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE));
150 int threadError = pthread_create( out_pThread, &attr, pStartRoutine, pParams);
152 AKVERIFY(!pthread_attr_destroy(&attr));
154 if( threadError != 0 )
171 int minPriority, maxPriority;
172 minPriority = sched_get_priority_min(sched_policy);
173 maxPriority = sched_get_priority_max(sched_policy);
176 sched_param schedParam;
177 schedParam.sched_priority = in_threadProperties.
nPriority;
180 int err = pthread_setschedparam(*out_pThread, sched_policy, &schedParam);
184 sched_policy = SCHED_OTHER;
185 minPriority = sched_get_priority_min(sched_policy);
186 maxPriority = sched_get_priority_max(sched_policy);
188 schedParam.sched_priority = maxPriority;
190 schedParam.sched_priority = minPriority;
192 schedParam.sched_priority = (maxPriority + minPriority) / 2;
193 err = pthread_setschedparam(*out_pThread, sched_policy, &schedParam);
198 #define AK_FILEHANDLE_TO_UINTPTR(_h) ((AkUIntPtr)_h)
199 #define AK_SET_FILEHANDLE_TO_UINTPTR(_h,_u) _h = (AkFileHandle)_u
201 #if (defined(AK_CPU_X86_64) || defined(AK_CPU_X86))
203 #if defined(__i386__) && defined(__PIC__)
205 #define __ak_cpuid_count(level, count, a, b, c, d) \
206 __asm__ ("xchg{l}\t{%%}ebx, %k1\n\t" \
208 "xchg{l}\t{%%}ebx, %k1\n\t" \
209 : "=a" (a), "=&r" (b), "=c" (c), "=d" (d) \
210 : "0" (level), "2" (count))
211 #elif defined(__x86_64__) && defined(__PIC__)
213 #define __ak_cpuid_count(level, count, a, b, c, d) \
214 __asm__ ("xchg{q}\t{%%}rbx, %q1\n\t" \
216 "xchg{q}\t{%%}rbx, %q1\n\t" \
217 : "=a" (a), "=&r" (b), "=c" (c), "=d" (d) \
218 : "0" (level), "2" (count))
220 #define __ak_cpuid_count(level, count, a, b, c, d) \
221 __asm__ ("cpuid\n\t" \
222 : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \
223 : "0" (level), "2" (count))
227 unsigned int __subleaf,
228 unsigned int *__eax,
unsigned int *__ebx,
229 unsigned int *__ecx,
unsigned int *__edx)
231 unsigned int __max_leaf = __get_cpuid_max(__leaf & 0x80000000, 0);
233 if (__max_leaf == 0 || __max_leaf < __leaf)
243 inline void CPUID(
AkUInt32 in_uLeafOpcode,
AkUInt32 in_uSubLeafOpcode,
unsigned int out_uCPUFeatures[4])
246 &out_uCPUFeatures[0],
247 &out_uCPUFeatures[1],
248 &out_uCPUFeatures[2],
249 &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)
int nPriority
Thread priority.
Platform-dependent helpers.
void OutputDebugMsg(const char *in_pszMsg)
Output a debug message on the console (Ansi string)
void CPUID(AkUInt32 in_uLeafOpcode, AkUInt32 in_uSubLeafOpcode, unsigned int out_uCPUFeatures[4])
void AkCreateThread(AkThreadRoutine pStartRoutine, void *pParams, const AkThreadProperties &in_threadProperties, AkThread *out_pThread, const char *)
Platform Independent Helper.
void OutputDebugMsgV(const char *in_pszFmt,...)
Output a debug message on the console (variadic function).
void PerformanceCounter(AkInt64 *out_piLastTime)
Platform Independent Helper.
#define AKASSERT(Condition)
AkForceInline void AkClearThread(AkThread *in_pThread)
Platform Independent Helper.
int64_t AkInt64
Signed 64-bit integer.
size_t uStackSize
Thread stack size.
void PerformanceFrequency(AkInt64 *out_piFreq)
Platform Independent Helper.
int uSchedPolicy
Thread scheduling policy.
uint32_t AkUInt32
Unsigned 32-bit integer.
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