Port to Fuchsia
Change-Id: Iad476ecfa574215546cbaaa40673c97659bfbfeb
diff --git a/README.fuchsia b/README.fuchsia
new file mode 100644
index 0000000..c2fd7dd
--- /dev/null
+++ b/README.fuchsia
@@ -0,0 +1,6 @@
+Name: gmmlib
+URL: n/a
+License: MIT
+License File: LICENSE.md
+Upstream Git: https://github.com/intel/gmmlib
+Description: The Intel(R) Graphics Memory Management Library provides device specific and buffer management for the Intel(R) Graphics Compute Runtime for OpenCL(TM) and the Intel(R) Media Driver for VAAPI.
diff --git a/Source/GmmLib/CMakeLists.txt b/Source/GmmLib/CMakeLists.txt
index 69938db..5e97c09 100644
--- a/Source/GmmLib/CMakeLists.txt
+++ b/Source/GmmLib/CMakeLists.txt
@@ -510,7 +510,7 @@
set(CMAKE_INSTALL_SYSCONFDIR "usr/share/defaults/etc")
endif()
-if(UNIX)
+if(UNIX OR ${CMAKE_SYSTEM_NAME} STREQUAL "Fuchsia")
include(GNUInstallDirs)
configure_file(${BS_DIR_GMMLIB}/igdgmm.h.in ${CMAKE_BINARY_DIR}/igdgmm.h)
diff --git a/Source/GmmLib/Platform/GmmPlatforms.h b/Source/GmmLib/Platform/GmmPlatforms.h
index 0659c33..92cb737 100644
--- a/Source/GmmLib/Platform/GmmPlatforms.h
+++ b/Source/GmmLib/Platform/GmmPlatforms.h
@@ -86,7 +86,7 @@
{
#if defined(__GMM_KMD__) || _WIN32
InterlockedIncrement((LONG *)&RefCount);
-#elif defined(__linux__)
+#elif defined(__linux__) || defined(__Fuchsia__)
__sync_fetch_and_add(&RefCount, 1);
#endif
//TODO[Android]
@@ -96,7 +96,7 @@
{
#if defined(__GMM_KMD__) || _WIN32
return(InterlockedDecrement((LONG *)&RefCount));
-#elif defined(__linux__)
+#elif defined(__linux__) || defined(__Fuchsia__)
return(__sync_sub_and_fetch(&RefCount, 1));
#endif
//TODO[Android]
diff --git a/Source/GmmLib/Resource/Linux/GmmResourceInfoLinCWrapper.cpp b/Source/GmmLib/Resource/Linux/GmmResourceInfoLinCWrapper.cpp
index 546815f..cd60e15 100644
--- a/Source/GmmLib/Resource/Linux/GmmResourceInfoLinCWrapper.cpp
+++ b/Source/GmmLib/Resource/Linux/GmmResourceInfoLinCWrapper.cpp
@@ -22,7 +22,7 @@
#include "Internal/Common/GmmLibInc.h"
-#if defined(__linux__) && !LHDM
+#if (defined(__linux__) || defined(__Fuchsia__)) && !LHDM
#include "Internal/Linux/GmmResourceInfoLinInt.h"
/////////////////////////////////////////////////////////////////////////////////////
diff --git a/Source/GmmLib/TranslationTable/GmmPageTableMgr.cpp b/Source/GmmLib/TranslationTable/GmmPageTableMgr.cpp
index d7fefce..43ec121 100644
--- a/Source/GmmLib/TranslationTable/GmmPageTableMgr.cpp
+++ b/Source/GmmLib/TranslationTable/GmmPageTableMgr.cpp
@@ -28,7 +28,7 @@
#include "../TranslationTable/GmmUmdTranslationTable.h"
#include "External/Common/GmmClientContext.h"
-#if defined(__linux__)
+#if defined(__linux__) || defined(__Fuchsia__)
#include "Internal/Linux/GmmResourceInfoLinInt.h"
#endif
@@ -44,7 +44,7 @@
LeaveCriticalSection(&PoolLock); \
}
-#if defined(__linux__)
+#if defined(__linux__) || defined(__Fuchsia__)
GMM_STATUS GmmLib::__GmmDeviceAlloc(GmmClientContext * pClientContext,
GMM_DEVICE_CALLBACKS_INT *pDeviceCbInt,
GMM_DEVICE_ALLOC * pAlloc)
@@ -607,7 +607,7 @@
return GMM_SUCCESS;
}
-#if defined(__linux__) && !_WIN32
+#if defined(__linux__) || defined(__Fuchsia__) && !_WIN32
/////////////////////////////////////////////////////////////////////////////////////
/// Gets size of PageTable buffer object (BOs) list
///
diff --git a/Source/GmmLib/TranslationTable/GmmUmdTranslationTable.cpp b/Source/GmmLib/TranslationTable/GmmUmdTranslationTable.cpp
index 3d94fcc..5588900 100644
--- a/Source/GmmLib/TranslationTable/GmmUmdTranslationTable.cpp
+++ b/Source/GmmLib/TranslationTable/GmmUmdTranslationTable.cpp
@@ -31,7 +31,7 @@
#if !defined(__GMM_KMD)
-#if defined(__linux__)
+#if defined(__linux__) || defined(__Fuchsia__)
#include "Internal/Linux/GmmResourceInfoLinInt.h"
#define _aligned_free(ptr) free(ptr)
diff --git a/Source/GmmLib/TranslationTable/GmmUmdTranslationTable.h b/Source/GmmLib/TranslationTable/GmmUmdTranslationTable.h
index 74de21d..01a5c8b 100644
--- a/Source/GmmLib/TranslationTable/GmmUmdTranslationTable.h
+++ b/Source/GmmLib/TranslationTable/GmmUmdTranslationTable.h
@@ -27,7 +27,7 @@
#pragma once
#include "External/Common/GmmPageTableMgr.h"
-#ifdef __linux__
+#if defined(__linux__) || defined(__Fuchsia__)
#include <pthread.h>
#include <string.h>
@@ -445,7 +445,7 @@
public:
#ifdef _WIN32
CRITICAL_SECTION TTLock; //synchronized access of PageTable obj
-#elif defined __linux__
+#elif defined __linux__ || defined(__Fuchsia__)
pthread_mutex_t TTLock;
#endif
diff --git a/Source/GmmLib/inc/External/Common/GmmCachePolicyCommon.h b/Source/GmmLib/inc/External/Common/GmmCachePolicyCommon.h
index 43fc980..cea5b1f 100644
--- a/Source/GmmLib/inc/External/Common/GmmCachePolicyCommon.h
+++ b/Source/GmmLib/inc/External/Common/GmmCachePolicyCommon.h
@@ -58,7 +58,7 @@
{
#if defined(__GMM_KMD__) || _WIN32
InterlockedIncrement((LONG *)&RefCount);
- #elif defined(__linux__)
+ #elif defined(__linux__) || defined(__Fuchsia__)
__sync_fetch_and_add(&RefCount, 1);
#endif
//TODO[Android]
@@ -68,7 +68,7 @@
{
#if defined(__GMM_KMD__) || _WIN32
return(InterlockedDecrement((LONG *)&RefCount));
- #elif defined(__linux__)
+ #elif defined(__linux__) || defined(__Fuchsia__)
return(__sync_sub_and_fetch(&RefCount, 1));
#endif
//TODO[Android]
diff --git a/Source/GmmLib/inc/External/Common/GmmCommonExt.h b/Source/GmmLib/inc/External/Common/GmmCommonExt.h
index 6c57195..71a5ef3 100644
--- a/Source/GmmLib/inc/External/Common/GmmCommonExt.h
+++ b/Source/GmmLib/inc/External/Common/GmmCommonExt.h
@@ -72,7 +72,7 @@
#define GMM_NO_FENCE_REG 0xDEADBEEF
#define GMM_MAX_DISPLAYS 3
-#if defined __linux__
+#if defined __linux__ || defined(__Fuchsia__)
typedef void* HANDLE;
#endif
diff --git a/Source/GmmLib/inc/External/Common/GmmInfo.h b/Source/GmmLib/inc/External/Common/GmmInfo.h
index 52cfe5a..10cc17f 100644
--- a/Source/GmmLib/inc/External/Common/GmmInfo.h
+++ b/Source/GmmLib/inc/External/Common/GmmInfo.h
@@ -127,7 +127,7 @@
{
#if defined(_WIN32)
return(InterlockedIncrement((LONG *)&RefCount) - 1); //InterLockedIncrement() returns incremented value
-#elif defined(__linux__)
+#elif defined(__linux__) || defined(__Fuchsia__)
return(__sync_fetch_and_add(&RefCount, 1));
#endif
}
@@ -149,7 +149,7 @@
}
#if defined(_WIN32)
} while (!(InterlockedCompareExchange((LONG *)&RefCount, TargetValue, CurrentValue) == CurrentValue));
-#elif defined(__linux__)
+#elif defined(__linux__) || defined(__Fuchsia__)
} while (!__sync_bool_compare_and_swap(&RefCount, CurrentValue, TargetValue));
#endif
diff --git a/Source/GmmLib/inc/External/Common/GmmPageTableMgr.h b/Source/GmmLib/inc/External/Common/GmmPageTableMgr.h
index beaed19..97f0f99 100644
--- a/Source/GmmLib/inc/External/Common/GmmPageTableMgr.h
+++ b/Source/GmmLib/inc/External/Common/GmmPageTableMgr.h
@@ -28,7 +28,7 @@
#pragma once
#include "GmmHw.h"
-#ifdef __linux__
+#if defined(__linux__) || defined(__Fuchsia__)
#include <pthread.h>
#endif
@@ -108,7 +108,7 @@
GmmClientContext *pClientContext; ///< ClientContext of the client creating this Object
//OS-specific defn
-#if defined __linux__
+#if defined __linux__ || defined(__Fuchsia__)
pthread_mutex_t PoolLock;
#endif
public:
@@ -134,7 +134,7 @@
GMM_VIRTUAL GMM_PAGETABLEPool * __GetFreePoolNode(uint32_t * FreePoolNodeIdx, POOL_TYPE PoolType);
-#if defined __linux__
+#if defined __linux__ || defined(__Fuchsia__)
//returns number of BOs for indicated TTs = NumNodePoolElements+1 BOs for root table and pools
GMM_VIRTUAL int GetNumOfPageTableBOs(uint8_t TTFlags);
//returns BO* list for indicated TT in client allocated memory
diff --git a/Source/GmmLib/inc/External/Common/GmmResourceInfoExt.h b/Source/GmmLib/inc/External/Common/GmmResourceInfoExt.h
index c50ac11..6d590e4 100644
--- a/Source/GmmLib/inc/External/Common/GmmResourceInfoExt.h
+++ b/Source/GmmLib/inc/External/Common/GmmResourceInfoExt.h
@@ -181,7 +181,7 @@
// TBD - Place holder for GMM_RESOURCE_FLAG definition.
//---------------------------------------------------------------------------
#include "GmmResourceFlags.h"
-#if defined __linux__
+#if defined __linux__ || defined(__Fuchsia__)
#include "External/Linux/GmmResourceInfoLinExt.h"
#endif
diff --git a/Source/GmmLib/inc/External/Linux/GmmResourceInfoLinExt.h b/Source/GmmLib/inc/External/Linux/GmmResourceInfoLinExt.h
index 20d3b95..cca8990 100644
--- a/Source/GmmLib/inc/External/Linux/GmmResourceInfoLinExt.h
+++ b/Source/GmmLib/inc/External/Linux/GmmResourceInfoLinExt.h
@@ -21,7 +21,7 @@
============================================================================*/
#pragma once
-#ifdef __linux__
+#if defined(__linux__) || defined(__Fuchsia__)
#ifdef __cplusplus
extern "C" {
diff --git a/Source/GmmLib/inc/Internal/Common/Texture/GmmTextureCalc.h b/Source/GmmLib/inc/Internal/Common/Texture/GmmTextureCalc.h
index e29f113..4a52322 100644
--- a/Source/GmmLib/inc/Internal/Common/Texture/GmmTextureCalc.h
+++ b/Source/GmmLib/inc/Internal/Common/Texture/GmmTextureCalc.h
@@ -176,7 +176,7 @@
{
#if defined(__GMM_KMD__) || _WIN32
InterlockedIncrement((LONG *)&RefCount);
- #elif defined(__linux__)
+ #elif defined(__linux__) || defined(__Fuchsia__)
__sync_fetch_and_add(&RefCount, 1);
#endif
//TODO[Android]
@@ -186,7 +186,7 @@
{
#if defined(__GMM_KMD__) || _WIN32
return(InterlockedDecrement((LONG *)&RefCount));
- #elif defined(__linux__)
+ #elif defined(__linux__) || defined(__Fuchsia__)
return(__sync_sub_and_fetch(&RefCount, 1));
#endif
//TODO[Android]
diff --git a/Source/GmmLib/inc/Internal/Linux/GmmResourceInfoLinInt.h b/Source/GmmLib/inc/Internal/Linux/GmmResourceInfoLinInt.h
index 750d537..9545e6c 100644
--- a/Source/GmmLib/inc/Internal/Linux/GmmResourceInfoLinInt.h
+++ b/Source/GmmLib/inc/Internal/Linux/GmmResourceInfoLinInt.h
@@ -22,7 +22,7 @@
#pragma once
-#if defined(__linux__) && !LHDM
+#if (defined(__linux__) || defined(__Fuchsia__)) && !LHDM
// GMM Lib Client Exports
#include "External/Common/GmmCommonExt.h"