Enable named mmap usage for CMake builds

Naming 'anonymous' mmap memory, which we use for Reactor's executable
memory, enables profilers to attribute JIT-compiled routine execution
to SwiftShader.

Also suppress a GCC warning about not using the result of ftruncate().

Bug: b/174801963
Bug: b/178614275
Change-Id: Iac4938f332f0e75a9b1d995c83f0cbaaf3532651
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/52228
Tested-by: Nicolas Capens <nicolascapens@google.com>
Commit-Queue: Nicolas Capens <nicolascapens@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
diff --git a/src/Reactor/CMakeLists.txt b/src/Reactor/CMakeLists.txt
index 0717fb9..268c1f7 100644
--- a/src/Reactor/CMakeLists.txt
+++ b/src/Reactor/CMakeLists.txt
@@ -72,6 +72,8 @@
     list(APPEND REACTOR_PUBLIC_COMPILE_DEFINITIONS "REACTOR_ENABLE_MEMORY_SANITIZER_INSTRUMENTATION")
 endif()
 
+list(APPEND REACTOR_PRIVATE_COMPILE_DEFINITIONS "REACTOR_ANONYMOUS_MMAP_NAME=swiftshader_jit")
+
 # SubzeroReactor library
 
 add_library(ReactorSubzero STATIC EXCLUDE_FROM_ALL
diff --git a/src/Reactor/ExecutableMemory.cpp b/src/Reactor/ExecutableMemory.cpp
index 38b73b7..46b4480 100644
--- a/src/Reactor/ExecutableMemory.cpp
+++ b/src/Reactor/ExecutableMemory.cpp
@@ -172,7 +172,8 @@
 	static size_t fileSize = 0;
 	if(length > fileSize)
 	{
-		ftruncate(anonFd, length);
+		[[maybe_unused]] int result = ftruncate(anonFd, length);
+		ASSERT(result == 0);
 		fileSize = length;
 	}
 }