diff options
author | Egbert Eich <eich@suse.de> | 2004-04-23 19:54:57 +0000 |
---|---|---|
committer | Egbert Eich <eich@suse.de> | 2004-04-23 19:54:57 +0000 |
commit | f74edc7a9e0494657c36f34208141f6a2aa3e1f9 (patch) | |
tree | 45b4fd079529d24635060a59882afe855d112b80 /get_load.c | |
parent | cc45a7487b867b181a5615eef75519d22f91d4f8 (diff) |
Merging XORG-CURRENT into trunkxprint_packagertest_20041217_basexprint_packagertest_20041125_basesco_port_update-baserel-0-6-1lg3d-rel-0-7-0lg3d-rel-0-6-2lg3d-baseXORG-6_8_99_9XORG-6_8_99_8XORG-6_8_99_7XORG-6_8_99_6XORG-6_8_99_5XORG-6_8_99_4XORG-6_8_99_3XORG-6_8_99_2XORG-6_8_99_16XORG-6_8_99_15XORG-6_8_99_14XORG-6_8_99_13XORG-6_8_99_12XORG-6_8_99_11XORG-6_8_99_10XORG-6_8_99_1XORG-6_8_2XORG-6_8_1_904XORG-6_8_1_903XORG-6_8_1_902XORG-6_8_1_901XORG-6_8_1XORG-6_8_0XORG-6_7_99_904XORG-6_7_99_903XORG-6_7_99_902XORG-6_7_99_901XORG-6_7_99_2XORG-6_7_99_1XACE-SELINUX-MERGExprint_packagertest_20041217xprint_packagertest_20041125sco_port_updatelg3d-masterlg3d-eventlg3d-dev-0-7-1lg3d-dev-0-7-0lg3d-dev-0-6-latestlg3d-dev-0-6-2lg3d-dev-0-6-1-latestlg3d-dev-0-6-1-currentlg3d-dev-0-6-1-1lg3d-dev-0-6-1lg3dXORG-6_8-branchCOMPOSITEWRAP
Diffstat (limited to 'get_load.c')
-rw-r--r-- | get_load.c | 61 |
1 files changed, 59 insertions, 2 deletions
@@ -1,5 +1,6 @@ +/* $XdotOrg$ */ /* $XConsortium: get_load.c /main/37 1996/03/09 09:38:04 kaleb $ */ -/* $XFree86: xc/programs/xload/get_load.c,v 1.22 2003/12/22 17:48:13 tsi Exp $ */ +/* $XFree86: xc/programs/xload/get_load.c,v 1.21tsi Exp $ */ /* Copyright (c) 1989 X Consortium @@ -46,6 +47,61 @@ from the X Consortium. #include <stdlib.h> #include "xload.h" +#if defined(__CYGWIN__) +#include <windows.h> +typedef struct { + DWORD stat; + union { + LONG vLong; + double vDouble; + LONGLONG vLongLong; + void *string; + } u; +} COUNTER; +static HANDLE query; +static HANDLE counter; +static HINSTANCE hdll; +static long (__stdcall *pdhopen)(LPCSTR, DWORD, HANDLE); +static long (__stdcall *pdhaddcounter)(HANDLE, LPCSTR, DWORD, HANDLE*); +static long (__stdcall *pdhcollectquerydata)(HANDLE); +static long (__stdcall *pdhgetformattedcountervalue)(HANDLE, DWORD, LPDWORD, COUNTER*); +#define CYGWIN_PERF +void InitLoadPoint() +{ + long ret; + hdll=LoadLibrary("pdh.dll"); + if (!hdll) exit(-1); + pdhopen=(void*)GetProcAddress(hdll, "PdhOpenQueryA"); + if (!pdhopen) exit(-1); + pdhaddcounter=(void*)GetProcAddress(hdll, "PdhAddCounterA"); + if (!pdhaddcounter) exit(-1); + pdhcollectquerydata=(void*)GetProcAddress(hdll, "PdhCollectQueryData"); + if (!pdhcollectquerydata) exit(-1); + pdhgetformattedcountervalue=(void*)GetProcAddress(hdll, "PdhGetFormattedCounterValue"); + if (!pdhgetformattedcountervalue) exit(-1); + ret = pdhopen( NULL , 0, &query ); + if (ret!=0) exit(-1); + ret = pdhaddcounter(query, "\\Processor(_Total)\\% Processor Time", 0, &counter); + if (ret!=0) exit(-1); +} +void GetLoadPoint( w, closure, call_data ) /* SYSV386 version */ + Widget w; /* unused */ + XtPointer closure; /* unused */ + XtPointer call_data; /* pointer to (double) return value */ +{ + double *loadavg = (double *)call_data; + COUNTER fmtvalue; + long ret; + *loadavg = 0.0; + ret = pdhcollectquerydata(query); + if (ret!=0) return; + ret = pdhgetformattedcountervalue(counter, 0x200, NULL, &fmtvalue); + if (ret!=0) return; + *loadavg = (fmtvalue.u.vDouble-0.01)/100.0; +} +#else + + #if !defined(DGUX) #if defined(att) || defined(QNX4) #define LOADSTUB @@ -859,7 +915,7 @@ void InitLoadPoint() } #else /* sun svr4 5.5 or later */ -#if (!defined(SVR4)) && !defined(sgi) && !defined(MOTOROLA) && !(BSD >= 199103) +#if !defined(SVR4) && !defined(sgi) && !defined(MOTOROLA) && !defined(AIXV5) && !(BSD >= 199103) extern void nlist(); #endif @@ -1168,3 +1224,4 @@ getloadavg (double loadavg[], int nelem) #endif /* END OF DG/ux */ +#endif /* END of __CYGWIN__ */ |