This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

libc time: fix linking bug and tweak clock test


Index: ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/language/c/libc/time/current/ChangeLog,v
retrieving revision 1.15
diff -u -5 -p -r1.15 ChangeLog
--- ChangeLog	25 Apr 2003 04:30:09 -0000	1.15
+++ ChangeLog	13 Jun 2003 14:05:39 -0000
@@ -1,5 +1,14 @@
+2003-06-13  Jonathan Larmour  <jifl@eCosCentric.com>
+
+	* tests/clock.c (main): Avoid div-by-zero if mean==0.
+
+	* cdl/time.cdl: build all POSIX files all the time because they
+	are used internally by the standard ISO C functions even if not
+	exported.
+	[Bug 1000001]
+
 2003-04-24  Robert Cragie  <rcc@jennic.com>
 
 	* include/time.inl:
 	* include/timeutil.h:
 	* src/timeutil.cxx:
Index: cdl/time.cdl
===================================================================
RCS file: /cvs/ecos/ecos/packages/language/c/libc/time/current/cdl/time.cdl,v
retrieving revision 1.8
diff -u -5 -p -r1.8 time.cdl
--- cdl/time.cdl	24 Feb 2003 14:28:38 -0000	1.8
+++ cdl/time.cdl	13 Jun 2003 14:05:39 -0000
@@ -63,16 +63,24 @@ cdl_package CYGPKG_LIBC_TIME {
                        "<cyg/libc/time/time.h>" }
     requires      CYGPKG_ISOINFRA
     requires      CYGINT_ISO_DIV
     requires      CYGINT_ISO_ABS
 
+    # Note: the POSIX files asctime_r,ctime_r,gmtime_r and
+    # localtime_r should be built all the time, not just in
+    # CYGFUN_LIBC_TIME_POSIX because the internal definitions
+    # are used by the ISO C functions regardless. Otherwise we
+    # get problems with certain inlining combinations. [Bug 1000001]
+
     compile       asctime.cxx       clock.cxx      \
                   ctime.cxx         difftime.cxx   \
                   gmtime.cxx        localtime.cxx  \
                   mktime.cxx        settime.cxx    \
                   strftime.cxx      time.cxx       \
-                  timeutil.cxx
+                  timeutil.cxx      asctime_r.cxx  \
+                  ctime_r.cxx       gmtime_r.cxx   \
+                  localtime_r.cxx 
 
 
 # ====================================================================
 
     cdl_option CYGSEM_LIBC_TIME_CLOCK_WORKING {
@@ -114,12 +122,11 @@ cdl_package CYGPKG_LIBC_TIME {
     
     cdl_option CYGFUN_LIBC_TIME_POSIX {
         display       "POSIX time functions"
         default_value 1
         requires      CYGFUN_LIBC_STRING_BSD_FUNCS
-        compile       asctime_r.cxx ctime_r.cxx gmtime_r.cxx \
-                      localtime_r.cxx strptime.cxx
+        compile       strptime.cxx
         description   "
             Enabling this option allows the use of the
             following functions defined in POSIX 1003.1:
             asctime_r(), ctime_r(), gmtime_r(), strptime(), and
             localtime_r()."
Index: tests/clock.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/language/c/libc/time/current/tests/clock.c,v
retrieving revision 1.9
diff -u -5 -p -r1.9 clock.c
--- tests/clock.c	23 May 2002 23:07:34 -0000	1.9
+++ tests/clock.c	13 Jun 2003 14:05:39 -0000
@@ -219,11 +219,12 @@ main(int argc, char *argv[])
 
     // now go through valid results and compare against average
     for (i=SKIPPED_SAMPLES;i<SAMPLES;i++) {
         unsigned long err;
 
-        err = (100 * my_abs(ctrs[i]-mean)) / mean;
+        // use mean+1 as divisor to avoid div-by-zero
+        err = (100 * my_abs(ctrs[i]-mean)) / (mean+1);
         if (err > TOLERANCE) {
             diag_printf("mean=%d, ctrs[%d]=%d, err=%d\n", mean, i, ctrs[i],
                         err);
             CYG_TEST_FAIL_FINISH("clock() within tolerance");
         }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]