about summary refs log tree commit diff
path: root/time
diff options
context:
space:
mode:
Diffstat (limited to 'time')
-rw-r--r--time/sys/time.h8
-rw-r--r--time/time.h29
2 files changed, 24 insertions, 13 deletions
diff --git a/time/sys/time.h b/time/sys/time.h
index c0753337c2..ca82d87aa9 100644
--- a/time/sys/time.h
+++ b/time/sys/time.h
@@ -35,12 +35,12 @@ struct timeval
 
 /* Macros for converting between `struct timeval' and `struct timespec'.  */
 #define TIMEVAL_TO_TIMESPEC(tv, ts) {                                   \
-        (ts)->ts_sec = (tv)->tv_sec;                                    \
-        (ts)->ts_nsec = (tv)->tv_usec * 1000;                           \
+        (ts)->tv_sec = (tv)->tv_sec;                                    \
+        (ts)->tv_nsec = (tv)->tv_usec * 1000;                           \
 }
 #define TIMESPEC_TO_TIMEVAL(tv, ts) {                                   \
-        (tv)->tv_sec = (ts)->ts_sec;                                    \
-        (tv)->tv_usec = (ts)->ts_nsec / 1000;                           \
+        (tv)->tv_sec = (ts)->tv_sec;                                    \
+        (tv)->tv_usec = (ts)->tv_nsec / 1000;                           \
 }
 
 
diff --git a/time/time.h b/time/time.h
index 5926d80c8e..596351bede 100644
--- a/time/time.h
+++ b/time/time.h
@@ -22,7 +22,8 @@ Cambridge, MA 02139, USA.  */
 
 #ifndef	_TIME_H
 
-#if	!defined(__need_time_t) && !defined(__need_clock_t)
+#if	(! defined (__need_time_t) && !defined(__need_clock_t) && \
+	 ! defined (__need_timespec))
 #define	_TIME_H		1
 #include <features.h>
 
@@ -78,6 +79,24 @@ typedef __time_t time_t;
 #undef	__need_time_t
 
 
+#if	! defined(__timespec_defined) &&			\
+	((defined (_TIME_H) && defined (__USE_POSIX)) ||	\
+	 defined (__need_timespec))
+#define	__timespec_defined	1
+
+/* POSIX.4 structure for a time value.  This is like a `struct timeval' but
+   has nanoseconds instead of microseconds.  */
+struct timespec
+  {
+    long int tv_sec;		/* Seconds.  */
+    long int tv_nsec;		/* Nanoseconds.  */
+  };
+
+#endif /* timespec not defined and <time.h> or need timespec.  */
+#undef	__need_timespec
+
+
+
 #ifdef	_TIME_H
 /* Used by other time functions.  */
 struct tm
@@ -229,14 +248,6 @@ extern int dysize __P ((int __year));
 #endif
 
 
-/* POSIX.4 structure for a time value.  This is like a `struct timeval' but
-   has nanoseconds instead of microseconds.  */
-struct timespec
-  {
-    long int ts_sec;		/* Seconds.  */
-    long int ts_nsec;		/* Nanoseconds.  */
-  };
-
 #ifdef __USE_POSIX
 /* Pause execution for a number of nanoseconds.  */
 extern int nanosleep __P ((__const struct timespec *__requested_time,