+halcaptive/perfcnt.c
authorshort <>
Fri, 31 Jan 2003 19:40:12 +0000 (19:40 +0000)
committershort <>
Fri, 31 Jan 2003 19:40:12 +0000 (19:40 +0000)
 - +KeQueryPerformanceCounter()

src/libcaptive/halcaptive/Makefile.am
src/libcaptive/halcaptive/perfcnt.c [new file with mode: 0644]

index 705439c..fb9e149 100644 (file)
@@ -22,4 +22,5 @@ include $(top_srcdir)/src/libcaptive/Makefile-libcaptive.am
 noinst_LTLIBRARIES=libhalcaptive.la
 libhalcaptive_la_SOURCES= \
                intrlck.c \
+               perfcnt.c \
                spinlock.c
diff --git a/src/libcaptive/halcaptive/perfcnt.c b/src/libcaptive/halcaptive/perfcnt.c
new file mode 100644 (file)
index 0000000..8db12a8
--- /dev/null
@@ -0,0 +1,54 @@
+/* $Id$
+ * reactos performance counters emulation of libcaptive
+ * Copyright (C) 2002 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; exactly version 2 of June 1991 is required
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#include "config.h"
+
+#include "reactos/ddk/kefuncs.h"       /* self */
+#include <sys/time.h>
+#include <glib/gmessages.h>
+
+
+/**
+ * KeQueryPerformanceCounter:
+ * @PerformanceFreq: Optionally returns the number of ticks per second.
+ * %NULL value is permitted.
+ *
+ * Reports the current system-wide timer value.
+ *
+ * Returns: Current system timer ticks count with unspecified base.
+ * You will want to subtract two such values to get some timing result.
+ */
+LARGE_INTEGER KeQueryPerformanceCounter(PLARGE_INTEGER PerformanceFreq)
+{
+LARGE_INTEGER  r;
+struct timeval tv;
+int errint;
+
+       errint=gettimeofday(
+                       &tv,    /* tv */
+                       NULL);  /* tz */
+       g_assert(errint==0);
+
+       r.QuadPart=((guint64)tv.tv_sec)*1000000+tv.tv_usec;
+
+       if (PerformanceFreq)
+               PerformanceFreq->QuadPart=1000000;
+
+       return r;
+}