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.

This commit is contained in:
Giovanni Petrantoni 2024-12-30 22:26:38 +09:00
parent c250ecb315
commit ee423cfae1
5 changed files with 34 additions and 0 deletions

View file

@ -30,6 +30,13 @@
#include <vector> #include <vector>
#if defined(__APPLE__) && defined(__MACH__) #if defined(__APPLE__) && defined(__MACH__)
#include <TargetConditionals.h>
#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 <sys/types.h> #include <sys/types.h>
#include <sys/sysctl.h> #include <sys/sysctl.h>
#endif #endif

View file

@ -23,6 +23,13 @@
#include <vector> #include <vector>
#ifdef __APPLE__ #ifdef __APPLE__
#include <TargetConditionals.h>
#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 <sys/types.h> #include <sys/types.h>
#include <sys/sysctl.h> #include <sys/sysctl.h>
#endif #endif

View file

@ -2382,6 +2382,13 @@ bool ggml_is_numa(void) {
#if defined(__linux__) && defined(__aarch64__) #if defined(__linux__) && defined(__aarch64__)
#include <sys/auxv.h> #include <sys/auxv.h>
#elif defined(__APPLE__) #elif defined(__APPLE__)
#include <TargetConditionals.h>
#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 <sys/sysctl.h> #include <sys/sysctl.h>
#endif #endif

View file

@ -15,6 +15,13 @@
#endif #endif
#if defined(__APPLE__) #if defined(__APPLE__)
#include <TargetConditionals.h>
#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 <sys/types.h> #include <sys/types.h>
#include <sys/sysctl.h> #include <sys/sysctl.h>
#endif #endif

View file

@ -8,6 +8,12 @@
#import <Metal/Metal.h> #import <Metal/Metal.h>
#include <TargetConditionals.h>
#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 MIN
#undef MAX #undef MAX
#define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b))