1// RUN: %clang %s -o %t -mmacosx-version-min=10.7 -framework CoreFoundation -DMAJOR=%macos_version_major -DMINOR=%macos_version_minor -DSUBMINOR=%macos_version_subminor
2// RUN: %run %t
3
4typedef int int32_t;
5typedef unsigned int uint32_t;
6
7int32_t __isPlatformVersionAtLeast(uint32_t Platform, uint32_t Major,
8 uint32_t Minor, uint32_t Subminor);
9
10#define PLATFORM_MACOS 1
11
12int32_t check(uint32_t Major, uint32_t Minor, uint32_t Subminor) {
13 int32_t Result =
14 __isPlatformVersionAtLeast(PLATFORM_MACOS, Major, Minor, Subminor);
15 return Result;
16}
17
18int main() {
19 if (!check(MAJOR, MINOR, SUBMINOR))
20 return 1;
21 if (check(MAJOR, MINOR, SUBMINOR + 1))
22 return 1;
23 if (SUBMINOR && check(MAJOR + 1, MINOR, SUBMINOR - 1))
24 return 1;
25 if (SUBMINOR && !check(MAJOR, MINOR, SUBMINOR - 1))
26 return 1;
27 if (MAJOR && !check(MAJOR - 1, MINOR + 1, SUBMINOR))
28 return 1;
29
30 return 0;
31}
32

source code of compiler-rt/test/builtins/TestCases/Darwin/platform_version_check_test.c