diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /gfx/angle/checkout/src/common/system_utils.h | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gfx/angle/checkout/src/common/system_utils.h')
-rw-r--r-- | gfx/angle/checkout/src/common/system_utils.h | 84 |
1 files changed, 84 insertions, 0 deletions
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 <string> + +namespace angle +{ +std::string GetExecutableName(); +std::string GetExecutablePath(); +std::string GetExecutableDirectory(); +std::string GetHelperExecutableDir(); +const char *GetSharedLibraryExtension(); +const char *GetExecutableExtension(); +char GetPathSeparator(); +Optional<std::string> 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<const char *> &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 <typename FuncT> + void getAs(const char *symbolName, FuncT *funcOut) + { + *funcOut = reinterpret_cast<FuncT>(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_ |