Skip to content

Commit

Permalink
build: Fix QNX CMake build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
aqnuep committed Jan 8, 2024
1 parent 456d7fa commit 3a467c6
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 8 deletions.
8 changes: 8 additions & 0 deletions loader/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -5366,15 +5366,23 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateInstance(const VkInstanceCreateI
loader_destroy_generic_list(ptr_instance, (struct loader_generic_list *)&icd_exts);

// Get the driver version from vkEnumerateInstanceVersion
#ifdef VULKANSC
uint32_t icd_version = VKSC_API_VERSION_1_0;
#else
uint32_t icd_version = VK_API_VERSION_1_0;
#endif // VULKANSC
VkResult icd_result = VK_SUCCESS;
if (icd_term->scanned_icd->api_version >= VK_API_VERSION_1_1) {
PFN_vkEnumerateInstanceVersion icd_enumerate_instance_version =
(PFN_vkEnumerateInstanceVersion)icd_term->scanned_icd->GetInstanceProcAddr(NULL, "vkEnumerateInstanceVersion");
if (icd_enumerate_instance_version != NULL) {
icd_result = icd_enumerate_instance_version(&icd_version);
if (icd_result != VK_SUCCESS) {
#ifdef VULKANSC
icd_version = VKSC_API_VERSION_1_0;
#else
icd_version = VK_API_VERSION_1_0;
#endif // VULKANSC
loader_log(ptr_instance, VULKAN_LOADER_DEBUG_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
"terminator_CreateInstance: ICD \"%s\" vkEnumerateInstanceVersion returned error. The ICD will be "
"treated as a 1.0 ICD",
Expand Down
4 changes: 4 additions & 0 deletions loader/vk_loader_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,10 @@
#define VK_SETTINGS_INFO_REGISTRY_LOC ""

#if defined(__QNX__)
#ifndef SYSCONFDIR
#define SYSCONFDIR "/etc"
#endif
#endif

// C99:
#define PRINTF_SIZE_T_SPECIFIER "%zu"
Expand Down Expand Up @@ -339,7 +341,9 @@ static inline char *loader_platform_executable_path(char *buffer, size_t size) {
static inline char *loader_platform_executable_path(char *buffer, size_t size) { return NULL; }
#elif defined(__QNX__)

#ifndef SYSCONFDIR
#define SYSCONFDIR "/etc"
#endif

#include <fcntl.h>
#include <sys/stat.h>
Expand Down
6 changes: 3 additions & 3 deletions tests/framework/framework_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,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__) || defined(__OpenBSD__) || defined(__GNU__)
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__GNU__) || defined(__QNX__)
#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"
Expand All @@ -96,7 +96,7 @@
#endif
#endif
#if defined(__linux__) || defined(__GNU__)
#if __x86_64__ || __ppc64__
#if __x86_64__ || __ppc64__ || __aarch64__
#define CURRENT_PLATFORM_DUMMY_BINARY_WRONG_TYPE DUMMY_BINARY_LINUX_32
#define CURRENT_PLATFORM_DUMMY_BINARY_BAD BAD_DUMMY_BINARY_LINUX_64
#else
Expand All @@ -105,7 +105,7 @@
#endif
#endif
// Apple doesn't have 32 bit but this should allow tests to run as if it was supported
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__QNX__)
#define CURRENT_PLATFORM_DUMMY_BINARY_WRONG_TYPE DUMMY_BINARY_LINUX_32
#define CURRENT_PLATFORM_DUMMY_BINARY_BAD BAD_DUMMY_BINARY_LINUX_64
#endif
2 changes: 1 addition & 1 deletion tests/framework/shim/shim.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ extern "C" {
using PFN_get_platform_shim = PlatformShim* (*)(std::vector<fs::FolderManager>* folders);
#define GET_PLATFORM_SHIM_STR "get_platform_shim"

#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__GNU__)
#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__GNU__) || defined(__QNX__)
// statically link on linux
PlatformShim* get_platform_shim(std::vector<fs::FolderManager>* folders);
#endif
Expand Down
4 changes: 2 additions & 2 deletions tests/framework/shim/unix_shim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

PlatformShim platform_shim;
extern "C" {
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__GNU__)
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__GNU__) || defined(__QNX__)
PlatformShim* get_platform_shim(std::vector<fs::FolderManager>* folders) {
platform_shim = PlatformShim(folders);
return &platform_shim;
Expand All @@ -48,7 +48,7 @@ FRAMEWORK_EXPORT PlatformShim* get_platform_shim(std::vector<fs::FolderManager>*
#endif

// Necessary for MacOS function shimming
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__GNU__)
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__GNU__) || defined(__QNX__)
#define OPENDIR_FUNC_NAME opendir
#define READDIR_FUNC_NAME readdir
#define CLOSEDIR_FUNC_NAME closedir
Expand Down
6 changes: 4 additions & 2 deletions tests/framework/test_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,9 @@ inline std::string test_platform_executable_path() {
inline std::string test_platform_executable_path() { return {}; }
#elif defined(__QNX__)

#ifndef SYSCONFDIR
#define SYSCONFDIR "/etc"
#endif

#include <fcntl.h>
#include <sys/stat.h>
Expand All @@ -869,14 +871,14 @@ inline std::string test_platform_executable_path() {
std::string buffer;
buffer.resize(1024);
int fd = open("/proc/self/exefile", O_RDONLY);
size_t rdsize;
ssize_t rdsize;

if (fd == -1) {
return NULL;
}

rdsize = read(fd, &buffer[0], buffer.size());
if (rdsize == size) {
if (rdsize < 0) {
return NULL;
}
buffer[rdsize] = 0x00;
Expand Down

0 comments on commit 3a467c6

Please sign in to comment.