chromium/third_party/angle/src/common/system_utils.cpp

//
// Copyright 2018 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//

// system_utils.cpp: Implementation of common functions

#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()
{}

// On Android return value cached in the process environment, if none, call
// GetEnvironmentVarOrUnCachedAndroidProperty if not in environment.
std::string GetEnvironmentVarOrAndroidProperty(const char *variableName, const char *propertyName)
{}

// On Android call out to 'getprop' on a shell to get an Android property.  On desktop, return
// the value of the environment variable.
std::string GetEnvironmentVarOrUnCachedAndroidProperty(const char *variableName,
                                                       const char *propertyName)
{}

// Look up a property and add it to the application's environment.
// Adding to the env is a performance optimization, as getting properties is expensive.
// This should only be used in non-Release paths, i.e. when using FrameCapture or DebugUtils.
// It can cause race conditions in stress testing. See http://anglebug.com/42265318
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)
// https://anglebug.com/42264979, similar to egl::GetCurrentThread() in libGLESv2/global_state.cpp
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

}  // namespace angle