]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
bug-2803 framework
authorHarlan Stenn <stenn@ntp.org>
Sun, 3 May 2015 03:41:35 +0000 (03:41 +0000)
committerHarlan Stenn <stenn@ntp.org>
Sun, 3 May 2015 03:41:35 +0000 (03:41 +0000)
bk: 554598efYEs_BhVURa35AIsc-T6EFA

sntp/configure.ac
sntp/unity/Makefile.am [new file with mode: 0644]
tests/bug-2803/Makefile.am
tests/bug-2803/bug-2803.c

index 172c6b1a1f7dc99cd2fb870eaba2e767adf33035..1b0e1e87727b9b11c27c216394a9b1f21d251a38 100644 (file)
@@ -150,5 +150,6 @@ AC_CONFIG_FILES([Makefile])
 AC_CONFIG_FILES([include/Makefile])
 AC_CONFIG_FILES([scripts/Makefile])
 AC_CONFIG_FILES([tests/Makefile])
+AC_CONFIG_FILES([unity/Makefile])
 
 AC_OUTPUT
diff --git a/sntp/unity/Makefile.am b/sntp/unity/Makefile.am
new file mode 100644 (file)
index 0000000..e5b36b4
--- /dev/null
@@ -0,0 +1,15 @@
+AUTOMAKE_OPTIONS = foreign 1.9 subdir-objects
+NULL =
+BUILT_SOURCES =
+CLEANFILES =
+
+noinst_LIBRARIES = libunity.a
+
+libunity_a_SOURCES =           \
+       unity.c                 \
+       unity.h                 \
+       unity_internals.h       \
+       $(NULL)
+
+include $(top_srcdir)/depsver.mf
+include $(top_srcdir)/includes.mf
index d0ad58feba6d3831b9b106d0a1fadb97b03344d5..d8caadf771a5d0b70294f55795a37023704eb1d1 100644 (file)
@@ -1,4 +1,4 @@
-AUTOMAKE_OPTIONS = foreign 1.9 subdir-objects
+#AUTOMAKE_OPTIONS = foreign 1.9 subdir-objects
 NULL =
 BUILT_SOURCES =
 CLEANFILES =
@@ -7,6 +7,7 @@ check_PROGRAMS = bug-2803
 
 # HMS: we may not need some of these:
 LDADD =                                        \
+       $(top_builddir)/sntp/unity/libunity.a   \
        $(top_builddir)/libntp/libntp.a \
        $(LDADD_LIBNTP)                 \
        $(PTHREAD_LIBS)                 \
@@ -17,16 +18,15 @@ AM_CFLAGS   = $(CFLAGS_NTP)
 
 # HMS: we may not need some of these:
 AM_CPPFLAGS  = $(NTP_INCS)
-AM_CPPFLAGS += -I$(top_srcdir)/sntp
 AM_CPPFLAGS += -I$(top_srcdir)/sntp/unity
-AM_CPPFLAGS += -I$(top_srcdir)/ntpd
+AM_CPPFLAGS += -I$(top_srcdir)/include
 AM_CPPFLAGS += $(CPPFLAGS_NTP)
 
 AM_LDFLAGS = $(LDFLAGS_NTP)
 
-tests_SOURCES = $(top_srcdir)/sntp/unity/unity.c       \
-               bug-2803.c                              \
-               $(NULL)
+bug_2803_SOURCES =                             \
+       bug-2803.c                              \
+       $(NULL)
 
 # HMS: we may not need some of these:
 #noinst_HEADERS =      ntpdtest.h      \
@@ -41,8 +41,8 @@ endif
 ## check-libntp.mf - automake fragment
 ## slightly adapted for deeper directory
 
-BUILT_SOURCES  += check-libntp
-CLEANFILES     += check-libntp
+BUILT_SOURCES  += check-libntp check-libunity
+CLEANFILES     += check-libntp check-libunity
 
 check-libntp: ../../libntp/libntp.a
        @echo stamp > $@
@@ -50,5 +50,11 @@ check-libntp: ../../libntp/libntp.a
 ../../libntp/libntp.a:
        cd ../../libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
 
+check-libunity: ../../sntp/unity/libunity.a
+       @echo stamp > $@
+
+../../sntp/unity/libunity.a:
+       cd ../../libunity && $(MAKE) $(AM_MAKEFLAGS) libunity.a
+
 include $(top_srcdir)/depsver.mf
 include $(top_srcdir)/includes.mf
index b474bd9929624af8c09be16eaff9b727e5174867..a31fccfdd1c53ca5295121b8c480a7e585524c22 100644 (file)
@@ -1,7 +1,11 @@
+#include <config.h>
 
 #include <stdio.h>
 #include <sys/time.h>
 
+#include <ntp_fp.h>
+#include <timevalops.h>
+
 /* microseconds per second */
 #define MICROSECONDS 1000000
 
@@ -10,140 +14,6 @@ static int verbose = 1;        // if not 0, also print results if test passed
 static int exit_on_err = 0;    // if not 0, exit if test failed
 
 
-/*
- * Inline functions below copied from NTP 4.source code,
-
-/* make sure microseconds are in nominal range */
-static inline struct timeval
-normalize_tval(
-       struct timeval  x
-       )
-{
-       long            z;
-
-       /*
-        * If the fraction becomes excessive denormal, we use division
-        * to do first partial normalisation. The normalisation loops
-        * following will do the remaining cleanup. Since the size of
-        * tv_usec has a peculiar definition by the standard the range
-        * check is coded manually. And labs() is intentionally not used
-        * here: it has implementation-defined behaviour when applied
-        * to LONG_MIN.
-        */
-       if (x.tv_usec < -3l * MICROSECONDS ||
-           x.tv_usec >  3l * MICROSECONDS  ) {
-               z = x.tv_usec / MICROSECONDS;
-               x.tv_usec -= z * MICROSECONDS;
-               x.tv_sec += z;
-       }
-
-       /*
-        * Do any remaining normalisation steps in loops. This takes 3
-        * steps max, and should outperform a division even if the
-        * mul-by-inverse trick is employed. (It also does the floor
-        * division adjustment if the above division was executed.)
-        */
-       if (x.tv_usec < 0)
-               do {
-                       x.tv_usec += MICROSECONDS;
-                       x.tv_sec--;
-               } while (x.tv_usec < 0);
-       else if (x.tv_usec >= MICROSECONDS)
-               do {
-                       x.tv_usec -= MICROSECONDS;
-                       x.tv_sec++;
-               } while (x.tv_usec >= MICROSECONDS);
-
-       return x;
-}
-
-
-
-/* x = a + b */
-static inline struct timeval
-add_tval(
-       struct timeval  a,
-       struct timeval  b
-       )
-{
-       struct timeval  x;
-
-       x = a;
-       x.tv_sec += b.tv_sec;
-       x.tv_usec += b.tv_usec;
-
-       return normalize_tval(x);
-}
-
-/* x = a + b, b is fraction only */
-static inline struct timeval
-add_tval_us(
-       struct timeval  a,
-       long            b
-       )
-{
-       struct timeval x;
-
-       x = a;
-       x.tv_usec += b;
-
-       return normalize_tval(x);
-}
-
-/* x = a - b */
-static inline struct timeval
-sub_tval(
-       struct timeval  a,
-       struct timeval  b
-       )
-{
-       struct timeval  x;
-
-       x = a;
-       x.tv_sec -= b.tv_sec;
-       x.tv_usec -= b.tv_usec;
-
-       return normalize_tval(x);
-}
-
-/* x = a - b, b is fraction only */
-static inline struct timeval
-sub_tval_us(
-       struct timeval  a,
-       long            b
-       )
-{
-       struct timeval x;
-
-       x = a;
-       x.tv_usec -= b;
-
-       return normalize_tval(x);
-}
-
-/* x = abs(a) */
-static inline struct timeval
-abs_tval(
-       struct timeval  a
-       )
-{
-       struct timeval  c;
-
-       c = normalize_tval(a);
-       if (c.tv_sec < 0) {
-               if (c.tv_usec != 0) {
-                       c.tv_sec = -c.tv_sec - 1;
-                       c.tv_usec = MICROSECONDS - c.tv_usec;
-               } else {
-                       c.tv_sec = -c.tv_sec;
-               }
-       }
-
-       return c;
-}
-
-
-
 /*
  * Test function calling the old and new code mentioned in
  * http://bugs.ntp.org/show_bug.cgi?id=2803#c22