[PATCH 6/6] libnetworking: Use rtems_clock_get_uptime_seconds

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Nov 16 15:31:11 UTC 2012


This reduces the start-up time of the network stack.

With a 1ms tick the ticks since boot value overflows after approximately
50 days.  This problem is avoided with the
rtems_clock_get_uptime_seconds() function.
---
 cpukit/libnetworking/rtems/rtems_bsdnet_internal.h |    6 +++++-
 cpukit/libnetworking/rtems/rtems_glue.c            |   15 ---------------
 testsuites/libtests/mghttpd01/init.c               |    2 +-
 3 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h b/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h
index c5ca26b..b477d7d 100644
--- a/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h
+++ b/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h
@@ -139,7 +139,11 @@ void rtems_bsdnet_semaphore_release (void);
 void rtems_bsdnet_schednetisr (int n);
 int rtems_bsdnet_parse_driver_name (const struct rtems_bsdnet_ifconfig *config, char **namep);
 
-unsigned long rtems_bsdnet_seconds_since_boot (void);
+static inline unsigned long rtems_bsdnet_seconds_since_boot(void)
+{
+  return (unsigned long) rtems_clock_get_uptime_seconds() + 1UL;
+}
+
 unsigned long rtems_bsdnet_random (void);
 
 rtems_id rtems_bsdnet_newproc (
diff --git a/cpukit/libnetworking/rtems/rtems_glue.c b/cpukit/libnetworking/rtems/rtems_glue.c
index 1f208ae..8380e4d 100644
--- a/cpukit/libnetworking/rtems/rtems_glue.c
+++ b/cpukit/libnetworking/rtems/rtems_glue.c
@@ -336,12 +336,6 @@ rtems_bsdnet_initialize (void)
 		1000000 / rtems_bsdnet_ticks_per_second;
 
 	/*
-	 * Ensure that `seconds' is greater than 0
-	 */
-    while (rtems_bsdnet_seconds_since_boot() == 0)
-        rtems_task_wake_after(1);
-
-	/*
 	 * Set up BSD-style sockets
 	 */
 	if (bsd_init () < 0)
@@ -714,15 +708,6 @@ rtems_status_code rtems_bsdnet_event_receive (
 	return sc;
 }
 
-unsigned long
-rtems_bsdnet_seconds_since_boot (void)
-{
-	rtems_interval now;
-
-	now = rtems_clock_get_ticks_since_boot();
-	return now / rtems_bsdnet_ticks_per_second;
-}
-
 /*
  * Fake random number generator
  */
diff --git a/testsuites/libtests/mghttpd01/init.c b/testsuites/libtests/mghttpd01/init.c
index dc6dd9c..f480851 100644
--- a/testsuites/libtests/mghttpd01/init.c
+++ b/testsuites/libtests/mghttpd01/init.c
@@ -44,7 +44,7 @@
 #define INDEX_HTML      "HTTP/1.1 200 OK\r\n" \
                         "Date: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\n" \
                         "Last-Modified: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\n" \
-                        "Etag: \"21dae501.a2\"\r\n" \
+                        "Etag: \"21dae500.a2\"\r\n" \
                         "Content-Type: text/html\r\n" \
                         "Content-Length: 162\r\n" \
                         "Connection: close\r\n" \
-- 
1.7.7




More information about the devel mailing list