From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- gfx/angle/checkout/src/common/system_utils.h | 84 ++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 gfx/angle/checkout/src/common/system_utils.h (limited to 'gfx/angle/checkout/src/common/system_utils.h') diff --git a/gfx/angle/checkout/src/common/system_utils.h b/gfx/angle/checkout/src/common/system_utils.h new file mode 100644 index 0000000000..efd8a98124 --- /dev/null +++ b/gfx/angle/checkout/src/common/system_utils.h @@ -0,0 +1,84 @@ +// +// Copyright 2014 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.h: declaration of OS-specific utility functions + +#ifndef COMMON_SYSTEM_UTILS_H_ +#define COMMON_SYSTEM_UTILS_H_ + +#include "common/Optional.h" +#include "common/angleutils.h" + +#include + +namespace angle +{ +std::string GetExecutableName(); +std::string GetExecutablePath(); +std::string GetExecutableDirectory(); +std::string GetHelperExecutableDir(); +const char *GetSharedLibraryExtension(); +const char *GetExecutableExtension(); +char GetPathSeparator(); +Optional GetCWD(); +bool SetCWD(const char *dirName); +bool SetEnvironmentVar(const char *variableName, const char *value); +bool UnsetEnvironmentVar(const char *variableName); +std::string GetEnvironmentVar(const char *variableName); +std::string GetEnvironmentVarOrUnCachedAndroidProperty(const char *variableName, + const char *propertyName); +std::string GetEnvironmentVarOrAndroidProperty(const char *variableName, const char *propertyName); +const char *GetPathSeparatorForEnvironmentVar(); +bool PrependPathToEnvironmentVar(const char *variableName, const char *path); +bool IsDirectory(const char *filename); + +// Get absolute time in seconds. Use this function to get an absolute time with an unknown origin. +double GetCurrentTime(); + +// Run an application and get the output. Gets a nullptr-terminated set of args to execute the +// application with, and returns the stdout and stderr outputs as well as the exit code. +// +// Pass nullptr for stdoutOut/stderrOut if you don't need to capture. exitCodeOut is required. +// +// Returns false if it fails to actually execute the application. +bool RunApp(const std::vector &args, + std::string *stdoutOut, + std::string *stderrOut, + int *exitCodeOut); + +class Library : angle::NonCopyable +{ + public: + virtual ~Library() {} + virtual void *getSymbol(const char *symbolName) = 0; + virtual void *getNative() const = 0; + + template + void getAs(const char *symbolName, FuncT *funcOut) + { + *funcOut = reinterpret_cast(getSymbol(symbolName)); + } +}; + +// Use SYSTEM_DIR to bypass loading ANGLE libraries with the same name as system DLLS +// (e.g. opengl32.dll) +enum class SearchType +{ + ApplicationDir, + SystemDir +}; + +Library *OpenSharedLibrary(const char *libraryName, SearchType searchType); +Library *OpenSharedLibraryWithExtension(const char *libraryName); + +// Returns true if the process is currently being debugged. +bool IsDebuggerAttached(); + +// Calls system APIs to break into the debugger. +void BreakDebugger(); +} // namespace angle + +#endif // COMMON_SYSTEM_UTILS_H_ -- cgit v1.2.3