<p dir="ltr">Does this address the warning in the RTEMS main_date.c command that popped up with the newlib guard changes?</p>
<p dir="ltr">I am guessing not. Have you looked at that warning when using a toolset with a recent newlib?</p>
<div class="gmail_quote">On Apr 7, 2016 5:58 AM, "Sebastian Huber" <<a href="mailto:sebastian.huber@embedded-brains.de">sebastian.huber@embedded-brains.de</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Move the kernel dependent parts of <sys/time.h> to new system-specific<br>
header file <machine/_time.h>. Provide an empty default implementation.<br>
Add a specialized implementation for RTEMS.<br>
<br>
Signed-off-by: Sebastian Huber <<a href="mailto:sebastian.huber@embedded-brains.de">sebastian.huber@embedded-brains.de</a>><br>
---<br>
newlib/libc/include/machine/_time.h | 3 +<br>
newlib/libc/include/sys/time.h | 151 +------------------<br>
newlib/libc/sys/rtems/include/machine/_time.h | 199 ++++++++++++++++++++++++++<br>
3 files changed, 204 insertions(+), 149 deletions(-)<br>
create mode 100644 newlib/libc/include/machine/_time.h<br>
create mode 100644 newlib/libc/sys/rtems/include/machine/_time.h<br>
<br>
diff --git a/newlib/libc/include/machine/_time.h b/newlib/libc/include/machine/_time.h<br>
new file mode 100644<br>
index 0000000..476760c<br>
--- /dev/null<br>
+++ b/newlib/libc/include/machine/_time.h<br>
@@ -0,0 +1,3 @@<br>
+#ifndef _SYS_TIME_H_<br>
+#error "must be included via <sys/time.h>"<br>
+#endif /* !_SYS_TIME_H_ */<br>
diff --git a/newlib/libc/include/sys/time.h b/newlib/libc/include/sys/time.h<br>
index 326d1a6..84c2ad2 100644<br>
--- a/newlib/libc/include/sys/time.h<br>
+++ b/newlib/libc/include/sys/time.h<br>
@@ -251,47 +251,6 @@ tvtosbt(struct timeval _tv)<br>
}<br>
#endif /* __BSD_VISIBLE */<br>
<br>
-#ifdef _KERNEL<br>
-<br>
-/* Operations on timespecs */<br>
-#define timespecclear(tvp) ((tvp)->tv_sec = (tvp)->tv_nsec = 0)<br>
-#define timespecisset(tvp) ((tvp)->tv_sec || (tvp)->tv_nsec)<br>
-#define timespeccmp(tvp, uvp, cmp) \<br>
- (((tvp)->tv_sec == (uvp)->tv_sec) ? \<br>
- ((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \<br>
- ((tvp)->tv_sec cmp (uvp)->tv_sec))<br>
-#define timespecadd(vvp, uvp) \<br>
- do { \<br>
- (vvp)->tv_sec += (uvp)->tv_sec; \<br>
- (vvp)->tv_nsec += (uvp)->tv_nsec; \<br>
- if ((vvp)->tv_nsec >= 1000000000) { \<br>
- (vvp)->tv_sec++; \<br>
- (vvp)->tv_nsec -= 1000000000; \<br>
- } \<br>
- } while (0)<br>
-#define timespecsub(vvp, uvp) \<br>
- do { \<br>
- (vvp)->tv_sec -= (uvp)->tv_sec; \<br>
- (vvp)->tv_nsec -= (uvp)->tv_nsec; \<br>
- if ((vvp)->tv_nsec < 0) { \<br>
- (vvp)->tv_sec--; \<br>
- (vvp)->tv_nsec += 1000000000; \<br>
- } \<br>
- } while (0)<br>
-<br>
-/* Operations on timevals. */<br>
-<br>
-#define timevalclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)<br>
-#define timevalisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)<br>
-#define timevalcmp(tvp, uvp, cmp) \<br>
- (((tvp)->tv_sec == (uvp)->tv_sec) ? \<br>
- ((tvp)->tv_usec cmp (uvp)->tv_usec) : \<br>
- ((tvp)->tv_sec cmp (uvp)->tv_sec))<br>
-<br>
-/* timevaladd and timevalsub are not inlined */<br>
-<br>
-#endif /* _KERNEL */<br>
-<br>
/*<br>
* Names of the interval timers, and structure<br>
* defining a timer setting.<br>
@@ -305,116 +264,9 @@ struct itimerval {<br>
struct timeval it_value; /* current value */<br>
};<br>
<br>
-#ifdef _KERNEL<br>
-<br>
-/*<br>
- * Kernel to clock driver interface.<br>
- */<br>
-void inittodr(time_t base);<br>
-void resettodr(void);<br>
-<br>
-extern volatile time_t time_second;<br>
-extern volatile time_t time_uptime;<br>
-extern struct bintime boottimebin;<br>
-extern struct timeval boottime;<br>
-extern struct bintime tc_tick_bt;<br>
-extern sbintime_t tc_tick_sbt;<br>
-extern struct bintime tick_bt;<br>
-extern sbintime_t tick_sbt;<br>
-extern int tc_precexp;<br>
-extern int tc_timepercentage;<br>
-extern struct bintime bt_timethreshold;<br>
-extern struct bintime bt_tickthreshold;<br>
-extern sbintime_t sbt_timethreshold;<br>
-extern sbintime_t sbt_tickthreshold;<br>
-<br>
-/*<br>
- * Functions for looking at our clock: [get]{bin,nano,micro}[up]time()<br>
- *<br>
- * Functions without the "get" prefix returns the best timestamp<br>
- * we can produce in the given format.<br>
- *<br>
- * "bin" == struct bintime == seconds + 64 bit fraction of seconds.<br>
- * "nano" == struct timespec == seconds + nanoseconds.<br>
- * "micro" == struct timeval == seconds + microseconds.<br>
- *<br>
- * Functions containing "up" returns time relative to boot and<br>
- * should be used for calculating time intervals.<br>
- *<br>
- * Functions without "up" returns UTC time.<br>
- *<br>
- * Functions with the "get" prefix returns a less precise result<br>
- * much faster than the functions without "get" prefix and should<br>
- * be used where a precision of 1/hz seconds is acceptable or where<br>
- * performance is priority. (NB: "precision", _not_ "resolution" !)<br>
- */<br>
-<br>
-void binuptime(struct bintime *bt);<br>
-void nanouptime(struct timespec *tsp);<br>
-void microuptime(struct timeval *tvp);<br>
-<br>
-static __inline sbintime_t<br>
-sbinuptime(void)<br>
-{<br>
- struct bintime _bt;<br>
-<br>
- binuptime(&_bt);<br>
- return (bttosbt(_bt));<br>
-}<br>
-<br>
-void bintime(struct bintime *bt);<br>
-void nanotime(struct timespec *tsp);<br>
-void microtime(struct timeval *tvp);<br>
-<br>
-void getbinuptime(struct bintime *bt);<br>
-void getnanouptime(struct timespec *tsp);<br>
-void getmicrouptime(struct timeval *tvp);<br>
-<br>
-static __inline sbintime_t<br>
-getsbinuptime(void)<br>
-{<br>
- struct bintime _bt;<br>
-<br>
- getbinuptime(&_bt);<br>
- return (bttosbt(_bt));<br>
-}<br>
-<br>
-void getbintime(struct bintime *bt);<br>
-void getnanotime(struct timespec *tsp);<br>
-void getmicrotime(struct timeval *tvp);<br>
-<br>
-/* Other functions */<br>
-int itimerdecr(struct itimerval *itp, int usec);<br>
-int itimerfix(struct timeval *tv);<br>
-int ppsratecheck(struct timeval *, int *, int);<br>
-int ratecheck(struct timeval *, const struct timeval *);<br>
-void timevaladd(struct timeval *t1, const struct timeval *t2);<br>
-void timevalsub(struct timeval *t1, const struct timeval *t2);<br>
-int tvtohz(struct timeval *tv);<br>
-<br>
-#define TC_DEFAULTPERC 5<br>
-<br>
-#define BT2FREQ(bt) \<br>
- (((uint64_t)0x8000000000000000 + ((bt)->frac >> 2)) / \<br>
- ((bt)->frac >> 1))<br>
-<br>
-#define SBT2FREQ(sbt) ((SBT_1S + ((sbt) >> 1)) / (sbt))<br>
-<br>
-#define FREQ2BT(freq, bt) \<br>
-{ \<br>
- (bt)->sec = 0; \<br>
- (bt)->frac = ((uint64_t)0x8000000000000000 / (freq)) << 1; \<br>
-}<br>
-<br>
-#define TIMESEL(sbt, sbt2) \<br>
- (((sbt2) >= sbt_timethreshold) ? \<br>
- ((*(sbt) = getsbinuptime()), 1) : ((*(sbt) = sbinuptime()), 0))<br>
-<br>
-#else /* !_KERNEL */<br>
+#ifndef _KERNEL<br>
#include <time.h><br>
<br>
-#include <sys/cdefs.h><br>
-<br>
__BEGIN_DECLS<br>
int _EXFUN(utimes, (const char *__path, const struct timeval *__tvp));<br>
<br>
@@ -444,5 +296,6 @@ int _EXFUN(_gettimeofday, (struct timeval *__p, void *__tz));<br>
__END_DECLS<br>
<br>
#endif /* !_KERNEL */<br>
+#include <machine/_time.h><br>
<br>
#endif /* !_SYS_TIME_H_ */<br>
diff --git a/newlib/libc/sys/rtems/include/machine/_time.h b/newlib/libc/sys/rtems/include/machine/_time.h<br>
new file mode 100644<br>
index 0000000..44a220d<br>
--- /dev/null<br>
+++ b/newlib/libc/sys/rtems/include/machine/_time.h<br>
@@ -0,0 +1,199 @@<br>
+/*-<br>
+ * Copyright (c) 1982, 1986, 1993<br>
+ * The Regents of the University of California. All rights reserved.<br>
+ *<br>
+ * Redistribution and use in source and binary forms, with or without<br>
+ * modification, are permitted provided that the following conditions<br>
+ * are met:<br>
+ * 1. Redistributions of source code must retain the above copyright<br>
+ * notice, this list of conditions and the following disclaimer.<br>
+ * 2. Redistributions in binary form must reproduce the above copyright<br>
+ * notice, this list of conditions and the following disclaimer in the<br>
+ * documentation and/or other materials provided with the distribution.<br>
+ * 4. Neither the name of the University nor the names of its contributors<br>
+ * may be used to endorse or promote products derived from this software<br>
+ * without specific prior written permission.<br>
+ *<br>
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND<br>
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE<br>
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE<br>
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE<br>
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL<br>
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS<br>
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)<br>
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT<br>
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY<br>
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF<br>
+ * SUCH DAMAGE.<br>
+ *<br>
+ * @(#)time.h 8.5 (Berkeley) 5/4/95<br>
+ * $FreeBSD$<br>
+ */<br>
+<br>
+#ifndef _SYS_TIME_H_<br>
+#error "must be included via <sys/time.h>"<br>
+#else /* _SYS_TIME_H_ */<br>
+<br>
+__BEGIN_DECLS<br>
+extern volatile time_t _Timecounter_Time_second;<br>
+extern volatile time_t _Timecounter_Time_uptime;<br>
+extern struct bintime _Timecounter_Boottimebin;<br>
+<br>
+void _Timecounter_Binuptime(struct bintime *);<br>
+void _Timecounter_Nanouptime(struct timespec *);<br>
+void _Timecounter_Microuptime(struct timeval *);<br>
+void _Timecounter_Bintime(struct bintime *);<br>
+void _Timecounter_Nanotime(struct timespec *);<br>
+void _Timecounter_Microtime(struct timeval *);<br>
+void _Timecounter_Getbinuptime(struct bintime *);<br>
+void _Timecounter_Getnanouptime(struct timespec *);<br>
+void _Timecounter_Getmicrouptime(struct timeval *);<br>
+void _Timecounter_Getbintime(struct bintime *);<br>
+void _Timecounter_Getnanotime(struct timespec *);<br>
+void _Timecounter_Getmicrotime(struct timeval *);<br>
+__END_DECLS<br>
+<br>
+#ifdef _KERNEL<br>
+<br>
+/* Operations on timespecs */<br>
+#define timespecclear(tvp) ((tvp)->tv_sec = (tvp)->tv_nsec = 0)<br>
+#define timespecisset(tvp) ((tvp)->tv_sec || (tvp)->tv_nsec)<br>
+#define timespeccmp(tvp, uvp, cmp) \<br>
+ (((tvp)->tv_sec == (uvp)->tv_sec) ? \<br>
+ ((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \<br>
+ ((tvp)->tv_sec cmp (uvp)->tv_sec))<br>
+#define timespecadd(vvp, uvp) \<br>
+ do { \<br>
+ (vvp)->tv_sec += (uvp)->tv_sec; \<br>
+ (vvp)->tv_nsec += (uvp)->tv_nsec; \<br>
+ if ((vvp)->tv_nsec >= 1000000000) { \<br>
+ (vvp)->tv_sec++; \<br>
+ (vvp)->tv_nsec -= 1000000000; \<br>
+ } \<br>
+ } while (0)<br>
+#define timespecsub(vvp, uvp) \<br>
+ do { \<br>
+ (vvp)->tv_sec -= (uvp)->tv_sec; \<br>
+ (vvp)->tv_nsec -= (uvp)->tv_nsec; \<br>
+ if ((vvp)->tv_nsec < 0) { \<br>
+ (vvp)->tv_sec--; \<br>
+ (vvp)->tv_nsec += 1000000000; \<br>
+ } \<br>
+ } while (0)<br>
+<br>
+/* Operations on timevals. */<br>
+<br>
+#define timevalclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)<br>
+#define timevalisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)<br>
+#define timevalcmp(tvp, uvp, cmp) \<br>
+ (((tvp)->tv_sec == (uvp)->tv_sec) ? \<br>
+ ((tvp)->tv_usec cmp (uvp)->tv_usec) : \<br>
+ ((tvp)->tv_sec cmp (uvp)->tv_sec))<br>
+<br>
+/* timevaladd and timevalsub are not inlined */<br>
+<br>
+/*<br>
+ * Kernel to clock driver interface.<br>
+ */<br>
+void inittodr(time_t base);<br>
+void resettodr(void);<br>
+<br>
+#define time_second _Timecounter_Time_second<br>
+#define time_uptime _Timecounter_Time_uptime<br>
+#define boottimebin _Timecounter_Boottimebin<br>
+extern struct timeval boottime;<br>
+extern struct bintime tc_tick_bt;<br>
+extern sbintime_t tc_tick_sbt;<br>
+extern struct bintime tick_bt;<br>
+extern sbintime_t tick_sbt;<br>
+extern int tc_precexp;<br>
+extern int tc_timepercentage;<br>
+extern struct bintime bt_timethreshold;<br>
+extern struct bintime bt_tickthreshold;<br>
+extern sbintime_t sbt_timethreshold;<br>
+extern sbintime_t sbt_tickthreshold;<br>
+<br>
+/*<br>
+ * Functions for looking at our clock: [get]{bin,nano,micro}[up]time()<br>
+ *<br>
+ * Functions without the "get" prefix returns the best timestamp<br>
+ * we can produce in the given format.<br>
+ *<br>
+ * "bin" == struct bintime == seconds + 64 bit fraction of seconds.<br>
+ * "nano" == struct timespec == seconds + nanoseconds.<br>
+ * "micro" == struct timeval == seconds + microseconds.<br>
+ *<br>
+ * Functions containing "up" returns time relative to boot and<br>
+ * should be used for calculating time intervals.<br>
+ *<br>
+ * Functions without "up" returns UTC time.<br>
+ *<br>
+ * Functions with the "get" prefix returns a less precise result<br>
+ * much faster than the functions without "get" prefix and should<br>
+ * be used where a precision of 1/hz seconds is acceptable or where<br>
+ * performance is priority. (NB: "precision", _not_ "resolution" !)<br>
+ */<br>
+<br>
+#define binuptime(_bt) _Timecounter_Binuptime(_bt)<br>
+#define nanouptime(_tsp) _Timecounter_Nanouptime(_tsp)<br>
+#define microuptime(_tvp) _Timecounter_Microuptime(_tvp)<br>
+<br>
+static __inline sbintime_t<br>
+sbinuptime(void)<br>
+{<br>
+ struct bintime _bt;<br>
+<br>
+ binuptime(&_bt);<br>
+ return (bttosbt(_bt));<br>
+}<br>
+<br>
+#define bintime(_bt) _Timecounter_Bintime(_bt)<br>
+#define nanotime(_tsp) _Timecounter_Nanotime(_tsp)<br>
+#define microtime(_tvp) _Timecounter_Microtime(_tvp)<br>
+<br>
+#define getbinuptime(_bt) _Timecounter_Getbinuptime(_bt)<br>
+#define getnanouptime(_tsp) _Timecounter_Getnanouptime(_tsp)<br>
+#define getmicrouptime(_tvp) _Timecounter_Getmicrouptime(_tvp)<br>
+<br>
+static __inline sbintime_t<br>
+getsbinuptime(void)<br>
+{<br>
+ struct bintime _bt;<br>
+<br>
+ getbinuptime(&_bt);<br>
+ return (bttosbt(_bt));<br>
+}<br>
+<br>
+#define getbintime(_bt) _Timecounter_Getbintime(_bt)<br>
+#define getnanotime(_tsp) _Timecounter_Getnanotime(_tsp)<br>
+#define getmicrotime(_tvp) _Timecounter_Getmicrotime(_tvp)<br>
+<br>
+/* Other functions */<br>
+int itimerdecr(struct itimerval *itp, int usec);<br>
+int itimerfix(struct timeval *tv);<br>
+int ppsratecheck(struct timeval *, int *, int);<br>
+int ratecheck(struct timeval *, const struct timeval *);<br>
+void timevaladd(struct timeval *t1, const struct timeval *t2);<br>
+void timevalsub(struct timeval *t1, const struct timeval *t2);<br>
+int tvtohz(struct timeval *tv);<br>
+<br>
+#define TC_DEFAULTPERC 5<br>
+<br>
+#define BT2FREQ(bt) \<br>
+ (((uint64_t)0x8000000000000000 + ((bt)->frac >> 2)) / \<br>
+ ((bt)->frac >> 1))<br>
+<br>
+#define SBT2FREQ(sbt) ((SBT_1S + ((sbt) >> 1)) / (sbt))<br>
+<br>
+#define FREQ2BT(freq, bt) \<br>
+{ \<br>
+ (bt)->sec = 0; \<br>
+ (bt)->frac = ((uint64_t)0x8000000000000000 / (freq)) << 1; \<br>
+}<br>
+<br>
+#define TIMESEL(sbt, sbt2) \<br>
+ (((sbt2) >= sbt_timethreshold) ? \<br>
+ ((*(sbt) = getsbinuptime()), 1) : ((*(sbt) = sbinuptime()), 0))<br>
+<br>
+#endif /* _KERNEL */<br>
+#endif /* _SYS_TIME_H_ */<br>
--<br>
1.8.4.5<br>
<br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
</blockquote></div>