From ee423cfae1248053db3da109024e459843d5ad6e Mon Sep 17 00:00:00 2001 From: Giovanni Petrantoni <7008900+sinkingsugar@users.noreply.github.com> Date: Mon, 30 Dec 2024 22:26:38 +0900 Subject: [PATCH] Enhance VisionOS compatibility by adding missing type definitions in common and ggml source files. This update includes conditional type definitions for `u_int`, `u_char`, `u_short`, and `uint` to address legacy type issues on VisionOS across multiple files: common.cpp, ggml-backend.cpp, ggml-cpu.c, ggml-cpu.cpp, and ggml-metal.m. --- common/common.cpp | 7 +++++++ ggml/src/ggml-backend.cpp | 7 +++++++ ggml/src/ggml-cpu/ggml-cpu.c | 7 +++++++ ggml/src/ggml-cpu/ggml-cpu.cpp | 7 +++++++ ggml/src/ggml-metal/ggml-metal.m | 6 ++++++ 5 files changed, 34 insertions(+) diff --git a/common/common.cpp b/common/common.cpp index 20be92911..ce7ae61ad 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -30,6 +30,13 @@ #include #if defined(__APPLE__) && defined(__MACH__) +#include +#if defined(TARGET_OS_VISION) && TARGET_OS_VISION +// VisionOS lacks some legacy types definitions +typedef unsigned int u_int; +typedef unsigned char u_char; +typedef unsigned short u_short; +#endif #include #include #endif diff --git a/ggml/src/ggml-backend.cpp b/ggml/src/ggml-backend.cpp index fdb4b986f..ce7d3dfa0 100644 --- a/ggml/src/ggml-backend.cpp +++ b/ggml/src/ggml-backend.cpp @@ -23,6 +23,13 @@ #include #ifdef __APPLE__ +#include +#if defined(TARGET_OS_VISION) && TARGET_OS_VISION +// VisionOS lacks some legacy types definitions +typedef unsigned int u_int; +typedef unsigned char u_char; +typedef unsigned short u_short; +#endif #include #include #endif diff --git a/ggml/src/ggml-cpu/ggml-cpu.c b/ggml/src/ggml-cpu/ggml-cpu.c index b7fefb9dd..568e1eb02 100644 --- a/ggml/src/ggml-cpu/ggml-cpu.c +++ b/ggml/src/ggml-cpu/ggml-cpu.c @@ -2382,6 +2382,13 @@ bool ggml_is_numa(void) { #if defined(__linux__) && defined(__aarch64__) #include #elif defined(__APPLE__) +#include +#if defined(TARGET_OS_VISION) && TARGET_OS_VISION +// VisionOS lacks some legacy types definitions +typedef unsigned int u_int; +typedef unsigned char u_char; +typedef unsigned short u_short; +#endif #include #endif diff --git a/ggml/src/ggml-cpu/ggml-cpu.cpp b/ggml/src/ggml-cpu/ggml-cpu.cpp index f11399cc6..a49c173db 100644 --- a/ggml/src/ggml-cpu/ggml-cpu.cpp +++ b/ggml/src/ggml-cpu/ggml-cpu.cpp @@ -15,6 +15,13 @@ #endif #if defined(__APPLE__) +#include +#if defined(TARGET_OS_VISION) && TARGET_OS_VISION +// VisionOS lacks some legacy types definitions +typedef unsigned int u_int; +typedef unsigned char u_char; +typedef unsigned short u_short; +#endif #include #include #endif diff --git a/ggml/src/ggml-metal/ggml-metal.m b/ggml/src/ggml-metal/ggml-metal.m index 28f590f92..ef03124ca 100644 --- a/ggml/src/ggml-metal/ggml-metal.m +++ b/ggml/src/ggml-metal/ggml-metal.m @@ -8,6 +8,12 @@ #import +#include +#if defined(TARGET_OS_VISION) && TARGET_OS_VISION +// VisionOS lacks some legacy types definitions, stdint.h did not help either +typedef unsigned int uint; +#endif + #undef MIN #undef MAX #define MIN(a, b) ((a) < (b) ? (a) : (b))