chromium/third_party/angle/src/common/system_utils_posix.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_posix.cpp: Implementation of POSIX OS-specific functions.

#include "common/debug.h"
#include "system_utils.h"

#include <array>
#include <iostream>

#include <dlfcn.h>
#include <grp.h>
#include <inttypes.h>
#include <pwd.h>
#include <signal.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>

#include "common/string_utils.h"

#ifdef ANGLE_PLATFORM_FUCHSIA
#    include <zircon/process.h>
#    include <zircon/syscalls.h>
#else
#    include <sys/resource.h>
#endif

namespace angle
{

namespace
{
std::string GetModulePath(void *moduleOrSymbol)
{}

void *OpenPosixLibrary(const std::string &fullPath, int extraFlags, std::string *errorOut)
{}
}  // namespace

Optional<std::string> GetCWD()
{}

bool SetCWD(const char *dirName)
{}

bool UnsetEnvironmentVar(const char *variableName)
{}

bool SetEnvironmentVar(const char *variableName, const char *value)
{}

std::string GetEnvironmentVar(const char *variableName)
{}

const char *GetPathSeparatorForEnvironmentVar()
{}

std::string GetModuleDirectoryAndGetError(std::string *errorOut)
{}

std::string GetModuleDirectory()
{}

void *OpenSystemLibraryWithExtensionAndGetError(const char *libraryName,
                                                SearchType searchType,
                                                std::string *errorOut)
{}

void *GetLibrarySymbol(void *libraryHandle, const char *symbolName)
{}

std::string GetLibraryPath(void *libraryHandle)
{}

void CloseSystemLibrary(void *libraryHandle)
{}

bool IsDirectory(const char *filename)
{}

bool IsDebuggerAttached()
{}

void BreakDebugger()
{}

const char *GetExecutableExtension()
{}

char GetPathSeparator()
{}

std::string GetRootDirectory()
{}

bool CreateDirectories(const std::string &path)
{}

void MakeForwardSlashThePathSeparator(std::string &path)
{}

Optional<std::string> GetTempDirectory()
{}

Optional<std::string> CreateTemporaryFileInDirectory(const std::string &directory)
{}

Optional<std::string> CreateTemporaryFileInDirectoryWithExtension(const std::string &directory,
                                                                  const std::string &extension)
{}

double GetCurrentProcessCpuTime()
{}

namespace
{
bool SetMemoryProtection(uintptr_t start, size_t size, int protections)
{}

class PosixPageFaultHandler : public PageFaultHandler
{};

PosixPageFaultHandler *gPosixPageFaultHandler =;
void SegfaultHandlerFunction(int sig, siginfo_t *info, void *unused)
{}

void PosixPageFaultHandler::handle(int sig, siginfo_t *info, void *unused)
{}

bool PosixPageFaultHandler::disable()
{}

bool PosixPageFaultHandler::enable()
{}
}  // namespace

// Set write protection
bool ProtectMemory(uintptr_t start, size_t size)
{}

// Allow reading and writing
bool UnprotectMemory(uintptr_t start, size_t size)
{}

size_t GetPageSize()
{}

PageFaultHandler *CreatePageFaultHandler(PageFaultCallback callback)
{}

uint64_t GetProcessMemoryUsageKB()
{}
}  // namespace angle