summaryrefslogtreecommitdiff
path: root/usr/src/lib/libresolv2/common/bsd/gettimeofday.c
diff options
context:
space:
mode:
authorRao Shoaib <Rao.Shoaib@Sun.COM>2009-11-11 08:45:41 -0800
committerRao Shoaib <Rao.Shoaib@Sun.COM>2009-11-11 08:45:41 -0800
commit9525b14bcdeb5b5f6f95ab27c2f48f18bd2ec829 (patch)
treedf51891a276edf456c1481f49653a76cdfedee53 /usr/src/lib/libresolv2/common/bsd/gettimeofday.c
parent0324f02a004039d6377111191fdd7134452d7817 (diff)
downloadillumos-gate-9525b14bcdeb5b5f6f95ab27c2f48f18bd2ec829.tar.gz
6289479 libresolv2 clean up and alignment with libbind.6.0
Diffstat (limited to 'usr/src/lib/libresolv2/common/bsd/gettimeofday.c')
-rw-r--r--usr/src/lib/libresolv2/common/bsd/gettimeofday.c47
1 files changed, 37 insertions, 10 deletions
diff --git a/usr/src/lib/libresolv2/common/bsd/gettimeofday.c b/usr/src/lib/libresolv2/common/bsd/gettimeofday.c
index 68b5ca39a0..2926a3575e 100644
--- a/usr/src/lib/libresolv2/common/bsd/gettimeofday.c
+++ b/usr/src/lib/libresolv2/common/bsd/gettimeofday.c
@@ -1,20 +1,47 @@
-/*
- * Copyright (c) 1997-2000 by Sun Microsystems, Inc.
- * All rights reserved.
- */
-
#ifndef LINT
-static const char rcsid[] = "$Id: gettimeofday.c,v 8.4 1999/10/13 16:39:21 vixie Exp $";
+static const char rcsid[] = "$Id: gettimeofday.c,v 1.4 2005/04/27 04:56:11 sra Exp $";
#endif
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "port_before.h"
+#include <stdio.h>
+#include <syslog.h>
+#include <sys/time.h>
#include "port_after.h"
#if !defined(NEED_GETTIMEOFDAY)
-int __bindcompat_gettimeofday;
+/*%
+ * gettimeofday() occasionally returns invalid tv_usec on some platforms.
+ */
+#define MILLION 1000000
+#undef gettimeofday
+
+int
+isc__gettimeofday(struct timeval *tp, struct timezone *tzp) {
+ int res;
+
+ res = gettimeofday(tp, tzp);
+ if (res < 0)
+ return (res);
+ if (tp == NULL)
+ return (res);
+ if (tp->tv_usec < 0) {
+ do {
+ tp->tv_usec += MILLION;
+ tp->tv_sec--;
+ } while (tp->tv_usec < 0);
+ goto log;
+ } else if (tp->tv_usec > MILLION) {
+ do {
+ tp->tv_usec -= MILLION;
+ tp->tv_sec++;
+ } while (tp->tv_usec > MILLION);
+ goto log;
+ }
+ return (res);
+ log:
+ syslog(LOG_ERR, "gettimeofday: tv_usec out of range\n");
+ return (res);
+}
#else
int
gettimeofday(struct timeval *tvp, struct _TIMEZONE *tzp) {