Table of Contents

include/AK/Tools/Common/AkPlatformFuncs.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002 The content of this file includes portions of the AUDIOKINETIC Wwise Technology
00003 released in source code form as part of the SDK installer package.
00004 
00005 Commercial License Usage
00006 
00007 Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology
00008 may use this file in accordance with the end user license agreement provided 
00009 with the software or, alternatively, in accordance with the terms contained in a
00010 written agreement between you and Audiokinetic Inc.
00011 
00012 Apache License Usage
00013 
00014 Alternatively, this file may be used under the Apache License, Version 2.0 (the 
00015 "Apache License"); you may not use this file except in compliance with the 
00016 Apache License. You may obtain a copy of the Apache License at 
00017 http://www.apache.org/licenses/LICENSE-2.0.
00018 
00019 Unless required by applicable law or agreed to in writing, software distributed
00020 under the Apache License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
00021 OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for
00022 the specific language governing permissions and limitations under the License.
00023 
00024   Version: <VERSION>  Build: <BUILDNUMBER>
00025   Copyright (c) <COPYRIGHTYEAR> Audiokinetic Inc.
00026 *******************************************************************************/
00027 
00028 // AkPlatformFuncs.h
00029 
00030 /// \file 
00031 /// Platform-dependent functions definition.
00032 
00033 #ifndef _AK_TOOLS_COMMON_AKPLATFORMFUNCS_H
00034 #define _AK_TOOLS_COMMON_AKPLATFORMFUNCS_H
00035 
00036 #include <AK/SoundEngine/Common/AkTypes.h>
00037 
00038 // Uncomment the following to enable built-in platform profiler markers in the sound engine
00039 //#define AK_ENABLE_INSTRUMENT
00040 
00041 #if defined(AK_WIN) || defined(AK_XBOXONE)
00042 #include <AK/Tools/Win32/AkPlatformFuncs.h>
00043 
00044 #elif defined (AK_APPLE)
00045 #include <AK/Tools/Mac/AkPlatformFuncs.h>
00046 #include <AK/Tools/POSIX/AkPlatformFuncs.h>
00047 
00048 #elif defined (AK_ANDROID)
00049 #include <AK/Tools/Android/AkPlatformFuncs.h>
00050 
00051 #elif defined (AK_PS4)
00052 #include <AK/Tools/PS4/AkPlatformFuncs.h>
00053 
00054 #elif defined (AK_EMSCRIPTEN)
00055 #include <AK/Tools/Emscripten/AkPlatformFuncs.h>
00056 
00057 #elif defined (AK_LINUX)
00058 #include <AK/Tools/Linux/AkPlatformFuncs.h>
00059 #include <AK/Tools/POSIX/AkPlatformFuncs.h>
00060 
00061 #elif defined (AK_QNX)
00062 #include <AK/Tools/QNX/AkPlatformFuncs.h>
00063 #include <AK/Tools/POSIX/AkPlatformFuncs.h>
00064 
00065 #elif defined (AK_NX)
00066 #include <AK/Tools/NX/AkPlatformFuncs.h>
00067 
00068 #else
00069 #error AkPlatformFuncs.h: Undefined platform
00070 #endif
00071 
00072 #ifndef AkPrefetchZero
00073 #define AkPrefetchZero(___Dest, ___Size)
00074 #endif
00075 
00076 #ifndef AkPrefetchZeroAligned
00077 #define AkPrefetchZeroAligned(___Dest, ___Size)
00078 #endif
00079 
00080 #ifndef AkZeroMemAligned
00081 #define AkZeroMemAligned(___Dest, ___Size) AKPLATFORM::AkMemSet(___Dest, 0, ___Size);
00082 #endif
00083 #ifndef AkZeroMemLarge
00084 #define AkZeroMemLarge(___Dest, ___Size) AKPLATFORM::AkMemSet(___Dest, 0, ___Size);
00085 #endif
00086 #ifndef AkZeroMemSmall
00087 #define AkZeroMemSmall(___Dest, ___Size) AKPLATFORM::AkMemSet(___Dest, 0, ___Size);
00088 #endif
00089 
00090 #ifndef AkAllocaSIMD
00091 #define AkAllocaSIMD( _size_ ) AkAlloca( _size_ )
00092 #endif
00093 
00094 #ifndef AK_THREAD_INIT_CODE
00095 #define AK_THREAD_INIT_CODE(_threadProperties)
00096 #endif
00097 
00098 /// Utility functions
00099 namespace AK
00100 {
00101     /// Count non-zero bits.
00102     /// \return Number of channels.
00103     AkForceInline AkUInt32 GetNumNonZeroBits( AkUInt32 in_uWord )
00104     {
00105         AkUInt32 num = 0;
00106         while( in_uWord ){ ++num; in_uWord &= in_uWord-1; }
00107         return num;
00108     }
00109 }
00110 
00111 namespace AKPLATFORM
00112 {
00113     inline void AkGetDefaultHighPriorityThreadProperties(AkThreadProperties & out_threadProperties)
00114     {
00115         AkGetDefaultThreadProperties(out_threadProperties);
00116         out_threadProperties.nPriority = AK_THREAD_PRIORITY_ABOVE_NORMAL;
00117     }
00118 }
00119 
00120 #ifndef AK_PERF_RECORDING_RESET
00121 #define AK_PERF_RECORDING_RESET()
00122 #endif
00123 #ifndef AK_PERF_RECORDING_START
00124 #define AK_PERF_RECORDING_START( __StorageName__, __uExecutionCountStart__, __uExecutionCountStop__ )
00125 #endif
00126 #ifndef AK_PERF_RECORDING_STOP
00127 #define AK_PERF_RECORDING_STOP( __StorageName__, __uExecutionCountStart__, __uExecutionCountStop__ )    
00128 #endif
00129 
00130 #ifndef AK_INSTRUMENT_BEGIN
00131     #define AK_INSTRUMENT_BEGIN( _zone_name_ )
00132     #define AK_INSTRUMENT_END( _zone_name_ )
00133     #define AK_INSTRUMENT_SCOPE( _zone_name_ )
00134 
00135     #define AK_INSTRUMENT_BEGIN_C(_colour_, _zone_name_ )
00136 
00137     #define AK_INSTRUMENT_IDLE_BEGIN( _zone_name_ )
00138     #define AK_INSTRUMENT_IDLE_END( _zone_name_ )
00139     #define AK_INSTRUMENT_IDLE_SCOPE( _zone_name_ )
00140 
00141     #define AK_INSTRUMENT_STALL_BEGIN( _zone_name_ )
00142     #define AK_INSTRUMENT_STALL_END( _zone_name_ )
00143     #define AK_INSTRUMENT_STALL_SCOPE( _zone_name_ )
00144 
00145     #define AK_INSTRUMENT_THREAD_START( _thread_name_ )
00146 #endif
00147 
00148 #endif // _AK_TOOLS_COMMON_AKPLATFORMFUNCS_H