aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/builtins/os_version_check.c
diff options
context:
space:
mode:
authororivej <orivej@yandex-team.ru>2022-02-10 16:44:49 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:49 +0300
commit718c552901d703c502ccbefdfc3c9028d608b947 (patch)
tree46534a98bbefcd7b1f3faa5b52c138ab27db75b7 /contrib/libs/cxxsupp/builtins/os_version_check.c
parente9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (diff)
downloadydb-718c552901d703c502ccbefdfc3c9028d608b947.tar.gz
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/cxxsupp/builtins/os_version_check.c')
-rw-r--r--contrib/libs/cxxsupp/builtins/os_version_check.c84
1 files changed, 42 insertions, 42 deletions
diff --git a/contrib/libs/cxxsupp/builtins/os_version_check.c b/contrib/libs/cxxsupp/builtins/os_version_check.c
index a3cb63886d..6df8ba3c5b 100644
--- a/contrib/libs/cxxsupp/builtins/os_version_check.c
+++ b/contrib/libs/cxxsupp/builtins/os_version_check.c
@@ -27,19 +27,19 @@
static int32_t GlobalMajor, GlobalMinor, GlobalSubminor;
static dispatch_once_t DispatchOnceCounter;
-// _availability_version_check darwin API support.
-typedef uint32_t dyld_platform_t;
-
-typedef struct {
- dyld_platform_t platform;
- uint32_t version;
-} dyld_build_version_t;
-
-typedef bool (*AvailabilityVersionCheckFuncTy)(uint32_t count,
- dyld_build_version_t versions[]);
-
-static AvailabilityVersionCheckFuncTy AvailabilityVersionCheck;
-
+// _availability_version_check darwin API support.
+typedef uint32_t dyld_platform_t;
+
+typedef struct {
+ dyld_platform_t platform;
+ uint32_t version;
+} dyld_build_version_t;
+
+typedef bool (*AvailabilityVersionCheckFuncTy)(uint32_t count,
+ dyld_build_version_t versions[]);
+
+static AvailabilityVersionCheckFuncTy AvailabilityVersionCheck;
+
/* We can't include <CoreFoundation/CoreFoundation.h> directly from here, so
* just forward declare everything that we need from it. */
@@ -88,15 +88,15 @@ typedef Boolean (*CFStringGetCStringFuncTy)(CFStringRef, char *, CFIndex,
typedef void (*CFReleaseFuncTy)(CFTypeRef);
/* Find and parse the SystemVersion.plist file. */
-static void initializeAvailabilityCheck(void *Unused) {
+static void initializeAvailabilityCheck(void *Unused) {
(void)Unused;
-
- // Use the new API if it's is available. Still load the PLIST to ensure that the
- // existing calls to __isOSVersionAtLeast still work even with new
- // compiler-rt and new OSes.
- AvailabilityVersionCheck = (AvailabilityVersionCheckFuncTy)dlsym(
- RTLD_DEFAULT, "_availability_version_check");
-
+
+ // Use the new API if it's is available. Still load the PLIST to ensure that the
+ // existing calls to __isOSVersionAtLeast still work even with new
+ // compiler-rt and new OSes.
+ AvailabilityVersionCheck = (AvailabilityVersionCheckFuncTy)dlsym(
+ RTLD_DEFAULT, "_availability_version_check");
+
/* Load CoreFoundation dynamically */
const void *NullAllocator = dlsym(RTLD_DEFAULT, "kCFAllocatorNull");
if (!NullAllocator)
@@ -223,12 +223,12 @@ Fail:
fclose(PropertyList);
}
-// This old API entry point is no longer used by Clang. We still need to keep it
-// around to ensure that object files that reference it are still usable when
-// linked with new compiler-rt.
+// This old API entry point is no longer used by Clang. We still need to keep it
+// around to ensure that object files that reference it are still usable when
+// linked with new compiler-rt.
int32_t __isOSVersionAtLeast(int32_t Major, int32_t Minor, int32_t Subminor) {
/* Populate the global version variables, if they haven't already. */
- dispatch_once_f(&DispatchOnceCounter, NULL, initializeAvailabilityCheck);
+ dispatch_once_f(&DispatchOnceCounter, NULL, initializeAvailabilityCheck);
if (Major < GlobalMajor)
return 1;
@@ -241,23 +241,23 @@ int32_t __isOSVersionAtLeast(int32_t Major, int32_t Minor, int32_t Subminor) {
return Subminor <= GlobalSubminor;
}
-static inline uint32_t ConstructVersion(uint32_t Major, uint32_t Minor,
- uint32_t Subminor) {
- return ((Major & 0xffff) << 16) | ((Minor & 0xff) << 8) | (Subminor & 0xff);
-}
-
-int32_t __isPlatformVersionAtLeast(uint32_t Platform, uint32_t Major,
- uint32_t Minor, uint32_t Subminor) {
- dispatch_once_f(&DispatchOnceCounter, NULL, initializeAvailabilityCheck);
-
- if (!AvailabilityVersionCheck) {
- return __isOSVersionAtLeast(Major, Minor, Subminor);
- }
- dyld_build_version_t Versions[] = {
- {Platform, ConstructVersion(Major, Minor, Subminor)}};
- return AvailabilityVersionCheck(1, Versions);
-}
-
+static inline uint32_t ConstructVersion(uint32_t Major, uint32_t Minor,
+ uint32_t Subminor) {
+ return ((Major & 0xffff) << 16) | ((Minor & 0xff) << 8) | (Subminor & 0xff);
+}
+
+int32_t __isPlatformVersionAtLeast(uint32_t Platform, uint32_t Major,
+ uint32_t Minor, uint32_t Subminor) {
+ dispatch_once_f(&DispatchOnceCounter, NULL, initializeAvailabilityCheck);
+
+ if (!AvailabilityVersionCheck) {
+ return __isOSVersionAtLeast(Major, Minor, Subminor);
+ }
+ dyld_build_version_t Versions[] = {
+ {Platform, ConstructVersion(Major, Minor, Subminor)}};
+ return AvailabilityVersionCheck(1, Versions);
+}
+
#else
/* Silence an empty translation unit warning. */