2 // BUILD: $CC main.c -o $BUILD_DIR/versions.exe
8 #include <mach-o/dyld_priv.h>
10 extern struct mach_header __dso_handle
;
14 printf("[BEGIN] dyld_version_spi\n");
15 dyld_platform_t active
= dyld_get_active_platform();
16 dyld_platform_t base
= dyld_get_base_platform(active
);
17 dyld_build_version_t absoluteMin
= { .platform
= base
, .version
= 0 };
18 dyld_build_version_t absoluteMax
= { .platform
= base
, .version
= 0xffffffff };
21 if ( base
!= PLATFORM_MACOS
) {
22 printf("[FAIL] base.platform %u incorrect for macOS\n", base
);
26 if ( base
!= PLATFORM_IOS
) {
27 printf("[FAIL] base.platform %u incorrect for iOS\n", base
);
31 if ( base
!= PLATFORM_TVOS
) {
32 printf("[FAIL] base.platform %u incorrect for tvOS\n", base
);
35 #elif TARGET_OS_BRIDGE
36 if ( base
!= PLATFORM_BRIDGEOS
) {
37 printf("[FAIL] base.platform %u incorrect for wacthOS\n", base
);
41 if ( base
!= PLATFORM_WATCHOS
) {
42 printf("[FAIL] base.platform %u incorrect for bridgeOS\n", base
);
46 printf("[FAIL] Running on unknown platform\n");
50 #if TARGET_OS_SIMULATOR
51 if (dyld_is_simulator_platform(active
) != true) {
52 printf("[FAIL] active platform %u should be a simulator\n", active
);
56 if (dyld_is_simulator_platform(active
) == true) {
57 printf("[FAIL] active platform %u should not be a simulator\n", active
);
62 if (dyld_is_simulator_platform(base
) == true) {
63 printf("[FAIL] base platform %u should not be a simulator\n", base
);
67 if (!dyld_sdk_at_least(&__dso_handle
, absoluteMin
)) {
68 printf("[FAIL] executable sdk version should not < 1.0.0\n");
72 if (dyld_sdk_at_least(&__dso_handle
, absoluteMax
)) {
73 printf("[FAIL] executable sdk version should not > 65536.0.0\n");
77 if (!dyld_minos_at_least(&__dso_handle
, absoluteMin
)) {
78 printf("[FAIL] executable min version should not < 1.0.0\n");
82 if (dyld_minos_at_least(&__dso_handle
, absoluteMax
)) {
83 printf("[FAIL] executable min version should not > 65536.0.0\n");
87 printf("[PASS] dyld_version_spi\n");