svn commit: r226358 - head/usr.bin/finger

2011-10-14 Thread Ed Schouten
Author: ed
Date: Fri Oct 14 07:24:23 2011
New Revision: 226358
URL: http://svn.freebsd.org/changeset/base/226358

Log:
  Build finger(1) with WARNS=6.

Modified:
  head/usr.bin/finger/Makefile
  head/usr.bin/finger/lprint.c

Modified: head/usr.bin/finger/Makefile
==
--- head/usr.bin/finger/MakefileFri Oct 14 06:38:45 2011
(r226357)
+++ head/usr.bin/finger/MakefileFri Oct 14 07:24:23 2011
(r226358)
@@ -5,6 +5,4 @@ PROG=   finger
 SRCS=  finger.c lprint.c net.c sprint.c util.c
 MAN=   finger.1 finger.conf.5
 
-WARNS?=2
-
 .include bsd.prog.mk

Modified: head/usr.bin/finger/lprint.c
==
--- head/usr.bin/finger/lprint.cFri Oct 14 06:38:45 2011
(r226357)
+++ head/usr.bin/finger/lprint.cFri Oct 14 07:24:23 2011
(r226358)
@@ -306,7 +306,7 @@ show_text(const char *directory, const c
return(0);
 
/* If short enough, and no newlines, show it on a single line.*/
-   if (sb.st_size = LINE_LEN - strlen(header) - 5) {
+   if (sb.st_size = (off_t)(LINE_LEN - strlen(header) - 5)) {
nr = read(fd, tbuf, sizeof(tbuf));
if (nr = 0) {
(void)close(fd);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r226359 - head/usr.bin/look

2011-10-14 Thread Ed Schouten
Author: ed
Date: Fri Oct 14 07:24:48 2011
New Revision: 226359
URL: http://svn.freebsd.org/changeset/base/226359

Log:
  Build look(1) with WARNS=6.

Modified:
  head/usr.bin/look/Makefile
  head/usr.bin/look/look.c

Modified: head/usr.bin/look/Makefile
==
--- head/usr.bin/look/Makefile  Fri Oct 14 07:24:23 2011(r226358)
+++ head/usr.bin/look/Makefile  Fri Oct 14 07:24:48 2011(r226359)
@@ -3,6 +3,4 @@
 
 PROG=  look
 
-WARNS?=2
-
 .include bsd.prog.mk

Modified: head/usr.bin/look/look.c
==
--- head/usr.bin/look/look.cFri Oct 14 07:24:23 2011(r226358)
+++ head/usr.bin/look/look.cFri Oct 14 07:24:48 2011(r226359)
@@ -134,7 +134,7 @@ main(int argc, char *argv[])
do {
if ((fd = open(file, O_RDONLY, 0))  0 || fstat(fd, sb))
err(2, %s, file);
-   if (sb.st_size  SIZE_T_MAX)
+   if (sb.st_size  (off_t)SIZE_T_MAX)
errx(2, %s: %s, file, strerror(EFBIG));
if (sb.st_size == 0) {
close(fd);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r226360 - head/usr.bin/tr

2011-10-14 Thread Ed Schouten
Author: ed
Date: Fri Oct 14 07:25:20 2011
New Revision: 226360
URL: http://svn.freebsd.org/changeset/base/226360

Log:
  Build tr(1) with WARNS=6.

Modified:
  head/usr.bin/tr/Makefile
  head/usr.bin/tr/cset.c
  head/usr.bin/tr/str.c

Modified: head/usr.bin/tr/Makefile
==
--- head/usr.bin/tr/MakefileFri Oct 14 07:24:48 2011(r226359)
+++ head/usr.bin/tr/MakefileFri Oct 14 07:25:20 2011(r226360)
@@ -4,6 +4,4 @@
 PROG=  tr
 SRCS=  cmap.c cset.c str.c tr.c
 
-WARNS?=1
-
 .include bsd.prog.mk

Modified: head/usr.bin/tr/cset.c
==
--- head/usr.bin/tr/cset.c  Fri Oct 14 07:24:48 2011(r226359)
+++ head/usr.bin/tr/cset.c  Fri Oct 14 07:25:20 2011(r226360)
@@ -153,11 +153,11 @@ cset_in_hard(struct cset *cs, wchar_t ch
struct csclass *csc;
 
for (csc = cs-cs_classes; csc != NULL; csc = csc-csc_next)
-   if (csc-csc_invert ^ iswctype(ch, csc-csc_type) != 0)
+   if ((csc-csc_invert ^ iswctype(ch, csc-csc_type)) != 0)
return (cs-cs_invert ^ true);
if (cs-cs_root != NULL) {
cs-cs_root = cset_splay(cs-cs_root, ch);
-   return (cs-cs_invert ^ cset_rangecmp(cs-cs_root, ch) == 0);
+   return ((cs-cs_invert ^ cset_rangecmp(cs-cs_root, ch)) == 0);
}
return (cs-cs_invert ^ false);
 }

Modified: head/usr.bin/tr/str.c
==
--- head/usr.bin/tr/str.c   Fri Oct 14 07:24:48 2011(r226359)
+++ head/usr.bin/tr/str.c   Fri Oct 14 07:25:20 2011(r226360)
@@ -57,8 +57,7 @@ static int  genrange(STR *, int);
 static voidgenseq(STR *);
 
 wint_t
-next(s)
-   STR *s;
+next(STR *s)
 {
int is_octal;
wint_t ch;
@@ -135,8 +134,7 @@ next(s)
 }
 
 static int
-bracket(s)
-   STR *s;
+bracket(STR *s)
 {
char *p;
 
@@ -173,8 +171,7 @@ bracket(s)
 }
 
 static void
-genclass(s)
-   STR *s;
+genclass(STR *s)
 {
 
if ((s-cclass = wctype(s-str)) == 0)
@@ -190,8 +187,7 @@ genclass(s)
 }
 
 static void
-genequiv(s)
-   STR *s;
+genequiv(STR *s)
 {
int i, p, pri;
char src[2], dst[3];
@@ -295,8 +291,7 @@ genrange(STR *s, int was_octal)
 }
 
 static void
-genseq(s)
-   STR *s;
+genseq(STR *s)
 {
char *ep;
wchar_t wc;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r226361 - in head/usr.bin: last leave

2011-10-14 Thread Ed Schouten
Author: ed
Date: Fri Oct 14 07:26:20 2011
New Revision: 226361
URL: http://svn.freebsd.org/changeset/base/226361

Log:
  Build last(1) and leave(1) with WARNS=6.
  
  These ports were only built with WARNS=1, because they use certain
  format extensions. We can use NO_WFORMAT for that instead.

Modified:
  head/usr.bin/last/Makefile
  head/usr.bin/leave/Makefile

Modified: head/usr.bin/last/Makefile
==
--- head/usr.bin/last/Makefile  Fri Oct 14 07:25:20 2011(r226360)
+++ head/usr.bin/last/Makefile  Fri Oct 14 07:26:20 2011(r226361)
@@ -3,6 +3,6 @@
 
 PROG=  last
 
-WARNS?=1
+NO_WFORMAT=
 
 .include bsd.prog.mk

Modified: head/usr.bin/leave/Makefile
==
--- head/usr.bin/leave/Makefile Fri Oct 14 07:25:20 2011(r226360)
+++ head/usr.bin/leave/Makefile Fri Oct 14 07:26:20 2011(r226361)
@@ -3,6 +3,6 @@
 
 PROG=  leave
 
-WARNS?=1
+NO_WFORMAT=
 
 .include bsd.prog.mk
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r226362 - head/usr.bin/nl

2011-10-14 Thread Ed Schouten
Author: ed
Date: Fri Oct 14 07:28:39 2011
New Revision: 226362
URL: http://svn.freebsd.org/changeset/base/226362

Log:
  Make nl(1) build with WARNS=6.
  
  Obtained from:NetBSD

Modified:
  head/usr.bin/nl/Makefile
  head/usr.bin/nl/nl.c

Modified: head/usr.bin/nl/Makefile
==
--- head/usr.bin/nl/MakefileFri Oct 14 07:26:20 2011(r226361)
+++ head/usr.bin/nl/MakefileFri Oct 14 07:28:39 2011(r226362)
@@ -2,6 +2,4 @@
 
 PROG=  nl
 
-WARNS?=2
-
 .include bsd.prog.mk

Modified: head/usr.bin/nl/nl.c
==
--- head/usr.bin/nl/nl.cFri Oct 14 07:26:20 2011(r226361)
+++ head/usr.bin/nl/nl.cFri Oct 14 07:28:39 2011(r226362)
@@ -73,9 +73,9 @@ struct numbering_property {
 #define NP_LASTHEADER
 
 static struct numbering_property numbering_properties[NP_LAST + 1] = {
-   { footer, number_none },
-   { body,   number_nonempty },
-   { header, number_none }
+   { .name = footer, .type = number_none },
+   { .name = body, .type = number_nonempty },
+   { .name = header, .type = number_none }
 };
 
 #define max(a, b)  ((a)  (b) ? (a) : (b))
@@ -128,9 +128,7 @@ static int width = 6;
 
 
 int
-main(argc, argv)
-   int argc;
-   char *argv[];
+main(int argc, char *argv[])
 {
int c;
long val;
@@ -258,7 +256,7 @@ main(argc, argv)
delimlen = delim1len + delim2len;
 
/* Allocate a buffer suitable for preformatting line number. */
-   intbuffersize = max(INT_STRLEN_MAXIMUM, width) + 1; /* NUL */
+   intbuffersize = max((int)INT_STRLEN_MAXIMUM, width) + 1; /* NUL */
if ((intbuffer = malloc(intbuffersize)) == NULL)
err(EXIT_FAILURE, cannot allocate preformatting buffer);
 
@@ -270,7 +268,7 @@ main(argc, argv)
 }
 
 static void
-filter()
+filter(void)
 {
char *buffer;
size_t buffersize;
@@ -359,9 +357,7 @@ nextline:
  */
 
 static void
-parse_numbering(argstr, section)
-   const char *argstr;
-   int section;
+parse_numbering(const char *argstr, int section)
 {
int error;
char errorbuf[NL_TEXTMAX];
@@ -403,7 +399,7 @@ parse_numbering(argstr, section)
 }
 
 static void
-usage()
+usage(void)
 {
 
(void)fprintf(stderr,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r226360 - head/usr.bin/tr

2011-10-14 Thread Jilles Tjoelker
On Fri, Oct 14, 2011 at 07:25:21AM +, Ed Schouten wrote:
 Author: ed
 Date: Fri Oct 14 07:25:20 2011
 New Revision: 226360
 URL: http://svn.freebsd.org/changeset/base/226360

 Log:
   Build tr(1) with WARNS=6.

 Modified:
   head/usr.bin/tr/Makefile
   head/usr.bin/tr/cset.c
   head/usr.bin/tr/str.c

 Modified: head/usr.bin/tr/cset.c
 ==
 --- head/usr.bin/tr/cset.cFri Oct 14 07:24:48 2011(r226359)
 +++ head/usr.bin/tr/cset.cFri Oct 14 07:25:20 2011(r226360)
 @@ -153,11 +153,11 @@ cset_in_hard(struct cset *cs, wchar_t ch
   struct csclass *csc;
  
   for (csc = cs-cs_classes; csc != NULL; csc = csc-csc_next)
 - if (csc-csc_invert ^ iswctype(ch, csc-csc_type) != 0)
 + if ((csc-csc_invert ^ iswctype(ch, csc-csc_type)) != 0)
   return (cs-cs_invert ^ true);
   if (cs-cs_root != NULL) {
   cs-cs_root = cset_splay(cs-cs_root, ch);
 - return (cs-cs_invert ^ cset_rangecmp(cs-cs_root, ch) == 0);
 + return ((cs-cs_invert ^ cset_rangecmp(cs-cs_root, ch)) == 0);
   }
   return (cs-cs_invert ^ false);
  }

These two changes are wrong. Contrary to what one might expect, the !=
and == operators bind more strongly than the ^ operator, and the
original code depends on that.

-- 
Jilles Tjoelker
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r226363 - head/usr.bin/tr

2011-10-14 Thread Ed Schouten
Author: ed
Date: Fri Oct 14 10:43:55 2011
New Revision: 226363
URL: http://svn.freebsd.org/changeset/base/226363

Log:
  Put parentheses in the right place.
  
  Noted by: jilles@
  Broken by:me. :-(

Modified:
  head/usr.bin/tr/cset.c

Modified: head/usr.bin/tr/cset.c
==
--- head/usr.bin/tr/cset.c  Fri Oct 14 07:28:39 2011(r226362)
+++ head/usr.bin/tr/cset.c  Fri Oct 14 10:43:55 2011(r226363)
@@ -153,11 +153,11 @@ cset_in_hard(struct cset *cs, wchar_t ch
struct csclass *csc;
 
for (csc = cs-cs_classes; csc != NULL; csc = csc-csc_next)
-   if ((csc-csc_invert ^ iswctype(ch, csc-csc_type)) != 0)
+   if (csc-csc_invert ^ (iswctype(ch, csc-csc_type) != 0))
return (cs-cs_invert ^ true);
if (cs-cs_root != NULL) {
cs-cs_root = cset_splay(cs-cs_root, ch);
-   return ((cs-cs_invert ^ cset_rangecmp(cs-cs_root, ch)) == 0);
+   return (cs-cs_invert ^ (cset_rangecmp(cs-cs_root, ch) == 0));
}
return (cs-cs_invert ^ false);
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r226355 - head/sys/dev/ath

2011-10-14 Thread John Baldwin
On Thursday, October 13, 2011 11:24:35 pm Adrian Chadd wrote:
 Author: adrian
 Date: Fri Oct 14 03:24:35 2011
 New Revision: 226355
 URL: http://svn.freebsd.org/changeset/base/226355
 
 Log:
   ath_pci PCI setup fixes.
   
   * Break out the PCI setup override code into a new function.
   * Re-apply the PCI overrides on powersave resume. The retry timeout
 register isn't currently being saved/resumed by the PCI driver/bus
 code.

It isn't a standard config register.  (Device-specific registers start at 
0x41).  Drivers have always been responsible for saving and restoring device-
specific registers:

if_ath_pci.c:#definePCIR_RETRY_TIMEOUT  0x41

-- 
John Baldwin
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r226364 - head/sys/compat/freebsd32

2011-10-14 Thread John Baldwin
Author: jhb
Date: Fri Oct 14 11:46:46 2011
New Revision: 226364
URL: http://svn.freebsd.org/changeset/base/226364

Log:
  Use PAIR32TO64() for the offset and length parameters to
  freebsd32_posix_fallocate() to properly handle big-endian platforms.
  
  Reviewed by:  mdf
  MFC after:1 week

Modified:
  head/sys/compat/freebsd32/freebsd32_misc.c
  head/sys/compat/freebsd32/syscalls.master

Modified: head/sys/compat/freebsd32/freebsd32_misc.c
==
--- head/sys/compat/freebsd32/freebsd32_misc.c  Fri Oct 14 10:43:55 2011
(r226363)
+++ head/sys/compat/freebsd32/freebsd32_misc.c  Fri Oct 14 11:46:46 2011
(r226364)
@@ -2831,7 +2831,7 @@ freebsd32_posix_fallocate(struct thread 
struct posix_fallocate_args ap;
 
ap.fd = uap-fd;
-   ap.offset = (uap-offsetlo | ((off_t)uap-offsethi  32));
-   ap.len = (uap-lenlo | ((off_t)uap-lenhi  32));
+   ap.offset = PAIR32TO64(off_t, uap-offset);
+   ap.len = PAIR32TO64(off_t, uap-len);
return (sys_posix_fallocate(td, ap));
 }

Modified: head/sys/compat/freebsd32/syscalls.master
==
--- head/sys/compat/freebsd32/syscalls.master   Fri Oct 14 10:43:55 2011
(r226363)
+++ head/sys/compat/freebsd32/syscalls.master   Fri Oct 14 11:46:46 2011
(r226364)
@@ -989,6 +989,6 @@
size_t inbuflen, void *outbufp, \
size_t outbuflen); }
 530AUE_NULLSTD { int freebsd32_posix_fallocate(int fd,\
-uint32_t offsetlo, uint32_t offsethi,\
-uint32_t lenlo, uint32_t lenhi); }
+   uint32_t offset1, uint32_t offset2,\
+   uint32_t len1, uint32_t len2); }
 531AUE_NULLUNIMPL  posix_fadvise
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r226365 - head/sys/compat/freebsd32

2011-10-14 Thread John Baldwin
Author: jhb
Date: Fri Oct 14 11:47:14 2011
New Revision: 226365
URL: http://svn.freebsd.org/changeset/base/226365

Log:
  Regen.

Modified:
  head/sys/compat/freebsd32/freebsd32_proto.h
  head/sys/compat/freebsd32/freebsd32_syscall.h
  head/sys/compat/freebsd32/freebsd32_syscalls.c
  head/sys/compat/freebsd32/freebsd32_sysent.c
  head/sys/compat/freebsd32/freebsd32_systrace_args.c

Modified: head/sys/compat/freebsd32/freebsd32_proto.h
==
--- head/sys/compat/freebsd32/freebsd32_proto.h Fri Oct 14 11:46:46 2011
(r226364)
+++ head/sys/compat/freebsd32/freebsd32_proto.h Fri Oct 14 11:47:14 2011
(r226365)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 226348 
2011-10-13 18:21:11Z marcel 
+ * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 226364 
2011-10-14 11:46:46Z jhb 
  */
 
 #ifndef _FREEBSD32_SYSPROTO_H_
@@ -575,10 +575,10 @@ struct freebsd32_pselect_args {
 };
 struct freebsd32_posix_fallocate_args {
char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
-   char offsetlo_l_[PADL_(uint32_t)]; uint32_t offsetlo; char 
offsetlo_r_[PADR_(uint32_t)];
-   char offsethi_l_[PADL_(uint32_t)]; uint32_t offsethi; char 
offsethi_r_[PADR_(uint32_t)];
-   char lenlo_l_[PADL_(uint32_t)]; uint32_t lenlo; char 
lenlo_r_[PADR_(uint32_t)];
-   char lenhi_l_[PADL_(uint32_t)]; uint32_t lenhi; char 
lenhi_r_[PADR_(uint32_t)];
+   char offset1_l_[PADL_(uint32_t)]; uint32_t offset1; char 
offset1_r_[PADR_(uint32_t)];
+   char offset2_l_[PADL_(uint32_t)]; uint32_t offset2; char 
offset2_r_[PADR_(uint32_t)];
+   char len1_l_[PADL_(uint32_t)]; uint32_t len1; char 
len1_r_[PADR_(uint32_t)];
+   char len2_l_[PADL_(uint32_t)]; uint32_t len2; char 
len2_r_[PADR_(uint32_t)];
 };
 #if !defined(PAD64_REQUIRED)  defined(__powerpc__)
 #define PAD64_REQUIRED

Modified: head/sys/compat/freebsd32/freebsd32_syscall.h
==
--- head/sys/compat/freebsd32/freebsd32_syscall.h   Fri Oct 14 11:46:46 
2011(r226364)
+++ head/sys/compat/freebsd32/freebsd32_syscall.h   Fri Oct 14 11:47:14 
2011(r226365)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 226348 
2011-10-13 18:21:11Z marcel 
+ * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 226364 
2011-10-14 11:46:46Z jhb 
  */
 
 #defineFREEBSD32_SYS_syscall   0

Modified: head/sys/compat/freebsd32/freebsd32_syscalls.c
==
--- head/sys/compat/freebsd32/freebsd32_syscalls.c  Fri Oct 14 11:46:46 
2011(r226364)
+++ head/sys/compat/freebsd32/freebsd32_syscalls.c  Fri Oct 14 11:47:14 
2011(r226365)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 226348 
2011-10-13 18:21:11Z marcel 
+ * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 226364 
2011-10-14 11:46:46Z jhb 
  */
 
 const char *freebsd32_syscallnames[] = {

Modified: head/sys/compat/freebsd32/freebsd32_sysent.c
==
--- head/sys/compat/freebsd32/freebsd32_sysent.cFri Oct 14 11:46:46 
2011(r226364)
+++ head/sys/compat/freebsd32/freebsd32_sysent.cFri Oct 14 11:47:14 
2011(r226365)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 226348 
2011-10-13 18:21:11Z marcel 
+ * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 226364 
2011-10-14 11:46:46Z jhb 
  */
 
 #include opt_compat.h

Modified: head/sys/compat/freebsd32/freebsd32_systrace_args.c
==
--- head/sys/compat/freebsd32/freebsd32_systrace_args.c Fri Oct 14 11:46:46 
2011(r226364)
+++ head/sys/compat/freebsd32/freebsd32_systrace_args.c Fri Oct 14 11:47:14 
2011(r226365)
@@ -3027,10 +3027,10 @@ systrace_args(int sysnum, void *params, 
case 530: {
struct freebsd32_posix_fallocate_args *p = params;
iarg[0] = p-fd; /* int */
-   uarg[1] = p-offsetlo; /* uint32_t */
-   uarg[2] = p-offsethi; /* uint32_t */
-   uarg[3] = p-lenlo; /* uint32_t */
-   uarg[4] = p-lenhi; /* uint32_t */
+   uarg[1] = p-offset1; /* uint32_t */
+   uarg[2] = p-offset2; /* uint32_t */
+   uarg[3] = p-len1; /* uint32_t */
+   uarg[4] = p-len2; /* uint32_t */

svn commit: r226366 - head/sys/vm

2011-10-14 Thread John Baldwin
Author: jhb
Date: Fri Oct 14 11:48:32 2011
New Revision: 226366
URL: http://svn.freebsd.org/changeset/base/226366

Log:
  Fix a typo in a comment.

Modified:
  head/sys/vm/vnode_pager.c

Modified: head/sys/vm/vnode_pager.c
==
--- head/sys/vm/vnode_pager.c   Fri Oct 14 11:47:14 2011(r226365)
+++ head/sys/vm/vnode_pager.c   Fri Oct 14 11:48:32 2011(r226366)
@@ -1150,7 +1150,7 @@ vnode_pager_generic_putpages(struct vnod
VM_OBJECT_UNLOCK(object);
 
/*
-* pageouts are already clustered, use IO_ASYNC t o force a bawrite()
+* pageouts are already clustered, use IO_ASYNC to force a bawrite()
 * rather then a bdwrite() to prevent paging I/O from saturating 
 * the buffer cache.  Dummy-up the sequential heuristic to cause
 * large ranges to cluster.  If neither IO_SYNC or IO_ASYNC is set,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r226355 - head/sys/dev/ath

2011-10-14 Thread Adrian Chadd
On 14 October 2011 19:43, John Baldwin j...@freebsd.org wrote:

 It isn't a standard config register.  (Device-specific registers start at
 0x41).  Drivers have always been responsible for saving and restoring device-
 specific registers:

 if_ath_pci.c:#define    PCIR_RETRY_TIMEOUT      0x41

Good to know, thanks.

Time to see if I can dig up the other registers. It seems there are
some latency register changes which our driver isn't doing.


Adrian
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r226343 - head/sys/vm

2011-10-14 Thread Kostik Belousov
On Thu, Oct 13, 2011 at 06:50:30PM -0400, David Schultz wrote:
 On Thu, Oct 13, 2011, Marcel Moolenaar wrote:
  
  On Oct 13, 2011, at 2:07 PM, John Baldwin wrote:
   
   That's really besides the point. ABI changes are made deliberately
   and ABIs must be well-documented for anyone to adhere to it. You
   can't post hoc wave your hand and say that at some unspecified time
   in the past the ABI changed: at what precise time does supported
   by hardware mean and how does that tie to a major FreeBSD version?
   
   Point in case: the JDK 1.4.x still works on FreeBSD 9.x (i386), so
   the ABI really hasn't changed at all in that respect.
   
   I think if you booted a FreeBSD 9.x i386 PAE kernel you'd find that the
   jdk did not work.  That will be true for any i386 PAE kernel back to
   when PG_NX support was introduced.
  
  That's bad.
After more thought about the issue, I do not agree with you.
Elf specification says about the PF_R flag that only read permission
for the memory image of the segment is required, but read and execute
is allowed.

In other words, it is a bug in the old jre, which is further confirmed
by the fact that later jres run with non-executable head.

 
 Recent binutils support a PT_GNU_HEAP flag in the ELF header that
 controls whether heap allocations are executable by default.  In
 Linux, the flag can be set using an ld option or the execstack(8)
 command.  That seems like a better way to go than breaking old
 JVMs or disabling the security feature.

No, recent binutils do not support PT_GNU_HEAD. git grep -e PT_GNU_HEAD
on the up to date checkout of binutils head gives zero matches. There are
indeed PT_GNU_HEAP patches floating around from some hardening projects.

There is indeed PT_GNU_STACK, which we do support.

I want to commit the following refinement:

diff --git a/sys/compat/freebsd32/freebsd32_misc.c 
b/sys/compat/freebsd32/freebsd32_misc.c
index 6638ec8..fc2932b 100644
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -445,7 +445,7 @@ freebsd32_mprotect(struct thread *td, struct 
freebsd32_mprotect_args *uap)
ap.len = uap-len;
ap.prot = uap-prot;
 #if defined(__amd64__) || defined(__ia64__)
-   if (ap.prot  PROT_READ)
+   if (i386_read_exec  (ap.prot  PROT_READ) != 0)
ap.prot |= PROT_EXEC;
 #endif
return (sys_mprotect(td, ap));
@@ -536,7 +536,7 @@ freebsd32_mmap(struct thread *td, struct 
freebsd32_mmap_args *uap)
 #endif
 
 #if defined(__amd64__) || defined(__ia64__)
-   if (prot  PROT_READ)
+   if (i386_read_exec  (prot  PROT_READ))
prot |= PROT_EXEC;
 #endif
 
diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c
index 669c652..9970386 100644
--- a/sys/kern/imgact_elf.c
+++ b/sys/kern/imgact_elf.c
@@ -118,11 +118,24 @@ static int elf_legacy_coredump = 0;
 SYSCTL_INT(_debug, OID_AUTO, __elfN(legacy_coredump), CTLFLAG_RW, 
 elf_legacy_coredump, 0, );
 
-static int __elfN(nxstack) = 0;
+static int __elfN(nxstack) =
+#if defined(__amd64__) || defined(__powerpc__) /* both 64 and 32 bit */
+   1;
+#else
+   0;
+#endif
 SYSCTL_INT(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO,
 nxstack, CTLFLAG_RW, __elfN(nxstack), 0,
 __XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE)) : enable non-executable stack);
 
+#if __ELF_WORD_SIZE == 32
+#if defined(__amd64__) || defined(__ia64__)
+int i386_read_exec = 0;
+SYSCTL_INT(_kern_elf32, OID_AUTO, read_exec, CTLFLAG_RW, i386_read_exec, 0,
+enable execution from readable segments);
+#endif
+#endif
+
 static Elf_Brandinfo *elf_brand_list[MAX_BRANDS];
 
 #definetrunc_page_ps(va, ps)   ((va)  ~(ps - 1))
@@ -1666,7 +1679,7 @@ __elfN(trans_prot)(Elf_Word flags)
prot |= VM_PROT_READ;
 #if __ELF_WORD_SIZE == 32
 #if defined(__amd64__) || defined(__ia64__)
-   if (flags  PF_R)
+   if (i386_read_exec  (flags  PF_R))
prot |= VM_PROT_EXECUTE;
 #endif
 #endif
diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h
index 6a4b485..3694ceb 100644
--- a/sys/sys/sysent.h
+++ b/sys/sys/sysent.h
@@ -151,6 +152,10 @@ extern struct sysentvec null_sysvec;
 extern struct sysent sysent[];
 extern const char *syscallnames[];
 
+#if defined(__amd64__) || defined(__ia64__)
+extern int i386_read_exec;
+#endif
+
 #defineNO_SYSCALL (-1)
 
 struct module;
diff --git a/sys/vm/vm_unix.c b/sys/vm/vm_unix.c
index d4ea3b7..253ab77 100644
--- a/sys/vm/vm_unix.c
+++ b/sys/vm/vm_unix.c
@@ -141,7 +141,7 @@ sys_obreak(td, uap)
prot = VM_PROT_RW;
 #ifdef COMPAT_FREEBSD32
 #if defined(__amd64__) || defined(__ia64__)
-   if (SV_PROC_FLAG(td-td_proc, SV_ILP32))
+   if (i386_read_exec  SV_PROC_FLAG(td-td_proc, SV_ILP32))
prot |= VM_PROT_EXECUTE;
 #endif
 #endif


pgpwU23KFwULl.pgp
Description: PGP signature


Re: svn commit: r226343 - head/sys/vm

2011-10-14 Thread Garrett Cooper
On Fri, Oct 14, 2011 at 11:24 AM, Kostik Belousov kostik...@gmail.com wrote:
 On Thu, Oct 13, 2011 at 06:50:30PM -0400, David Schultz wrote:
 On Thu, Oct 13, 2011, Marcel Moolenaar wrote:
 
  On Oct 13, 2011, at 2:07 PM, John Baldwin wrote:
  
   That's really besides the point. ABI changes are made deliberately
   and ABIs must be well-documented for anyone to adhere to it. You
   can't post hoc wave your hand and say that at some unspecified time
   in the past the ABI changed: at what precise time does supported
   by hardware mean and how does that tie to a major FreeBSD version?
  
   Point in case: the JDK 1.4.x still works on FreeBSD 9.x (i386), so
   the ABI really hasn't changed at all in that respect.
  
   I think if you booted a FreeBSD 9.x i386 PAE kernel you'd find that the
   jdk did not work.  That will be true for any i386 PAE kernel back to
   when PG_NX support was introduced.
 
  That's bad.
 After more thought about the issue, I do not agree with you.
 Elf specification says about the PF_R flag that only read permission
 for the memory image of the segment is required, but read and execute
 is allowed.

 In other words, it is a bug in the old jre, which is further confirmed
 by the fact that later jres run with non-executable head.


 Recent binutils support a PT_GNU_HEAP flag in the ELF header that
 controls whether heap allocations are executable by default.  In
 Linux, the flag can be set using an ld option or the execstack(8)
 command.  That seems like a better way to go than breaking old
 JVMs or disabling the security feature.

 No, recent binutils do not support PT_GNU_HEAD. git grep -e PT_GNU_HEAD
 on the up to date checkout of binutils head gives zero matches. There are
 indeed PT_GNU_HEAP patches floating around from some hardening projects.

 There is indeed PT_GNU_STACK, which we do support.

 I want to commit the following refinement:

 diff --git a/sys/compat/freebsd32/freebsd32_misc.c 
 b/sys/compat/freebsd32/freebsd32_misc.c
 index 6638ec8..fc2932b 100644
 --- a/sys/compat/freebsd32/freebsd32_misc.c
 +++ b/sys/compat/freebsd32/freebsd32_misc.c
 @@ -445,7 +445,7 @@ freebsd32_mprotect(struct thread *td, struct 
 freebsd32_mprotect_args *uap)
        ap.len = uap-len;
        ap.prot = uap-prot;
  #if defined(__amd64__) || defined(__ia64__)
 -       if (ap.prot  PROT_READ)
 +       if (i386_read_exec  (ap.prot  PROT_READ) != 0)
                ap.prot |= PROT_EXEC;
  #endif
        return (sys_mprotect(td, ap));
 @@ -536,7 +536,7 @@ freebsd32_mmap(struct thread *td, struct 
 freebsd32_mmap_args *uap)
  #endif

  #if defined(__amd64__) || defined(__ia64__)
 -       if (prot  PROT_READ)
 +       if (i386_read_exec  (prot  PROT_READ))
                prot |= PROT_EXEC;
  #endif

 diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c
 index 669c652..9970386 100644
 --- a/sys/kern/imgact_elf.c
 +++ b/sys/kern/imgact_elf.c
 @@ -118,11 +118,24 @@ static int elf_legacy_coredump = 0;
  SYSCTL_INT(_debug, OID_AUTO, __elfN(legacy_coredump), CTLFLAG_RW,
     elf_legacy_coredump, 0, );

 -static int __elfN(nxstack) = 0;
 +static int __elfN(nxstack) =
 +#if defined(__amd64__) || defined(__powerpc__) /* both 64 and 32 bit */
 +       1;
 +#else
 +       0;
 +#endif
  SYSCTL_INT(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO,
     nxstack, CTLFLAG_RW, __elfN(nxstack), 0,
     __XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE)) : enable non-executable 
 stack);

 +#if __ELF_WORD_SIZE == 32
 +#if defined(__amd64__) || defined(__ia64__)
 +int i386_read_exec = 0;
 +SYSCTL_INT(_kern_elf32, OID_AUTO, read_exec, CTLFLAG_RW, i386_read_exec, 0,
 +    enable execution from readable segments);
 +#endif
 +#endif
 +
  static Elf_Brandinfo *elf_brand_list[MAX_BRANDS];

  #define        trunc_page_ps(va, ps)   ((va)  ~(ps - 1))
 @@ -1666,7 +1679,7 @@ __elfN(trans_prot)(Elf_Word flags)
                prot |= VM_PROT_READ;
  #if __ELF_WORD_SIZE == 32
  #if defined(__amd64__) || defined(__ia64__)
 -       if (flags  PF_R)
 +       if (i386_read_exec  (flags  PF_R))
                prot |= VM_PROT_EXECUTE;
  #endif
  #endif
 diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h
 index 6a4b485..3694ceb 100644
 --- a/sys/sys/sysent.h
 +++ b/sys/sys/sysent.h
 @@ -151,6 +152,10 @@ extern struct sysentvec null_sysvec;
  extern struct sysent sysent[];
  extern const char *syscallnames[];

 +#if defined(__amd64__) || defined(__ia64__)
 +extern int i386_read_exec;
 +#endif
 +
  #define        NO_SYSCALL (-1)

  struct module;
 diff --git a/sys/vm/vm_unix.c b/sys/vm/vm_unix.c
 index d4ea3b7..253ab77 100644
 --- a/sys/vm/vm_unix.c
 +++ b/sys/vm/vm_unix.c
 @@ -141,7 +141,7 @@ sys_obreak(td, uap)
                prot = VM_PROT_RW;
  #ifdef COMPAT_FREEBSD32
  #if defined(__amd64__) || defined(__ia64__)
 -               if (SV_PROC_FLAG(td-td_proc, SV_ILP32))
 +               if (i386_read_exec  SV_PROC_FLAG(td-td_proc, SV_ILP32))
                        prot |= VM_PROT_EXECUTE;
  #endif
  #endif

Would you want to be able 

Re: svn commit: r226305 - head/release

2011-10-14 Thread Doug Barton
On 10/12/2011 10:52, Nathan Whitehorn wrote:
 On 10/12/11 12:37, Doug Barton wrote:
 On 10/12/2011 8:34 AM, Nathan Whitehorn wrote:
 Author: nwhitehorn
 Date: Wed Oct 12 15:34:25 2011
 New Revision: 226305
 URL: http://svn.freebsd.org/changeset/base/226305

 Log:
Missed file in r225937 (sysinstall removal).
 I, and from my reading others, asked you to revert the removal of
 sysinstall. Isn't this moving in the wrong direction? :)

 
 I said I'd be open to it, but thought it wasn't too important since it
 will stay in 9 and removed it in the first place after getting several
 requests to do so. There wasn't any response after that.

The ensuing discussion was about the installer. The point that I
attempted to reiterate was that my concern is that there is no
substitute for sysinstall's post-installation system configuration
features, and until there is we should keep it around. Sorry if I wasn't
clear.

 Are you requesting these commits be reverted?

I'm requesting that sysinstall remain in the base until there are
replacements for all of its functionality. So just to be 100% clear,
yes, I'm asking you to revert its removal.


Doug

-- 

Nothin' ever doesn't change, but nothin' changes much.
-- OK Go

Breadth of IT experience, and depth of knowledge in the DNS.
Yours for the right price.  :)  http://SupersetSolutions.com/

___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r226367 - head/sys/netinet

2011-10-14 Thread Gleb Smirnoff
Author: glebius
Date: Fri Oct 14 19:05:26 2011
New Revision: 226367
URL: http://svn.freebsd.org/changeset/base/226367

Log:
  Never switch directly from INIT to MASTER, since this produces
  nasty status flaps.
  
  PR:   kern/161123
  Submitted by: Damien Fleuriot dam my.gd
  OpenBSD:  ip_carp.c, rev. 1.115

Modified:
  head/sys/netinet/ip_carp.c

Modified: head/sys/netinet/ip_carp.c
==
--- head/sys/netinet/ip_carp.c  Fri Oct 14 11:48:32 2011(r226366)
+++ head/sys/netinet/ip_carp.c  Fri Oct 14 19:05:26 2011(r226367)
@@ -1424,24 +1424,10 @@ carp_setrun(struct carp_softc *sc, sa_fa
 
switch (sc-sc_state) {
case INIT:
-   if (carp_opts[CARPCTL_PREEMPT]  !carp_suppress_preempt) {
-   carp_send_ad_locked(sc);
-#ifdef INET
-   carp_send_arp(sc);
-#endif
-#ifdef INET6
-   carp_send_na(sc);
-#endif /* INET6 */
-   CARP_LOG(%s: INIT - MASTER (preempting)\n,
-   SC2IFP(sc)-if_xname);
-   carp_set_state(sc, MASTER);
-   carp_setroute(sc, RTM_ADD);
-   } else {
-   CARP_LOG(%s: INIT - BACKUP\n, SC2IFP(sc)-if_xname);
-   carp_set_state(sc, BACKUP);
-   carp_setroute(sc, RTM_DELETE);
-   carp_setrun(sc, 0);
-   }
+   CARP_LOG(%s: INIT - BACKUP\n, SC2IFP(sc)-if_xname);
+   carp_set_state(sc, BACKUP);
+   carp_setroute(sc, RTM_DELETE);
+   carp_setrun(sc, 0);
break;
case BACKUP:
callout_stop(sc-sc_ad_tmo);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r226343 - head/sys/vm

2011-10-14 Thread John Baldwin
On Friday, October 14, 2011 2:30:47 pm Garrett Cooper wrote:
 Would you want to be able to toggle this feature at runtime after
 you've fully booted your kernel?

Yes, you do.  When a sysadmin sees that an old Java doesn't run, they don't
really want to have to reboot just to fix it.  We've used runtime tunable
sysctls for similar things previously (mmap at zero).

-- 
John Baldwin
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r226343 - head/sys/vm

2011-10-14 Thread Marcel Moolenaar

On Oct 14, 2011, at 11:24 AM, Kostik Belousov wrote:
 
 After more thought about the issue, I do not agree with you.
 Elf specification says about the PF_R flag that only read permission
 for the memory image of the segment is required, but read and execute
 is allowed.

The ELF specification does not contain CPU specifics. Those are
always covered by processor supplements. Since this is very i386
specific behaviour we're talking about, it's a non sequitur to
use the generic ELF specification to argue a point in this
respect.


 I want to commit the following refinement:

The patch is good.

 diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c
 index 669c652..9970386 100644
 --- a/sys/kern/imgact_elf.c
 +++ b/sys/kern/imgact_elf.c
 @@ -118,11 +118,24 @@ static int elf_legacy_coredump = 0;
 SYSCTL_INT(_debug, OID_AUTO, __elfN(legacy_coredump), CTLFLAG_RW, 
 elf_legacy_coredump, 0, );
 
 -static int __elfN(nxstack) = 0;
 +static int __elfN(nxstack) =
 +#if defined(__amd64__) || defined(__powerpc__) /* both 64 and 32 bit */
 + 1;
 +#else
 + 0;
 +#endif
 SYSCTL_INT(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO,
 nxstack, CTLFLAG_RW, __elfN(nxstack), 0,
 __XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE)) : enable non-executable 
 stack);

Please do not commit this change with the rest. It's
not to the point. In fact, if you're changing it to
the above, please add ia64 to the list as well.

-- 
Marcel Moolenaar
mar...@xcllnt.net


___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r226372 - head/lib/msun/i387

2011-10-14 Thread David Schultz
Author: das
Date: Sat Oct 15 04:17:20 2011
New Revision: 226372
URL: http://svn.freebsd.org/changeset/base/226372

Log:
  Replace two lines accidentally removed in r226218. Thanks to bde
  for noticing this.

Modified:
  head/lib/msun/i387/fenv.c

Modified: head/lib/msun/i387/fenv.c
==
--- head/lib/msun/i387/fenv.c   Sat Oct 15 04:16:58 2011(r226371)
+++ head/lib/msun/i387/fenv.c   Sat Oct 15 04:17:20 2011(r226372)
@@ -223,3 +223,6 @@ __fedisableexcept(int mask)
}
return (~omask);
 }
+
+__weak_reference(__feenableexcept, feenableexcept);
+__weak_reference(__fedisableexcept, fedisableexcept);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r226371 - head/lib/msun/src

2011-10-14 Thread David Schultz
Author: das
Date: Sat Oct 15 04:16:58 2011
New Revision: 226371
URL: http://svn.freebsd.org/changeset/base/226371

Log:
  Fix a double-rounding bug in fma{,f,l}.  The bug would occur in
  round-to-nearest mode when the result, rounded to twice machine
  precision, was exactly halfway between two machine-precision
  values.  The essence of the fix is to simulate a sticky bit in
  the pathological cases, which is how hardware implementations
  break the ties.
  
  MFC after:1 month

Modified:
  head/lib/msun/src/s_fma.c
  head/lib/msun/src/s_fmaf.c
  head/lib/msun/src/s_fmal.c

Modified: head/lib/msun/src/s_fma.c
==
--- head/lib/msun/src/s_fma.c   Fri Oct 14 22:52:46 2011(r226370)
+++ head/lib/msun/src/s_fma.c   Sat Oct 15 04:16:58 2011(r226371)
@@ -31,6 +31,8 @@ __FBSDID($FreeBSD$);
 #include float.h
 #include math.h
 
+#include math_private.h
+
 /*
  * A struct dd represents a floating-point number with twice the precision
  * of a double.  We maintain the invariant that hi stores the 53 high-order
@@ -59,6 +61,73 @@ dd_add(double a, double b)
 }
 
 /*
+ * Compute a+b, with a small tweak:  The least significant bit of the
+ * result is adjusted into a sticky bit summarizing all the bits that
+ * were lost to rounding.  This adjustment negates the effects of double
+ * rounding when the result is added to another number with a higher
+ * exponent.  For an explanation of round and sticky bits, see any reference
+ * on FPU design, e.g.,
+ *
+ * J. Coonen.  An Implementation Guide to a Proposed Standard for
+ * Floating-Point Arithmetic.  Computer, vol. 13, no. 1, Jan 1980.
+ */
+static inline double
+add_adjusted(double a, double b)
+{
+   struct dd sum;
+   uint64_t hibits, lobits;
+
+   sum = dd_add(a, b);
+   if (sum.lo != 0) {
+   EXTRACT_WORD64(hibits, sum.hi);
+   if ((hibits  1) == 0) {
+   /* hibits += (int)copysign(1.0, sum.hi * sum.lo) */
+   EXTRACT_WORD64(lobits, sum.lo);
+   hibits += 1 - ((hibits ^ lobits)  62);
+   INSERT_WORD64(sum.hi, hibits);
+   }
+   }
+   return (sum.hi);
+}
+
+/*
+ * Compute ldexp(a+b, scale) with a single rounding error. It is assumed
+ * that the result will be subnormal, and care is taken to ensure that
+ * double rounding does not occur.
+ */
+static inline double
+add_and_denormalize(double a, double b, int scale)
+{
+   struct dd sum;
+   uint64_t hibits, lobits;
+   int bits_lost;
+
+   sum = dd_add(a, b);
+
+   /*
+* If we are losing at least two bits of accuracy to denormalization,
+* then the first lost bit becomes a round bit, and we adjust the
+* lowest bit of sum.hi to make it a sticky bit summarizing all the
+* bits in sum.lo. With the sticky bit adjusted, the hardware will
+* break any ties in the correct direction.
+*
+* If we are losing only one bit to denormalization, however, we must
+* break the ties manually.
+*/
+   if (sum.lo != 0) {
+   EXTRACT_WORD64(hibits, sum.hi);
+   bits_lost = -((int)(hibits  52)  0x7ff) - scale + 1;
+   if (bits_lost != 1 ^ (int)(hibits  1)) {
+   /* hibits += (int)copysign(1.0, sum.hi * sum.lo) */
+   EXTRACT_WORD64(lobits, sum.lo);
+   hibits += 1 - (((hibits ^ lobits)  62)  2);
+   INSERT_WORD64(sum.hi, hibits);
+   }
+   }
+   return (ldexp(sum.hi, scale));
+}
+
+/*
  * Compute a*b exactly, returning the exact result in a struct dd.  We assume
  * that both a and b are normalized, so no underflow or overflow will occur.
  * The current rounding mode must be round-to-nearest.
@@ -105,14 +174,11 @@ dd_mul(double a, double b)
  * Hardware instructions should be used on architectures that support it,
  * since this implementation will likely be several times slower.
  */
-#if LDBL_MANT_DIG != 113
 double
 fma(double x, double y, double z)
 {
-   double xs, ys, zs;
-   struct dd xy, r, r2;
-   double p;
-   double s;
+   double xs, ys, zs, adj;
+   struct dd xy, r;
int oround;
int ex, ey, ez;
int spread;
@@ -142,41 +208,6 @@ fma(double x, double y, double z)
 * will overflow, so we handle these cases specially.  Rounding
 * modes other than FE_TONEAREST are painful.
 */
-   if (spread  DBL_MANT_DIG * 2) {
-   fenv_t env;
-   feraiseexcept(FE_INEXACT);
-   switch(oround) {
-   case FE_TONEAREST:
-   return (x * y);
-   case FE_TOWARDZERO:
-   if (x  0.0 ^ y  0.0 ^ z  0.0)
-   return (x * y);
-   feholdexcept(env);
-   

svn commit: r226373 - head/lib/msun/src

2011-10-14 Thread David Schultz
Author: das
Date: Sat Oct 15 04:22:55 2011
New Revision: 226373
URL: http://svn.freebsd.org/changeset/base/226373

Log:
  Add INSERT_WORD64 and EXTRACT_WORD64 macros for use in s_fma.c.

Modified:
  head/lib/msun/src/math_private.h

Modified: head/lib/msun/src/math_private.h
==
--- head/lib/msun/src/math_private.hSat Oct 15 04:17:20 2011
(r226372)
+++ head/lib/msun/src/math_private.hSat Oct 15 04:22:55 2011
(r226373)
@@ -58,6 +58,10 @@ typedef union
 u_int32_t msw;
 u_int32_t lsw;
   } parts;
+  struct
+  {
+u_int64_t w;
+  } xparts;
 } ieee_double_shape_type;
 
 #endif
@@ -72,6 +76,10 @@ typedef union
 u_int32_t lsw;
 u_int32_t msw;
   } parts;
+  struct
+  {
+u_int64_t w;
+  } xparts;
 } ieee_double_shape_type;
 
 #endif
@@ -86,6 +94,14 @@ do { 
\
   (ix1) = ew_u.parts.lsw;  \
 } while (0)
 
+/* Get a 64-bit int from a double. */
+#define EXTRACT_WORD64(ix,d)   \
+do {   \
+  ieee_double_shape_type ew_u; \
+  ew_u.value = (d);\
+  (ix) = ew_u.xparts.w;\
+} while (0)
+
 /* Get the more significant 32 bit int from a double.  */
 
 #define GET_HIGH_WORD(i,d) \
@@ -114,6 +130,14 @@ do {   
\
   (d) = iw_u.value;\
 } while (0)
 
+/* Set a double from a 64-bit int. */
+#define INSERT_WORD64(d,ix)\
+do {   \
+  ieee_double_shape_type iw_u; \
+  iw_u.xparts.w = (ix);\
+  (d) = iw_u.value;\
+} while (0)
+
 /* Set the more significant 32 bits of a double from an int.  */
 
 #define SET_HIGH_WORD(d,v) \
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r226374 - head/lib/msun/src

2011-10-14 Thread David Schultz
Author: das
Date: Sat Oct 15 04:24:54 2011
New Revision: 226374
URL: http://svn.freebsd.org/changeset/base/226374

Log:
  Don't define FP_FAST_FMA on sparc64; with the recent fixes, fma() is
  no longer fast on sparc64.  (It really wasn't to begin with, since
  the old implementation was using long doubles, and long doubles are
  emulated in software on sparc64.)

Modified:
  head/lib/msun/src/math.h

Modified: head/lib/msun/src/math.h
==
--- head/lib/msun/src/math.hSat Oct 15 04:22:55 2011(r226373)
+++ head/lib/msun/src/math.hSat Oct 15 04:24:54 2011(r226374)
@@ -68,14 +68,11 @@ extern const union __nan_un {
 #defineMATH_ERREXCEPT  2
 #definemath_errhandlingMATH_ERREXCEPT
 
-/* XXX We need a machine/math.h. */
-#if defined(__ia64__) || defined(__sparc64__)
-#defineFP_FAST_FMA 1
-#endif
+#defineFP_FAST_FMAF1
 #ifdef __ia64__
+#defineFP_FAST_FMA 1
 #defineFP_FAST_FMAL1
 #endif
-#defineFP_FAST_FMAF1
 
 /* Symbolic constants to classify floating point numbers. */
 #defineFP_INFINITE 0x01
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r226375 - head/lib/msun/src

2011-10-14 Thread David Schultz
Author: das
Date: Sat Oct 15 05:00:56 2011
New Revision: 226375
URL: http://svn.freebsd.org/changeset/base/226375

Log:
  Style fixes and updates to comments.
  
  Submitted by: bde

Modified:
  head/lib/msun/src/e_log10.c
  head/lib/msun/src/e_log10f.c
  head/lib/msun/src/e_log2.c
  head/lib/msun/src/e_log2f.c

Modified: head/lib/msun/src/e_log10.c
==
--- head/lib/msun/src/e_log10.c Sat Oct 15 04:24:54 2011(r226374)
+++ head/lib/msun/src/e_log10.c Sat Oct 15 05:00:56 2011(r226375)
@@ -15,7 +15,8 @@
 __FBSDID($FreeBSD$);
 
 /*
- * Return the base 10 logarithm of x. See k_log.c for details on the algorithm.
+ * Return the base 10 logarithm of x.  See e_log.c and k_log.h for most
+ * comments.
  */
 
 #include math.h
@@ -40,14 +41,14 @@ __ieee754_log10(double x)
 
EXTRACT_WORDS(hx,lx,x);
 
-k=0;
-if (hx  0x0010) {  /* x  2**-1022  */
-if (((hx0x7fff)|lx)==0)
-return -two54/zero; /* log(+-0)=-inf */
-if (hx0) return (x-x)/zero;/* log(-#) = NaN */
-k -= 54; x *= two54; /* subnormal number, scale up x */
+   k=0;
+   if (hx  0x0010) {  /* x  2**-1022  */
+   if (((hx0x7fff)|lx)==0)
+   return -two54/zero; /* log(+-0)=-inf */
+   if (hx0) return (x-x)/zero;/* log(-#) = NaN */
+   k -= 54; x *= two54; /* subnormal number, scale up x */
GET_HIGH_WORD(hx,x);
-}
+   }
if (hx = 0x7ff0) return x+x;
k += (hx20)-1023;
hx = 0x000f;

Modified: head/lib/msun/src/e_log10f.c
==
--- head/lib/msun/src/e_log10f.cSat Oct 15 04:24:54 2011
(r226374)
+++ head/lib/msun/src/e_log10f.cSat Oct 15 05:00:56 2011
(r226375)
@@ -13,7 +13,7 @@
 __FBSDID($FreeBSD$);
 
 /*
- * Return the base 10 logarithm of x. See k_log.c for details on the algorithm.
+ * Float version of e_log10.c.  See the latter for most comments.
  */
 
 #include math.h
@@ -37,14 +37,14 @@ __ieee754_log10f(float x)
 
GET_FLOAT_WORD(hx,x);
 
-k=0;
-if (hx  0x0080) {  /* x  2**-126  */
-if ((hx0x7fff)==0)
-return -two25/zero; /* log(+-0)=-inf */
-if (hx0) return (x-x)/zero;/* log(-#) = NaN */
-k -= 25; x *= two25; /* subnormal number, scale up x */
+   k=0;
+   if (hx  0x0080) {  /* x  2**-126  */
+   if ((hx0x7fff)==0)
+   return -two25/zero; /* log(+-0)=-inf */
+   if (hx0) return (x-x)/zero;/* log(-#) = NaN */
+   k -= 25; x *= two25; /* subnormal number, scale up x */
GET_FLOAT_WORD(hx,x);
-}
+   }
if (hx = 0x7f80) return x+x;
k += (hx23)-127;
hx = 0x007f;

Modified: head/lib/msun/src/e_log2.c
==
--- head/lib/msun/src/e_log2.c  Sat Oct 15 04:24:54 2011(r226374)
+++ head/lib/msun/src/e_log2.c  Sat Oct 15 05:00:56 2011(r226375)
@@ -15,7 +15,8 @@
 __FBSDID($FreeBSD$);
 
 /*
- * Return the base 2 logarithm of x. See k_log.c for details on the algorithm.
+ * Return the base 2 logarithm of x.  See e_log.c and k_log.h for most
+ * comments.
  */
 
 #include math.h
@@ -38,14 +39,14 @@ __ieee754_log2(double x)
 
EXTRACT_WORDS(hx,lx,x);
 
-k=0;
-if (hx  0x0010) {  /* x  2**-1022  */
-if (((hx0x7fff)|lx)==0)
-return -two54/zero; /* log(+-0)=-inf */
-if (hx0) return (x-x)/zero;/* log(-#) = NaN */
-k -= 54; x *= two54; /* subnormal number, scale up x */
+   k=0;
+   if (hx  0x0010) {  /* x  2**-1022  */
+   if (((hx0x7fff)|lx)==0)
+   return -two54/zero; /* log(+-0)=-inf */
+   if (hx0) return (x-x)/zero;/* log(-#) = NaN */
+   k -= 54; x *= two54; /* subnormal number, scale up x */
GET_HIGH_WORD(hx,x);
-}
+   }
if (hx = 0x7ff0) return x+x;
k += (hx20)-1023;
hx = 0x000f;

Modified: head/lib/msun/src/e_log2f.c
==
--- head/lib/msun/src/e_log2f.c Sat Oct 15 04:24:54 2011(r226374)
+++ head/lib/msun/src/e_log2f.c Sat Oct 15 05:00:56 2011(r226375)
@@ -13,7 +13,7 @@
 __FBSDID($FreeBSD$);
 
 /*
- * Return the base 2 logarithm of x. See k_log.c for details on the algorithm.
+ * Float version of e_log2.c.  See the latter for most comments.
  */
 
 #include math.h
@@ -35,14 +35,14 @@ __ieee754_log2f(float x)
 
GET_FLOAT_WORD(hx,x);

svn commit: r226376 - head/lib/msun/src

2011-10-14 Thread David Schultz
Author: das
Date: Sat Oct 15 05:23:28 2011
New Revision: 226376
URL: http://svn.freebsd.org/changeset/base/226376

Log:
  Various changes to improve the accuracy and speed of log{2,10}{,f}.
  - Rename __kernel_log() to k_log1p().
  - Move some of the work that was previously done in the kernel log into
the callers.  This enables further refactoring to improve accuracy or
speed, although I don't recall the details.
  - Use extra precision when adding the final scaling term, which improves
accuracy.
  - Describe and work around compiler problems that break some of the
multiprecision calculations.
  
  A fix for a small bug is also included:
  - Add a special case for log*(1).  This is needed to ensure that log*(1) == +0
instead of -0, even when the rounding mode is FE_DOWNWARD.
  
  Submitted by: bde

Modified:
  head/lib/msun/src/e_log10.c
  head/lib/msun/src/e_log10f.c
  head/lib/msun/src/e_log2.c
  head/lib/msun/src/e_log2f.c
  head/lib/msun/src/k_log.h
  head/lib/msun/src/k_logf.h

Modified: head/lib/msun/src/e_log10.c
==
--- head/lib/msun/src/e_log10.c Sat Oct 15 05:00:56 2011(r226375)
+++ head/lib/msun/src/e_log10.c Sat Oct 15 05:23:28 2011(r226376)
@@ -17,6 +17,9 @@ __FBSDID($FreeBSD$);
 /*
  * Return the base 10 logarithm of x.  See e_log.c and k_log.h for most
  * comments.
+ *
+ *log10(x) = (f - 0.5*f*f + k_log1p(f)) / ln10 + k * log10(2)
+ * in not-quite-routine extra precision.
  */
 
 #include math.h
@@ -35,7 +38,7 @@ static const double zero   =  0.0;
 double
 __ieee754_log10(double x)
 {
-   double f,hi,lo,y,z;
+   double f,hfsq,hi,lo,r,val_hi,val_lo,w,y,y2;
int32_t i,k,hx;
u_int32_t lx;
 
@@ -50,16 +53,35 @@ __ieee754_log10(double x)
GET_HIGH_WORD(hx,x);
}
if (hx = 0x7ff0) return x+x;
+   if (hx == 0x3ff0  lx == 0)
+   return zero;/* log(1) = +0 */
k += (hx20)-1023;
hx = 0x000f;
i = (hx+0x95f64)0x10;
SET_HIGH_WORD(x,hx|(i^0x3ff0)); /* normalize x or x/2 */
k += (i20);
y = (double)k;
-   f = __kernel_log(x);
-   hi = x = x - 1;
+   f = x - 1.0;
+   hfsq = 0.5*f*f;
+   r = k_log1p(f);
+
+   /* See e_log2.c for most details. */
+   hi = f - hfsq;
SET_LOW_WORD(hi,0);
-   lo = x - hi;
-   z = y*log10_2lo + (x+f)*ivln10lo + (lo+f)*ivln10hi + hi*ivln10hi;
-   return  z+y*log10_2hi;
+   lo = (f - hi) - hfsq + r;
+   val_hi = hi*ivln10hi;
+   y2 = y*log10_2hi;
+   val_lo = y*log10_2lo + (lo+hi)*ivln10lo + lo*ivln10hi;
+
+   /*
+* Extra precision in for adding y*log10_2hi is not strictly needed
+* since there is no very large cancellation near x = sqrt(2) or
+* x = 1/sqrt(2), but we do it anyway since it costs little on CPUs
+* with some parallelism and it reduces the error for many args.
+*/
+   w = y2 + val_hi;
+   val_lo += (y2 - w) + val_hi;
+   val_hi = w;
+
+   return val_lo + val_hi;
 }

Modified: head/lib/msun/src/e_log10f.c
==
--- head/lib/msun/src/e_log10f.cSat Oct 15 05:00:56 2011
(r226375)
+++ head/lib/msun/src/e_log10f.cSat Oct 15 05:23:28 2011
(r226376)
@@ -32,7 +32,7 @@ static const float zero   =  0.0;
 float
 __ieee754_log10f(float x)
 {
-   float f,hi,lo,y,z;
+   float f,hfsq,hi,lo,r,y,y2;
int32_t i,k,hx;
 
GET_FLOAT_WORD(hx,x);
@@ -46,17 +46,26 @@ __ieee754_log10f(float x)
GET_FLOAT_WORD(hx,x);
}
if (hx = 0x7f80) return x+x;
+   if (hx == 0x3f80)
+   return zero;/* log(1) = +0 */
k += (hx23)-127;
hx = 0x007f;
i = (hx+(0x4afb0d))0x80;
SET_FLOAT_WORD(x,hx|(i^0x3f80));/* normalize x or x/2 */
k += (i23);
y = (float)k;
-   f = __kernel_logf(x);
-   x = x - (float)1.0;
-   GET_FLOAT_WORD(hx,x);
+   f = x - (float)1.0;
+   hfsq = (float)0.5*f*f;
+   r = k_log1pf(f);
+
+   /* See e_log2f.c and e_log2.c for details. */
+   if (sizeof(float_t)  sizeof(float))
+   return (r - hfsq + f) * ((float_t)ivln10lo + ivln10hi) +
+   y * ((float_t)log10_2lo + log10_2hi);
+   hi = f - hfsq;
+   GET_FLOAT_WORD(hx,hi);
SET_FLOAT_WORD(hi,hx0xf000);
-   lo = x - hi;
-   z = y*log10_2lo + (x+f)*ivln10lo + (lo+f)*ivln10hi + hi*ivln10hi;
-   return  z+y*log10_2hi;
+   lo = (f - hi) - hfsq + r;
+   return y*log10_2lo + (lo+hi)*ivln10lo + lo*ivln10hi + hi*ivln10hi +
+   y*log10_2hi;
 }

Modified: head/lib/msun/src/e_log2.c
==
--- head/lib/msun/src/e_log2.c  Sat Oct 15 05:00:56 

svn commit: r226377 - head/tools/regression/lib/msun

2011-10-14 Thread David Schultz
Author: das
Date: Sat Oct 15 05:26:16 2011
New Revision: 226377
URL: http://svn.freebsd.org/changeset/base/226377

Log:
  Add some tests for double-rounding bugs in fma().

Modified:
  head/tools/regression/lib/msun/test-fma.c

Modified: head/tools/regression/lib/msun/test-fma.c
==
--- head/tools/regression/lib/msun/test-fma.c   Sat Oct 15 05:23:28 2011
(r226376)
+++ head/tools/regression/lib/msun/test-fma.c   Sat Oct 15 05:26:16 2011
(r226377)
@@ -364,13 +364,63 @@ test_accuracy(void)
 #endif
 }
 
+static void
+test_double_rounding(void)
+{
+
+   /*
+* a =  0x1.80001p0
+* b =  0x1.80001p0
+* c = -0x0.0080...1p+1
+* a * b =  0x1.20001880p+1
+*
+* The correct behavior is to round DOWN to 0x1.20001p+1 in
+* round-to-nearest mode.  An implementation that computes a*b+c in
+* double+double precision, however, will get 0x1.200018p+1,
+* and then round UP.
+*/
+   fesetround(FE_TONEAREST);
+   test(fma, 0x1.80001p0, 0x1.80001p0,
+-0x1.1p-104, 0x1.20001p+1,
+ALL_STD_EXCEPT, FE_INEXACT);
+   fesetround(FE_DOWNWARD);
+   test(fma, 0x1.80001p0, 0x1.80001p0,
+-0x1.1p-104, 0x1.20001p+1,
+ALL_STD_EXCEPT, FE_INEXACT);
+   fesetround(FE_UPWARD);
+   test(fma, 0x1.80001p0, 0x1.80001p0,
+-0x1.1p-104, 0x1.20002p+1,
+ALL_STD_EXCEPT, FE_INEXACT);
+
+   fesetround(FE_TONEAREST);
+   test(fmaf, 0x1.82p+0, 0x1.82p+0, -0x1.02p-46, 0x1.22p+1,
+ALL_STD_EXCEPT, FE_INEXACT);
+   fesetround(FE_DOWNWARD);
+   test(fmaf, 0x1.82p+0, 0x1.82p+0, -0x1.02p-46, 0x1.22p+1,
+ALL_STD_EXCEPT, FE_INEXACT);
+   fesetround(FE_UPWARD);
+   test(fmaf, 0x1.82p+0, 0x1.82p+0, -0x1.02p-46, 0x1.24p+1,
+ALL_STD_EXCEPT, FE_INEXACT);
+
+   fesetround(FE_TONEAREST);
+#if LDBL_MANT_DIG == 64
+   test(fmal, 0x1.4p+0L, 0x1.0004p+0L, 0x1p-128L,
+0x1.4006p+0L, ALL_STD_EXCEPT, FE_INEXACT);
+#elif LDBL_MANT_DIG == 113
+   /* XXX untested test */
+   test(fmal, 0x1.4p+0L, 0x1.0002p+0L, 0x1p-224L,
+0x1.4003p+0L, ALL_STD_EXCEPT, FE_INEXACT);
+#endif
+
+}
+
 int
 main(int argc, char *argv[])
 {
int rmodes[] = { FE_TONEAREST, FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO };
int i;
 
-   printf(1..18\n);
+   printf(1..19\n);
 
for (i = 0; i  4; i++) {
fesetround(rmodes[i]);
@@ -404,6 +454,9 @@ main(int argc, char *argv[])
test_accuracy();
printf(ok 18 - fma accuracy\n);
 
+   test_double_rounding();
+   printf(ok 19 - fma double rounding\n);
+
/*
 * TODO:
 * - Tests for subnormals
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r226378 - head/tools/regression/lib/msun

2011-10-14 Thread David Schultz
Author: das
Date: Sat Oct 15 05:28:13 2011
New Revision: 226378
URL: http://svn.freebsd.org/changeset/base/226378

Log:
  Add some tests for corner cases of log() in unusual rounding modes.
  I wrote these ages ago, but they've been failing until now.

Modified:
  head/tools/regression/lib/msun/test-logarithm.c

Modified: head/tools/regression/lib/msun/test-logarithm.c
==
--- head/tools/regression/lib/msun/test-logarithm.c Sat Oct 15 05:26:16 
2011(r226377)
+++ head/tools/regression/lib/msun/test-logarithm.c Sat Oct 15 05:28:13 
2011(r226378)
@@ -97,7 +97,7 @@ void
 run_generic_tests(void)
 {
 
-   /* exp(1) == 0, no exceptions raised */
+   /* log(1) == 0, no exceptions raised */
testall0(1.0, 0.0, ALL_STD_EXCEPT, 0);
testall1(0.0, 0.0, ALL_STD_EXCEPT, 0);
testall1(-0.0, -0.0, ALL_STD_EXCEPT, 0);
@@ -142,11 +142,35 @@ run_log2_tests(void)
}
 }
 
+void
+run_roundingmode_tests(void)
+{
+
+   /*
+* Corner cases in other rounding modes.
+*/
+   fesetround(FE_DOWNWARD);
+   /* These are still positive per IEEE 754R */
+   testall0(1.0, 0.0, ALL_STD_EXCEPT, 0);
+   testall1(0.0, 0.0, ALL_STD_EXCEPT, 0);
+   fesetround(FE_TOWARDZERO);
+   testall0(1.0, 0.0, ALL_STD_EXCEPT, 0);
+   testall1(0.0, 0.0, ALL_STD_EXCEPT, 0);
+
+   fesetround(FE_UPWARD);
+   testall0(1.0, 0.0, ALL_STD_EXCEPT, 0);
+   testall1(0.0, 0.0, ALL_STD_EXCEPT, 0);
+   /* log1p(-0.0) == -0.0 even when rounding upwards */
+   testall1(-0.0, -0.0, ALL_STD_EXCEPT, 0);
+
+   fesetround(FE_TONEAREST);
+}
+
 int
 main(int argc, char *argv[])
 {
 
-   printf(1..2\n);
+   printf(1..3\n);
 
run_generic_tests();
printf(ok 1 - logarithm\n);
@@ -154,5 +178,8 @@ main(int argc, char *argv[])
run_log2_tests();
printf(ok 2 - logarithm\n);
 
+   run_roundingmode_tests();
+   printf(ok 3 - logarithm\n);
+
return (0);
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org