From f74edc7a9e0494657c36f34208141f6a2aa3e1f9 Mon Sep 17 00:00:00 2001 From: Egbert Eich Date: Fri, 23 Apr 2004 19:54:57 +0000 Subject: Merging XORG-CURRENT into trunk --- get_load.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- get_rload.c | 4 ++-- xload.c | 2 +- xload.h | 2 +- xload.man | 2 +- 5 files changed, 64 insertions(+), 7 deletions(-) diff --git a/get_load.c b/get_load.c index 015cf5f..ce7ce79 100644 --- a/get_load.c +++ b/get_load.c @@ -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 #include "xload.h" +#if defined(__CYGWIN__) +#include +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__ */ diff --git a/get_rload.c b/get_rload.c index 0ff77b4..9629d01 100644 --- a/get_rload.c +++ b/get_rload.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/xload/get_rload.c,v 1.5 2002/01/07 21:46:49 dawes Exp $ */ +/* $XFree86: xc/programs/xload/get_rload.c,v 1.4 2002/01/07 20:38:31 dawes Exp $ */ #include #include @@ -10,7 +10,7 @@ /* Not all OS supports get_rload steal the STUB idea from get_load */ -#if defined(QNX4) +#if defined(QNX4) || defined(__CYGWIN__) #define RLOADSTUB #endif diff --git a/xload.c b/xload.c index 60ce080..65595f0 100644 --- a/xload.c +++ b/xload.c @@ -1,5 +1,5 @@ /* $XConsortium: xload.c,v 1.37 94/04/17 20:43:44 converse Exp $ */ -/* $XFree86: xc/programs/xload/xload.c,v 1.7 2002/09/18 17:11:57 tsi Exp $ */ +/* $XFree86: xc/programs/xload/xload.c,v 1.6tsi Exp $ */ /* Copyright (c) 1989 X Consortium diff --git a/xload.h b/xload.h index 300c8e4..d32383c 100644 --- a/xload.h +++ b/xload.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/xload/xload.h,v 1.2 2001/08/28 17:10:39 tsi Exp $ */ +/* $XFree86: xc/programs/xload/xload.h,v 1.1 2001/08/27 23:35:14 dawes Exp $ */ #ifndef _XLOAD_H_ #define _XLOAD_H_ diff --git a/xload.man b/xload.man index e94911c..4da1e77 100644 --- a/xload.man +++ b/xload.man @@ -1,6 +1,6 @@ .\" $XConsortium: xload.man,v 1.29 94/04/17 20:43:44 matt Exp $ .\" -.\" $XFree86: xc/programs/xload/xload.man,v 1.5 2002/10/12 16:06:48 herrb Exp $ +.\" $XFree86: xc/programs/xload/xload.man,v 1.4 2001/08/13 19:35:01 dawes Exp $ .\" .TH XLOAD 1 __xorgversion__ .SH NAME -- cgit v1.2.3