[prev in list] [next in list] [prev in thread] [next in thread]
List: wine-devel
Subject: [PATCH 1/7] ntdll: implement setting SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION.IdleTime on FreeBSD
From: Damjan Jovanovic <damjan.jov () gmail ! com>
Date: 2021-10-31 15:47:26
Message-ID: CAJm2B-kmQ9pQj6dTA6m1=btKK3hMsJmBEZ+j7GHCZf-uyaueAw () mail ! gmail ! com
[Download RAW message or body]
Signed-off-by: Damjan Jovanovic <damjan.jov@gmail.com>
---
dlls/ntdll/unix/system.c | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
["0001-ntdll-implement-setting-SYSTEM_PROCESSOR_PERFORMANCE_I.txt" (text/plain)]
diff --git a/dlls/ntdll/unix/system.c b/dlls/ntdll/unix/system.c
index c37fc360f3e..6640a66597b 100644
--- a/dlls/ntdll/unix/system.c
+++ b/dlls/ntdll/unix/system.c
@@ -52,6 +52,9 @@
#ifdef HAVE_SYS_RANDOM_H
# include <sys/random.h>
#endif
+#ifdef HAVE_SYS_RESOURCE_H
+# include <sys/resource.h>
+#endif
#ifdef HAVE_IOKIT_IOKITLIB_H
# include <CoreFoundation/CoreFoundation.h>
# include <IOKit/IOKitLib.h>
@@ -2611,7 +2614,7 @@ NTSTATUS WINAPI NtQuerySystemInformation( \
SYSTEM_INFORMATION_CLASS class,
vm_deallocate (mach_task_self (), (vm_address_t) pinfo, info_count * \
sizeof(natural_t)); }
}
-#else
+#elif defined(linux)
{
FILE *cpuinfo = fopen("/proc/stat", "r");
if (cpuinfo)
@@ -2644,6 +2647,33 @@ NTSTATUS WINAPI NtQuerySystemInformation( \
SYSTEM_INFORMATION_CLASS class, fclose(cpuinfo);
}
}
+#elif defined(__FreeBSD__) || defined (__FreeBSD_kernel__)
+ {
+ static int clockrate_name[] = { CTL_KERN, KERN_CLOCKRATE };
+ size_t size = 0;
+ struct clockinfo clockrate;
+ int have_clockrate;
+ long *ptimes;
+
+ size = sizeof(clockrate);
+ have_clockrate = !sysctl(clockrate_name, 2, &clockrate, &size, NULL, 0);
+ size = out_cpus * CPUSTATES * sizeof(long);
+ ptimes = malloc(size + 1);
+ if (ptimes)
+ {
+ if (have_clockrate && (!sysctlbyname("kern.cp_times", ptimes, &size, \
NULL, 0) || errno == ENOMEM)) + {
+ for (cpus = 0; cpus < out_cpus; cpus++)
+ {
+ if (cpus * CPUSTATES * sizeof(long) >= size) break;
+ sppi[cpus].IdleTime.QuadPart = \
(ULONGLONG)ptimes[cpus*CPUSTATES + CP_IDLE] * 10000000 / clockrate.stathz; + \
sppi[cpus].KernelTime.QuadPart = (ULONGLONG)ptimes[cpus*CPUSTATES + CP_SYS] * \
10000000 / clockrate.stathz; + sppi[cpus].UserTime.QuadPart = \
(ULONGLONG)ptimes[cpus*CPUSTATES + CP_USER] * 10000000 / clockrate.stathz; + \
} + }
+ free(ptimes);
+ }
+ }
#endif
if (cpus == 0)
{
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic