#include "common/system_utils.h"
#include "common/debug.h"
#include <stdlib.h>
#include <atomic>
#if defined(ANGLE_PLATFORM_ANDROID)
# include <sys/system_properties.h>
#endif
#if defined(ANGLE_PLATFORM_APPLE)
# include <dispatch/dispatch.h>
# include <pthread.h>
#endif
namespace angle
{
std::string GetExecutableName()
{ … }
std::string GetEnvironmentVarOrAndroidProperty(const char *variableName, const char *propertyName)
{ … }
std::string GetEnvironmentVarOrUnCachedAndroidProperty(const char *variableName,
const char *propertyName)
{ … }
std::string GetAndSetEnvironmentVarOrUnCachedAndroidProperty(const char *variableName,
const char *propertyName)
{ … }
bool GetBoolEnvironmentVar(const char *variableName)
{ … }
bool PrependPathToEnvironmentVar(const char *variableName, const char *path)
{ … }
bool IsFullPath(std::string dirName)
{ … }
std::string ConcatenatePath(std::string first, std::string second)
{ … }
Optional<std::string> CreateTemporaryFile()
{ … }
PageFaultHandler::PageFaultHandler(PageFaultCallback callback) : … { … }
PageFaultHandler::~PageFaultHandler() { … }
Library *OpenSharedLibrary(const char *libraryName, SearchType searchType)
{ … }
Library *OpenSharedLibraryWithExtension(const char *libraryName, SearchType searchType)
{ … }
Library *OpenSharedLibraryAndGetError(const char *libraryName,
SearchType searchType,
std::string *errorOut)
{ … }
Library *OpenSharedLibraryWithExtensionAndGetError(const char *libraryName,
SearchType searchType,
std::string *errorOut)
{ … }
void *OpenSystemLibrary(const char *libraryName, SearchType searchType)
{ … }
void *OpenSystemLibraryWithExtension(const char *libraryName, SearchType searchType)
{ … }
void *OpenSystemLibraryAndGetError(const char *libraryName,
SearchType searchType,
std::string *errorOut)
{ … }
std::string StripFilenameFromPath(const std::string &path)
{ … }
#if defined(ANGLE_PLATFORM_APPLE)
uint64_t GetCurrentThreadUniqueId()
{
static std::atomic<uint64_t> globalThreadSerial;
static pthread_key_t tlsIndex;
static dispatch_once_t once;
dispatch_once(&once, ^{
auto result = pthread_key_create(&tlsIndex, nullptr);
ASSERT(result == 0);
});
void *tlsValue = pthread_getspecific(tlsIndex);
if (ANGLE_UNLIKELY(tlsValue == nullptr))
{
uint64_t threadId = ++globalThreadSerial;
auto result = pthread_setspecific(tlsIndex, reinterpret_cast<void *>(threadId));
ASSERT(result == 0);
return threadId;
}
return reinterpret_cast<uint64_t>(tlsValue);
}
#else
uint64_t GetCurrentThreadUniqueId()
{ … }
#endif
}