This repository has been archived by the owner on Oct 19, 2024. It is now read-only.
forked from Code-Hex/vz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
virtualization_helper.h
73 lines (60 loc) · 2.04 KB
/
virtualization_helper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#pragma once
#import <Availability.h>
#import <Foundation/Foundation.h>
NSDictionary *dumpProcessinfo();
#define RAISE_REASON_MESSAGE \
"This may possibly be a bug due to library handling errors.\n" \
"I would appreciate it if you could report it to https://github.com/lima-vm/vz/issues/new/choose\n\n" \
"Information: %@\n"
#define RAISE_UNSUPPORTED_MACOS_EXCEPTION() \
do { \
[NSException \
raise:@"UnhandledAvailabilityException" \
format:@RAISE_REASON_MESSAGE, dumpProcessinfo()]; \
__builtin_unreachable(); \
} while (0)
// for macOS 12.3 API
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 120300
#define INCLUDE_TARGET_OSX_12_3 1
#else
#pragma message("macOS 12.3 API has been disabled")
#endif
// for macOS 13 API
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 130000
#define INCLUDE_TARGET_OSX_13 1
#else
#pragma message("macOS 13 API has been disabled")
#endif
// for macOS 14 API
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 140000
#define INCLUDE_TARGET_OSX_14 1
#else
#pragma message("macOS 14 API has been disabled")
#endif
// for macOS 15 API
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 150000
#define INCLUDE_TARGET_OSX_15 1
#else
#pragma message("macOS 15 API has been disabled")
#endif
static inline int mac_os_x_version_max_allowed()
{
#ifdef __MAC_OS_X_VERSION_MAX_ALLOWED
return __MAC_OS_X_VERSION_MAX_ALLOWED;
#else
return 0;
#endif
}
typedef struct nbyteslice {
void *ptr;
int len;
} nbyteslice;
/* exported from cgo */
void virtualMachineCompletionHandler(uintptr_t cgoHandle, void *errPtr);
typedef void (^vm_completion_handler_t)(NSError *);
static inline vm_completion_handler_t makeVMCompletionHandler(uintptr_t cgoHandle)
{
return Block_copy(^(NSError *err) {
virtualMachineCompletionHandler(cgoHandle, err);
});
}