[xorg-commit-diffs] xc/programs/xload get_load.c, 1.1.4.6, 1.1.4.7 get_rload.c, 1.1.4.1, 1.1.4.2

Egbert Eich xorg-commit at pdx.freedesktop.org
Thu Apr 15 03:17:54 PDT 2004


Committed by: eich

Update of /cvs/xorg/xc/programs/xload
In directory pdx:/home/eich/tstbuild/xc/programs/xload

Modified Files:
      Tag: XORG-CURRENT
	get_load.c get_rload.c 
Log Message:
2004-04-15  Egbert Eich  <eich at freedesktop.org>
        Merged changes from RELEASE-1 branch
	


Index: get_load.c
===================================================================
RCS file: /cvs/xorg/xc/programs/xload/get_load.c,v
retrieving revision 1.1.4.6
retrieving revision 1.1.4.7
diff -u -d -r1.1.4.6 -r1.1.4.7
--- a/get_load.c	5 Mar 2004 13:41:36 -0000	1.1.4.6
+++ b/get_load.c	15 Apr 2004 10:17:49 -0000	1.1.4.7
@@ -47,6 +47,61 @@
 #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
@@ -1169,3 +1224,4 @@
 #endif /* END OF DG/ux */
 
 
+#endif /* END of __CYGWIN__ */

Index: get_rload.c
===================================================================
RCS file: /cvs/xorg/xc/programs/xload/get_rload.c,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/get_rload.c	5 Mar 2004 13:41:36 -0000	1.1.4.1
+++ b/get_rload.c	15 Apr 2004 10:17:49 -0000	1.1.4.2
@@ -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
 




More information about the xorg-commit-diffs mailing list