summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--winsup/cygwin/autoload.cc4
-rw-r--r--winsup/cygwin/loadavg.cc40
2 files changed, 27 insertions, 17 deletions
diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc
index 056fac7dc..c4d91611e 100644
--- a/winsup/cygwin/autoload.cc
+++ b/winsup/cygwin/autoload.cc
@@ -755,8 +755,8 @@ LoadDLLfunc (WSASocketW, 24, ws2_32)
// LoadDLLfunc (WSAStartup, 8, ws2_32)
LoadDLLfunc (WSAWaitForMultipleEvents, 20, ws2_32)
-LoadDLLfunc (PdhAddEnglishCounterA, 16, pdh)
+LoadDLLfunc (PdhAddEnglishCounterW, 16, pdh)
LoadDLLfunc (PdhCollectQueryData, 4, pdh)
LoadDLLfunc (PdhGetFormattedCounterValue, 16, pdh)
-LoadDLLfunc (PdhOpenQueryA, 12, pdh)
+LoadDLLfunc (PdhOpenQueryW, 12, pdh)
}
diff --git a/winsup/cygwin/loadavg.cc b/winsup/cygwin/loadavg.cc
index bef80e13a..127591a2e 100644
--- a/winsup/cygwin/loadavg.cc
+++ b/winsup/cygwin/loadavg.cc
@@ -39,14 +39,7 @@
#include <math.h>
#include <time.h>
#include <sys/strace.h>
-
-/* Prototype for PdhAddEnglishCounterA in pdh.h under _WIN32_WINNT >= 0x0600 is
- missing WINAPI */
-#undef _WIN32_WINNT
#include <pdh.h>
-extern "C"
-PDH_FUNCTION PdhAddEnglishCounterA(PDH_HQUERY hQuery, LPCSTR szFullCounterPath,
- DWORD_PTR dwUserData, PDH_HCOUNTER *phCounter);
static PDH_HQUERY query;
static PDH_HCOUNTER counter1;
@@ -61,14 +54,31 @@ static bool load_init (void)
if (!tried) {
tried = true;
- if (!((PdhOpenQueryA (NULL, 0, &query) == ERROR_SUCCESS) &&
- (PdhAddEnglishCounterA (query, "\\Processor(_Total)\\% Processor Time",
- 0, &counter1) == ERROR_SUCCESS) &&
- (PdhAddEnglishCounterA (query, "\\System\\Processor Queue Length",
- 0, &counter2) == ERROR_SUCCESS))) {
- debug_printf("loadavg PDH initialization failed\n");
- return false;
- }
+ PDH_STATUS status;
+
+ status = PdhOpenQueryW (NULL, 0, &query);
+ if (status != STATUS_SUCCESS)
+ {
+ debug_printf ("PdhOpenQueryW, status %y", status);
+ return false;
+ }
+ status = PdhAddEnglishCounterW (query,
+ L"\\Processor(_Total)\\% Processor Time",
+ 0, &counter1);
+ if (status != STATUS_SUCCESS)
+ {
+ debug_printf ("PdhAddEnglishCounterW(time), status %y", status);
+ return false;
+ }
+ status = PdhAddEnglishCounterW (query,
+ L"\\System\\Processor Queue Length",
+ 0, &counter2);
+
+ if (status != STATUS_SUCCESS)
+ {
+ debug_printf ("PdhAddEnglishCounterW(queue length), status %y", status);
+ return false;
+ }
mutex = CreateMutex(&sec_all_nih, FALSE, "cyg.loadavg.mutex");
if (!mutex) {