Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2001-02-27 01:36:09 +0300
committerChristopher Faylor <me@cgf.cx>2001-02-27 01:36:09 +0300
commit5b331f1ef18682349a65af219c987fe827246531 (patch)
tree7ab2e3b9cfbebee9ce77828be4fea1626294f03d /winsup/cygwin/times.cc
parent88429768bb3cc21d871e912cde3efaf92eec8213 (diff)
* times.cc (settimeofday): Replace function stub with working code.
Diffstat (limited to 'winsup/cygwin/times.cc')
-rw-r--r--winsup/cygwin/times.cc26
1 files changed, 23 insertions, 3 deletions
diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc
index 790291248..0681b4064 100644
--- a/winsup/cygwin/times.cc
+++ b/winsup/cygwin/times.cc
@@ -17,6 +17,7 @@ details. */
#include <stdlib.h>
#include <errno.h>
#include "cygerrno.h"
+#include "perprocess.h"
#include "fhandler.h"
#include "path.h"
#include "sync.h"
@@ -92,10 +93,29 @@ _times (struct tms * buf)
/* settimeofday: BSD */
extern "C" int
-settimeofday (const struct timeval *, const struct timezone *)
+settimeofday (const struct timeval *tv, const struct timezone *tz)
{
- set_errno (ENOSYS);
- return -1;
+ SYSTEMTIME st;
+ struct tm *ptm;
+ int res;
+
+ tz = tz; /* silence warning about unused variable */
+
+ ptm = gmtime(&tv->tv_sec);
+ st.wYear = ptm->tm_year + 1900;
+ st.wMonth = ptm->tm_mon + 1;
+ st.wDayOfWeek = ptm->tm_wday;
+ st.wDay = ptm->tm_mday;
+ st.wHour = ptm->tm_hour;
+ st.wMinute = ptm->tm_min;
+ st.wSecond = ptm->tm_sec;
+ st.wMilliseconds = tv->tv_usec / 1000;
+
+ res = !SetSystemTime(&st);
+
+ syscall_printf ("%d = settimeofday (%x, %x)", res, tv, tz);
+
+ return res;
}
/* timezone: standards? */