System: ntp version 3.4 Patch #: 7 Priority: From: Description: Add definition of NOSWAP for Ultrix systems. Removed unused variables from ntp.c program. Removed unused variable from ntp_adjust.c module. Don't clear peer.reach register in the clear() procedure. Code to prevent flapping between two peers with very similar dispersions. Deleted unused variables in ntp_sock.c Added NOSWAP code for Ultrix systems to lock NTP process in memory. Deleted unused variable in ntpd.c In stat.pl, handle ntpd log files that cross months. Add check for SUN_FLT_BUG problem in test.c Repeat-By: Fix: From rn, say "| patch -p -N -d DIR", where DIR is your ntp source directory. Outside of rn, say "cd DIR; patch -p -N #define PATCHLEVEL 7 Index: Makefile *** Makefile.old Fri Apr 7 19:10:46 1989 --- Makefile Fri Apr 7 19:10:47 1989 *************** *** 1,6 **** ! # $Source: /usr/users/louie/ntp/RCS/Makefile,v $ $Revision: 3.4.1.3 $ $Date: 89/03/29 12:21:27 $ # # $Log: Makefile,v $ # Revision 3.4.1.3 89/03/29 12:21:27 louie # Don't bother to create the Version file for the distribution any longer. # Define SUN_FLT_BUG rather than just 'sun' to get the a fix for a floating --- 1,9 ---- ! # $Source: /usr/users/louie/ntp/RCS/Makefile,v $ $Revision: 3.4.1.4 $ $Date: 89/04/07 18:04:14 $ # # $Log: Makefile,v $ + # Revision 3.4.1.4 89/04/07 18:04:14 louie + # Add definition of NOSWAP for Ultrix systems. + # # Revision 3.4.1.3 89/03/29 12:21:27 louie # Don't bother to create the Version file for the distribution any longer. # Define SUN_FLT_BUG rather than just 'sun' to get the a fix for a floating *************** *** 71,76 **** --- 74,80 ---- # LOG_NTP=foo - to change the syslog facility. You could specify # something like -DLOG_NTP=LOG_LOCAL3 to log into the # LOG_LOCAL3 syslog facility + # NOSWAP - allow use of plock() to prevent swapping # # FEATURES= *************** *** 87,93 **** # it should be declared as a u_long not a in_addr (the doc is wrong also) # (Note 3.0 has it fixed). VAX_COMPILER_FLT_BUG is defined for pcc which # doesn't know how to convert an unsigned long into a float/double ! #DEFINES= -DVAX_COMPILER_FLT_BUG CFLAGS= -O ${DEFINES} ${FEATURES} ${INCPATH} # --- 91,97 ---- # it should be declared as a u_long not a in_addr (the doc is wrong also) # (Note 3.0 has it fixed). VAX_COMPILER_FLT_BUG is defined for pcc which # doesn't know how to convert an unsigned long into a float/double ! #DEFINES= -DVAX_COMPILER_FLT_BUG -DNOSWAP CFLAGS= -O ${DEFINES} ${FEATURES} ${INCPATH} # Index: ntp.c *** ntp.c.old Fri Apr 7 19:10:51 1989 --- ntp.c Fri Apr 7 19:10:53 1989 *************** *** 1,9 **** #ifndef lint ! static char *rcsid = "$Source: /usr/users/louie/ntp/RCS/ntp.c,v $ $Revision: 3.4.1.3 $ $Date: 89/03/22 18:29:22 $"; #endif lint /* * $Log: ntp.c,v $ * Revision 3.4.1.3 89/03/22 18:29:22 louie * patch3: Use new RCS headers. * --- 1,12 ---- #ifndef lint ! static char *rcsid = "$Source: /usr/users/louie/ntp/RCS/ntp.c,v $ $Revision: 3.4.1.4 $ $Date: 89/04/07 18:04:49 $"; #endif lint /* * $Log: ntp.c,v $ + * Revision 3.4.1.4 89/04/07 18:04:49 louie + * Removed unused variables from ntp.c program. + * * Revision 3.4.1.3 89/03/22 18:29:22 louie * patch3: Use new RCS headers. * *************** *** 123,133 **** struct l_fixedpt in_timestamp; static struct ntpdata ntp_data; struct ntpdata *pkt = &ntp_data; ! struct timeval tp, tp1, timeout; int host, n, retry, s; fd_set readfds; int dstlen = sizeof(dst); ! double ref, t1, t2, t3, t4, offset, delay; char ref_clock[5]; time_t net_time; ref_clock[4] = NULL; --- 126,136 ---- struct l_fixedpt in_timestamp; static struct ntpdata ntp_data; struct ntpdata *pkt = &ntp_data; ! struct timeval tp, timeout; int host, n, retry, s; fd_set readfds; int dstlen = sizeof(dst); ! double t1, t2, t3, t4, offset, delay; char ref_clock[5]; time_t net_time; ref_clock[4] = NULL; *************** *** 327,333 **** /* set the clock */ gettimeofday(&tp, (struct timezone *) 0); - tp1 = tp; offset += tp.tv_sec; offset += tp.tv_usec / 1000000.0; tp.tv_sec = offset; --- 330,335 ---- Index: ntp_adjust.c *** ntp_adjust.c.old Fri Apr 7 19:10:57 1989 --- ntp_adjust.c Fri Apr 7 19:10:58 1989 *************** *** 1,5 **** #ifndef lint ! static char *RCSid = "$Source: /usr/users/louie/ntp/RCS/ntp_adjust.c,v $ $Revision: 3.4.1.2 $ $Date: 89/03/22 18:30:52 $"; #endif /* --- 1,5 ---- #ifndef lint ! static char *RCSid = "$Source: /usr/users/louie/ntp/RCS/ntp_adjust.c,v $ $Revision: 3.4.1.3 $ $Date: 89/04/07 18:05:17 $"; #endif /* *************** *** 7,12 **** --- 7,15 ---- * 5. of the NTP specification. * * $Log: ntp_adjust.c,v $ + * Revision 3.4.1.3 89/04/07 18:05:17 louie + * Removed unused variable from ntp_adjust.c module. + * * Revision 3.4.1.2 89/03/22 18:30:52 louie * patch3: Use new RCS headers. * *************** *** 130,136 **** double offset; { struct timeval tv2; - int i; #ifdef XADJTIME2 struct timeval delta, olddelta; #endif --- 133,138 ---- Index: ntp_proto.c *** ntp_proto.c.old Fri Apr 7 19:11:05 1989 --- ntp_proto.c Fri Apr 7 19:11:07 1989 *************** *** 1,5 **** #ifndef lint ! static char *rcsid = "$Source: /usr/users/louie/ntp/RCS/ntp_proto.c,v $ $Revision: 3.4.1.5 $ $Date: 89/03/31 16:36:38 $"; #endif /* --- 1,5 ---- #ifndef lint ! static char *rcsid = "$Source: /usr/users/louie/ntp/RCS/ntp_proto.c,v $ $Revision: 3.4.1.6 $ $Date: 89/04/07 19:07:10 $"; #endif /* *************** *** 7,15 **** * It contains a minimum of machine and operating system dependencies (or at * least that's the idea). Setup of UDP sockets, timers, etc is done in the * ntpd.c module, while arithmetic conversion routines are in ntpsubs.c ! * ! * * $Log: ntp_proto.c,v $ * Revision 3.4.1.5 89/03/31 16:36:38 louie * There is now a run-time option that can be specified in the configuration * which specifies if we will synchronize to unconfigured hosts. Fixes to --- 7,20 ---- * It contains a minimum of machine and operating system dependencies (or at * least that's the idea). Setup of UDP sockets, timers, etc is done in the * ntpd.c module, while arithmetic conversion routines are in ntpsubs.c ! */ ! ! /* * $Log: ntp_proto.c,v $ + * Revision 3.4.1.6 89/04/07 19:07:10 louie + * Don't clear peer.reach register in the clear() procedure. Code to prevent + * flapping between two peers with very similar dispersions. + * * Revision 3.4.1.5 89/03/31 16:36:38 louie * There is now a run-time option that can be specified in the configuration * which specifies if we will synchronize to unconfigured hosts. Fixes to *************** *** 306,311 **** --- 311,317 ---- peer->src = *dst; peer->sock = sock; peer->hmode = MODE_SYM_PAS; + peer->reach = 0; clear(peer); } else peer = check_peer(dst, sock); *************** *** 321,328 **** peer->sock = sock; /* remember which socket we heard this from */ peer->hmode = MODE_SYM_PAS; clear(peer); - #if 1 /* * If we decide to consider any random NTP peer that might * come as a peer we might sync to, then set the PEER_FL_SYNC --- 327,334 ---- peer->sock = sock; /* remember which socket we heard this from */ peer->hmode = MODE_SYM_PAS; + peer->reach = 0; clear(peer); /* * If we decide to consider any random NTP peer that might * come as a peer we might sync to, then set the PEER_FL_SYNC *************** *** 333,339 **** */ if (trusting) peer->flags |= PEER_FL_SYNC; - #endif enqueue(&peer_list, peer); } --- 339,344 ---- *************** *** 654,660 **** for (i = 0; i < NTP_WINDOW; i++) peer->filter.offset[i] = 0.0; peer->filter.samples = 0; /* Implementation specific */ - peer->reach = 0; peer->valid = 0; peer->org.int_part = peer->org.fraction = 0; peer->rec.int_part = peer->rec.fraction = 0; --- 659,664 ---- *************** *** 995,1000 **** --- 999,1031 ---- ntoa(sel_lst[0].peer->src.sin_addr), sel_lst[0].peer->stratum); } + + if (sys.peer != NULL && sys.peer != sel_lst[0].peer) { + /* + * Potential peer is different that current one; don't switch + * to new peer unless the offset is suitably "large". + */ + if (sys.peer->stratum == sel_lst[0].peer->stratum) { + double threshold ; + + threshold = NTP_MAXSKW + + 1.0/(unsigned long)(1L << -sys.precision); + + /* make sure we don't try to divide by zero */ + if (-sel_lst[0].peer->precision < sizeof(long)) + threshold += 1.0/(unsigned long) + (1L << -sel_lst[0].peer->precision); + + if (sel_lst[0].peer->estoffset < threshold) { + #ifdef DEBUG + if (debug > 2) + printf("clock: inhibit peer switch\n"); + #endif + return; + } + } + } + #ifdef DEBUG if ((debug > 2) || (sys.peer != sel_lst[0].peer)) printf("clock: select peer %s stratum %d\n", Index: ntp_sock.c *** ntp_sock.c.old Fri Apr 7 19:11:12 1989 --- ntp_sock.c Fri Apr 7 19:11:13 1989 *************** *** 1,9 **** #ifndef lint ! static char *RCSid = "$Source: /usr/users/louie/ntp/RCS/ntp_sock.c,v $ $Revision: 3.4.1.1 $ $Date: 89/03/22 18:31:20 $"; #endif /* * $Log: ntp_sock.c,v $ * Revision 3.4.1.1 89/03/22 18:31:20 louie * patch3: Use new RCS headers. * --- 1,12 ---- #ifndef lint ! static char *RCSid = "$Source: /usr/users/louie/ntp/RCS/ntp_sock.c,v $ $Revision: 3.4.1.2 $ $Date: 89/04/07 19:07:46 $"; #endif /* * $Log: ntp_sock.c,v $ + * Revision 3.4.1.2 89/04/07 19:07:46 louie + * Deleted unused variables in ntp_sock.c + * * Revision 3.4.1.1 89/03/22 18:31:20 louie * patch3: Use new RCS headers. * *************** *** 148,154 **** struct ifreq ifreq, *ifr; int on = 1, off = 0; int n, i, vs; - struct sockaddr_in sock; extern char *malloc(); /* --- 151,156 ---- *************** *** 162,171 **** nintf = 1; - sock.sin_family = AF_INET; - sock.sin_port = port; - sock.sin_addr.s_addr = INADDR_ANY; - if ((vs = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { syslog(LOG_ERR, "vs=socket(AF_INET, SOCK_DGRAM) %m"); #ifdef TEST --- 164,169 ---- *************** *** 317,322 **** --- 315,321 ---- * is being bound anyway.. */ if (setsockopt(addrs[i].fd, SOL_SOCKET, SO_REUSEADDR, + (char *)&off, sizeof(off))) { syslog(LOG_ERR, "setsockopt SO_REUSEADDR off fails: %m"); #ifdef TEST Index: ntpd.c *** ntpd.c.old Fri Apr 7 19:11:20 1989 --- ntpd.c Fri Apr 7 19:11:23 1989 *************** *** 1,9 **** #ifndef lint ! static char *rcsid = "$Source: /usr/users/louie/ntp/RCS/ntpd.c,v $ $Revision: 3.4.1.5 $ $Date: 89/03/31 16:37:49 $"; #endif lint /* * $Log: ntpd.c,v $ * Revision 3.4.1.5 89/03/31 16:37:49 louie * Add support for "trusting" directive in NTP configuration file. It allows * you to specify at run time if non-configured peers will be synced to. --- 1,13 ---- #ifndef lint ! static char *rcsid = "$Source: /usr/users/louie/ntp/RCS/ntpd.c,v $ $Revision: 3.4.1.6 $ $Date: 89/04/07 19:09:04 $"; #endif lint /* * $Log: ntpd.c,v $ + * Revision 3.4.1.6 89/04/07 19:09:04 louie + * Added NOSWAP code for Ultrix systems to lock NTP process in memory. Deleted + * unused variable in ntpd.c + * * Revision 3.4.1.5 89/03/31 16:37:49 louie * Add support for "trusting" directive in NTP configuration file. It allows * you to specify at run time if non-configured peers will be synced to. *************** *** 73,78 **** --- 77,85 ---- #include #include #include + #ifdef NOSWAP + #include + #endif #include *************** *** 115,120 **** --- 122,131 ---- int dotickadj = 0; #endif + #ifdef NOSWAP + int noswap = 0; + #endif + int doset = 1; int ticked; int selfds; *************** *** 130,136 **** extern char *malloc(), *ntoa(); extern double s_fixed_to_double(), ul_fixed_to_double(); ! void finish(), timeout(), tock(), make_new_peer(), init_ntp(), init_kern_vars(), hourly(); extern void transmit(), process_packet(), clock_update(), clear(), clock_filter(), select_clock(); --- 141,147 ---- extern char *malloc(), *ntoa(); extern double s_fixed_to_double(), ul_fixed_to_double(); ! void finish(), timeout(), tock(), make_new_peer(), init_ntp(), initialize(), init_kern_vars(), hourly(); extern void transmit(), process_packet(), clock_update(), clear(), clock_filter(), select_clock(); *************** *** 157,163 **** then allow others to override default values */ prog_name = argv[0]; ! while ((cc = getopt(argc, argv, "a:c:dD:st")) != EOF) { switch (cc) { case 'a': if (strcmp(optarg, "any") == 0) --- 168,174 ---- then allow others to override default values */ prog_name = argv[0]; ! while ((cc = getopt(argc, argv, "a:c:dD:stn")) != EOF) { switch (cc) { case 'a': if (strcmp(optarg, "any") == 0) *************** *** 197,202 **** --- 208,222 ---- #endif break; + case 'n': + #ifdef NOSWAP + noswap = 1; + #else + fprintf(stderr, "%s: not compiled for noswap\n", + prog_name); + #endif + break; + case 'c': conf = optarg; break; *************** *** 247,262 **** setlogmask(LOG_UPTO(LOG_INFO)); #endif /* LOG_DAEMON */ ! syslog(LOG_NOTICE, "%s version $Revision: 3.4.1.5 $", prog_name); syslog(LOG_NOTICE, "patchlevel %d", PATCHLEVEL); #ifdef DEBUG if (debug) ! printf("%s version $Revision: 3.4.1.5 $ patchlevel %d\n", prog_name, PATCHLEVEL); #endif (void) setpriority(PRIO_PROCESS, 0, -10); servp = getservbyname("ntp", "udp"); if (servp == NULL) { syslog(LOG_CRIT, "udp/ntp: service unknown, using default %d", --- 267,293 ---- setlogmask(LOG_UPTO(LOG_INFO)); #endif /* LOG_DAEMON */ ! syslog(LOG_NOTICE, "%s version $Revision: 3.4.1.6 $", prog_name); syslog(LOG_NOTICE, "patchlevel %d", PATCHLEVEL); #ifdef DEBUG if (debug) ! printf("%s version $Revision: 3.4.1.6 $ patchlevel %d\n", prog_name, PATCHLEVEL); #endif (void) setpriority(PRIO_PROCESS, 0, -10); + #ifdef NOSWAP + if (noswap) + if (plock(PROCLOCK) != 0) { + syslog(LOG_ERR, "plock() failed: %m"); + #ifdef DEBUG + if (debug) + perror("plock() failed"); + #endif + } + #endif + servp = getservbyname("ntp", "udp"); if (servp == NULL) { syslog(LOG_CRIT, "udp/ntp: service unknown, using default %d", *************** *** 737,742 **** --- 768,777 ---- error = TRUE; else tickadj = i; #endif + #ifdef NOSWAP + } else if (strcmp(name, "noswap") == 0) { + noswap = 1; + #endif #ifdef BROADCAST_NTP } else if (strcmp(name, "broadcast") == 0) { if (fscanf(fp, "%s", name) != 1) { *************** *** 855,861 **** } } skipit:; ! } /* end else ntppeer */ do c = fgetc(fp); while (c != '\n' && c != EOF); /* next line */ --- 890,902 ---- } } skipit:; ! } else if( *name != '#' ) { ! syslog(LOG_ERR, "config file: %s not recognized", name); ! #ifdef DEBUG ! if(debug) ! printf("unrecognized option in config file: %s\n", name); ! #endif ! } do c = fgetc(fp); while (c != '\n' && c != EOF); /* next line */ *************** *** 1117,1123 **** /* every hour, dump some useful information to the log */ void hourly() { - register struct ntp_peer *peer = peer_list.head; char buf[200]; register int p = 0; extern double drift_comp, compliance; --- 1158,1163 ---- Index: stat.pl *** stat.pl.old Fri Apr 7 19:11:28 1989 --- stat.pl Fri Apr 7 19:11:29 1989 *************** *** 1,5 **** #!/usr/bin/perl ! # $Source: /usr/users/louie/ntp/RCS/stat.pl,v $ $Revision: 3.4.1.4 $ $Date: 89/03/31 16:38:42 $ # # Make plots from ntpd syslog messages. Invoked as: # --- 1,5 ---- #!/usr/bin/perl ! # $Source: /usr/users/louie/ntp/RCS/stat.pl,v $ $Revision: 3.4.1.5 $ $Date: 89/04/07 19:10:00 $ # # Make plots from ntpd syslog messages. Invoked as: # *************** *** 29,36 **** # off -0.015756 drft 0.000000 cmpl 0.000000 # Mar 10 08:56:19 trantor ntpd[27755]: clock: select peer 128.8.10.1 stratum 1 # was 130.126.174.40 stratum 1 # - # $scriptfile = $0; $month{'Jan'} = 0; $month{'Feb'} = 1; $month{'Mar'} = 2; $month{'Apr'} = 3; --- 29,37 ---- # off -0.015756 drft 0.000000 cmpl 0.000000 # Mar 10 08:56:19 trantor ntpd[27755]: clock: select peer 128.8.10.1 stratum 1 # was 130.126.174.40 stratum 1 + # Mar 31 16:55:19 trantor ntpd[2195]: /usr/local/etc/ntpd version $Revision: + # 3.4.1.5 $# # $scriptfile = $0; $month{'Jan'} = 0; $month{'Feb'} = 1; $month{'Mar'} = 2; $month{'Apr'} = 3; *************** *** 37,42 **** --- 38,61 ---- $month{'May'} = 4; $month{'Jun'} = 5; $month{'Jul'} = 6; $month{'Aug'} = 7; $month{'Sep'} = 8; $month{'Oct'} = 9; $month{'Nov'} = 10; $month{'Dec'} = 11; + # + # Currently, the year is not included in the syslog messages. We'll have to + # assume that the log files be processed were written this year. + # + ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); + + if ($year % 4) { + # not leap year + $days[0] = 0; $days[1] = 31; $days[2] = 59; $days[3] = 90; + $days[4] = 120; $days[5] = 151; $days[6] = 181; $days[7] = 212; + $days[8] = 243; $days[9] = 273; $days[10] = 304; $days[11] = 334; + } else { + # leap year + $days[0] = 0; $days[1] = 31; $days[2] = 60; $days[3] = 91; + $days[4] = 121; $days[5] = 152; $days[6] = 182; $days[7] = 213; + $days[8] = 244; $days[9] = 274; $days[10] = 305; $days[11] = 335; + } + die "Can't open drift compansation file\n" unless open(DRIFT, ">stats.drift"); die "Can't open offset file\n" unless open(OFF, ">stats.off"); die "Can't open compliance file\n" unless open(COMP, ">stats.comp"); *************** *** 66,78 **** } while (<>) { ! if (/.* ntpd\[[0-9]*\]: *.ntpd version/) { chop; @in = split; $recs++; @time = split(/:/,$in[2]); ! $t = $in[1]*24 + $time[0] + $time[1]/60 + $time[2]/3600; if (!$start) { $start = $t; --- 85,101 ---- } while (<>) { ! if (/.* ntpd\[[0-9]*\]: (.*\/ntpd) version \$Revision: \b(.*)\b/) { chop; @in = split; $recs++; + $revision = $1 . " " . $2; + print "Revision $revision\n"; + @time = split(/:/,$in[2]); ! $t = $in[1]*24 + $time[0] + $time[1]/60 + $time[2]/3600 + ! $days[$month{$in[0]}]*24; if (!$start) { $start = $t; *************** *** 83,89 **** chop; @in = split; @time = split(/:/,$in[2]); ! $t = $in[1]*24 + $time[0] + $time[1]/60 + $time[2]/3600; if (!$start) { $start = $t; --- 106,113 ---- chop; @in = split; @time = split(/:/,$in[2]); ! $t = $in[1]*24 + $time[0] + $time[1]/60 + $time[2]/3600 + ! $days[$month{$in[0]}]*24; if (!$start) { $start = $t; *************** *** 103,110 **** $recs++; @time = split(/:/,$in[2]); ! $t = $in[1]*24 + $time[0] + $time[1]/60 + $time[2]/3600; ! if (!$start) { $start = $t; printf "Start time is %s %s %s\n",$in[0],$in[1],$in[2]; --- 127,134 ---- $recs++; @time = split(/:/,$in[2]); ! $t = $in[1]*24 + $time[0] + $time[1]/60 + $time[2]/3600 + ! $days[$month{$in[0]}]*24; if (!$start) { $start = $t; printf "Start time is %s %s %s\n",$in[0],$in[1],$in[2]; Index: test.c *** test.c.old Fri Apr 7 19:11:33 1989 --- test.c Fri Apr 7 19:11:33 1989 *************** *** 1,9 **** #ifndef lint ! static char *RCSid = "$Source: /usr/users/louie/ntp/RCS/test.c,v $ $Revision: 3.4.1.2 $ $Date: 89/03/31 16:39:19 $"; #endif /* * $Log: test.c,v $ * Revision 3.4.1.2 89/03/31 16:39:19 louie * Bug fix for VAX_COMPILER_FLT_BUG test, start of test for Sun problem. * --- 1,12 ---- #ifndef lint ! static char *RCSid = "$Source: /usr/users/louie/ntp/RCS/test.c,v $ $Revision: 3.4.1.3 $ $Date: 89/04/07 19:10:41 $"; #endif /* * $Log: test.c,v $ + * Revision 3.4.1.3 89/04/07 19:10:41 louie + * Add check for SUN_FLT_BUG problem in test.c + * * Revision 3.4.1.2 89/03/31 16:39:19 louie * Bug fix for VAX_COMPILER_FLT_BUG test, start of test for Sun problem. * *************** *** 57,65 **** #define TRUE 1 #define FALSE 0 - #define BSD_43 ! int test1(), test2(), test3(); double value[8] = {5.1, -5.1, 1.5, -1.5, 0.5, -0.5, -0.05, 0.0}; main(argc, argv) --- 60,67 ---- #define TRUE 1 #define FALSE 0 ! int test1(), test2(), test3(), test4(); double value[8] = {5.1, -5.1, 1.5, -1.5, 0.5, -0.5, -0.05, 0.0}; main(argc, argv) *************** *** 67,80 **** char **argv; { if (argc > 1 && strcmp(argv[1], "-v") == 0) { ! if (test1(1)) ! exit(1); ! if (test2(1)) ! exit(2); ! if (test3(1)) ! exit(3); ! if (test4(1)) ! exit(4); } else { if (test3(0)) exit(3); --- 69,78 ---- char **argv; { if (argc > 1 && strcmp(argv[1], "-v") == 0) { ! exit(test1(1) ! + test2(1) ! + test3(1) ! + test4(1)); } else { if (test3(0)) exit(3); *************** *** 92,98 **** struct l_fixedpt sample; double s_fixed_to_double(); struct s_fixedpt s_sample; - double x; for (i = 0; i < 8; i++) { printf(" %4.2f ", value[i]); --- 90,95 ---- *************** *** 126,132 **** test3(v) int v; { ! unsigned long ul = 0x80000000; double dbl; dbl = ul; --- 123,129 ---- test3(v) int v; { ! unsigned long ul = 0x80000001; double dbl; dbl = ul; *************** *** 133,141 **** #ifdef VAX_COMPILER_FLT_BUG if (dbl < 0.0) dbl += 4.294967296e9; #endif ! if (dbl != 2147483648.0) { printf("test3 fails: can't convert from unsigned long to float\n"); ! printf(" (%lu != %f)\n", ul, dbl); printf("Try defining VAX_COMPILER_FLT_BUG in the Makefile.\n"); return 1; } else { --- 130,138 ---- #ifdef VAX_COMPILER_FLT_BUG if (dbl < 0.0) dbl += 4.294967296e9; #endif ! if (dbl != 2147483649.0) { printf("test3 fails: can't convert from unsigned long to float\n"); ! printf(" (%lu != %15g)\n", ul, dbl); printf("Try defining VAX_COMPILER_FLT_BUG in the Makefile.\n"); return 1; } else { *************** *** 148,163 **** test4(v) int v; { ! /* ! * Need a test for the SUN 2^31 - 2^32 problem (in ntpsubs.c). Anyone ! * with a Sun out there that can come up with one? ! * ! */ ! if (0) { printf("test4 fails:\n"); printf("Try defining SUN_FLT_BUG in the Makefile\n"); return 1; } - return 0; } - --- 145,168 ---- test4(v) int v; { ! double dbl = 1024.0 * 1024.0 * 1024.0; /* 2^30 */ ! #ifdef SUN_FLT_BUG ! int l = 1.5 * dbl; ! u_long ul = (l<<1); ! #else ! u_long ul = 3.0 * dbl; /* between 2^31 and 2^32 */ ! #endif ! if (v) ! printf("test4: 3.0*1024.0*1024.0*1024.0 = 0x%08x\n", ul); ! ! if (ul != 0xc0000000) { printf("test4 fails:\n"); + printf("Can't convert unsigned long to double.\n"); printf("Try defining SUN_FLT_BUG in the Makefile\n"); return 1; + } else { + if (v) + printf("test4 passes\n"); + return 0; } }