summaryrefslogtreecommitdiff
path: root/ACE/apps/JAWS/clients/WebSTONE/src/gettimeofday.c
diff options
context:
space:
mode:
Diffstat (limited to 'ACE/apps/JAWS/clients/WebSTONE/src/gettimeofday.c')
-rw-r--r--ACE/apps/JAWS/clients/WebSTONE/src/gettimeofday.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/ACE/apps/JAWS/clients/WebSTONE/src/gettimeofday.c b/ACE/apps/JAWS/clients/WebSTONE/src/gettimeofday.c
new file mode 100644
index 00000000000..7c685ad90c5
--- /dev/null
+++ b/ACE/apps/JAWS/clients/WebSTONE/src/gettimeofday.c
@@ -0,0 +1,57 @@
+/* $Id$ */
+
+/*
+ * This file defines functions that are required for unix compatibility.
+ *
+ * These functions are not available in the Microsoft C/C++ Run Time
+ * and the Win32 API.
+ *
+ * The following functions list may not be complete
+ *
+ * FUNCTIONS:
+ * SHARED _gettimeofday
+ *
+ */
+
+
+#include <windows.h>
+#include <errno.h>
+#include <winsock.h> /* For definition of "timeval" structure */
+#include <sys/timeb.h> /* For prototype of "_ftime()" */
+
+
+/*
+ * gettimeofday() -- gets the current time in elapsed seconds and
+ * microsends since GMT Jan 1, 1970.
+ *
+ * ARGUMENTS: - Pointer to a timeval struct to return the time into
+ *
+ * RETURN CODES: - 0 on success
+ * -1 on failure
+ */
+int gettimeofday(curTimeP)
+ struct timeval *curTimeP;
+{
+struct _timeb localTime;
+
+ if (curTimeP == (struct timeval *) NULL) {
+ errno = EFAULT;
+ return (-1);
+ }
+
+ /*
+ * Compute the elapsed time since Jan 1, 1970 by first
+ * obtaining the elapsed time from the system using the
+ * _ftime(..) call and then convert to the "timeval"
+ * equivalent.
+ */
+
+ _ftime(&localTime);
+
+ curTimeP->tv_sec = localTime.time + localTime.timezone;
+ curTimeP->tv_usec = localTime.millitm * 1000;
+
+ return(0);
+}
+
+