Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / ACE / apps / JAWS / clients / WebSTONE / src / gettimeofday.c
blobf5092182a00c2fd5c597671bdf3265bd64c62118
1 /*
2 * This file defines functions that are required for unix compatibility.
4 * These functions are not available in the Microsoft C/C++ Run Time
5 * and the Win32 API.
7 * The following functions list may not be complete
9 * FUNCTIONS:
10 * SHARED _gettimeofday
14 #include <windows.h>
15 #include <errno.h>
16 #include <winsock.h> /* For definition of "timeval" structure */
17 #include <sys/timeb.h> /* For prototype of "_ftime()" */
21 * gettimeofday() -- gets the current time in elapsed seconds and
22 * microsends since GMT Jan 1, 1970.
24 * ARGUMENTS: - Pointer to a timeval struct to return the time into
26 * RETURN CODES: - 0 on success
27 * -1 on failure
29 int gettimeofday(curTimeP)
30 struct timeval *curTimeP;
32 struct _timeb localTime;
34 if (curTimeP == (struct timeval *) 0)
36 errno = EFAULT;
37 return (-1);
41 * Compute the elapsed time since Jan 1, 1970 by first
42 * obtaining the elapsed time from the system using the
43 * _ftime(..) call and then convert to the "timeval"
44 * equivalent.
47 _ftime(&localTime);
49 curTimeP->tv_sec = localTime.time + localTime.timezone;
50 curTimeP->tv_usec = localTime.millitm * 1000;
52 return(0);