Go to the documentation of this file.
31 #include <android/log.h>
34 #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
47 struct timespec clockNow;
48 clock_gettime(CLOCK_MONOTONIC, &clockNow);
61 #include <AK/Tools/POSIX/AkPlatformFuncs.h>
63 #define AK_FORCE_CRASH abort()
66 #define AkAlloca( _size_ ) __builtin_alloca( _size_ )
72 #if defined(AK_OPTIMIZED)
75 template <
int MaxSize = 0>
82 __android_log_print(ANDROID_LOG_INFO,
"AKDEBUG",
"%s", in_pszMsg);
86 template <
int MaxSize = 0>
90 va_start(args, in_pszFmt);
91 __android_log_vprint(ANDROID_LOG_INFO,
"AKDEBUG", in_pszFmt, args);
96 template<
class destType,
class srcType>
97 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 *) )
100 size_t lenToCopy = srcStrLen(in_pSrc);
102 lenToCopy = (lenToCopy > in_MaxSize-1) ? in_MaxSize-1 : lenToCopy;
103 for(i = 0; i < lenToCopy; i++)
105 in_pdDest[i] = (destType) in_pSrc[i];
107 in_pdDest[lenToCopy] = (destType)0;
112 #define CONVERT_UTF16_TO_CHAR( _astring_, _charstring_ ) \
113 _charstring_ = (char*)AkAlloca( (1 + AKPLATFORM::AkUtf16StrLen((const AkUtf16*)_astring_)) * sizeof(char) ); \
114 AK_UTF16_TO_CHAR( _charstring_, (const AkUtf16*)_astring_, AKPLATFORM::AkUtf16StrLen((const AkUtf16*)_astring_)+1 )
116 #define AK_UTF8_TO_OSCHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, strlen, strlen )
117 #define AK_UTF16_TO_OSCHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, strlen, AKPLATFORM::AkUtf16StrLen )
118 #define AK_UTF16_TO_CHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, strlen, AKPLATFORM::AkUtf16StrLen )
119 #define AK_CHAR_TO_UTF16( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, AKPLATFORM::AkUtf16StrLen, strlen)
120 #define AK_OSCHAR_TO_UTF16( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, AKPLATFORM::AkUtf16StrLen, strlen)
122 #if __BIGGEST_ALIGNMENT__ < AK_SIMD_ALIGNMENT
123 #define AkAllocaSIMD( _size_ ) __builtin_alloca_with_align( _size_, AK_SIMD_ALIGNMENT*8 )
139 AKVERIFY(!pthread_attr_init(&attr));
143 AKVERIFY(!pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE));
146 int threadError = pthread_create( out_pThread, &attr, pStartRoutine, pParams);
148 AKVERIFY(!pthread_attr_destroy(&attr));
150 if( threadError != 0 )
167 int minPriority, maxPriority;
168 minPriority = sched_get_priority_min(sched_policy);
169 maxPriority = sched_get_priority_max(sched_policy);
172 sched_param schedParam;
173 schedParam.sched_priority = in_threadProperties.
nPriority;
177 int err = pthread_setschedparam(*out_pThread, sched_policy, &schedParam);
181 sched_policy = SCHED_NORMAL;
182 minPriority = sched_get_priority_min(sched_policy);
183 maxPriority = sched_get_priority_max(sched_policy);
185 schedParam.sched_priority = maxPriority;
187 schedParam.sched_priority = minPriority;
189 schedParam.sched_priority = (maxPriority + minPriority) / 2;
190 err = pthread_setschedparam(*out_pThread, sched_policy, &schedParam);
195 #define AK_FILEHANDLE_TO_UINTPTR(_h) ((AkUIntPtr)_h)
196 #define AK_SET_FILEHANDLE_TO_UINTPTR(_h,_u) _h = (AkFileHandle)_u
198 #if (defined(AK_CPU_X86_64) || defined(AK_CPU_X86))
200 #if defined(__i386__) && defined(__PIC__)
202 #define __ak_cpuid_count(level, count, a, b, c, d) \
203 __asm__ ("xchg{l}\t{%%}ebx, %k1\n\t" \
205 "xchg{l}\t{%%}ebx, %k1\n\t" \
206 : "=a" (a), "=&r" (b), "=c" (c), "=d" (d) \
207 : "0" (level), "2" (count))
208 #elif defined(__x86_64__) && defined(__PIC__)
210 #define __ak_cpuid_count(level, count, a, b, c, d) \
211 __asm__ ("xchg{q}\t{%%}rbx, %q1\n\t" \
213 "xchg{q}\t{%%}rbx, %q1\n\t" \
214 : "=a" (a), "=&r" (b), "=c" (c), "=d" (d) \
215 : "0" (level), "2" (count))
217 #define __ak_cpuid_count(level, count, a, b, c, d) \
218 __asm__ ("cpuid\n\t" \
219 : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \
220 : "0" (level), "2" (count))
224 unsigned int __subleaf,
225 unsigned int *__eax,
unsigned int *__ebx,
226 unsigned int *__ecx,
unsigned int *__edx)
228 unsigned int __max_leaf = __get_cpuid_max(__leaf & 0x80000000, 0);
230 if (__max_leaf == 0 || __max_leaf < __leaf)
243 &out_uCPUFeatures[0],
244 &out_uCPUFeatures[1],
245 &out_uCPUFeatures[2],
246 &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