Convert stub C files to C++

This allows us to use magma utility and platform functions from them.
pvrsrv.h needs a minor change to be valid C++.

Change-Id: Ic290d7533bce71a4582312c6e2abd3a6746a48b0
diff --git a/BUILD.gn b/BUILD.gn
index ffd856a..ad827a4 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -88,19 +88,19 @@
   ]
 
   sources += [
-    "services/server/devices/rgx/env/fuchsia/rgxfwload.c",
-    "services/server/env/fuchsia/allocmem.c",
-    "services/server/env/fuchsia/km_apphint.c",
-    "services/server/env/fuchsia/lock.c",
-    "services/server/env/fuchsia/osfunc.c",
-    "services/server/env/fuchsia/osfunc_platform.c",
+    "services/server/devices/rgx/env/fuchsia/rgxfwload.cc",
+    "services/server/env/fuchsia/allocmem.cc",
+    "services/server/env/fuchsia/km_apphint.cc",
+    "services/server/env/fuchsia/lock.cc",
+    "services/server/env/fuchsia/osfunc.cc",
+    "services/server/env/fuchsia/osfunc_platform.cc",
     "services/server/env/fuchsia/osmmap_stub.c",
-    "services/server/env/fuchsia/physmem_osmem_fuchsia.c",
-    "services/server/env/fuchsia/pmr_os.c",
-    "services/server/env/fuchsia/pvr_bridge_k.c",
-    "services/server/env/fuchsia/pvr_debug.c",
-    "services/system/common/env/fuchsia/dma_support.c",
-    "services/system/fuchsia/sysconfig.c",
+    "services/server/env/fuchsia/physmem_osmem_fuchsia.cc",
+    "services/server/env/fuchsia/pmr_os.cc",
+    "services/server/env/fuchsia/pvr_bridge_k.cc",
+    "services/server/env/fuchsia/pvr_debug.cc",
+    "services/system/common/env/fuchsia/dma_support.cc",
+    "services/system/fuchsia/sysconfig.cc",
   ]
 
   sources += [
diff --git a/services/server/devices/rgx/env/fuchsia/rgxfwload.c b/services/server/devices/rgx/env/fuchsia/rgxfwload.cc
similarity index 98%
rename from services/server/devices/rgx/env/fuchsia/rgxfwload.c
rename to services/server/devices/rgx/env/fuchsia/rgxfwload.cc
index 0e8bab4..593ef59 100644
--- a/services/server/devices/rgx/env/fuchsia/rgxfwload.c
+++ b/services/server/devices/rgx/env/fuchsia/rgxfwload.cc
@@ -31,9 +31,11 @@
 
 #include <stdio.h>
 
+extern "C" {
 #include "device.h"
 #include "rgxfwload.h"
 #include "srvkm.h"
+}
 
 #define NOT_IMPLEMENTED() fprintf(stderr, "msd-img-rgx-mtk:Not implemented in %s:%s:%d\n", __func__, __FILE__, __LINE__);
 
diff --git a/services/server/env/fuchsia/allocmem.c b/services/server/env/fuchsia/allocmem.cc
similarity index 98%
rename from services/server/env/fuchsia/allocmem.c
rename to services/server/env/fuchsia/allocmem.cc
index 8e4e7b2..460524f 100644
--- a/services/server/env/fuchsia/allocmem.c
+++ b/services/server/env/fuchsia/allocmem.cc
@@ -28,10 +28,11 @@
 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */ /**************************************************************************/
 
-
+extern "C" {
 #include "img_defs.h"
 #include "allocmem.h"
 #include "osfunc.h"
+}
 
 #define NOT_IMPLEMENTED() fprintf(stderr, "msd-img-rgx-mtk: Not implemented in %s:%s:%d\n", __func__, __FILE__, __LINE__);
 
diff --git a/services/server/env/fuchsia/km_apphint.c b/services/server/env/fuchsia/km_apphint.cc
similarity index 99%
rename from services/server/env/fuchsia/km_apphint.c
rename to services/server/env/fuchsia/km_apphint.cc
index f60ec32..ef48dcc 100644
--- a/services/server/env/fuchsia/km_apphint.c
+++ b/services/server/env/fuchsia/km_apphint.cc
@@ -29,6 +29,7 @@
 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */ /**************************************************************************/
 
+extern "C" {
 /* Common and SO layer */
 #include "img_defs.h"
 //#include "sofunc_pvr.h"
@@ -41,6 +42,7 @@
 
 #include "km_apphint_defs.h"
 #include "km_apphint.h"
+}
 
 #define NOT_IMPLEMENTED() fprintf(stderr, "msd-img-rgx-mtk: Not implemented in %s:%s:%d\n", __func__, __FILE__, __LINE__);
 
diff --git a/services/server/env/fuchsia/lock.c b/services/server/env/fuchsia/lock.cc
similarity index 99%
rename from services/server/env/fuchsia/lock.c
rename to services/server/env/fuchsia/lock.cc
index 3fccb1c..1922368 100644
--- a/services/server/env/fuchsia/lock.c
+++ b/services/server/env/fuchsia/lock.cc
@@ -27,12 +27,13 @@
 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */ /**************************************************************************/
-
+extern "C" {
 #include "osfunc.h"
 #include "cache_km.h"
 #include "img_types.h"
 #include "allocmem.h"
 #include "pvr_debug.h"
+}
 
 #define NOT_IMPLEMENTED() fprintf(stderr, "msd-img-rgx-mtk: Not implemented in %s:%s:%d\n", __func__, __FILE__, __LINE__);
 
@@ -274,7 +275,7 @@
 OSTryLockAcquire(POS_LOCK hLock)
 {
 	NOT_IMPLEMENTED();
-	return 0;
+	return IMG_FALSE;
 }
 
 /**************************************************************************/ /*!
@@ -302,5 +303,5 @@
 OSLockIsLocked(POS_LOCK hLock)
 {
 	NOT_IMPLEMENTED();
-	return 0;
+	return IMG_FALSE;
 }
diff --git a/services/server/env/fuchsia/osfunc.c b/services/server/env/fuchsia/osfunc.cc
similarity index 99%
rename from services/server/env/fuchsia/osfunc.c
rename to services/server/env/fuchsia/osfunc.cc
index 5716ab6..6482fda 100644
--- a/services/server/env/fuchsia/osfunc.c
+++ b/services/server/env/fuchsia/osfunc.cc
@@ -28,6 +28,7 @@
 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */ /**************************************************************************/
 
+extern "C" {
 #include "log2.h"
 #include "osfunc.h"
 #include "cache_km.h"
@@ -38,6 +39,7 @@
 #if defined(PVRSRV_ENABLE_PROCESS_STATS)
 #include "process_stats.h"
 #endif
+}
 
 #define NOT_IMPLEMENTED() fprintf(stderr, "msd-img-rgx-mtk: Not implemented in %s:%s:%d\n", __func__, __FILE__, __LINE__);
 
@@ -263,28 +265,28 @@
 }
 
 
-INLINE IMG_UINT64
+IMG_UINT64
 OSGetCurrentProcessVASpaceSize(void)
 {
 	NOT_IMPLEMENTED();
 	return 0;
 }
 
-INLINE IMG_PID
+IMG_PID
 OSGetCurrentProcessID(void)
 {
 	NOT_IMPLEMENTED();
 	return 0;
 }
 
-INLINE IMG_CHAR *
+IMG_CHAR *
 OSGetCurrentProcessName(void)
 {
 	NOT_IMPLEMENTED();
 	return 0;
 }
 
-INLINE uintptr_t
+uintptr_t
 OSGetCurrentThreadID(void)
 {
 	NOT_IMPLEMENTED();
@@ -450,7 +452,7 @@
 OSUnMapPhysToLin(void *pvLinAddr, size_t ui32Bytes, IMG_UINT32 ui32MappingFlags)
 {
 	NOT_IMPLEMENTED();
-	return 0;
+	return IMG_FALSE;
 }
 
 IMG_HANDLE
diff --git a/services/server/env/fuchsia/osfunc_platform.c b/services/server/env/fuchsia/osfunc_platform.cc
similarity index 99%
rename from services/server/env/fuchsia/osfunc_platform.c
rename to services/server/env/fuchsia/osfunc_platform.cc
index b95d106..8d1df59 100644
--- a/services/server/env/fuchsia/osfunc_platform.c
+++ b/services/server/env/fuchsia/osfunc_platform.cc
@@ -29,10 +29,11 @@
 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */ /**************************************************************************/
 
+extern "C" {
 #include "pvrsrv_error.h"
 #include "img_types.h"
 #include "osfunc.h"
-
+}
 #if defined(CONFIG_OUTER_CACHE)
 /* If you encounter a 64-bit ARM system with an outer cache, you'll need
    * to add the necessary code to manage that cache. See osfunc_arm.c
diff --git a/services/server/env/fuchsia/physmem_osmem_fuchsia.c b/services/server/env/fuchsia/physmem_osmem_fuchsia.cc
similarity index 98%
rename from services/server/env/fuchsia/physmem_osmem_fuchsia.c
rename to services/server/env/fuchsia/physmem_osmem_fuchsia.cc
index f5e6ac8..8dd61e3 100644
--- a/services/server/env/fuchsia/physmem_osmem_fuchsia.c
+++ b/services/server/env/fuchsia/physmem_osmem_fuchsia.cc
@@ -31,6 +31,7 @@
 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */ /**************************************************************************/
 /* include/ */
+extern "C" {
 #include "rgx_heaps.h"
 #include "img_types.h"
 #include "pvrsrv_error.h"
@@ -44,6 +45,7 @@
 
 /* ourselves */
 #include "physmem_osmem.h"
+}
 
 #define NOT_IMPLEMENTED() fprintf(stderr, "msd-img-rgx-mtk: Not implemented in %s:%s:%d\n", __func__, __FILE__, __LINE__);
 
diff --git a/services/server/env/fuchsia/pmr_os.c b/services/server/env/fuchsia/pmr_os.cc
similarity index 98%
rename from services/server/env/fuchsia/pmr_os.c
rename to services/server/env/fuchsia/pmr_os.cc
index 1d3ec22..56c1c6a 100644
--- a/services/server/env/fuchsia/pmr_os.c
+++ b/services/server/env/fuchsia/pmr_os.cc
@@ -28,11 +28,13 @@
 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */ /**************************************************************************/
 
+extern "C" {
 #include "img_defs.h"
 #include "allocmem.h"
 #include "devicemem_server_utils.h"
 #include "pmr.h"
 #include "pmr_os.h"
+}
 
 #define NOT_IMPLEMENTED() fprintf(stderr, "msd-img-rgx-mtk:Not implemented in %s:%s:%d\n", __func__, __FILE__, __LINE__);
 PVRSRV_ERROR
diff --git a/services/server/env/fuchsia/pvr_bridge_k.c b/services/server/env/fuchsia/pvr_bridge_k.cc
similarity index 98%
rename from services/server/env/fuchsia/pvr_bridge_k.c
rename to services/server/env/fuchsia/pvr_bridge_k.cc
index b282253..eb09d7c 100644
--- a/services/server/env/fuchsia/pvr_bridge_k.c
+++ b/services/server/env/fuchsia/pvr_bridge_k.cc
@@ -30,6 +30,7 @@
 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */ /**************************************************************************/
 
+extern "C" {
 #include "img_defs.h"
 #include "pvr_bridge.h"
 #include "connection_server.h"
@@ -37,6 +38,7 @@
 
 #include "srvcore.h"
 #include "common_srvcore_bridge.h"
+}
 
 #define NOT_IMPLEMENTED() fprintf(stderr, "msd-img-rgx-mtk: Not implemented in %s:%s:%d\n", __func__, __FILE__, __LINE__);
 
diff --git a/services/server/env/fuchsia/pvr_debug.c b/services/server/env/fuchsia/pvr_debug.cc
similarity index 99%
rename from services/server/env/fuchsia/pvr_debug.c
rename to services/server/env/fuchsia/pvr_debug.cc
index a93247e..9f280f1 100644
--- a/services/server/env/fuchsia/pvr_debug.c
+++ b/services/server/env/fuchsia/pvr_debug.cc
@@ -31,10 +31,12 @@
 
 #include <stdlib.h>
 
+extern "C" {
 #include "pvrversion.h"
 #include "img_types.h"
 #include "pvr_debug.h"
 #include "pvrsrv.h"
+}
 
 #define NOT_IMPLEMENTED() fprintf(stderr, "msd-img-rgx-mtk: Not implemented in %s:%s:%d\n", __func__, __FILE__, __LINE__);
 
diff --git a/services/server/include/pvrsrv.h b/services/server/include/pvrsrv.h
index 9436064..ea5b852 100644
--- a/services/server/include/pvrsrv.h
+++ b/services/server/include/pvrsrv.h
@@ -371,13 +371,13 @@
 	if(ui32BridgeGroup >= PVRSRV_BRIDGE_RGX_FIRST)
 	{
 		return ((1U << (ui32BridgeGroup - PVRSRV_BRIDGE_RGX_FIRST)) &
-							gui32RGXBridges) != 0;
+							gui32RGXBridges) != 0 ? IMG_TRUE : IMG_FALSE;
 	}
 	else
 #endif /* SUPPORT_RGX */
 	{
 		return ((1U << (ui32BridgeGroup - PVRSRV_BRIDGE_FIRST)) &
-							gui32PVRBridges) != 0;
+							gui32PVRBridges) != 0 ? IMG_TRUE : IMG_FALSE;
 	}
 }
 
diff --git a/services/system/common/env/fuchsia/dma_support.c b/services/system/common/env/fuchsia/dma_support.cc
similarity index 99%
rename from services/system/common/env/fuchsia/dma_support.c
rename to services/system/common/env/fuchsia/dma_support.cc
index d2ce09e..013a184 100644
--- a/services/system/common/env/fuchsia/dma_support.c
+++ b/services/system/common/env/fuchsia/dma_support.cc
@@ -29,8 +29,10 @@
 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */ /**************************************************************************/
+extern "C" {
 #include "allocmem.h"
 #include "dma_support.h"
+}
 
 #define NOT_IMPLEMENTED() fprintf(stderr, "msd-img-rgx-mtk:Not implemented in %s:%s:%d\n", __func__, __FILE__, __LINE__);
 
diff --git a/services/system/fuchsia/sysconfig.c b/services/system/fuchsia/sysconfig.cc
similarity index 98%
rename from services/system/fuchsia/sysconfig.c
rename to services/system/fuchsia/sysconfig.cc
index 34807e9..6e4df04 100644
--- a/services/system/fuchsia/sysconfig.c
+++ b/services/system/fuchsia/sysconfig.cc
@@ -29,11 +29,14 @@
 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */ /**************************************************************************/
 
+extern "C" {
 #include "sysinfo.h"
 
 #include "pvrsrv_device.h"
 #include "rgxdevice.h"
 #include "syscommon.h"
+}
+
 #define NOT_IMPLEMENTED() fprintf(stderr, "msd-img-rgx-mtk:Not implemented in %s:%s:%d\n", __func__, __FILE__, __LINE__);
 
 PVRSRV_ERROR