From fd08167b613980b1157a15870f6647043565f15c Mon Sep 17 00:00:00 2001 From: X512 Date: Sun, 9 Jan 2022 06:34:23 +0900 Subject: basic fixes for haiku diff --git a/loader/loader.c b/loader/loader.c index 062c1af..b46401c 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -88,6 +88,17 @@ struct activated_layer_info { char *enable_value_env; }; +#if defined(__HAIKU__) + char *xdg_config_home = NULL; + char *xdg_config_dirs = NULL; + char *xdg_data_home = NULL; + char *xdg_data_dirs = + "/boot/home/config/non-packaged/add-ons:" + "/boot/home/config/add-ons:" + "/boot/system/non-packaged/add-ons:" + "/boot/system/add-ons"; +#endif + // thread safety lock for accessing global data structures such as "loader" // all entrypoints on the instance chain need to be locked except GPA // additionally CreateDevice and DestroyDevice needs to be locked diff --git a/loader/loader_environment.c b/loader/loader_environment.c index 6489efa..c8f4096 100644 --- a/loader/loader_environment.c +++ b/loader/loader_environment.c @@ -49,7 +49,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__) || defined(__OpenBSD__) +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__HAIKU__) // 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. -- 2.48.1 From 5a5654e8f7edce571d64df8e153e60df74a9888b Mon Sep 17 00:00:00 2001 From: Ken Mays Date: Fri, 6 Sep 2024 05:26:34 +0000 Subject: Improve port for Haiku diff --git a/CMakeLists.txt b/CMakeLists.txt index 82173ad..9765f19 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,7 +108,7 @@ elseif(APPLE) if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") target_compile_definitions(platform_wsi INTERFACE VK_USE_PLATFORM_MACOS_MVK) endif() -elseif(CMAKE_SYSTEM_NAME MATCHES "Linux|BSD|DragonFly|GNU") +elseif(CMAKE_SYSTEM_NAME MATCHES "Linux|BSD|DragonFly|GNU|Haiku") option(BUILD_WSI_XCB_SUPPORT "Build XCB WSI support" ON) option(BUILD_WSI_XLIB_SUPPORT "Build Xlib WSI support" ON) option(BUILD_WSI_XLIB_XRANDR_SUPPORT "Build X11 Xrandr WSI support" ON) @@ -155,6 +155,7 @@ endif() add_library(loader_common_options INTERFACE) target_link_libraries(loader_common_options INTERFACE platform_wsi) +include_directories("/sources-2/Vulkan-Headers-1.4.311/include") # Enable beta Vulkan extensions target_compile_definitions(loader_common_options INTERFACE VK_ENABLE_BETA_EXTENSIONS) diff --git a/loader/vk_loader_platform.h b/loader/vk_loader_platform.h index 9a3b9c1..9104239 100644 --- a/loader/vk_loader_platform.h +++ b/loader/vk_loader_platform.h @@ -26,7 +26,7 @@ */ #pragma once -#if defined(__FreeBSD__) || defined(__OpenBSD__) +#if defined(__FreeBSD__) || defined(__OpenBSD__)|| defined(__HAIKU__) #include #include #endif @@ -44,7 +44,7 @@ // Set of platforms with a common set of functionality which is queried throughout the program #if defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__QNX__) || defined(__FreeBSD__) || \ - defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__GNU__) + defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__GNU__) || defined(__HAIKU__) #define COMMON_UNIX_PLATFORMS 1 #else #define COMMON_UNIX_PLATFORMS 0 @@ -353,7 +353,7 @@ static inline char *loader_platform_executable_path(char *buffer, size_t size) { return buffer; } -#elif defined(__Fuchsia__) || defined(__OpenBSD__) +#elif defined(__Fuchsia__) || defined(__OpenBSD__) || defined(__HAIKU__) static inline char *loader_platform_executable_path(char *buffer, size_t size) { return NULL; } #elif defined(__QNX__) -- 2.48.1 From 205083553a767c71ecdfc901bfb6a7499f9e79a3 Mon Sep 17 00:00:00 2001 From: X512 Date: Sun, 9 Mar 2025 19:11:24 +0900 Subject: haiku: use FindDirectory diff --git a/loader/loader.c b/loader/loader.c index b46401c..b166286 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -44,6 +44,11 @@ #include #endif +#if defined(__HAIKU__) +#include +#include +#endif + #include #if defined(_WIN32) #include "dirent_on_windows.h" @@ -88,17 +93,6 @@ struct activated_layer_info { char *enable_value_env; }; -#if defined(__HAIKU__) - char *xdg_config_home = NULL; - char *xdg_config_dirs = NULL; - char *xdg_data_home = NULL; - char *xdg_data_dirs = - "/boot/home/config/non-packaged/add-ons:" - "/boot/home/config/add-ons:" - "/boot/system/non-packaged/add-ons:" - "/boot/system/add-ons"; -#endif - // thread safety lock for accessing global data structures such as "loader" // all entrypoints on the instance chain need to be locked except GPA // additionally CreateDevice and DestroyDevice needs to be locked @@ -3155,6 +3149,9 @@ VkResult read_data_files_in_search_paths(const struct loader_instance *inst, enu #if defined(_WIN32) char *package_path = NULL; +#elif defined(__HAIKU__) + char** directories = NULL; + size_t directory_count = 0; #elif COMMON_UNIX_PLATFORMS // Determine how much space is needed to generate the full search path // for the current manifest files. @@ -3293,6 +3290,15 @@ VkResult read_data_files_in_search_paths(const struct loader_instance *inst, enu if (search_path_size == 2) { goto out; } +#elif defined(__HAIKU__) + } + if (find_paths_etc(get_architecture(), B_FIND_PATH_ADD_ONS_DIRECTORY, relative_location, 0, &directories, &directory_count) != B_OK) { + vk_result = VK_ERROR_OUT_OF_HOST_MEMORY; + goto out; + } + for (size_t i = 0; i < directory_count; i++) { + search_path_size += strlen(directories[i]) + 1; + } #elif COMMON_UNIX_PLATFORMS } @@ -3349,6 +3355,10 @@ VkResult read_data_files_in_search_paths(const struct loader_instance *inst, enu if (NULL != package_path) { copy_data_file_info(package_path, NULL, 0, &cur_path_ptr); } +#elif defined(__HAIKU__) + for (size_t i = 0; i < directory_count; i++) { + copy_data_file_info(directories[i], NULL, 0, &cur_path_ptr); + } #elif COMMON_UNIX_PLATFORMS if (rel_size > 0) { #if defined(__APPLE__) @@ -3486,6 +3496,8 @@ out: loader_free_getenv(override_env, inst); #if defined(_WIN32) loader_instance_heap_free(inst, package_path); +#elif defined(__HAIKU__) + free(directories); #elif COMMON_UNIX_PLATFORMS loader_free_getenv(xdg_config_home, inst); loader_free_getenv(xdg_config_dirs, inst); -- 2.48.1