Merge commit '7621e2f8dec938cf48181c8b10afc9b01f444e68' into beta

This commit is contained in:
Ilya Laktyushin
2025-12-06 02:17:48 +04:00
commit 8344b97e03
28070 changed files with 7995182 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
objc_library(
name = "MonotonicTime",
enable_modules = True,
module_name = "MonotonicTime",
srcs = glob([
"Sources/*.m",
"Sources/*.h",
], allow_empty=True),
hdrs = glob([
"PublicHeaders/**/*.h",
]),
includes = [
"PublicHeaders",
],
sdk_frameworks = [
"Foundation",
],
visibility = [
"//visibility:public",
],
)
@@ -0,0 +1,3 @@
#import <Foundation/Foundation.h>
int32_t getDeviceUptimeSeconds(int32_t *bootTime);
@@ -0,0 +1,22 @@
#import <MonotonicTime/DeviceUptime.h>
#include <sys/sysctl.h>
int32_t getDeviceUptimeSeconds(int32_t *bootTime) {
struct timeval boottime;
int mib[2] = {CTL_KERN, KERN_BOOTTIME};
size_t size = sizeof(boottime);
time_t now;
time_t uptime = -1;
(void)time(&now);
if (sysctl(mib, 2, &boottime, &size, NULL, 0) != -1 && boottime.tv_sec != 0) {
uptime = now - boottime.tv_sec;
if (bootTime != NULL) {
*bootTime = boottime.tv_sec;
}
}
return uptime;
}