Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/Vulkan-Loader.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Smith <brad@comstyle.com>2022-08-31 03:14:18 +0300
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>2022-08-31 19:02:13 +0300
commitc745281f0f548e4bca412985b09f0af98efe15e1 (patch)
tree637fca15b3939e94753d5b235c847ee227b36f45
parent40faec799ce6b17f46f4bf28ce81782a1bafbbb0 (diff)
loader: Add OpenBSD support
-rw-r--r--loader/get_environment.c4
-rw-r--r--loader/get_environment.h4
-rw-r--r--loader/stack_allocation.h2
-rw-r--r--loader/vk_loader_platform.h8
-rw-r--r--tests/framework/framework_config.h.in2
-rw-r--r--tests/framework/shim/shim.h4
-rw-r--r--tests/framework/shim/shim_common.cpp4
-rw-r--r--tests/framework/shim/unix_shim.cpp4
-rw-r--r--tests/framework/test_environment.cpp2
-rw-r--r--tests/framework/test_util.cpp4
-rw-r--r--tests/framework/test_util.h8
-rw-r--r--tests/loader_envvar_tests.cpp4
-rw-r--r--tests/loader_regression_tests.cpp2
-rw-r--r--tests/loader_testing_main.cpp4
14 files changed, 28 insertions, 28 deletions
diff --git a/loader/get_environment.c b/loader/get_environment.c
index 424123895..41ed61f66 100644
--- a/loader/get_environment.c
+++ b/loader/get_environment.c
@@ -32,7 +32,7 @@
#include "log.h"
// Environment variables
-#if defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__QNXNTO__) || defined(__FreeBSD__)
+#if defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__QNXNTO__) || defined(__FreeBSD__) || defined(__OpenBSD__)
bool is_high_integrity() { return geteuid() != getuid() || getegid() != getgid(); }
@@ -44,7 +44,7 @@ char *loader_getenv(const char *name, const struct loader_instance *inst) {
}
char *loader_secure_getenv(const char *name, const struct loader_instance *inst) {
-#if defined(__APPLE__) || defined(__FreeBSD__)
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
// Apple does not appear to have a secure getenv implementation.
// The main difference between secure getenv and getenv is that secure getenv
// returns NULL if the process is being run with elevated privileges by a normal user.
diff --git a/loader/get_environment.h b/loader/get_environment.h
index 0da7286a7..2b1663b41 100644
--- a/loader/get_environment.h
+++ b/loader/get_environment.h
@@ -35,10 +35,10 @@
char *loader_getenv(const char *name, const struct loader_instance *inst);
void loader_free_getenv(char *val, const struct loader_instance *inst);
-#if defined(WIN32) || defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__QNXNTO__) || defined(__FreeBSD__)
+#if defined(WIN32) || defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__QNXNTO__) || defined(__FreeBSD__) || defined(__OpenBSD__)
bool is_high_integrity();
char *loader_secure_getenv(const char *name, const struct loader_instance *inst);
-#endif \ No newline at end of file
+#endif
diff --git a/loader/stack_allocation.h b/loader/stack_allocation.h
index 0ddd5ca3c..c724de6ca 100644
--- a/loader/stack_allocation.h
+++ b/loader/stack_allocation.h
@@ -34,7 +34,7 @@
#include <alloca.h>
#endif
-#if defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__QNXNTO__) || defined(__FreeBSD__)
+#if defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__QNXNTO__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#define loader_stack_alloc(size) alloca(size)
#elif defined(_WIN32)
#define loader_stack_alloc(size) _alloca(size)
diff --git a/loader/vk_loader_platform.h b/loader/vk_loader_platform.h
index 864eaf4be..8ad97545e 100644
--- a/loader/vk_loader_platform.h
+++ b/loader/vk_loader_platform.h
@@ -24,7 +24,7 @@
*/
#pragma once
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) || defined(__OpenBSD__)
#include <sys/types.h>
#include <sys/select.h>
#endif
@@ -43,7 +43,7 @@
#include "dlopen_fuchsia.h"
#endif // defined(__Fuchsia__)
-#if defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__QNXNTO__) || defined(__FreeBSD__)
+#if defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__QNXNTO__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#include <unistd.h>
// Note: The following file is for dynamic loading:
#include <dlfcn.h>
@@ -98,7 +98,7 @@
#define LAYERS_PATH_ENV "VK_LAYER_PATH"
#define ENABLED_LAYERS_ENV "VK_INSTANCE_LAYERS"
-#if defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__QNXNTO__) || defined(__FreeBSD__)
+#if defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__QNXNTO__) || defined(__FreeBSD__) || defined(__OpenBSD__)
/* Linux-specific common code: */
// VK Library Filenames, Paths, etc.:
@@ -219,7 +219,7 @@ static inline void loader_platform_thread_once_fn(pthread_once_t *ctl, void (*fu
#endif
-#if defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__QNXNTO__) || defined(__FreeBSD__)
+#if defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__QNXNTO__) || defined(__FreeBSD__) || defined(__OpenBSD__)
// File IO
static inline bool loader_platform_file_exists(const char *path) {
diff --git a/tests/framework/framework_config.h.in b/tests/framework/framework_config.h.in
index 4b956937b..406722cb3 100644
--- a/tests/framework/framework_config.h.in
+++ b/tests/framework/framework_config.h.in
@@ -72,7 +72,7 @@
#define BAD_DUMMY_BINARY_WINDOWS_64 "${CMAKE_CURRENT_SOURCE_DIR}/data/binaries/libdummy_library_elf_64.dll"
#define BAD_DUMMY_BINARY_WINDOWS_32 "${CMAKE_CURRENT_SOURCE_DIR}/data/binaries/libdummy_library_elf_32.dll"
#endif
-#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
+#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#define DUMMY_BINARY_LINUX_64 "${CMAKE_CURRENT_SOURCE_DIR}/data/binaries/libdummy_library_elf_64.so"
#define DUMMY_BINARY_LINUX_32 "${CMAKE_CURRENT_SOURCE_DIR}/data/binaries/libdummy_library_elf_32.so"
#define BAD_DUMMY_BINARY_LINUX_64 "${CMAKE_CURRENT_SOURCE_DIR}/data/binaries/dummy_library_pe_64.so"
diff --git a/tests/framework/shim/shim.h b/tests/framework/shim/shim.h
index 4b0c8bc23..066ec3e64 100644
--- a/tests/framework/shim/shim.h
+++ b/tests/framework/shim/shim.h
@@ -110,7 +110,7 @@ struct D3DKMT_Adapter {
D3DKMT_Adapter& add_path(fs::path src, std::vector<std::wstring>& dest);
};
-#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
+#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
struct DirEntry {
DIR* directory;
@@ -181,7 +181,7 @@ struct PlatformShim {
size_t created_key_count = 0;
std::vector<HKeyHandle> created_keys;
-#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
+#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
bool is_fake_path(fs::path const& path);
fs::path const& get_fake_path(fs::path const& path);
diff --git a/tests/framework/shim/shim_common.cpp b/tests/framework/shim/shim_common.cpp
index e946c0d4c..dd4c4bf8e 100644
--- a/tests/framework/shim/shim_common.cpp
+++ b/tests/framework/shim/shim_common.cpp
@@ -42,7 +42,7 @@ std::vector<std::string> parse_env_var_list(std::string const& var) {
for (size_t i = 0; i < var.size(); i++) {
#if defined(WIN32)
if (var[i] == ';') {
-#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
+#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
if (var[i] == ':') {
#endif
if (len != 0) {
@@ -145,7 +145,7 @@ void PlatformShim::add_CM_Device_ID(std::wstring const& id, fs::path const& icd_
void PlatformShim::redirect_category(fs::path const& new_path, ManifestCategory search_category) {}
-#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
+#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#include <dirent.h>
#include <unistd.h>
diff --git a/tests/framework/shim/unix_shim.cpp b/tests/framework/shim/unix_shim.cpp
index 1fdadbcfb..c52bec7bc 100644
--- a/tests/framework/shim/unix_shim.cpp
+++ b/tests/framework/shim/unix_shim.cpp
@@ -29,7 +29,7 @@
static PlatformShim platform_shim;
extern "C" {
-#if defined(__linux__) || defined(__FreeBSD__)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
PlatformShim* get_platform_shim(std::vector<fs::FolderManager>* folders) {
platform_shim = PlatformShim(folders);
return &platform_shim;
@@ -42,7 +42,7 @@ FRAMEWORK_EXPORT PlatformShim* get_platform_shim(std::vector<fs::FolderManager>*
#endif
// Necessary for MacOS function shimming
-#if defined(__linux__) || defined(__FreeBSD__)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#define OPENDIR_FUNC_NAME opendir
#define READDIR_FUNC_NAME readdir
#define CLOSEDIR_FUNC_NAME closedir
diff --git a/tests/framework/test_environment.cpp b/tests/framework/test_environment.cpp
index 7654be723..5d058ab52 100644
--- a/tests/framework/test_environment.cpp
+++ b/tests/framework/test_environment.cpp
@@ -142,7 +142,7 @@ PlatformShimWrapper::PlatformShimWrapper(std::vector<fs::FolderManager>* folders
PFN_get_platform_shim get_platform_shim_func = shim_library.get_symbol(GET_PLATFORM_SHIM_STR);
assert(get_platform_shim_func != NULL && "Must be able to get \"platform_shim\"");
platform_shim = get_platform_shim_func(folders);
-#elif defined(__linux__) || defined(__FreeBSD__)
+#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
platform_shim = get_platform_shim(folders);
#endif
platform_shim->reset();
diff --git a/tests/framework/test_util.cpp b/tests/framework/test_util.cpp
index e77b2c375..f7acaee19 100644
--- a/tests/framework/test_util.cpp
+++ b/tests/framework/test_util.cpp
@@ -77,7 +77,7 @@ std::string get_env_var(std::string const& name, bool report_failure) {
}
return narrow(value);
}
-#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
+#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
void set_env_var(std::string const& name, std::string const& value) { setenv(name.c_str(), value.c_str(), 1); }
void remove_env_var(std::string const& name) { unsetenv(name.c_str()); }
@@ -224,7 +224,7 @@ std::string make_native(std::string const& in_path) {
else
out += c;
}
-#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
+#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
for (size_t i = 0; i < in_path.size(); i++) {
if (i + 1 < in_path.size() && in_path[i] == '\\' && in_path[i + 1] == '\\') {
out += '/';
diff --git a/tests/framework/test_util.h b/tests/framework/test_util.h
index f3ee26b23..d9f4d2bd1 100644
--- a/tests/framework/test_util.h
+++ b/tests/framework/test_util.h
@@ -66,7 +66,7 @@
#include <direct.h>
#include <windows.h>
#include <strsafe.h>
-#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
+#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -109,7 +109,7 @@ void set_env_var(std::string const& name, std::string const& value);
void remove_env_var(std::string const& name);
std::string get_env_var(std::string const& name, bool report_failure = true);
-#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
+#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
void set_env_var(std::string const& name, std::string const& value);
void remove_env_var(std::string const& name);
std::string get_env_var(std::string const& name, bool report_failure = true);
@@ -141,7 +141,7 @@ struct path {
private:
#if defined(WIN32)
static const char path_separator = '\\';
-#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
+#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
static const char path_separator = '/';
#endif
@@ -282,7 +282,7 @@ inline char* loader_platform_get_proc_address_error(const char* name) {
return errorMsg;
}
-#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
+#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
typedef void* loader_platform_dl_handle;
inline loader_platform_dl_handle loader_platform_open_library(const char* libPath) {
diff --git a/tests/loader_envvar_tests.cpp b/tests/loader_envvar_tests.cpp
index b7d7534f3..63e050c9b 100644
--- a/tests/loader_envvar_tests.cpp
+++ b/tests/loader_envvar_tests.cpp
@@ -151,7 +151,7 @@ TEST(EnvVarICDOverrideSetup, TestOnlyDriverEnvVar) {
remove_env_var("VK_DRIVER_FILES");
}
-#if defined(__linux__) || defined(__FreeBSD__)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
// Make sure the loader reports the correct message based on if USE_UNSAFE_FILE_SEARCH is set or not
TEST(EnvVarICDOverrideSetup, NonSecureEnvVarLookup) {
FrameworkEnvironment env{};
@@ -255,7 +255,7 @@ TEST(EnvVarICDOverrideSetup, TestBothDriverEnvVars) {
remove_env_var("VK_ADD_DRIVER_FILES");
}
-#if defined(__linux__) || defined(__FreeBSD__)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
// Test VK_LAYER_PATH environment variable
TEST(EnvVarICDOverrideSetup, TestOnlyLayerEnvVar) {
FrameworkEnvironment env{};
diff --git a/tests/loader_regression_tests.cpp b/tests/loader_regression_tests.cpp
index da1b3721f..0b7389ecd 100644
--- a/tests/loader_regression_tests.cpp
+++ b/tests/loader_regression_tests.cpp
@@ -1027,7 +1027,7 @@ TEST(TryLoadWrongBinaries, WrongICD) {
#if _WIN32 || _WIN64
ASSERT_TRUE(log.find("Failed to open dynamic library"));
#endif
-#if defined(__linux__) || defined(__FreeBSD__)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#if defined(__x86_64__)
ASSERT_TRUE(log.find("wrong ELF class: ELFCLASS32"));
#else
diff --git a/tests/loader_testing_main.cpp b/tests/loader_testing_main.cpp
index 36c018e4a..eb2c8f836 100644
--- a/tests/loader_testing_main.cpp
+++ b/tests/loader_testing_main.cpp
@@ -58,13 +58,13 @@ int main(int argc, char** argv) {
remove_env_var("VK_LOADER_DEBUG");
remove_env_var("VK_LOADER_DISABLE_INST_EXT_FILTER");
-#if defined(__linux__) || defined(__FreeBSD__)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
set_env_var("XDG_CONFIG_HOME", "/etc");
set_env_var("XDG_CONFIG_DIRS", "/etc");
set_env_var("XDG_DATA_HOME", "/etc");
set_env_var("XDG_DATA_DIRS", "/etc");
#endif
-#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
+#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
set_env_var("HOME", "/home/fake_home");
#endif