svn commit: r226594 - in head/lib/msun: amd64 i387

2011-10-21 Thread David Schultz
Author: das
Date: Fri Oct 21 06:25:31 2011
New Revision: 226594
URL: http://svn.freebsd.org/changeset/base/226594

Log:
  Bugfix: feenableexcept() and fedisableexcept() should just return the
  old exception mask, not mask | ~FE_ALL_EXCEPT.
  
  MFC after:2 weeks

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

Modified: head/lib/msun/amd64/fenv.c
==
--- head/lib/msun/amd64/fenv.c  Fri Oct 21 05:41:20 2011(r226593)
+++ head/lib/msun/amd64/fenv.c  Fri Oct 21 06:25:31 2011(r226594)
@@ -135,12 +135,12 @@ __feenableexcept(int mask)
mask = FE_ALL_EXCEPT;
__fnstcw(control);
__stmxcsr(mxcsr);
-   omask = (control | mxcsr  _SSE_EMASK_SHIFT)  FE_ALL_EXCEPT;
+   omask = ~(control | mxcsr  _SSE_EMASK_SHIFT)  FE_ALL_EXCEPT;
control = ~mask;
__fldcw(control);
mxcsr = ~(mask  _SSE_EMASK_SHIFT);
__ldmxcsr(mxcsr);
-   return (~omask);
+   return (omask);
 }
 
 int
@@ -152,12 +152,12 @@ __fedisableexcept(int mask)
mask = FE_ALL_EXCEPT;
__fnstcw(control);
__stmxcsr(mxcsr);
-   omask = (control | mxcsr  _SSE_EMASK_SHIFT)  FE_ALL_EXCEPT;
+   omask = ~(control | mxcsr  _SSE_EMASK_SHIFT)  FE_ALL_EXCEPT;
control |= mask;
__fldcw(control);
mxcsr |= mask  _SSE_EMASK_SHIFT;
__ldmxcsr(mxcsr);
-   return (~omask);
+   return (omask);
 }
 
 __weak_reference(__feenableexcept, feenableexcept);

Modified: head/lib/msun/i387/fenv.c
==
--- head/lib/msun/i387/fenv.c   Fri Oct 21 05:41:20 2011(r226593)
+++ head/lib/msun/i387/fenv.c   Fri Oct 21 06:25:31 2011(r226594)
@@ -192,14 +192,14 @@ __feenableexcept(int mask)
__stmxcsr(mxcsr);
else
mxcsr = 0;
-   omask = (control | mxcsr  _SSE_EMASK_SHIFT)  FE_ALL_EXCEPT;
+   omask = ~(control | mxcsr  _SSE_EMASK_SHIFT)  FE_ALL_EXCEPT;
control = ~mask;
__fldcw(control);
if (__HAS_SSE()) {
mxcsr = ~(mask  _SSE_EMASK_SHIFT);
__ldmxcsr(mxcsr);
}
-   return (~omask);
+   return (omask);
 }
 
 int
@@ -214,14 +214,14 @@ __fedisableexcept(int mask)
__stmxcsr(mxcsr);
else
mxcsr = 0;
-   omask = (control | mxcsr  _SSE_EMASK_SHIFT)  FE_ALL_EXCEPT;
+   omask = ~(control | mxcsr  _SSE_EMASK_SHIFT)  FE_ALL_EXCEPT;
control |= mask;
__fldcw(control);
if (__HAS_SSE()) {
mxcsr |= mask  _SSE_EMASK_SHIFT;
__ldmxcsr(mxcsr);
}
-   return (~omask);
+   return (omask);
 }
 
 __weak_reference(__feenableexcept, feenableexcept);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


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

2011-10-21 Thread David Schultz
Author: das
Date: Fri Oct 21 06:26:07 2011
New Revision: 226595
URL: http://svn.freebsd.org/changeset/base/226595

Log:
  Per IEEE754r, pow(1, y) is 1 even if y is NaN, and pow(-1, +-Inf) is 1.
  
  MFC after:2 weeks

Modified:
  head/lib/msun/src/e_pow.c
  head/lib/msun/src/e_powf.c

Modified: head/lib/msun/src/e_pow.c
==
--- head/lib/msun/src/e_pow.c   Fri Oct 21 06:25:31 2011(r226594)
+++ head/lib/msun/src/e_pow.c   Fri Oct 21 06:26:07 2011(r226595)
@@ -109,6 +109,9 @@ __ieee754_pow(double x, double y)
 /* y==zero: x**0 = 1 */
if((iy|ly)==0) return one;  
 
+/* x==1: 1**y = 1, even if y is NaN */
+   if (hx==0x3ff0  lx == 0) return one;
+
 /* y!=zero: result is NaN if either arg is NaN */
if(ix  0x7ff0 || ((ix==0x7ff0)(lx!=0)) ||
   iy  0x7ff0 || ((iy==0x7ff0)(ly!=0))) 
@@ -138,7 +141,7 @@ __ieee754_pow(double x, double y)
if(ly==0) { 
if (iy==0x7ff0) {   /* y is +-inf */
if(((ix-0x3ff0)|lx)==0)
-   return  y - y;  /* inf**+-1 is NaN */
+   return  one;/* (-1)**+-inf is NaN */
else if (ix = 0x3ff0)/* (|x|1)**+-inf = inf,0 */
return (hy=0)? y: zero;
else/* (|x|1)**-,+inf = inf,0 */

Modified: head/lib/msun/src/e_powf.c
==
--- head/lib/msun/src/e_powf.c  Fri Oct 21 06:25:31 2011(r226594)
+++ head/lib/msun/src/e_powf.c  Fri Oct 21 06:26:07 2011(r226595)
@@ -67,6 +67,9 @@ __ieee754_powf(float x, float y)
 /* y==zero: x**0 = 1 */
if(iy==0) return one;
 
+/* x==1: 1**y = 1, even if y is NaN */
+   if (hx==0x3f80) return one;
+
 /* y!=zero: result is NaN if either arg is NaN */
if(ix  0x7f80 ||
   iy  0x7f80)
@@ -90,7 +93,7 @@ __ieee754_powf(float x, float y)
 /* special value of y */
if (iy==0x7f80) {   /* y is +-inf */
if (ix==0x3f80)
-   return  y - y;  /* inf**+-1 is NaN */
+   return  one;/* (-1)**+-inf is NaN */
else if (ix  0x3f80)/* (|x|1)**+-inf = inf,0 */
return (hy=0)? y: zero;
else/* (|x|1)**-,+inf = inf,0 */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


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

2011-10-21 Thread David Schultz
Author: das
Date: Fri Oct 21 06:26:38 2011
New Revision: 226596
URL: http://svn.freebsd.org/changeset/base/226596

Log:
  Use STRICT_ASSIGN() to ensure that the compiler doesn't screw things
  up by storing x in a wider type than it's supposed to.
  
  Submitted by: bde

Modified:
  head/lib/msun/src/e_exp.c
  head/lib/msun/src/e_expf.c
  head/lib/msun/src/s_expm1.c
  head/lib/msun/src/s_expm1f.c

Modified: head/lib/msun/src/e_exp.c
==
--- head/lib/msun/src/e_exp.c   Fri Oct 21 06:26:07 2011(r226595)
+++ head/lib/msun/src/e_exp.c   Fri Oct 21 06:26:38 2011(r226596)
@@ -76,6 +76,8 @@ __FBSDID($FreeBSD$);
  * to produce the hexadecimal values shown.
  */
 
+#include float.h
+
 #include math.h
 #include math_private.h
 
@@ -133,7 +135,7 @@ __ieee754_exp(double x) /* default IEEE 
hi = x - t*ln2HI[0];/* t*ln2HI is exact here */
lo = t*ln2LO[0];
}
-   x  = hi - lo;
+   STRICT_ASSIGN(double, x, hi - lo);
} 
else if(hx  0x3e30)  { /* when |x|2**-28 */
if(huge+xone) return one+x;/* trigger inexact */

Modified: head/lib/msun/src/e_expf.c
==
--- head/lib/msun/src/e_expf.c  Fri Oct 21 06:26:07 2011(r226595)
+++ head/lib/msun/src/e_expf.c  Fri Oct 21 06:26:38 2011(r226596)
@@ -16,6 +16,8 @@
 #include sys/cdefs.h
 __FBSDID($FreeBSD$);
 
+#include float.h
+
 #include math.h
 #include math_private.h
 
@@ -40,7 +42,7 @@ P2 = -2.7667332906e-3;/* -0xb55215.0p-
 static volatile float twom100 = 7.8886090522e-31;  /* 2**-100=0x0d80 */
 
 float
-__ieee754_expf(float x)/* default IEEE double exp */
+__ieee754_expf(float x)
 {
float y,hi=0.0,lo=0.0,c,t,twopk;
int32_t k=0,xsb;
@@ -70,7 +72,7 @@ __ieee754_expf(float x)   /* default IEEE 
hi = x - t*ln2HI[0];/* t*ln2HI is exact here */
lo = t*ln2LO[0];
}
-   x  = hi - lo;
+   STRICT_ASSIGN(float, x, hi - lo);
}
else if(hx  0x3900)  { /* when |x|2**-14 */
if(huge+xone) return one+x;/* trigger inexact */

Modified: head/lib/msun/src/s_expm1.c
==
--- head/lib/msun/src/s_expm1.c Fri Oct 21 06:26:07 2011(r226595)
+++ head/lib/msun/src/s_expm1.c Fri Oct 21 06:26:38 2011(r226596)
@@ -108,6 +108,8 @@ __FBSDID($FreeBSD$);
  * to produce the hexadecimal values shown.
  */
 
+#include float.h
+
 #include math.h
 #include math_private.h
 
@@ -168,7 +170,7 @@ expm1(double x)
hi = x - t*ln2_hi;  /* t*ln2_hi is exact here */
lo = t*ln2_lo;
}
-   x  = hi - lo;
+   STRICT_ASSIGN(double, x, hi - lo);
c  = (hi-x)-lo;
}
else if(hx  0x3c90) {  /* when |x|2**-54, return x */

Modified: head/lib/msun/src/s_expm1f.c
==
--- head/lib/msun/src/s_expm1f.cFri Oct 21 06:26:07 2011
(r226595)
+++ head/lib/msun/src/s_expm1f.cFri Oct 21 06:26:38 2011
(r226596)
@@ -16,6 +16,8 @@
 #include sys/cdefs.h
 __FBSDID($FreeBSD$);
 
+#include float.h
+
 #include math.h
 #include math_private.h
 
@@ -74,7 +76,7 @@ expm1f(float x)
hi = x - t*ln2_hi;  /* t*ln2_hi is exact here */
lo = t*ln2_lo;
}
-   x  = hi - lo;
+   STRICT_ASSIGN(float, x, hi - lo);
c  = (hi-x)-lo;
}
else if(hx  0x3300) {  /* when |x|2**-25, return x */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r226597 - in head/lib/msun: . src

2011-10-21 Thread David Schultz
Author: das
Date: Fri Oct 21 06:27:56 2011
New Revision: 226597
URL: http://svn.freebsd.org/changeset/base/226597

Log:
  The cexp() and {,c}{cos,sin}h functions all need to be able to compute
  exp(x) scaled down by some factor, and the challenge is doing this
  accurately when exp(x) would overflow.  This change replaces all of
  the tricks we've been using with common __ldexp_exp() and
  __ldexp_cexp() routines that handle all the scaling.
  
  bde plans to improve on this further by moving the guts of exp() into
  k_exp.c and handling the scaling in a more direct manner.  But the
  current approach is simple and adequate for now.

Added:
  head/lib/msun/src/k_exp.c   (contents, props changed)
  head/lib/msun/src/k_expf.c   (contents, props changed)
Modified:
  head/lib/msun/Makefile
  head/lib/msun/src/math_private.h
  head/lib/msun/src/s_cexp.c
  head/lib/msun/src/s_cexpf.c

Modified: head/lib/msun/Makefile
==
--- head/lib/msun/Makefile  Fri Oct 21 06:26:38 2011(r226596)
+++ head/lib/msun/Makefile  Fri Oct 21 06:27:56 2011(r226597)
@@ -49,7 +49,7 @@ COMMON_SRCS= b_exp.c b_log.c b_tgamma.c 
e_pow.c e_powf.c e_rem_pio2.c \
e_rem_pio2f.c e_remainder.c e_remainderf.c e_scalb.c e_scalbf.c \
e_sinh.c e_sinhf.c e_sqrt.c e_sqrtf.c fenv.c \
-   k_cos.c k_cosf.c k_rem_pio2.c k_sin.c k_sinf.c \
+   k_cos.c k_cosf.c k_exp.c k_expf.c k_rem_pio2.c k_sin.c k_sinf.c \
k_tan.c k_tanf.c \
s_asinh.c s_asinhf.c s_atan.c s_atanf.c s_carg.c s_cargf.c s_cargl.c \
s_cbrt.c s_cbrtf.c s_ceil.c s_ceilf.c \

Added: head/lib/msun/src/k_exp.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/lib/msun/src/k_exp.c   Fri Oct 21 06:27:56 2011(r226597)
@@ -0,0 +1,108 @@
+/*-
+ * Copyright (c) 2011 David Schultz d...@freebsd.org
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include sys/cdefs.h
+__FBSDID($FreeBSD$);
+
+#include complex.h
+
+#include math.h
+#include math_private.h
+
+static const uint32_t k = 1799;/* constant for reduction */
+static const double kln2 =  1246.97177782734161156;/* k * ln2 */
+
+/*
+ * Compute exp(x), scaled to avoid spurious overflow.  An exponent is
+ * returned separately in 'expt'.
+ *
+ * Input:  ln(DBL_MAX) = x  ln(2 * DBL_MAX / DBL_MIN_DENORM) ~= 1454.91
+ * Output: 2**1023 = y  2**1024
+ */
+static double
+__frexp_exp(double x, int *expt)
+{
+   double exp_x;
+   uint32_t hx;
+
+   /*
+* We use exp(x) = exp(x - kln2) * 2**k, carefully chosen to
+* minimize |exp(kln2) - 2**k|.  We also scale the exponent of
+* exp_x to MAX_EXP so that the result can be multiplied by
+* a tiny number without losing accuracy due to denormalization.
+*/
+   exp_x = exp(x - kln2);
+   GET_HIGH_WORD(hx, exp_x);
+   *expt = (hx  20) - (0x3ff + 1023) + k;
+   SET_HIGH_WORD(exp_x, (hx  0xf) | ((0x3ff + 1023)  20));
+   return (exp_x);
+}
+
+/*
+ * __ldexp_exp(x, expt) and __ldexp_cexp(x, expt) compute exp(x) * 2**expt.
+ * They are intended for large arguments (real part = ln(DBL_MAX))
+ * where care is needed to avoid overflow.
+ *
+ * The present implementation is narrowly tailored for our hyperbolic and
+ * exponential functions.  We assume expt is small (0 or -1), and the caller
+ * has filtered out very large x, for which overflow would be inevitable.
+ */
+
+double
+__ldexp_exp(double x, int expt)
+{
+   double exp_x, scale;
+   int ex_expt;
+
+   exp_x = __frexp_exp(x, 

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

2011-10-21 Thread David Schultz
Author: das
Date: Fri Oct 21 06:28:47 2011
New Revision: 226598
URL: http://svn.freebsd.org/changeset/base/226598

Log:
  Use __ldexp_exp() to simplify things and improve accuracy for x near
  the overflow threshold.

Modified:
  head/lib/msun/src/e_cosh.c
  head/lib/msun/src/e_coshf.c
  head/lib/msun/src/e_sinh.c
  head/lib/msun/src/e_sinhf.c

Modified: head/lib/msun/src/e_cosh.c
==
--- head/lib/msun/src/e_cosh.c  Fri Oct 21 06:27:56 2011(r226597)
+++ head/lib/msun/src/e_cosh.c  Fri Oct 21 06:28:47 2011(r226598)
@@ -45,7 +45,6 @@ __ieee754_cosh(double x)
 {
double t,w;
int32_t ix;
-   u_int32_t lx;
 
 /* High word of |x|. */
GET_HIGH_WORD(ix,x);
@@ -72,13 +71,8 @@ __ieee754_cosh(double x)
if (ix  0x40862E42)  return half*__ieee754_exp(fabs(x));
 
 /* |x| in [log(maxdouble), overflowthresold] */
-   GET_LOW_WORD(lx,x);
-   if (ix0x408633CE ||
- ((ix==0x408633ce)(lx=(u_int32_t)0x8fb9f87d))) {
-   w = __ieee754_exp(half*fabs(x));
-   t = half*w;
-   return t*w;
-   }
+   if (ix=0x408633CE)
+   return __ldexp_exp(fabs(x), -1);
 
 /* |x|  overflowthresold, cosh(x) overflow */
return huge*huge;

Modified: head/lib/msun/src/e_coshf.c
==
--- head/lib/msun/src/e_coshf.c Fri Oct 21 06:27:56 2011(r226597)
+++ head/lib/msun/src/e_coshf.c Fri Oct 21 06:28:47 2011(r226598)
@@ -51,11 +51,8 @@ __ieee754_coshf(float x)
if (ix  0x42b17217)  return half*__ieee754_expf(fabsf(x));
 
 /* |x| in [log(maxfloat), overflowthresold] */
-   if (ix=0x42b2d4fc) {
-   w = __ieee754_expf(half*fabsf(x));
-   t = half*w;
-   return t*w;
-   }
+   if (ix=0x42b2d4fc)
+   return __ldexp_expf(fabsf(x), -1);
 
 /* |x|  overflowthresold, cosh(x) overflow */
return huge*huge;

Modified: head/lib/msun/src/e_sinh.c
==
--- head/lib/msun/src/e_sinh.c  Fri Oct 21 06:27:56 2011(r226597)
+++ head/lib/msun/src/e_sinh.c  Fri Oct 21 06:28:47 2011(r226598)
@@ -40,9 +40,8 @@ static const double one = 1.0, shuge = 1
 double
 __ieee754_sinh(double x)
 {
-   double t,w,h;
+   double t,h;
int32_t ix,jx;
-   u_int32_t lx;
 
 /* High word of |x|. */
GET_HIGH_WORD(jx,x);
@@ -66,12 +65,8 @@ __ieee754_sinh(double x)
if (ix  0x40862E42)  return h*__ieee754_exp(fabs(x));
 
 /* |x| in [log(maxdouble), overflowthresold] */
-   GET_LOW_WORD(lx,x);
-   if (ix0x408633CE || ((ix==0x408633ce)(lx=(u_int32_t)0x8fb9f87d))) {
-   w = __ieee754_exp(0.5*fabs(x));
-   t = h*w;
-   return t*w;
-   }
+   if (ix=0x408633CE)
+   return h*2.0*__ldexp_exp(fabs(x), -1);
 
 /* |x|  overflowthresold, sinh(x) overflow */
return x*shuge;

Modified: head/lib/msun/src/e_sinhf.c
==
--- head/lib/msun/src/e_sinhf.c Fri Oct 21 06:27:56 2011(r226597)
+++ head/lib/msun/src/e_sinhf.c Fri Oct 21 06:28:47 2011(r226598)
@@ -24,7 +24,7 @@ static const float one = 1.0, shuge = 1.
 float
 __ieee754_sinhf(float x)
 {
-   float t,w,h;
+   float t,h;
int32_t ix,jx;
 
GET_FLOAT_WORD(jx,x);
@@ -48,11 +48,8 @@ __ieee754_sinhf(float x)
if (ix  0x42b17217)  return h*__ieee754_expf(fabsf(x));
 
 /* |x| in [logf(maxfloat), overflowthresold] */
-   if (ix=0x42b2d4fc) {
-   w = __ieee754_expf((float)0.5*fabsf(x));
-   t = h*w;
-   return t*w;
-   }
+   if (ix=0x42b2d4fc)
+   return h*2.0F*__ldexp_expf(fabsf(x), -1);
 
 /* |x|  overflowthresold, sinh(x) overflow */
return x*shuge;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


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

2011-10-21 Thread David Schultz
Author: das
Date: Fri Oct 21 06:29:32 2011
New Revision: 226599
URL: http://svn.freebsd.org/changeset/base/226599

Log:
  Improved handling of large x in ccosh{,f}():
  - Handle cases where exp(x) would overflow, but ccosh(x) ~= exp(x) / 2
shouldn't.
  - Use the ccosh(x) ~= exp(x) / 2 approximation to simplify the calculation
when x is large.
  
  Similarly for csinh().  Also fixed the return value of csinh(-Inf +- 0i).

Modified:
  head/lib/msun/src/s_ccosh.c
  head/lib/msun/src/s_ccoshf.c
  head/lib/msun/src/s_csinh.c
  head/lib/msun/src/s_csinhf.c

Modified: head/lib/msun/src/s_ccosh.c
==
--- head/lib/msun/src/s_ccosh.c Fri Oct 21 06:28:47 2011(r226598)
+++ head/lib/msun/src/s_ccosh.c Fri Oct 21 06:29:32 2011(r226599)
@@ -42,10 +42,12 @@ __FBSDID($FreeBSD$);
 
 #include math_private.h
 
+static const double huge = 0x1p1023;
+
 double complex
 ccosh(double complex z)
 {
-   double x, y;
+   double x, y, h;
int32_t hx, hy, ix, iy, lx, ly;
 
x = creal(z);
@@ -61,8 +63,23 @@ ccosh(double complex z)
if (ix  0x7ff0  iy  0x7ff0) {
if ((iy | ly) == 0)
return (cpack(cosh(x), x * y));
-   /* XXX We don't handle |x|  DBL_MAX ln(2) yet. */
-   return (cpack(cosh(x) * cos(y), sinh(x) * sin(y)));
+   if (ix  0x4036)/* small x: normal case */
+   return (cpack(cosh(x) * cos(y), sinh(x) * sin(y)));
+
+   /* |x| = 22, so cosh(x) ~= exp(|x|) */
+   if (ix  0x40862e42) {
+   /* x  710: exp(|x|) won't overflow */
+   h = exp(fabs(x)) * 0.5;
+   return (cpack(h * cos(y), copysign(h, x) * sin(y)));
+   } else if (ix  0x4096bbaa) {
+   /* x  1455: scale to avoid overflow */
+   z = __ldexp_cexp(cpack(fabs(x), y), -1);
+   return (cpack(creal(z), cimag(z) * copysign(1, x)));
+   } else {
+   /* x = 1455: the result always overflows */
+   h = huge * x;
+   return (cpack(h * h * cos(y), h * sin(y)));
+   }
}
 
/*

Modified: head/lib/msun/src/s_ccoshf.c
==
--- head/lib/msun/src/s_ccoshf.cFri Oct 21 06:28:47 2011
(r226598)
+++ head/lib/msun/src/s_ccoshf.cFri Oct 21 06:29:32 2011
(r226599)
@@ -36,10 +36,12 @@ __FBSDID($FreeBSD$);
 
 #include math_private.h
 
+static const float huge = 0x1p127;
+
 float complex
 ccoshf(float complex z)
 {
-   float x, y;
+   float x, y, h;
int32_t hx, hy, ix, iy;
 
x = crealf(z);
@@ -54,8 +56,23 @@ ccoshf(float complex z)
if (ix  0x7f80  iy  0x7f80) {
if (iy == 0)
return (cpackf(coshf(x), x * y));
-   /* XXX We don't handle |x|  FLT_MAX ln(2) yet. */
-   return (cpackf(coshf(x) * cosf(y), sinhf(x) * sinf(y)));
+   if (ix  0x4110)/* small x: normal case */
+   return (cpackf(coshf(x) * cosf(y), sinhf(x) * sinf(y)));
+
+   /* |x| = 9, so cosh(x) ~= exp(|x|) */
+   if (ix  0x42b17218) {
+   /* x  88.7: expf(|x|) won't overflow */
+   h = expf(fabsf(x)) * 0.5f;
+   return (cpackf(h * cosf(y), copysignf(h, x) * sinf(y)));
+   } else if (ix  0x4340b1e7) {
+   /* x  192.7: scale to avoid overflow */
+   z = __ldexp_cexpf(cpackf(fabsf(x), y), -1);
+   return (cpackf(crealf(z), cimagf(z) * copysignf(1, x)));
+   } else {
+   /* x = 192.7: the result always overflows */
+   h = huge * x;
+   return (cpackf(h * h * cosf(y), h * sinf(y)));
+   }
}
 
if (ix == 0  iy = 0x7f80)

Modified: head/lib/msun/src/s_csinh.c
==
--- head/lib/msun/src/s_csinh.c Fri Oct 21 06:28:47 2011(r226598)
+++ head/lib/msun/src/s_csinh.c Fri Oct 21 06:29:32 2011(r226599)
@@ -42,10 +42,12 @@ __FBSDID($FreeBSD$);
 
 #include math_private.h
 
+static const double huge = 0x1p1023;
+
 double complex
 csinh(double complex z)
 {
-   double x, y;
+   double x, y, h;
int32_t hx, hy, ix, iy, lx, ly;
 
x = creal(z);
@@ -61,8 +63,23 @@ csinh(double complex z)
if (ix  0x7ff0  iy  0x7ff0) {
if ((iy | ly) == 0)
return (cpack(sinh(x), y));
-   /* XXX We don't handle |x|  DBL_MAX ln(2) yet. */
-   return (cpack(sinh(x) * cos(y), cosh(x) * sin(y)));
+   if 

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

2011-10-21 Thread David Schultz
Author: das
Date: Fri Oct 21 06:30:16 2011
New Revision: 226600
URL: http://svn.freebsd.org/changeset/base/226600

Log:
  Fix a corner case: tan(large + Inf i) == NaN + NaN i.

Modified:
  head/lib/msun/src/s_ctanh.c
  head/lib/msun/src/s_ctanhf.c

Modified: head/lib/msun/src/s_ctanh.c
==
--- head/lib/msun/src/s_ctanh.c Fri Oct 21 06:29:32 2011(r226599)
+++ head/lib/msun/src/s_ctanh.c Fri Oct 21 06:30:16 2011(r226600)
@@ -108,6 +108,13 @@ ctanh(double complex z)
}
 
/*
+* ctanh(x + i NAN) = NaN + i NaN
+* ctanh(x +- i Inf) = NaN + i NaN
+*/
+   if (!isfinite(y))
+   return (cpack(y - y, y - y));
+
+   /*
 * ctanh(+-huge + i +-y) ~= +-1 +- i 2sin(2y)/exp(2x), using the
 * approximation sinh^2(huge) ~= exp(2*huge) / 4.
 * We use a modified formula to avoid spurious overflow.

Modified: head/lib/msun/src/s_ctanhf.c
==
--- head/lib/msun/src/s_ctanhf.cFri Oct 21 06:29:32 2011
(r226599)
+++ head/lib/msun/src/s_ctanhf.cFri Oct 21 06:30:16 2011
(r226600)
@@ -57,6 +57,9 @@ ctanhf(float complex z)
copysignf(0, isinf(y) ? y : sinf(y) * cosf(y;
}
 
+   if (!isfinite(y))
+   return (cpackf(y - y, y - y));
+
if (ix = 0x4130) { /* x = 11 */
float exp_mx = expf(-fabsf(x));
return (cpackf(copysignf(1, x),
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


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

2011-10-21 Thread David Schultz
Author: das
Date: Fri Oct 21 06:30:43 2011
New Revision: 226601
URL: http://svn.freebsd.org/changeset/base/226601

Log:
  Fix a regression introduced in r226371: When the high part of x*y
  exactly cancels with z, return the low part of x*y instead of
  discarding it.

Modified:
  head/lib/msun/src/s_fma.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 21 06:30:16 2011(r226600)
+++ head/lib/msun/src/s_fma.c   Fri Oct 21 06:30:43 2011(r226601)
@@ -250,6 +250,8 @@ fma(double x, double y, double z)
xy = dd_mul(xs, ys);
r = dd_add(xy.hi, zs);
 
+   spread = ex + ey;
+
if (r.hi == 0.0) {
/*
 * When the addends cancel to 0, ensure that the result has
@@ -257,11 +259,9 @@ fma(double x, double y, double z)
 */
fesetround(oround);
volatile double vzs = zs; /* XXX gcc CSE bug workaround */
-   return (xy.hi + vzs);
+   return (xy.hi + vzs + ldexp(xy.lo, spread));
}
 
-   spread = ex + ey;
-
if (oround != FE_TONEAREST) {
/*
 * There is no need to worry about double rounding in directed

Modified: head/lib/msun/src/s_fmal.c
==
--- head/lib/msun/src/s_fmal.c  Fri Oct 21 06:30:16 2011(r226600)
+++ head/lib/msun/src/s_fmal.c  Fri Oct 21 06:30:43 2011(r226601)
@@ -238,6 +238,8 @@ fmal(long double x, long double y, long 
xy = dd_mul(xs, ys);
r = dd_add(xy.hi, zs);
 
+   spread = ex + ey;
+
if (r.hi == 0.0) {
/*
 * When the addends cancel to 0, ensure that the result has
@@ -245,11 +247,9 @@ fmal(long double x, long double y, long 
 */
fesetround(oround);
volatile long double vzs = zs; /* XXX gcc CSE bug workaround */
-   return (xy.hi + vzs);
+   return (xy.hi + vzs + ldexpl(xy.lo, spread));
}
 
-   spread = ex + ey;
-
if (oround != FE_TONEAREST) {
/*
 * There is no need to worry about double rounding in directed
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


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

2011-10-21 Thread David Schultz
Author: das
Date: Fri Oct 21 06:32:54 2011
New Revision: 226602
URL: http://svn.freebsd.org/changeset/base/226602

Log:
  Tests for cancellation in fma(). Also include more tests for 128-bit
  long doubles. Thanks for clusteradm (simon) for making the needed
  hardware available.

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   Fri Oct 21 06:30:43 2011
(r226601)
+++ head/tools/regression/lib/msun/test-fma.c   Fri Oct 21 06:32:54 2011
(r226602)
@@ -362,6 +362,65 @@ test_accuracy(void)
0x1.d87da3aafda40p70L, 0x1.d87da3aafda3fp70L,
0x1.d87da3aafda3fp70L, ALL_STD_EXCEPT, FE_INEXACT);
 #endif
+
+   /* ilogb(x*y) - ilogb(z) = 0 */
+   testrnd(fmaf, 0x1.31ad02p+100, 0x1.2fbf7ap-42, -0x1.c3e106p+58,
+   -0x1.64c27cp+56, -0x1.64c27ap+56, -0x1.64c27cp+56,
+   -0x1.64c27ap+56, ALL_STD_EXCEPT, FE_INEXACT);
+   testrnd(fma, 0x1.31ad012ede8aap+100, 0x1.2fbf79c839067p-42,
+   -0x1.c3e106929056ep+58, -0x1.64c282b970a5fp+56,
+   -0x1.64c282b970a5ep+56, -0x1.64c282b970a5fp+56,
+   -0x1.64c282b970a5ep+56, ALL_STD_EXCEPT, FE_INEXACT);
+#if LDBL_MANT_DIG == 113
+   testrnd(fmal, 0x1.31ad012ede8aa282fa1c19376d16p+100L,
+0x1.2fbf79c839066f0f5c68f6d2e814p-42L,
+   -0x1.c3e106929056ec19de72bfe64215p+58L,
+   -0x1.64c282b970a612598fc025ca8cddp+56L,
+   -0x1.64c282b970a612598fc025ca8cddp+56L,
+   -0x1.64c282b970a612598fc025ca8cdep+56L,
+   -0x1.64c282b970a612598fc025ca8cddp+56L,
+   ALL_STD_EXCEPT, FE_INEXACT);
+#elif LDBL_MANT_DIG == 64
+   testrnd(fmal, 0x1.31ad012ede8aa4eap+100L, 0x1.2fbf79c839066aeap-42L,
+   -0x1.c3e106929056e61p+58L, -0x1.64c282b970a60298p+56L,
+   -0x1.64c282b970a60298p+56L, -0x1.64c282b970a6029ap+56L,
+   -0x1.64c282b970a60298p+56L, ALL_STD_EXCEPT, FE_INEXACT);
+#elif LDBL_MANT_DIG == 53
+   testrnd(fmal, 0x1.31ad012ede8aap+100L, 0x1.2fbf79c839067p-42L,
+   -0x1.c3e106929056ep+58L, -0x1.64c282b970a5fp+56L,
+   -0x1.64c282b970a5ep+56L, -0x1.64c282b970a5fp+56L,
+   -0x1.64c282b970a5ep+56L, ALL_STD_EXCEPT, FE_INEXACT);
+#endif
+
+   /* x*y (rounded) ~= -z */
+   /* XXX spurious inexact exceptions */
+   testrnd(fmaf, 0x1.bbffeep-30, -0x1.1d164cp-74, 0x1.ee7296p-104,
+   -0x1.c46ea8p-128, -0x1.c46ea8p-128, -0x1.c46ea8p-128,
+   -0x1.c46ea8p-128, ALL_STD_EXCEPT  ~FE_INEXACT, 0);
+   testrnd(fma, 0x1.bbffeea6fc7d6p-30, 0x1.1d164c6cbf078p-74,
+   -0x1.ee72993aff948p-104, -0x1.71f72ac7d9d8p-159,
+   -0x1.71f72ac7d9d8p-159, -0x1.71f72ac7d9d8p-159,
+   -0x1.71f72ac7d9d8p-159, ALL_STD_EXCEPT  ~FE_INEXACT, 0);
+#if LDBL_MANT_DIG == 113
+   testrnd(fmal, 0x1.bbffeea6fc7d65927d147f437675p-30L,
+   0x1.1d164c6cbf078b7a22607d1cd6a2p-74L,
+   -0x1.ee72993aff94973876031bec0944p-104L,
+   0x1.64e086175b3a2adc36e607058814p-217L,
+   0x1.64e086175b3a2adc36e607058814p-217L,
+   0x1.64e086175b3a2adc36e607058814p-217L,
+   0x1.64e086175b3a2adc36e607058814p-217L,
+   ALL_STD_EXCEPT  ~FE_INEXACT, 0);
+#elif LDBL_MANT_DIG == 64
+   testrnd(fmal, 0x1.bbffeea6fc7d6592p-30L, 0x1.1d164c6cbf078b7ap-74L,
+   -0x1.ee72993aff949736p-104L, 0x1.af190e7a1ee6ad94p-168L,
+   0x1.af190e7a1ee6ad94p-168L, 0x1.af190e7a1ee6ad94p-168L,
+   0x1.af190e7a1ee6ad94p-168L, ALL_STD_EXCEPT  ~FE_INEXACT, 0);
+#elif LDBL_MANT_DIG == 53
+   testrnd(fmal, 0x1.bbffeea6fc7d6p-30L, 0x1.1d164c6cbf078p-74L,
+   -0x1.ee72993aff948p-104L, -0x1.71f72ac7d9d8p-159L,
+   -0x1.71f72ac7d9d8p-159L, -0x1.71f72ac7d9d8p-159L,
+   -0x1.71f72ac7d9d8p-159L, ALL_STD_EXCEPT  ~FE_INEXACT, 0);
+#endif
 }
 
 static void
@@ -407,9 +466,10 @@ test_double_rounding(void)
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);
+   test(fmal, 0x1.8001p+0L,
+0x1.8001p+0L,
+-0x1.0001p-224L,
+0x1.2001p+1L, ALL_STD_EXCEPT, FE_INEXACT);
 #endif
 
 }
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


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

2011-10-21 Thread David Schultz
Author: das
Date: Fri Oct 21 06:34:38 2011
New Revision: 226603
URL: http://svn.freebsd.org/changeset/base/226603

Log:
  Tests for complex trig and hyperbolic functions.

Added:
  head/tools/regression/lib/msun/test-ctrig.c   (contents, props changed)
  head/tools/regression/lib/msun/test-ctrig.t   (contents, props changed)
Modified:
  head/tools/regression/lib/msun/Makefile

Modified: head/tools/regression/lib/msun/Makefile
==
--- head/tools/regression/lib/msun/Makefile Fri Oct 21 06:32:54 2011
(r226602)
+++ head/tools/regression/lib/msun/Makefile Fri Oct 21 06:34:38 2011
(r226603)
@@ -1,6 +1,7 @@
 # $FreeBSD$
 
-TESTS= test-cexp test-conj test-csqrt test-exponential test-fenv test-fma \
+TESTS= test-cexp test-conj test-csqrt test-ctrig \
+   test-exponential test-fenv test-fma \
test-fmaxmin test-ilogb test-invtrig test-logarithm test-lrint \
test-lround test-nan test-nearbyint test-next test-rem test-trig
 CFLAGS+= -O0 -lm

Added: head/tools/regression/lib/msun/test-ctrig.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/regression/lib/msun/test-ctrig.c Fri Oct 21 06:34:38 2011
(r226603)
@@ -0,0 +1,540 @@
+/*-
+ * Copyright (c) 2008-2011 David Schultz d...@freebsd.org
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Tests for csin[h](), ccos[h](), and ctan[h]().
+ */
+
+#include sys/cdefs.h
+__FBSDID($FreeBSD$);
+
+#include assert.h
+#include complex.h
+#include fenv.h
+#include float.h
+#include math.h
+#include stdio.h
+
+#defineALL_STD_EXCEPT  (FE_DIVBYZERO | FE_INEXACT | FE_INVALID | \
+FE_OVERFLOW | FE_UNDERFLOW)
+#defineOPT_INVALID (ALL_STD_EXCEPT  ~FE_INVALID)
+#defineOPT_INEXACT (ALL_STD_EXCEPT  ~FE_INEXACT)
+#defineFLT_ULP()   ldexpl(1.0, 1 - FLT_MANT_DIG)
+#defineDBL_ULP()   ldexpl(1.0, 1 - DBL_MANT_DIG)
+#defineLDBL_ULP()  ldexpl(1.0, 1 - LDBL_MANT_DIG)
+
+#pragma STDC FENV_ACCESS   ON
+#pragmaSTDC CX_LIMITED_RANGE   OFF
+
+/*
+ * XXX gcc implements complex multiplication incorrectly. In
+ * particular, it implements it as if the CX_LIMITED_RANGE pragma
+ * were ON. Consequently, we need this function to form numbers
+ * such as x + INFINITY * I, since gcc evalutes INFINITY * I as
+ * NaN + INFINITY * I.
+ */
+static inline long double complex
+cpackl(long double x, long double y)
+{
+   long double complex z;
+
+   __real__ z = x;
+   __imag__ z = y;
+   return (z);
+}
+
+/* Flags that determine whether to check the signs of the result. */
+#defineCS_REAL 1
+#defineCS_IMAG 2
+#defineCS_BOTH (CS_REAL | CS_IMAG)
+
+#ifdef DEBUG
+#definedebug(...)  printf(__VA_ARGS__)
+#else
+#definedebug(...)  (void)0
+#endif
+
+/*
+ * Test that a function returns the correct value and sets the
+ * exception flags correctly. The exceptmask specifies which
+ * exceptions we should check. We need to be lenient for several
+ * reasons, but mainly because on some architectures it's impossible
+ * to raise FE_OVERFLOW without raising FE_INEXACT.
+ *
+ * These are macros instead of functions so that assert provides more
+ * meaningful error messages.
+ *
+ * XXX The volatile here is to avoid gcc's bogus constant folding and work
+ * around the lack of support for the FENV_ACCESS pragma.
+ */
+#definetest_p(func, z, result, exceptmask, excepts, checksign) do {
\
+   volatile long double complex _d = z;  

svn commit: r226604 - head/lib/libc/stdio

2011-10-21 Thread David Schultz
Author: das
Date: Fri Oct 21 06:35:58 2011
New Revision: 226604
URL: http://svn.freebsd.org/changeset/base/226604

Log:
  Add support for the 'x' mode option in fopen() as specified in the C1X
  draft standard.  The option is equivalent to O_EXCL.
  
  MFC after:1 month

Modified:
  head/lib/libc/stdio/flags.c
  head/lib/libc/stdio/fopen.3

Modified: head/lib/libc/stdio/flags.c
==
--- head/lib/libc/stdio/flags.c Fri Oct 21 06:34:38 2011(r226603)
+++ head/lib/libc/stdio/flags.c Fri Oct 21 06:35:58 2011(r226604)
@@ -80,11 +80,30 @@ __sflags(mode, optr)
return (0);
}
 
-   /* [rwa]\+ or [rwa]b\+ means read and write */
-   if (*mode == '+' || (*mode == 'b'  mode[1] == '+')) {
+   /* 'b' (binary) is ignored */
+   if (*mode == 'b')
+   mode++;
+
+   /* [rwa][b]\+ means read and write */
+   if (*mode == '+') {
+   mode++;
ret = __SRW;
m = O_RDWR;
}
+
+   /* 'b' (binary) can appear here, too -- and is ignored again */
+   if (*mode == 'b')
+   mode++;
+
+   /* 'x' means exclusive (fail if the file exists) */
+   if (*mode == 'x') {
+   if (m == O_RDONLY) {
+   errno = EINVAL;
+   return (0);
+   }
+   o |= O_EXCL;
+   }
+
*optr = m | o;
return (ret);
 }

Modified: head/lib/libc/stdio/fopen.3
==
--- head/lib/libc/stdio/fopen.3 Fri Oct 21 06:34:38 2011(r226603)
+++ head/lib/libc/stdio/fopen.3 Fri Oct 21 06:35:58 2011(r226604)
@@ -32,7 +32,7 @@
 .\ @(#)fopen.38.1 (Berkeley) 6/4/93
 .\ $FreeBSD$
 .\
-.Dd January 26, 2003
+.Dd October 17, 2011
 .Dt FOPEN 3
 .Os
 .Sh NAME
@@ -60,45 +60,51 @@ and associates a stream with it.
 .Pp
 The argument
 .Fa mode
-points to a string beginning with one of the following
-sequences (Additional characters may follow these sequences.):
+points to a string beginning with one of the following letters:
 .Bl -tag -width indent
 .It Dq Li r
-Open text file for reading.
-The stream is positioned at the beginning of the file.
-.It Dq Li r+
-Open for reading and writing.
+Open for reading.
 The stream is positioned at the beginning of the file.
+Fail if the file does not exist.
 .It Dq Li w
-Truncate to zero length or create text file for writing.
-The stream is positioned at the beginning of the file.
-.It Dq Li w+
-Open for reading and writing.
-The file is created if it does not exist, otherwise it is truncated.
+Open for writing.
 The stream is positioned at the beginning of the file.
+Create the file if it does not exist.
 .It Dq Li a
 Open for writing.
-The file is created if it does not exist.
-The stream is positioned at the end of the file.
-Subsequent writes to the file will always end up at the then current
-end of file, irrespective of any intervening
-.Xr fseek 3
-or similar.
-.It Dq Li a+
-Open for reading and writing.
-The file is created if it does not exist.
 The stream is positioned at the end of the file.
 Subsequent writes to the file will always end up at the then current
 end of file, irrespective of any intervening
 .Xr fseek 3
 or similar.
+Create the file if it does not exist.
 .El
 .Pp
+An optional
+.Dq Li +
+following
+.Dq Li r ,
+.Dq Li w ,
+or
+.Dq Li a
+opens the file for both reading and writing.
+An optional
+.Dq Li x
+following
+.Dq Li w
+or
+.Dq Li w+
+causes the
+.Fn fopen
+call to fail if the file already exists.
+.Pp
 The
 .Fa mode
-string can also include the letter ``b'' either as last character or
-as a character between the characters in any of the two-character strings
-described above.
+string can also include the letter
+.Dq Li b
+after either the
+.Dq Li +
+or the first letter.
 This is strictly for compatibility with
 .St -isoC
 and has no effect; the ``b'' is ignored.
@@ -135,6 +141,9 @@ function associates a stream with the ex
 .Fa fildes .
 The mode
 of the stream must be compatible with the mode of the file descriptor.
+The
+.Dq Li x
+mode option is ignored.
 When the stream is closed via
 .Xr fclose 3 ,
 .Fa fildes
@@ -165,29 +174,12 @@ attempts to re-open the file associated 
 with a new mode.
 The new mode must be compatible with the mode that the stream was originally
 opened with:
-.Bl -bullet -offset indent
-.It
-Streams originally opened with mode
-.Dq Li r
-can only be reopened with that same mode.
-.It
-Streams originally opened with mode
-.Dq Li a
-can be reopened with the same mode, or mode
-.Dq Li w .
-.It
-Streams originally opened with mode
-.Dq Li w
-can be reopened with the same mode, or mode
-.Dq Li a .
-.It
-Streams originally opened with mode
-.Dq Li r+ ,
-.Dq Li w+ ,
-or
-.Dq Li a+
-can be reopened with any mode.
-.El
+Streams open for reading can only be re-opened for reading,
+streams open for 

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

2011-10-21 Thread David Schultz
Author: das
Date: Fri Oct 21 06:36:40 2011
New Revision: 226605
URL: http://svn.freebsd.org/changeset/base/226605

Log:
  Add regression tests for modf{,f,l}().

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

Modified: head/tools/regression/lib/msun/test-nearbyint.c
==
--- head/tools/regression/lib/msun/test-nearbyint.c Fri Oct 21 06:35:58 
2011(r226604)
+++ head/tools/regression/lib/msun/test-nearbyint.c Fri Oct 21 06:36:40 
2011(r226605)
@@ -30,7 +30,6 @@
  * TODO:
  * - adapt tests for rint(3)
  * - tests for harder values (more mantissa bits than float)
- * - tests in other rounding modes
  */
 
 #include sys/cdefs.h
@@ -44,6 +43,27 @@ __FBSDID($FreeBSD$);
 #defineALL_STD_EXCEPT  (FE_DIVBYZERO | FE_INEXACT | FE_INVALID | \
 FE_OVERFLOW | FE_UNDERFLOW)
 
+static int testnum;
+
+static const int rmodes[] = {
+   FE_TONEAREST, FE_DOWNWARD, FE_UPWARD, FE_TOWARDZERO,
+};
+
+static const struct {
+   float in;
+   float out[3];   /* one answer per rounding mode except towardzero */
+} tests[] = {
+/* input   output (expected) */
+{ 0.0, { 0.0, 0.0, 0.0 }},
+{ 0.5, { 0.0, 0.0, 1.0 }},
+{ M_PI,{ 3.0, 3.0, 4.0 }},
+{ 65536.5, { 65536, 65536, 65537 }},
+{ INFINITY,{ INFINITY, INFINITY, INFINITY }},
+{ NAN, { NAN, NAN, NAN }},
+};
+
+static const int ntests = sizeof(tests) / sizeof(tests[0]);
+
 /*
  * Compare d1 and d2 using special rules: NaN == NaN and +0 != -0.
  * Fail an assertion if they differ.
@@ -57,44 +77,106 @@ fpequal(long double d1, long double d2)
return (copysignl(1.0, d1) == copysignl(1.0, d2));
 }
 
-static void testit(int testnum, float in, float out)
+/* Get the appropriate result for the current rounding mode. */
+static float
+get_output(int testindex, int rmodeindex, int negative)
 {
+   double out;
 
-feclearexcept(ALL_STD_EXCEPT);
-assert(fpequal(out, nearbyintf(in)));
-assert(fpequal(-out, nearbyintf(-in)));
-assert(fetestexcept(ALL_STD_EXCEPT) == 0);
-
-assert(fpequal(out, nearbyint(in)));
-assert(fpequal(-out, nearbyint(-in)));
-assert(fetestexcept(ALL_STD_EXCEPT) == 0);
-
-assert(fpequal(out, nearbyintl(in)));
-assert(fpequal(-out, nearbyintl(-in)));
-assert(fetestexcept(ALL_STD_EXCEPT) == 0);
+   if (negative) { /* swap downwards and upwards if input is negative */
+   if (rmodeindex == 1)
+   rmodeindex = 2;
+   else if (rmodeindex == 2)
+   rmodeindex = 1;
+   }
+   if (rmodeindex == 3) /* FE_TOWARDZERO uses the value for downwards */
+   rmodeindex = 1;
+   out = tests[testindex].out[rmodeindex];
+   return (negative ? -out : out);
+}
 
-printf(ok %d\t\t# nearbyint(%g)\n, testnum, in);
+static void
+test_nearby(int testindex)
+{
+   float in, out;
+   int i;
+
+   for (i = 0; i  sizeof(rmodes) / sizeof(rmodes[0]); i++) {
+   fesetround(rmodes[i]);
+   feclearexcept(ALL_STD_EXCEPT);
+
+   in = tests[testindex].in;
+   out = get_output(testindex, i, 0);
+   assert(fpequal(out, nearbyintf(in)));
+   assert(fpequal(out, nearbyint(in)));
+   assert(fpequal(out, nearbyintl(in)));
+   assert(fetestexcept(ALL_STD_EXCEPT) == 0);
+
+   in = -tests[testindex].in;
+   out = get_output(testindex, i, 1);
+   assert(fpequal(out, nearbyintf(in)));
+   assert(fpequal(out, nearbyint(in)));
+   assert(fpequal(out, nearbyintl(in)));
+   assert(fetestexcept(ALL_STD_EXCEPT) == 0);
+   }
+
+   printf(ok %d\t\t# nearbyint(+%g)\n, testnum++, in);
 }
 
-static const float tests[] = {
-/* input   output (expected) */
-0.0,   0.0,
-0.5,   0.0,
-M_PI,  3,
-65536.5,   65536,
-INFINITY,  INFINITY,
-NAN,   NAN,
-};
+static void
+test_modf(int testindex)
+{
+   float in, out;
+   float ipartf, ipart_expected;
+   double ipart;
+   long double ipartl;
+   int i;
+
+   for (i = 0; i  sizeof(rmodes) / sizeof(rmodes[0]); i++) {
+   fesetround(rmodes[i]);
+   feclearexcept(ALL_STD_EXCEPT);
+
+   in = tests[testindex].in;
+   ipart_expected = tests[testindex].out[1];
+   out = copysignf(
+   isinf(ipart_expected) ? 0.0 : in - ipart_expected, in);
+   ipartl = ipart = ipartf = 42.0;
+
+   assert(fpequal(out, modff(in, ipartf)));
+   assert(fpequal(ipart_expected, ipartf));
+   assert(fpequal(out, modf(in, ipart)));
+   assert(fpequal(ipart_expected, ipart));
+   assert(fpequal(out, modfl(in, ipartl)));
+   assert(fpequal(ipart_expected, ipartl));
+ 

svn commit: r226606 - in head/lib/libc: amd64 amd64/gen arm arm/gen gen i386 i386/gen ia64 ia64/gen mips mips/gen powerpc powerpc/gen powerpc64 powerpc64/gen sparc64 sparc64/gen

2011-10-21 Thread David Schultz
Author: das
Date: Fri Oct 21 06:40:36 2011
New Revision: 226606
URL: http://svn.freebsd.org/changeset/base/226606

Log:
  Replace a proliferation of buggy MD implementations of modf() with a
  working MI one.  The MI one only needs to be overridden on machines
  with non-IEEE754 arithmetic.  (The last supported one was the VAX.)
  It can also be overridden if someone comes up with a faster one that
  actually passes the regression tests -- but this is harder than it sounds.

Added:
  head/lib/libc/gen/modf.c
 - copied, changed from r226410, head/lib/msun/src/s_modf.c
Deleted:
  head/lib/libc/amd64/gen/modf.S
  head/lib/libc/arm/gen/modf.c
  head/lib/libc/i386/gen/modf.S
  head/lib/libc/ia64/gen/modf.c
  head/lib/libc/mips/gen/modf.S
  head/lib/libc/mips/gen/modf.c
  head/lib/libc/powerpc/gen/modf.c
  head/lib/libc/powerpc64/gen/modf.c
  head/lib/libc/sparc64/gen/modf.S
Modified:
  head/lib/libc/amd64/Symbol.map
  head/lib/libc/amd64/gen/Makefile.inc
  head/lib/libc/arm/Symbol.map
  head/lib/libc/arm/gen/Makefile.inc
  head/lib/libc/gen/Makefile.inc
  head/lib/libc/gen/Symbol.map
  head/lib/libc/i386/Symbol.map
  head/lib/libc/i386/gen/Makefile.inc
  head/lib/libc/ia64/Symbol.map
  head/lib/libc/ia64/gen/Makefile.inc
  head/lib/libc/mips/Symbol.map
  head/lib/libc/mips/gen/Makefile.inc
  head/lib/libc/powerpc/Symbol.map
  head/lib/libc/powerpc/gen/Makefile.inc
  head/lib/libc/powerpc64/Symbol.map
  head/lib/libc/powerpc64/gen/Makefile.inc
  head/lib/libc/sparc64/Symbol.map
  head/lib/libc/sparc64/gen/Makefile.inc

Modified: head/lib/libc/amd64/Symbol.map
==
--- head/lib/libc/amd64/Symbol.map  Fri Oct 21 06:36:40 2011
(r226605)
+++ head/lib/libc/amd64/Symbol.map  Fri Oct 21 06:40:36 2011
(r226606)
@@ -26,7 +26,6 @@ FBSD_1.0 {
__infinity;
__nan;
makecontext;
-   modf;
rfork_thread;
setjmp;
longjmp;

Modified: head/lib/libc/amd64/gen/Makefile.inc
==
--- head/lib/libc/amd64/gen/Makefile.incFri Oct 21 06:36:40 2011
(r226605)
+++ head/lib/libc/amd64/gen/Makefile.incFri Oct 21 06:40:36 2011
(r226606)
@@ -2,7 +2,7 @@
 # $FreeBSD$
 
 SRCS+= _setjmp.S _set_tp.c rfork_thread.S setjmp.S sigsetjmp.S \
-   fabs.S modf.S \
+   fabs.S \
infinity.c ldexp.c makecontext.c signalcontext.c \
flt_rounds.c fpgetmask.c fpsetmask.c fpgetprec.c fpsetprec.c \
fpgetround.c fpsetround.c fpgetsticky.c

Modified: head/lib/libc/arm/Symbol.map
==
--- head/lib/libc/arm/Symbol.mapFri Oct 21 06:36:40 2011
(r226605)
+++ head/lib/libc/arm/Symbol.mapFri Oct 21 06:40:36 2011
(r226606)
@@ -19,7 +19,6 @@ FBSD_1.0 {
__infinity;
__nan;
makecontext;
-   modf;
setjmp;
longjmp;
sigsetjmp;

Modified: head/lib/libc/arm/gen/Makefile.inc
==
--- head/lib/libc/arm/gen/Makefile.inc  Fri Oct 21 06:36:40 2011
(r226605)
+++ head/lib/libc/arm/gen/Makefile.inc  Fri Oct 21 06:40:36 2011
(r226606)
@@ -2,5 +2,5 @@
 # $FreeBSD$
 
 SRCS+= _ctx_start.S _setjmp.S _set_tp.c alloca.S fabs.c \
-   infinity.c ldexp.c makecontext.c modf.c \
+   infinity.c ldexp.c makecontext.c \
setjmp.S signalcontext.c sigsetjmp.S divsi3.S

Modified: head/lib/libc/gen/Makefile.inc
==
--- head/lib/libc/gen/Makefile.inc  Fri Oct 21 06:36:40 2011
(r226605)
+++ head/lib/libc/gen/Makefile.inc  Fri Oct 21 06:40:36 2011
(r226606)
@@ -35,6 +35,8 @@ SRCS+=  __getosreldate.c __xuname.c \
usleep.c utime.c utxdb.c valloc.c vis.c wait.c wait3.c waitpid.c \
wordexp.c
 
+MISRCS+=modf.c
+
 CANCELPOINTS_SRCS=sem.c sem_new.c
 .for src in ${CANCELPOINTS_SRCS}
 SRCS+=cancelpoints_${src}

Modified: head/lib/libc/gen/Symbol.map
==
--- head/lib/libc/gen/Symbol.mapFri Oct 21 06:36:40 2011
(r226605)
+++ head/lib/libc/gen/Symbol.mapFri Oct 21 06:40:36 2011
(r226606)
@@ -213,6 +213,7 @@ FBSD_1.0 {
ldexp;
lockf;
lrand48;
+   modf;
mrand48;
nftw;
nice;

Copied and modified: head/lib/libc/gen/modf.c (from r226410, 
head/lib/msun/src/s_modf.c)
==
--- head/lib/msun/src/s_modf.c  Sat Oct 15 23:15:55 2011(r226410, copy 
source)
+++ head/lib/libc/gen/modf.cFri Oct 21 06:40:36 2011(r226606)
@@ -10,9 +10,8 @@
  * 
  */
 
-#ifndef lint
-static char rcsid[] = 

svn commit: r226607 - in head: include sys/amd64/include sys/arm/include sys/i386/include sys/ia64/include sys/mips/include sys/powerpc/include sys/sparc64/include

2011-10-21 Thread David Schultz
Author: das
Date: Fri Oct 21 06:41:46 2011
New Revision: 226607
URL: http://svn.freebsd.org/changeset/base/226607

Log:
  People porting FreeBSD to new architectures ought not have to
  implement a deprecated FPU control interface in addition to the
  standard one.  To make this clearer, further deprecate ieeefp.h
  by not declaring the function prototypes except on architectures
  that implement them already.
  
  Currently i386 and amd64 implement the ieeefp.h interface for
  compatibility, and for fp[gs]etprec(), which doesn't exist on
  most other hardware.  Powerpc, sparc64, and ia64 partially implement
  it and probably shouldn't, and other architectures don't implement it
  at all.

Modified:
  head/include/ieeefp.h
  head/sys/amd64/include/ieeefp.h
  head/sys/arm/include/ieeefp.h
  head/sys/i386/include/ieeefp.h
  head/sys/ia64/include/ieeefp.h
  head/sys/mips/include/ieeefp.h
  head/sys/powerpc/include/ieeefp.h
  head/sys/sparc64/include/ieeefp.h

Modified: head/include/ieeefp.h
==
--- head/include/ieeefp.h   Fri Oct 21 06:40:36 2011(r226606)
+++ head/include/ieeefp.h   Fri Oct 21 06:41:46 2011(r226607)
@@ -12,15 +12,4 @@
 #include sys/cdefs.h
 #include machine/ieeefp.h
 
-#if !defined(_IEEEFP_INLINED_)
-__BEGIN_DECLS
-extern fp_rnd_tfpgetround(void);
-extern fp_rnd_tfpsetround(fp_rnd_t);
-extern fp_except_t fpgetmask(void);
-extern fp_except_t fpsetmask(fp_except_t);
-extern fp_except_t fpgetsticky(void);
-extern fp_except_t fpsetsticky(fp_except_t);
-__END_DECLS
-#endif /* !_IEEEFP_INLINED_ */
-
 #endif /* _IEEEFP_H_ */

Modified: head/sys/amd64/include/ieeefp.h
==
--- head/sys/amd64/include/ieeefp.h Fri Oct 21 06:40:36 2011
(r226606)
+++ head/sys/amd64/include/ieeefp.h Fri Oct 21 06:41:46 2011
(r226607)
@@ -39,6 +39,8 @@
 #define _MACHINE_IEEEFP_H_
 
 /*
+ * Deprecated historical FPU control interface
+ *
  * IEEE floating point type, constant and function definitions.
  * XXX: {FP,SSE}*FLD and {FP,SSE}*OFF are undocumented pollution.
  */
@@ -287,13 +289,16 @@ __fpgetsticky(void)
 #definefpsetprec(m)__fpsetprec(m)
 #definefpsetround(m)   __fpsetround(m)
 
-/* Suppress prototypes in the MI header. */
-#define_IEEEFP_INLINED_1
-
 #else /* !(!__IEEEFP_NOINLINES__  __GNUCLIKE_ASM) */
 
 /* Augment the userland declarations. */
 __BEGIN_DECLS
+extern fp_rnd_tfpgetround(void);
+extern fp_rnd_tfpsetround(fp_rnd_t);
+extern fp_except_t fpgetmask(void);
+extern fp_except_t fpsetmask(fp_except_t);
+extern fp_except_t fpgetsticky(void);
+extern fp_except_t fpsetsticky(fp_except_t);
 fp_prec_t  fpgetprec(void);
 fp_prec_t  fpsetprec(fp_prec_t);
 __END_DECLS

Modified: head/sys/arm/include/ieeefp.h
==
--- head/sys/arm/include/ieeefp.h   Fri Oct 21 06:40:36 2011
(r226606)
+++ head/sys/arm/include/ieeefp.h   Fri Oct 21 06:41:46 2011
(r226607)
@@ -8,6 +8,8 @@
 #ifndef _MACHINE_IEEEFP_H_
 #define _MACHINE_IEEEFP_H_
 
+/* Deprecated historical FPU control interface */
+
 /* FP exception codes */
 #define FP_EXCEPT_INV  0
 #define FP_EXCEPT_DZ   1

Modified: head/sys/i386/include/ieeefp.h
==
--- head/sys/i386/include/ieeefp.h  Fri Oct 21 06:40:36 2011
(r226606)
+++ head/sys/i386/include/ieeefp.h  Fri Oct 21 06:41:46 2011
(r226607)
@@ -39,6 +39,8 @@
 #define _MACHINE_IEEEFP_H_
 
 /*
+ * Deprecated historical FPU control interface
+ *
  * IEEE floating point type, constant and function definitions.
  * XXX: FP*FLD and FP*OFF are undocumented pollution.
  */
@@ -253,7 +255,4 @@ fpresetsticky(fp_except_t _m)
 
 #endif /* __GNUCLIKE_ASM */
 
-/* Suppress prototypes in the MI header. */
-#define_IEEEFP_INLINED_1
-
 #endif /* !_MACHINE_IEEEFP_H_ */

Modified: head/sys/ia64/include/ieeefp.h
==
--- head/sys/ia64/include/ieeefp.h  Fri Oct 21 06:40:36 2011
(r226606)
+++ head/sys/ia64/include/ieeefp.h  Fri Oct 21 06:41:46 2011
(r226607)
@@ -29,6 +29,8 @@
 #ifndef _MACHINE_IEEEFP_H_
 #define _MACHINE_IEEEFP_H_
 
+/* Deprecated historical FPU control interface */
+
 #include machine/fpu.h
 
 typedef int fp_except_t;
@@ -45,4 +47,11 @@ typedef enum {
FP_RZ   /* round toward zero */
 } fp_rnd_t;
 
+__BEGIN_DECLS
+extern fp_rnd_tfpgetround(void);
+extern fp_rnd_tfpsetround(fp_rnd_t);
+extern fp_except_t fpgetmask(void);
+extern fp_except_t fpsetmask(fp_except_t);
+__END_DECLS
+
 #endif /* !_MACHINE_IEEEFP_H_ */

Modified: head/sys/mips/include/ieeefp.h
==

Re: svn commit: r226606 - in head/lib/libc: amd64 amd64/gen arm arm/gen gen i386 i386/gen ia64 ia64/gen mips mips/gen powerpc powerpc/gen powerpc64 powerpc64/gen sparc64 sparc64/gen

2011-10-21 Thread Kostik Belousov
On Fri, Oct 21, 2011 at 06:40:36AM +, David Schultz wrote:
 Author: das
 Date: Fri Oct 21 06:40:36 2011
 New Revision: 226606
 URL: http://svn.freebsd.org/changeset/base/226606
 
 Log:
   Replace a proliferation of buggy MD implementations of modf() with a
   working MI one.  The MI one only needs to be overridden on machines
   with non-IEEE754 arithmetic.  (The last supported one was the VAX.)
   It can also be overridden if someone comes up with a faster one that
   actually passes the regression tests -- but this is harder than it sounds.
 
 Added:
   head/lib/libc/gen/modf.c
  - copied, changed from r226410, head/lib/msun/src/s_modf.c
 Deleted:
   head/lib/libc/amd64/gen/modf.S
   head/lib/libc/arm/gen/modf.c
   head/lib/libc/i386/gen/modf.S
   head/lib/libc/ia64/gen/modf.c
   head/lib/libc/mips/gen/modf.S
   head/lib/libc/mips/gen/modf.c
   head/lib/libc/powerpc/gen/modf.c
   head/lib/libc/powerpc64/gen/modf.c
   head/lib/libc/sparc64/gen/modf.S
 Modified:
   head/lib/libc/amd64/Symbol.map
   head/lib/libc/amd64/gen/Makefile.inc
   head/lib/libc/arm/Symbol.map
   head/lib/libc/arm/gen/Makefile.inc
   head/lib/libc/gen/Makefile.inc
   head/lib/libc/gen/Symbol.map
   head/lib/libc/i386/Symbol.map
   head/lib/libc/i386/gen/Makefile.inc
   head/lib/libc/ia64/Symbol.map
   head/lib/libc/ia64/gen/Makefile.inc
   head/lib/libc/mips/Symbol.map
   head/lib/libc/mips/gen/Makefile.inc
   head/lib/libc/powerpc/Symbol.map
   head/lib/libc/powerpc/gen/Makefile.inc
   head/lib/libc/powerpc64/Symbol.map
   head/lib/libc/powerpc64/gen/Makefile.inc
   head/lib/libc/sparc64/Symbol.map
   head/lib/libc/sparc64/gen/Makefile.inc
 
 Modified: head/lib/libc/amd64/Symbol.map
 ==
 --- head/lib/libc/amd64/Symbol.mapFri Oct 21 06:36:40 2011
 (r226605)
 +++ head/lib/libc/amd64/Symbol.mapFri Oct 21 06:40:36 2011
 (r226606)
 @@ -26,7 +26,6 @@ FBSD_1.0 {
   __infinity;
   __nan;
   makecontext;
 - modf;
   rfork_thread;
   setjmp;
   longjmp;
You cannot do this, you just completely broke the ABI.
The symbols must not be removed from the versioned library.


pgpHVabtNEOTi.pgp
Description: PGP signature


Re: svn commit: r226157 - head/usr.bin/kdump

2011-10-21 Thread Garrett Cooper
On Sat, Oct 8, 2011 at 5:47 AM, Dag-Erling Smorgrav d...@freebsd.org wrote:
 Author: des
 Date: Sat Oct  8 12:47:00 2011
 New Revision: 226157
 URL: http://svn.freebsd.org/changeset/base/226157

 Log:
  Bring ioctlname() in line with all the other *name() functions, which
  actually print the name (or the numeric value, if they can't figure out
  the correct name) instead of just returning a pointer to it.  Also, since
  ioctl numbers are not and probably never will be unique, drop support for
  using a switch statement instead of an if/else chain.

This commit broke truss by changing the ioctlname API signature. Example:

$ truss camcontrol devlist
# ...
Segmentation fault: 11 (core dumped)

Reason being is that truss uses ioctlname via an extern, so the
compiler doesn't note the difference (I assume because NO_WERROR= is
set in the Makefile) things go down in flames when it tries to print
out the ioctl call (dereferences a bad pointer with strdup)

This patch fixes it (with some minor Makefile cleanup), at the cost of
duplicating the mkioctls guts between kdump and truss (truss depended
on the old API signature).

Note: I did an `svn copy ../kdump/mkioctls .' beforehand in order to
bootstrap the svn history; that will need to be done before committing
my attached patch.

Thanks!
-Garrett
Index: usr.bin/truss/mkioctls
===
--- usr.bin/truss/mkioctls	(working copy)
+++ usr.bin/truss/mkioctls	(working copy)
@@ -58,12 +58,12 @@
 	print #include stdio.h
 	print #include cam/cam.h
 	print 
-	print void ioctlname(unsigned long val, int decimal);
+	print const char	*ioctlname(unsigned long val);
 	print 
 	print ioctl_includes
 	print 
-	print void
-	print ioctlname(unsigned long val, int decimal)
+	print const char*
+	print ioctlname(unsigned long val)
 	print {
 	print \tconst char *str = NULL;
 	print 
@@ -85,12 +85,7 @@
 }
 END {
 	print \n
-	print \tif (str != NULL)\n
-	print \t\tprintf(\%s\, str);\n
-	print \telse if (decimal)\n
-	print \t\tprintf(\%lu\, val);\n
-	print \telse\n
-	print \t\tprintf(\%#lx\, val);\n
+	print \treturn (str);\n
 	print }
 }
 '
Index: usr.bin/truss/extern.h
===
--- usr.bin/truss/extern.h	(revision 226524)
+++ usr.bin/truss/extern.h	(working copy)
@@ -35,7 +35,7 @@
 extern int start_tracing(int);
 extern void restore_proc(int);
 extern void waitevent(struct trussinfo *);
-extern const char *ioctlname(register_t val);
+const char *ioctlname(unsigned long val);
 extern char *strsig(int sig);
 #ifdef __amd64__
 extern void amd64_syscall_entry(struct trussinfo *, int);
Index: usr.bin/truss/Makefile
===
--- usr.bin/truss/Makefile	(revision 226524)
+++ usr.bin/truss/Makefile	(working copy)
@@ -11,7 +11,7 @@
 .endif
 
 CFLAGS+= -I${.CURDIR} -I.
-CLEANFILES= syscalls.master syscalls.h ioctl.c
+CLEANFILES= syscalls.master
 
 .SUFFIXES: .master
 
@@ -22,8 +22,8 @@
 	/bin/sh ${.CURDIR}/../../sys/kern/makesyscalls.sh syscalls.master \
 		${.CURDIR}/i386.conf
 
-ioctl.c: ${.CURDIR}/../kdump/mkioctls
-	sh ${.CURDIR}/../kdump/mkioctls ${DESTDIR}/usr/include  ${.TARGET}
+ioctl.c: ${.CURDIR}/mkioctls
+	sh ${.CURDIR}/mkioctls ${DESTDIR}/usr/include  ${.TARGET}
 
 .if ${MACHINE_CPUARCH} == i386
 SRCS+=	i386-linux.c linux_syscalls.h
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org

Re: svn commit: r226157 - head/usr.bin/kdump

2011-10-21 Thread Dag-Erling Smørgrav
Garrett Cooper yaneg...@gmail.com writes:
 This commit broke truss by changing the ioctlname API signature. Example:

I didn't realize truss used code from kdump...  Thanks for the patch.

DES
-- 
Dag-Erling Smørgrav - d...@des.no
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r226608 - in head/usr.bin: kdump truss

2011-10-21 Thread Dag-Erling Smorgrav
Author: des
Date: Fri Oct 21 11:08:25 2011
New Revision: 226608
URL: http://svn.freebsd.org/changeset/base/226608

Log:
  It turns out that truss also used kdump's mkioctls script, and expected
  ioctlname() to return a pointer to the name rather than print it.  This did
  not show up in testing because truss had its own prototype for ioctlname(),
  so it would build fine and run fine as long as the program being traced did
  not issue an ioctl.
  
  Teach mkioctls to generate different versions of ioctlname() based on its
  first command-line argument.
  
  Pointed out by:   Garrett Cooper yaneg...@gmail.com

Modified:
  head/usr.bin/kdump/Makefile
  head/usr.bin/kdump/mkioctls
  head/usr.bin/truss/Makefile
  head/usr.bin/truss/extern.h

Modified: head/usr.bin/kdump/Makefile
==
--- head/usr.bin/kdump/Makefile Fri Oct 21 06:41:46 2011(r226607)
+++ head/usr.bin/kdump/Makefile Fri Oct 21 11:08:25 2011(r226608)
@@ -22,7 +22,7 @@ CLEANFILES=   ioctl.c kdump_subr.c kdump_s
 
 ioctl.c: mkioctls
env MACHINE=${MACHINE} \
-   sh ${.CURDIR}/mkioctls ${DESTDIR}/usr/include  ${.TARGET}
+   sh ${.CURDIR}/mkioctls print ${DESTDIR}/usr/include  ${.TARGET}
 
 kdump_subr.h: mksubr
sh ${.CURDIR}/mksubr ${DESTDIR}/usr/include | \

Modified: head/usr.bin/kdump/mkioctls
==
--- head/usr.bin/kdump/mkioctls Fri Oct 21 06:41:46 2011(r226607)
+++ head/usr.bin/kdump/mkioctls Fri Oct 21 11:08:25 2011(r226608)
@@ -1,20 +1,26 @@
 #!/bin/sh
 #
 # $FreeBSD$
+#
+# When editing this script, keep in mind that truss also uses it.
+#
 
 set -e
 
-if [ -z $1 ]; then
-   echo usage: sh $0 include-dir
+if [ $# -ne 2 -o \( $1 != print -a $1 != return \) ]; then
+   echo usage: sh $0 print|return include-dir
exit 1
 fi
 
+style=$1
+includedir=$2
+
 LC_ALL=C; export LC_ALL
 
 # Build a list of headers that have ioctls in them.
 # XXX should we use an ANSI cpp?
 ioctl_includes=$(
-   cd $1
+   cd $includedir
find -H -s * -name '*.h' | grep -v '.*disk.*\.h' | \
xargs egrep -l \
 '^#[   ]*define[   ]+[A-Za-z_][A-Za-z0-9_]*[   ]+_IO[^a-z0-9_]' |
@@ -33,7 +39,7 @@ esac
 
 awk -v x=$ioctl_includes 'BEGIN {print x}' |
gcc -E -I$1 -dM -DCOMPAT_43TTY - |
-   awk -v ioctl_includes=$ioctl_includes '
+   awk -v ioctl_includes=$ioctl_includes -v style=$style '
 BEGIN {
print /* XXX obnoxious prerequisites. */
print #define COMPAT_43
@@ -58,12 +64,19 @@ BEGIN {
print #include stdio.h
print #include cam/cam.h
print 
-   print void ioctlname(unsigned long val, int decimal);
-   print 
print ioctl_includes
print 
-   print void
-   print ioctlname(unsigned long val, int decimal)
+   if (style == print) {
+   print void ioctlname(unsigned long val, int decimal);
+   print 
+   print void
+   print ioctlname(unsigned long val, int decimal)
+   } else {
+   print const char *ioctlname(unsigned long val);
+   print 
+   print const char *
+   print ioctlname(unsigned long val)
+   }
print {
print \tconst char *str = NULL;
print 
@@ -77,20 +90,24 @@ BEGIN {
break;
++i;
#
-   print(\t);
+   printf(\t);
if (n++  0)
-   print(else );
+   printf(else );
printf(if (val == %s)\n, $i);
printf(\t\tstr = \%s\;\n, $i);
 }
 END {
-   print \n
-   print \tif (str != NULL)\n
-   print \t\tprintf(\%s\, str);\n
-   print \telse if (decimal)\n
-   print \t\tprintf(\%lu\, val);\n
-   print \telse\n
-   print \t\tprintf(\%#lx\, val);\n
+   print 
+   if (style == print) {
+   print \tif (str != NULL)
+   print \t\tprintf(\%s\, str);
+   print \telse if (decimal)
+   print \t\tprintf(\%lu\, val);
+   print \telse
+   print \t\tprintf(\%#lx\, val);
+   } else {
+   print \treturn (str);
+   }
print }
 }
 '

Modified: head/usr.bin/truss/Makefile
==
--- head/usr.bin/truss/Makefile Fri Oct 21 06:41:46 2011(r226607)
+++ head/usr.bin/truss/Makefile Fri Oct 21 11:08:25 2011(r226608)
@@ -23,7 +23,8 @@ syscalls.h:   syscalls.master
${.CURDIR}/i386.conf
 
 ioctl.c: ${.CURDIR}/../kdump/mkioctls
-   sh ${.CURDIR}/../kdump/mkioctls ${DESTDIR}/usr/include  ${.TARGET}
+   env MACHINE=${MACHINE} \
+   /bin/sh ${.CURDIR}/../kdump/mkioctls return 
${DESTDIR}/usr/include  ${.TARGET}
 
 .if ${MACHINE_CPUARCH} == i386
 SRCS+= i386-linux.c linux_syscalls.h

Modified: 

svn commit: r226609 - head/sys/contrib/pf/net

2011-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Fri Oct 21 11:11:18 2011
New Revision: 226609
URL: http://svn.freebsd.org/changeset/base/226609

Log:
  In FreeBSD ip_output() expects ip_len and ip_off in host byte order
  
  PR:   kern/159029

Modified:
  head/sys/contrib/pf/net/if_pfsync.c

Modified: head/sys/contrib/pf/net/if_pfsync.c
==
--- head/sys/contrib/pf/net/if_pfsync.c Fri Oct 21 11:08:25 2011
(r226608)
+++ head/sys/contrib/pf/net/if_pfsync.c Fri Oct 21 11:11:18 2011
(r226609)
@@ -1959,7 +1959,11 @@ pfsyncioctl(struct ifnet *ifp, u_long cm
ip-ip_hl = sizeof(sc-sc_template)  2;
ip-ip_tos = IPTOS_LOWDELAY;
/* len and id are set later */
+#ifdef __FreeBSD__
+   ip-ip_off = IP_DF;
+#else
ip-ip_off = htons(IP_DF);
+#endif
ip-ip_ttl = PFSYNC_DFLTTL;
ip-ip_p = IPPROTO_PFSYNC;
ip-ip_src.s_addr = INADDR_ANY;
@@ -2211,7 +2215,11 @@ pfsync_sendout(void)
bcopy(sc-sc_template, ip, sizeof(*ip));
offset = sizeof(*ip);
 
+#ifdef __FreeBSD__
+   ip-ip_len = m-m_pkthdr.len;
+#else
ip-ip_len = htons(m-m_pkthdr.len);
+#endif
ip-ip_id = htons(ip_randomid());
 
/* build the pfsync header */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r226610 - in head/sys: net netinet

2011-10-21 Thread Ed Schouten
Author: ed
Date: Fri Oct 21 12:58:34 2011
New Revision: 226610
URL: http://svn.freebsd.org/changeset/base/226610

Log:
  Add missing #includes.
  
  According to POSIX, these two header files should be able to be included
  by themselves, not depending on other headers. The net/if.h header
  uses struct sockaddr when __BSD_VISIBLE=1, while netinet/tcp.h uses
  integer datatypes (u_int32_t, u_short, etc).
  
  MFC after:2 months

Modified:
  head/sys/net/if.h
  head/sys/netinet/tcp.h

Modified: head/sys/net/if.h
==
--- head/sys/net/if.h   Fri Oct 21 11:11:18 2011(r226609)
+++ head/sys/net/if.h   Fri Oct 21 12:58:34 2011(r226610)
@@ -43,9 +43,11 @@
 /*
  * net/if.h does not depend on sys/time.h on most other systems.  This
  * helps userland compatibility.  (struct timeval ifi_lastchange)
+ * The same holds for sys/socket.h.  (struct sockaddr ifru_addr)
  */
 #ifndef _KERNEL
 #include sys/time.h
+#include sys/socket.h
 #endif
 
 struct ifnet;

Modified: head/sys/netinet/tcp.h
==
--- head/sys/netinet/tcp.h  Fri Oct 21 11:11:18 2011(r226609)
+++ head/sys/netinet/tcp.h  Fri Oct 21 12:58:34 2011(r226610)
@@ -34,6 +34,7 @@
 #define _NETINET_TCP_H_
 
 #include sys/cdefs.h
+#include sys/types.h
 
 #if __BSD_VISIBLE
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r226611 - head/tools/tools/zfsboottest

2011-10-21 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Oct 21 13:13:18 2011
New Revision: 226611
URL: http://svn.freebsd.org/changeset/base/226611

Log:
  - Allow to specify multiple files to check, eg.
  
zfsboottest gpt/system0 gpt/system1 - /boot/kernel/kernel 
/boot/zfsloader
  
  - Instead of printing file's content calculate MD5 hash of the file,
so it can be easly compared to the hash calculated via file system.
  - Some other minor improvements.
  
  MFC after:3 days

Modified:
  head/tools/tools/zfsboottest/Makefile
  head/tools/tools/zfsboottest/zfsboottest.c

Modified: head/tools/tools/zfsboottest/Makefile
==
--- head/tools/tools/zfsboottest/Makefile   Fri Oct 21 12:58:34 2011
(r226610)
+++ head/tools/tools/zfsboottest/Makefile   Fri Oct 21 13:13:18 2011
(r226611)
@@ -12,6 +12,7 @@ CFLAGS=   -O1 \
-fdiagnostics-show-option \
-W -Wextra -Wno-sign-compare -Wno-unused-parameter \
-Werror
+LDFLAGS+=-lmd
 
 .if ${MACHINE_CPUARCH} == amd64
 beforedepend zfsboottest.o: machine

Modified: head/tools/tools/zfsboottest/zfsboottest.c
==
--- head/tools/tools/zfsboottest/zfsboottest.c  Fri Oct 21 12:58:34 2011
(r226610)
+++ head/tools/tools/zfsboottest/zfsboottest.c  Fri Oct 21 13:13:18 2011
(r226611)
@@ -1,6 +1,7 @@
 /*-
  * Copyright (c) 2010 Doug Rabson
  * Copyright (c) 2011 Andriy Gapon
+ * Copyright (c) 2011 Pawel Jakub Dawidek pa...@dawidek.net
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -28,8 +29,10 @@
 
 #include sys/param.h
 #include sys/queue.h
+#include err.h
 #include errno.h
 #include fcntl.h
+#include md5.h
 #include stdint.h
 #include stdio.h
 #include string.h
@@ -43,6 +46,7 @@
 void
 pager_output(const char *line)
 {
+
fprintf(stderr, %s, line);
 }
 
@@ -54,7 +58,7 @@ pager_output(const char *line)
 static int
 vdev_read(vdev_t *vdev, void *priv, off_t off, void *buf, size_t bytes)
 {
-   int fd = *(int *) priv;
+   int fd = *(int *)priv;
 
if (pread(fd, buf, bytes, off) != bytes)
return (-1);
@@ -73,7 +77,7 @@ zfs_read(spa_t *spa, dnode_phys_t *dn, v
n = zp-zp_size - off;
 
rc = dnode_read(spa, dn, off, buf, n);
-   if (rc)
+   if (rc != 0)
return (-rc);
 
return (n);
@@ -82,31 +86,49 @@ zfs_read(spa_t *spa, dnode_phys_t *dn, v
 int
 main(int argc, char** argv)
 {
-   char buf[512];
-   int fd[100];
+   char buf[512], hash[33];
+   MD5_CTX ctx;
struct stat sb;
dnode_phys_t dn;
spa_t *spa;
off_t off;
ssize_t n;
-   int i;
+   int i, failures, *fd;
 
zfs_init();
if (argc == 1) {
static char *av[] = {
-   zfstest, COPYRIGHT,
-   /dev/da0p2, /dev/da1p2, /dev/da2p2,
+   zfsboottest,
+   /dev/gpt/system0,
+   /dev/gpt/system1,
+   -,
+   /boot/zfsloader,
+   /boot/support.4th,
+   /boot/kernel/kernel,
NULL,
};
-   argc = 5;
+   argc = sizeof(av) / sizeof(av[0]) - 1;
argv = av;
}
-   for (i = 2; i  argc; i++) {
-   fd[i] = open(argv[i], O_RDONLY);
-   if (fd[i]  0)
+   for (i = 1; i  argc; i++) {
+   if (strcmp(argv[i], -) == 0)
+   break;
+   }
+   fd = malloc(sizeof(fd[0]) * (i - 1));
+   if (fd == NULL)
+   errx(1, Unable to allocate memory.);
+   for (i = 1; i  argc; i++) {
+   if (strcmp(argv[i], -) == 0)
+   break;
+   fd[i - 1] = open(argv[i], O_RDONLY);
+   if (fd[i - 1] == -1) {
+   warn(open(%s) failed, argv[i]);
continue;
-   if (vdev_probe(vdev_read, fd[i], NULL) != 0)
-   close(fd[i]);
+   }
+   if (vdev_probe(vdev_read, fd[i - 1], NULL) != 0) {
+   warnx(vdev_probe(%s) failed, argv[i]);
+   close(fd[i - 1]);
+   }
}
spa_all_status();
 
@@ -121,29 +143,40 @@ main(int argc, char** argv)
exit(1);
}
 
-   if (zfs_lookup(spa, argv[1], dn)) {
-   fprintf(stderr, can't lookup\n);
-   exit(1);
-   }
-
-   if (zfs_dnode_stat(spa, dn, sb)) {
-   fprintf(stderr, can't stat\n);
-   exit(1);
-   }
-
+   printf(\n);
+   for (++i, failures = 0; i  argc; i++) {
+   if (zfs_lookup(spa, argv[i], dn)) {
+   fprintf(stderr, %s: can't lookup\n, argv[i]);
+

Re: svn commit: r226606 - in head/lib/libc: amd64 amd64/gen arm arm/gen gen i386 i386/gen ia64 ia64/gen mips mips/gen powerpc powerpc/gen powerpc64 powerpc64/gen sparc64 sparc64/gen

2011-10-21 Thread John Baldwin
On Friday, October 21, 2011 4:12:01 am Kostik Belousov wrote:
 On Fri, Oct 21, 2011 at 06:40:36AM +, David Schultz wrote:
  Author: das
  Date: Fri Oct 21 06:40:36 2011
  New Revision: 226606
  URL: http://svn.freebsd.org/changeset/base/226606
  
  Log:
Replace a proliferation of buggy MD implementations of modf() with a
working MI one.  The MI one only needs to be overridden on machines
with non-IEEE754 arithmetic.  (The last supported one was the VAX.)
It can also be overridden if someone comes up with a faster one that
actually passes the regression tests -- but this is harder than it sounds.
  
  Added:
head/lib/libc/gen/modf.c
   - copied, changed from r226410, head/lib/msun/src/s_modf.c
  Deleted:
head/lib/libc/amd64/gen/modf.S
head/lib/libc/arm/gen/modf.c
head/lib/libc/i386/gen/modf.S
head/lib/libc/ia64/gen/modf.c
head/lib/libc/mips/gen/modf.S
head/lib/libc/mips/gen/modf.c
head/lib/libc/powerpc/gen/modf.c
head/lib/libc/powerpc64/gen/modf.c
head/lib/libc/sparc64/gen/modf.S
  Modified:
head/lib/libc/amd64/Symbol.map
head/lib/libc/amd64/gen/Makefile.inc
head/lib/libc/arm/Symbol.map
head/lib/libc/arm/gen/Makefile.inc
head/lib/libc/gen/Makefile.inc
head/lib/libc/gen/Symbol.map
head/lib/libc/i386/Symbol.map
head/lib/libc/i386/gen/Makefile.inc
head/lib/libc/ia64/Symbol.map
head/lib/libc/ia64/gen/Makefile.inc
head/lib/libc/mips/Symbol.map
head/lib/libc/mips/gen/Makefile.inc
head/lib/libc/powerpc/Symbol.map
head/lib/libc/powerpc/gen/Makefile.inc
head/lib/libc/powerpc64/Symbol.map
head/lib/libc/powerpc64/gen/Makefile.inc
head/lib/libc/sparc64/Symbol.map
head/lib/libc/sparc64/gen/Makefile.inc
  
  Modified: head/lib/libc/amd64/Symbol.map
  ==
  --- head/lib/libc/amd64/Symbol.map  Fri Oct 21 06:36:40 2011
  (r226605)
  +++ head/lib/libc/amd64/Symbol.map  Fri Oct 21 06:40:36 2011
  (r226606)
  @@ -26,7 +26,6 @@ FBSD_1.0 {
  __infinity;
  __nan;
  makecontext;
  -   modf;
  rfork_thread;
  setjmp;
  longjmp;
 You cannot do this, you just completely broke the ABI.
 The symbols must not be removed from the versioned library.

He just moved it to the MI Symbol.map, he didn't remove it:

Modified: head/lib/libc/gen/Symbol.map
==
--- head/lib/libc/gen/Symbol.mapFri Oct 21 06:36:40 2011
(r226605)
+++ head/lib/libc/gen/Symbol.mapFri Oct 21 06:40:36 2011
(r226606)
@@ -213,6 +213,7 @@ FBSD_1.0 {
ldexp;
lockf;
lrand48;
+   modf;
mrand48;
nftw;
nice;


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


Re: svn commit: r226606 - in head/lib/libc: amd64 amd64/gen arm arm/gen gen i386 i386/gen ia64 ia64/gen mips mips/gen powerpc powerpc/gen powerpc64 powerpc64/gen sparc64 sparc64/gen

2011-10-21 Thread Kostik Belousov
On Fri, Oct 21, 2011 at 08:22:42AM -0400, John Baldwin wrote:
 On Friday, October 21, 2011 4:12:01 am Kostik Belousov wrote:
  On Fri, Oct 21, 2011 at 06:40:36AM +, David Schultz wrote:
   Author: das
   Date: Fri Oct 21 06:40:36 2011
   New Revision: 226606
   URL: http://svn.freebsd.org/changeset/base/226606
   
   Log:
 Replace a proliferation of buggy MD implementations of modf() with a
 working MI one.  The MI one only needs to be overridden on machines
 with non-IEEE754 arithmetic.  (The last supported one was the VAX.)
 It can also be overridden if someone comes up with a faster one that
 actually passes the regression tests -- but this is harder than it 
   sounds.
   
   Added:
 head/lib/libc/gen/modf.c
- copied, changed from r226410, head/lib/msun/src/s_modf.c
   Deleted:
 head/lib/libc/amd64/gen/modf.S
 head/lib/libc/arm/gen/modf.c
 head/lib/libc/i386/gen/modf.S
 head/lib/libc/ia64/gen/modf.c
 head/lib/libc/mips/gen/modf.S
 head/lib/libc/mips/gen/modf.c
 head/lib/libc/powerpc/gen/modf.c
 head/lib/libc/powerpc64/gen/modf.c
 head/lib/libc/sparc64/gen/modf.S
   Modified:
 head/lib/libc/amd64/Symbol.map
 head/lib/libc/amd64/gen/Makefile.inc
 head/lib/libc/arm/Symbol.map
 head/lib/libc/arm/gen/Makefile.inc
 head/lib/libc/gen/Makefile.inc
 head/lib/libc/gen/Symbol.map
 head/lib/libc/i386/Symbol.map
 head/lib/libc/i386/gen/Makefile.inc
 head/lib/libc/ia64/Symbol.map
 head/lib/libc/ia64/gen/Makefile.inc
 head/lib/libc/mips/Symbol.map
 head/lib/libc/mips/gen/Makefile.inc
 head/lib/libc/powerpc/Symbol.map
 head/lib/libc/powerpc/gen/Makefile.inc
 head/lib/libc/powerpc64/Symbol.map
 head/lib/libc/powerpc64/gen/Makefile.inc
 head/lib/libc/sparc64/Symbol.map
 head/lib/libc/sparc64/gen/Makefile.inc
   
   Modified: head/lib/libc/amd64/Symbol.map
   ==
   --- head/lib/libc/amd64/Symbol.mapFri Oct 21 06:36:40 2011
   (r226605)
   +++ head/lib/libc/amd64/Symbol.mapFri Oct 21 06:40:36 2011
   (r226606)
   @@ -26,7 +26,6 @@ FBSD_1.0 {
 __infinity;
 __nan;
 makecontext;
   - modf;
 rfork_thread;
 setjmp;
 longjmp;
  You cannot do this, you just completely broke the ABI.
  The symbols must not be removed from the versioned library.
 
 He just moved it to the MI Symbol.map, he didn't remove it:
Ah, sorry.

 
 Modified: head/lib/libc/gen/Symbol.map
 ==
 --- head/lib/libc/gen/Symbol.mapFri Oct 21 06:36:40 2011
 (r226605)
 +++ head/lib/libc/gen/Symbol.mapFri Oct 21 06:40:36 2011
 (r226606)
 @@ -213,6 +213,7 @@ FBSD_1.0 {
 ldexp;
 lockf;
 lrand48;
 +   modf;
 mrand48;
 nftw;
 nice;
 
 
 -- 
 John Baldwin


pgpNKqURcbxtu.pgp
Description: PGP signature


svn commit: r226612 - head/tools/tools/zfsboottest

2011-10-21 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Oct 21 13:44:26 2011
New Revision: 226612
URL: http://svn.freebsd.org/changeset/base/226612

Log:
  Because ZFS boot code was very fragile in the past and real PITA to debug,
  introduce zfsboottest.sh script that will verify if it will be possible to 
boot
  from the given pool.
  
# zfsboottest.sh system
  
  Where system is pool name of the pool we want to boot from.
  
  What is being verified by the script:
  - Does the pool exist?
  - Does it have bootfs property configured?
  - Is mountpoint property of the boot dataset set to 'legacy'?
  
  Dataset configured in bootfs property has to be mounted to perform more
  checks:
  - Does the /boot directory in boot dataset exist?
  - Is this dataset configured as root file system in /etc/fstab or set
in vfs.root.mountfrom variable in /boot/loader.conf?
  
  By using zfsboottest tool the script will read all the files in /boot
  directory using ZFS boot code and calculate their checksums.
  Then, it will walk /boot directory using find(1) though regular file sytem
  and also read all the files in /boot directory and calculate their checksums.
  If any of the files cannot be looked up, read or checksum is invalid it will
  be reported and booting off of this pool is probably not possible.
  
  Some additional checks may be interesting as well. For example if the disks
  contain proper pmbr and gptzfsboot code or if all expected files in /boot/
  are present.
  
  When upgrading FreeBSD, one should snapshot datasets that contain operating
  system, upgrade (install new world and kernel) and use zfsboottest.sh to 
verify
  if it will be possible to boot from new configuration. If all is good one
  should upgrade boot blocks, by eg.:
  
# gpart -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada1
  
  If something is wrong, one should rollback datasets and report the problems.
  
  MFC after:3 days

Added:
  head/tools/tools/zfsboottest/zfsboottest.sh   (contents, props changed)
Modified:
  head/tools/tools/zfsboottest/Makefile

Modified: head/tools/tools/zfsboottest/Makefile
==
--- head/tools/tools/zfsboottest/Makefile   Fri Oct 21 13:13:18 2011
(r226611)
+++ head/tools/tools/zfsboottest/Makefile   Fri Oct 21 13:44:26 2011
(r226612)
@@ -2,7 +2,12 @@
 
 .PATH: ${.CURDIR}/../../../sys/boot/zfs 
${.CURDIR}/../../../sys/cddl/boot/zfs
 
+BINDIR?=   /usr/bin
+SCRIPTSDIR?=   /usr/bin
+
 PROG=  zfsboottest
+SCRIPTS=   zfsboottest.sh
+SCRIPTSNAME=   zfsboottest.sh
 NO_MAN=
 
 CFLAGS=-O1 \

Added: head/tools/tools/zfsboottest/zfsboottest.sh
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/tools/zfsboottest/zfsboottest.sh Fri Oct 21 13:44:26 2011
(r226612)
@@ -0,0 +1,130 @@
+#!/bin/sh
+#
+# Copyright (c) 2011 Pawel Jakub Dawidek pa...@dawidek.net
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#notice, this list of conditions and the following disclaimer in the
+#documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+if [ $# -ne 1 ]; then
+   echo usage: zfsboottest.sh pool 2
+   exit 1
+fi
+
+which -s zfsboottest
+if [ $? -eq 0 ]; then
+   zfsboottest=zfsboottest
+else
+   if [ ! -x /usr/src/tools/tools/zfsboottest/zfsboottest ]; then
+   echo Unable to find \zfsboottest\ utility. 2
+   exit 1
+   fi
+   zfsboottest=/usr/src/tools/tools/zfsboottest/zfsboottest
+fi
+
+startdir=/boot
+
+pool=${1}
+zpool list ${pool} /dev/null 21
+if [ $? -ne 0 ]; then
+   echo No such pool \${pool}\. 2
+   exit 1
+fi
+bootfs=`zpool get bootfs ${pool} | tail -1 | awk '{print $3}'`
+if [ ${bootfs} = - ]; then
+

svn commit: r226613 - head/cddl/contrib/opensolaris/lib/libzpool/common

2011-10-21 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Oct 21 13:53:06 2011
New Revision: 226613
URL: http://svn.freebsd.org/changeset/base/226613

Log:
  libzpool task_alloc: pass only valid flags to kmem_alloc
  
  tqflags may contain other flags besided those that are suitable for
  kmem_alloc == umem_alloc
  
  Submitted by: avg
  MFC after:3 days

Modified:
  head/cddl/contrib/opensolaris/lib/libzpool/common/taskq.c

Modified: head/cddl/contrib/opensolaris/lib/libzpool/common/taskq.c
==
--- head/cddl/contrib/opensolaris/lib/libzpool/common/taskq.c   Fri Oct 21 
13:44:26 2011(r226612)
+++ head/cddl/contrib/opensolaris/lib/libzpool/common/taskq.c   Fri Oct 21 
13:53:06 2011(r226613)
@@ -87,7 +87,7 @@ again:if ((t = tq-tq_freelist) != NULL
}
mutex_exit(tq-tq_lock);
 
-   t = kmem_alloc(sizeof (task_t), tqflags);
+   t = kmem_alloc(sizeof (task_t), tqflags  KM_SLEEP);
 
mutex_enter(tq-tq_lock);
if (t != NULL)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r226614 - head/share/man/man9

2011-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Fri Oct 21 13:54:17 2011
New Revision: 226614
URL: http://svn.freebsd.org/changeset/base/226614

Log:
  Note that it is still not possible to guard special kind of allocations, those
  that have special relationships with uma(9). Currently only mbuf clusters.

Modified:
  head/share/man/man9/memguard.9

Modified: head/share/man/man9/memguard.9
==
--- head/share/man/man9/memguard.9  Fri Oct 21 13:53:06 2011
(r226613)
+++ head/share/man/man9/memguard.9  Fri Oct 21 13:54:17 2011
(r226614)
@@ -24,7 +24,7 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd October 12, 2011
+.Dd October 21, 2011
 .Dt MEMGUARD 9
 .Os
 .Sh NAME
@@ -204,3 +204,17 @@ Additions have been made by
 and
 .An Gleb Smirnoff Aq gleb...@freebsd.org
 to both the implementation and the documentation.
+.Sh BUGS
+It is not possible to guard allocations that really expect theirselves to be
+allocated from
+.Xr uma 9 ,
+utilizing additional interfaces apart from
+.Fn uma_zalloc
+and
+.Fn uma_free ,
+for example
+.Fn uma_find_refcnt .
+For the moment of writing only
+.Xr mbuf 9
+cluster zones belong to that kind of allocations.
+Attempt to guard them would lead to kernel panic.
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r226615 - head/cddl/contrib/opensolaris/head

2011-10-21 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Oct 21 13:54:58 2011
New Revision: 226615
URL: http://svn.freebsd.org/changeset/base/226615

Log:
  thr_create: new_thread_ID may be NULL
  
  Submitted by: avg
  MFC after:3 days

Modified:
  head/cddl/contrib/opensolaris/head/thread.h

Modified: head/cddl/contrib/opensolaris/head/thread.h
==
--- head/cddl/contrib/opensolaris/head/thread.h Fri Oct 21 13:54:17 2011
(r226614)
+++ head/cddl/contrib/opensolaris/head/thread.h Fri Oct 21 13:54:58 2011
(r226615)
@@ -76,6 +76,7 @@ static __inline int
 thr_create(void *stack_base, size_t stack_size, void *(*start_func) (void*),
 void *arg, long flags, thread_t *new_thread_ID)
 {
+   pthread_t dummy;
int ret;
 
assert(stack_base == NULL);
@@ -85,9 +86,12 @@ thr_create(void *stack_base, size_t stac
pthread_attr_t attr;
pthread_attr_init(attr);
 
-   if(flags  THR_DETACHED)
+   if (flags  THR_DETACHED)
pthread_attr_setdetachstate(attr, PTHREAD_CREATE_DETACHED);
 
+   if (new_thread_ID == NULL)
+   new_thread_ID = dummy;
+
/* This function ignores the THR_BOUND flag, since NPTL doesn't seem to 
support PTHREAD_SCOPE_PROCESS */
 
ret = pthread_create(new_thread_ID, attr, start_func, arg);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r226616 - head/cddl/contrib/opensolaris/cmd/zdb

2011-10-21 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Oct 21 13:56:17 2011
New Revision: 226616
URL: http://svn.freebsd.org/changeset/base/226616

Log:
  zdb: access dp_free_bpobj only if pool version is = SPA_VERSION_DEADLISTS
  
  Submitted by: avg
  MFC after:3 days

Modified:
  head/cddl/contrib/opensolaris/cmd/zdb/zdb.c

Modified: head/cddl/contrib/opensolaris/cmd/zdb/zdb.c
==
--- head/cddl/contrib/opensolaris/cmd/zdb/zdb.c Fri Oct 21 13:54:58 2011
(r226615)
+++ head/cddl/contrib/opensolaris/cmd/zdb/zdb.c Fri Oct 21 13:56:17 2011
(r226616)
@@ -2190,8 +2190,10 @@ dump_block_stats(spa_t *spa)
 */
(void) bpobj_iterate_nofree(spa-spa_deferred_bpobj,
count_block_cb, zcb, NULL);
-   (void) bpobj_iterate_nofree(spa-spa_dsl_pool-dp_free_bpobj,
-   count_block_cb, zcb, NULL);
+   if (spa_version(spa) = SPA_VERSION_DEADLISTS) {
+   (void) bpobj_iterate_nofree(spa-spa_dsl_pool-dp_free_bpobj,
+   count_block_cb, zcb, NULL);
+   }
 
if (dump_opt['c']  1)
flags |= TRAVERSE_PREFETCH_DATA;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r226617 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2011-10-21 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Oct 21 14:00:48 2011
New Revision: 226617
URL: http://svn.freebsd.org/changeset/base/226617

Log:
  zfs vdev_file_io_start: validate vdev before using vdev_tsd
  
  vdev_tsd can be NULL for certain vdev states.
  At least in userland testing with ztest.
  
  Submitted by: avg
  MFC after:3 days

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_file.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_file.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_file.c Fri Oct 
21 13:56:17 2011(r226616)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_file.c Fri Oct 
21 14:00:48 2011(r226617)
@@ -153,17 +153,19 @@ static int
 vdev_file_io_start(zio_t *zio)
 {
vdev_t *vd = zio-io_vd;
-   vdev_file_t *vf = vd-vdev_tsd;
-   vnode_t *vp = vf-vf_vnode;
+   vdev_file_t *vf;
+   vnode_t *vp;
ssize_t resid;
 
-   if (zio-io_type == ZIO_TYPE_IOCTL) {
-   /* XXPOLICY */
-   if (!vdev_readable(vd)) {
-   zio-io_error = ENXIO;
-   return (ZIO_PIPELINE_CONTINUE);
-   }
+   if (!vdev_readable(vd)) {
+   zio-io_error = ENXIO;
+   return (ZIO_PIPELINE_CONTINUE);
+   }
+
+   vf = vd-vdev_tsd;
+   vp = vf-vf_vnode;
 
+   if (zio-io_type == ZIO_TYPE_IOCTL) {
switch (zio-io_cmd) {
case DKIOCFLUSHWRITECACHE:
zio-io_error = VOP_FSYNC(vp, FSYNC | FDSYNC,
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r226618 - head/lib/msun/man

2011-10-21 Thread David Schultz
Author: das
Date: Fri Oct 21 14:23:59 2011
New Revision: 226618
URL: http://svn.freebsd.org/changeset/base/226618

Log:
  Minor corrections and clarifications regarding exceptions.

Modified:
  head/lib/msun/man/fenv.3

Modified: head/lib/msun/man/fenv.3
==
--- head/lib/msun/man/fenv.3Fri Oct 21 14:00:48 2011(r226617)
+++ head/lib/msun/man/fenv.3Fri Oct 21 14:23:59 2011(r226618)
@@ -91,24 +91,35 @@ The following macros expand to bit flags
 representing the five standard floating-point exceptions.
 .Bl -tag -width .Dv FE_DIVBYZERO
 .It Dv FE_DIVBYZERO
-A divide-by-zero exception occurs when the program attempts to
-divide a finite non-zero number by zero.
+A divide-by-zero exception occurs when the
+.Em exact
+result of a computation is infinite (according to the limit definition).
+For example, dividing a finite non-zero number by zero or computing
+.Fn log 0
+raises a divide-by-zero exception.
 .It Dv FE_INEXACT
-An inexact exception is raised whenever there is a loss of precision
+An inexact exception is raised whenever there is a loss of accuracy
 due to rounding.
 .It Dv FE_INVALID
 Invalid operation exceptions occur when a program attempts to
 perform calculations for which there is no reasonable representable
 answer.
-For instance, subtraction of infinities, division of zero by zero,
-ordered comparison involving \*(Nas, and taking the square root of a
+For instance, subtraction of like-signed infinities, division of zero by zero,
+ordered comparison involving \*(Nas, and taking the real square root of a
 negative number are all invalid operations.
 .It Dv FE_OVERFLOW
-An overflow exception occurs when the magnitude of the result of a
-computation is too large to fit in the destination type.
+In contrast with divide-by-zero,
+an overflow exception occurs when an infinity is produced because
+the magnitude of the exact result is
+.Em finite
+but too large to fit in the destination type.
+For example, computing
+.Li DBL_MAX * 2
+raises an overflow exception.
 .It Dv FE_UNDERFLOW
-Underflow occurs when the result of a computation is too close to zero
-to be represented as a non-zero value in the destination type.
+Underflow occurs when the result of a computation loses precision
+because it is too close to zero.
+The result is a subnormal number or zero.
 .El
 .Pp
 Additionally, the
@@ -183,9 +194,9 @@ as usual, but no
 .Dv SIGFPE
 signals will be generated as a result.
 Non-stop mode is the default, but it may be altered by
-non-standard mechanisms.
-.\ XXX Mention fe[gs]etmask() here after the interface is finalized
-.\ XXX and ready to be officially documented.
+.Fn feenableexcept
+and
+.Fn fedisableexcept .
 The
 .Fn feupdateenv
 function restores a saved environment similarly to
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r226536 - head/sys/contrib/pf/net

2011-10-21 Thread Ermal Luçi
On Wed, Oct 19, 2011 at 1:04 PM, Bjoern A. Zeeb b...@freebsd.org wrote:
 Author: bz
 Date: Wed Oct 19 11:04:49 2011
 New Revision: 226536
 URL: http://svn.freebsd.org/changeset/base/226536

 Log:
  De-virtualize the pf_task_mtx lock.  At the current state of pf locking
  and virtualization it is not helpful but complicates things.

I would disagree with this since its a step backwards and different
direction with pf(4) code in general.
The patch to actually fix it for vimage enabled kernels was simpler!



  Current state of art is to not virtualize these kinds of locks -
  inp_group/hash/info/.. are all not virtualized either.

  MFC after:    3 days

 Modified:
  head/sys/contrib/pf/net/pf_ioctl.c
  head/sys/contrib/pf/net/pfvar.h

 Modified: head/sys/contrib/pf/net/pf_ioctl.c
 ==
 --- head/sys/contrib/pf/net/pf_ioctl.c  Wed Oct 19 10:16:42 2011        
 (r226535)
 +++ head/sys/contrib/pf/net/pf_ioctl.c  Wed Oct 19 11:04:49 2011        
 (r226536)
 @@ -266,7 +266,7 @@ static struct cdevsw pf_cdevsw = {
  static volatile VNET_DEFINE(int, pf_pfil_hooked);
  #define V_pf_pfil_hooked       VNET(pf_pfil_hooked)
  VNET_DEFINE(int,               pf_end_threads);
 -VNET_DEFINE(struct mtx,                pf_task_mtx);
 +struct mtx                     pf_task_mtx;

  /* pfsync */
  pfsync_state_import_t          *pfsync_state_import_ptr = NULL;
 @@ -287,18 +287,18 @@ SYSCTL_VNET_INT(_debug, OID_AUTO, pfugid
        VNET_NAME(debug_pfugidhack), 0,
        Enable/disable pf user/group rules mpsafe hack);

 -void
 +static void
  init_pf_mutex(void)
  {

 -       mtx_init(V_pf_task_mtx, pf task mtx, NULL, MTX_DEF);
 +       mtx_init(pf_task_mtx, pf task mtx, NULL, MTX_DEF);
  }

 -void
 +static void
  destroy_pf_mutex(void)
  {

 -       mtx_destroy(V_pf_task_mtx);
 +       mtx_destroy(pf_task_mtx);
  }
  void
  init_zone_var(void)
 @@ -4381,11 +4381,8 @@ pf_load(void)

        init_zone_var();
        sx_init(V_pf_consistency_lock, pf_statetbl_lock);
 -       init_pf_mutex();
 -       if (pfattach()  0) {
 -               destroy_pf_mutex();
 +       if (pfattach()  0)
                return (ENOMEM);
 -       }

        return (0);
  }
 @@ -4413,14 +4410,13 @@ pf_unload(void)
        V_pf_end_threads = 1;
        while (V_pf_end_threads  2) {
                wakeup_one(pf_purge_thread);
 -               msleep(pf_purge_thread, V_pf_task_mtx, 0, pftmo, hz);
 +               msleep(pf_purge_thread, pf_task_mtx, 0, pftmo, hz);
        }
        pfi_cleanup();
        pf_osfp_flush();
        pf_osfp_cleanup();
        cleanup_pf_zone();
        PF_UNLOCK();
 -       destroy_pf_mutex();
        sx_destroy(V_pf_consistency_lock);
        return error;
  }
 @@ -4432,10 +4428,12 @@ pf_modevent(module_t mod, int type, void

        switch(type) {
        case MOD_LOAD:
 +               init_pf_mutex();
                pf_dev = make_dev(pf_cdevsw, 0, 0, 0, 0600, PF_NAME);
                break;
        case MOD_UNLOAD:
                destroy_dev(pf_dev);
 +               destroy_pf_mutex();
                break;
        default:
                error = EINVAL;

 Modified: head/sys/contrib/pf/net/pfvar.h
 ==
 --- head/sys/contrib/pf/net/pfvar.h     Wed Oct 19 10:16:42 2011        
 (r226535)
 +++ head/sys/contrib/pf/net/pfvar.h     Wed Oct 19 11:04:49 2011        
 (r226536)
 @@ -237,19 +237,18 @@ struct pfi_dynaddr {
                uma_zdestroy(var)

  #ifdef __FreeBSD__
 -VNET_DECLARE(struct mtx,        pf_task_mtx);
 -#define        V_pf_task_mtx            VNET(pf_task_mtx)
 +extern struct mtx pf_task_mtx;

 -#define        PF_LOCK_ASSERT()        mtx_assert(V_pf_task_mtx, MA_OWNED)
 -#define        PF_UNLOCK_ASSERT()      mtx_assert(V_pf_task_mtx, 
 MA_NOTOWNED)
 +#define        PF_LOCK_ASSERT()        mtx_assert(pf_task_mtx, MA_OWNED)
 +#define        PF_UNLOCK_ASSERT()      mtx_assert(pf_task_mtx, MA_NOTOWNED)

  #define        PF_LOCK()       do {                            \
        PF_UNLOCK_ASSERT();                             \
 -       mtx_lock(V_pf_task_mtx);                       \
 +       mtx_lock(pf_task_mtx);                         \
  } while(0)
  #define        PF_UNLOCK()     do {                            \
        PF_LOCK_ASSERT();                               \
 -       mtx_unlock(V_pf_task_mtx);                     \
 +       mtx_unlock(pf_task_mtx);                       \
  } while(0)
  #else
  #define        PF_LOCK_ASSERT()
 @@ -270,9 +269,6 @@ VNET_DECLARE(struct mtx,     pf_task_mtx);
        PF_LOCK();                                      \
  } while(0)

 -extern void init_pf_mutex(void);
 -extern void destroy_pf_mutex(void);
 -
  #define        PF_MODVER       1
  #define        PFLOG_MODVER    1
  #define        PFSYNC_MODVER   1




-- 
Ermal
___
svn-src-all@freebsd.org mailing list

Re: svn commit: r226614 - head/share/man/man9

2011-10-21 Thread Doug Barton
On 10/21/2011 06:54, Gleb Smirnoff wrote:

 +It is not possible to guard allocations that really expect theirselves to be

s/theirselves/themselves/  Running this through aspell should have
caught this. :)


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-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r226619 - head/share/man/man9

2011-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Fri Oct 21 20:23:40 2011
New Revision: 226619
URL: http://svn.freebsd.org/changeset/base/226619

Log:
  Spelling.
  
  Submitted by: dougb

Modified:
  head/share/man/man9/memguard.9

Modified: head/share/man/man9/memguard.9
==
--- head/share/man/man9/memguard.9  Fri Oct 21 14:23:59 2011
(r226618)
+++ head/share/man/man9/memguard.9  Fri Oct 21 20:23:40 2011
(r226619)
@@ -205,7 +205,7 @@ and
 .An Gleb Smirnoff Aq gleb...@freebsd.org
 to both the implementation and the documentation.
 .Sh BUGS
-It is not possible to guard allocations that really expect theirselves to be
+It is not possible to guard allocations that really expect themselves to be
 allocated from
 .Xr uma 9 ,
 utilizing additional interfaces apart from
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r226619 - head/share/man/man9

2011-10-21 Thread Doug Barton
On 10/21/2011 13:23, Gleb Smirnoff wrote:
 Author: glebius
 Date: Fri Oct 21 20:23:40 2011
 New Revision: 226619
 URL: http://svn.freebsd.org/changeset/base/226619
 
 Log:
   Spelling.

Thanks. :)

   Submitted by:   dougb
 
 Modified:
   head/share/man/man9/memguard.9
 
 Modified: head/share/man/man9/memguard.9
 ==
 --- head/share/man/man9/memguard.9Fri Oct 21 14:23:59 2011
 (r226618)
 +++ head/share/man/man9/memguard.9Fri Oct 21 20:23:40 2011
 (r226619)
 @@ -205,7 +205,7 @@ and
  .An Gleb Smirnoff Aq gleb...@freebsd.org
  to both the implementation and the documentation.
  .Sh BUGS
 -It is not possible to guard allocations that really expect theirselves to be
 +It is not possible to guard allocations that really expect themselves to be
  allocated from
  .Xr uma 9 ,
  utilizing additional interfaces apart from
 



-- 

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-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r226620 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2011-10-21 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Oct 21 21:49:34 2011
New Revision: 226620
URL: http://svn.freebsd.org/changeset/base/226620

Log:
  Update per-thread I/O statistics collection in ZFS.
  This allows to see processes I/O activity in 'top -m io' output.
  
  PRkern/156218
  Reported by:  Marcus Reid mar...@blazingdot.com
  Patch by: avg
  MFC after:3 days

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c  Fri Oct 21 
20:23:40 2011(r226619)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c  Fri Oct 21 
21:49:34 2011(r226620)
@@ -627,6 +627,10 @@ dbuf_read(dmu_buf_impl_t *db, zio_t *zio
} else if (db-db_state == DB_UNCACHED) {
spa_t *spa = dn-dn_objset-os_spa;
 
+#ifdef _KERNEL
+   curthread-td_ru.ru_inblock++;
+#endif
+
if (zio == NULL)
zio = zio_root(spa, NULL, NULL, ZIO_FLAG_CANFAIL);
dbuf_read_impl(db, zio, flags);

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c   Fri Oct 21 
20:23:40 2011(r226619)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c   Fri Oct 21 
21:49:34 2011(r226620)
@@ -397,9 +397,12 @@ dmu_buf_hold_array_by_dnode(dnode_t *dn,
return (EIO);
}
/* initiate async i/o */
-   if (read) {
+   if (read)
(void) dbuf_read(db, zio, dbuf_flags);
-   }
+#ifdef _KERNEL
+   else
+   curthread-td_ru.ru_oublock++;
+#endif
dbp[i] = db-db;
}
rw_exit(dn-dn_struct_rwlock);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r226621 - stable/9/sbin/tunefs

2011-10-21 Thread Kirk McKusick
Author: mckusick
Date: Fri Oct 21 22:07:52 2011
New Revision: 226621
URL: http://svn.freebsd.org/changeset/base/226621

Log:
  MFC 226266:
  After creating a filesystem using newfs -j the time stamps are all
  zero and thus report as having been made in January 1970. Apart
  from looking a bit silly, it also triggers alarms from scripts
  that detect weird time stamps. This update sets all 4 (or 3, in
  the case of UFS1) time stamps to the current time when enabling
  journaling during newfs or later when enabling it with tunefs.
  
  Reported by: Hans Ottevanger h...@beastielabs.net
  Approved by: re (kib)

Modified:
  stable/9/sbin/tunefs/tunefs.c

Modified: stable/9/sbin/tunefs/tunefs.c
==
--- stable/9/sbin/tunefs/tunefs.c   Fri Oct 21 21:49:34 2011
(r226620)
+++ stable/9/sbin/tunefs/tunefs.c   Fri Oct 21 22:07:52 2011
(r226621)
@@ -64,6 +64,7 @@ __FBSDID($FreeBSD$);
 #include stdlib.h
 #include stdint.h
 #include string.h
+#include time.h
 #include unistd.h
 
 /* the optimization warning string template */
@@ -923,6 +924,7 @@ journal_alloc(int64_t size)
ino_t ino;
int blks;
int mode;
+   time_t utime;
int i;
 
cgp = disk.d_cg;
@@ -983,18 +985,26 @@ journal_alloc(int64_t size)
 */
dp2 = ip;
dp1 = ip;
+   time(utime);
if (sblock.fs_magic == FS_UFS1_MAGIC) {
bzero(dp1, sizeof(*dp1));
dp1-di_size = size;
dp1-di_mode = IFREG | IREAD;
dp1-di_nlink = 1;
dp1-di_flags = SF_IMMUTABLE | SF_NOUNLINK | UF_NODUMP;
+   dp1-di_atime = utime;
+   dp1-di_mtime = utime;
+   dp1-di_ctime = utime;
} else {
bzero(dp2, sizeof(*dp2));
dp2-di_size = size;
dp2-di_mode = IFREG | IREAD;
dp2-di_nlink = 1;
dp2-di_flags = SF_IMMUTABLE | SF_NOUNLINK | UF_NODUMP;
+   dp2-di_atime = utime;
+   dp2-di_mtime = utime;
+   dp2-di_ctime = utime;
+   dp2-di_birthtime = utime;
}
for (i = 0; i  NDADDR  resid; i++, resid--) {
blk = journal_balloc();
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r226622 - stable/9/sys/kern

2011-10-21 Thread Kirk McKusick
Author: mckusick
Date: Fri Oct 21 22:12:24 2011
New Revision: 226622
URL: http://svn.freebsd.org/changeset/base/226622

Log:
  MFC: 226265
  
  When unmounting a filesystem always wait for the vfs_busy lock to clear
  so that if no vnodes in the filesystem are actively in use the unmount
  will succeed rather than failing with EBUSY.
  
  Reported by: Garrett Cooper
  Reviewed by: Attilio Rao and Kostik Belousov
  Tested by:   Garrett Cooper
  Approved by: re (kib)
  PR:  kern/161016

Modified:
  stable/9/sys/kern/vfs_mount.c

Modified: stable/9/sys/kern/vfs_mount.c
==
--- stable/9/sys/kern/vfs_mount.c   Fri Oct 21 22:07:52 2011
(r226621)
+++ stable/9/sys/kern/vfs_mount.c   Fri Oct 21 22:12:24 2011
(r226622)
@@ -1227,18 +1227,6 @@ dounmount(mp, flags, td)
mp-mnt_kern_flag |= MNTK_UNMOUNTF;
error = 0;
if (mp-mnt_lockref) {
-   if ((flags  MNT_FORCE) == 0) {
-   mp-mnt_kern_flag = ~(MNTK_UNMOUNT | MNTK_NOINSMNTQ |
-   MNTK_UNMOUNTF);
-   if (mp-mnt_kern_flag  MNTK_MWAIT) {
-   mp-mnt_kern_flag = ~MNTK_MWAIT;
-   wakeup(mp);
-   }
-   MNT_IUNLOCK(mp);
-   if (coveredvp)
-   VOP_UNLOCK(coveredvp, 0);
-   return (EBUSY);
-   }
mp-mnt_kern_flag |= MNTK_DRAINING;
error = msleep(mp-mnt_lockref, MNT_MTX(mp), PVFS,
mount drain, 0);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r226623 - head/sys/contrib/pf/net

2011-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Fri Oct 21 22:28:15 2011
New Revision: 226623
URL: http://svn.freebsd.org/changeset/base/226623

Log:
  Fix a race: we should update sc_len before dropping the pf lock, otherwise a
  number of packets can be queued on sc, while we are in ip_output(), and then
  we wipe the accumulated sc_len. On next pfsync_sendout() that would lead to
  writing beyond our mbuf cluster.

Modified:
  head/sys/contrib/pf/net/if_pfsync.c

Modified: head/sys/contrib/pf/net/if_pfsync.c
==
--- head/sys/contrib/pf/net/if_pfsync.c Fri Oct 21 22:12:24 2011
(r226622)
+++ head/sys/contrib/pf/net/if_pfsync.c Fri Oct 21 22:28:15 2011
(r226623)
@@ -2354,6 +2354,7 @@ pfsync_sendout(void)
sc-sc_if.if_obytes += m-m_pkthdr.len;
 #endif
 
+   sc-sc_len = PFSYNC_MINPKT;
 #ifdef __FreeBSD__
PF_UNLOCK();
 #endif
@@ -2375,9 +2376,6 @@ pfsync_sendout(void)
 #ifdef __FreeBSD__
}
 #endif
-
-   /* start again */
-   sc-sc_len = PFSYNC_MINPKT;
 }
 
 void
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r226614 - head/share/man/man9

2011-10-21 Thread Sean C. Farley

On Fri, 21 Oct 2011, Doug Barton wrote:


On 10/21/2011 06:54, Gleb Smirnoff wrote:

+It is not possible to guard allocations that really expect 
theirselves to be


s/theirselves/themselves/  Running this through aspell should have 
caught this. :)


ispell says it is OK.  It is in /usr/share/dict/web2.

Of course, themselves is much more commonly used while theirselves 
appears to be more logical[1].  :)


Sean
  1. http://color-connection.com/EngVW/Lessons/lesson1.htm
--
s...@freebsd.org
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r226614 - head/share/man/man9

2011-10-21 Thread Doug Barton
On 10/21/2011 17:27, Sean C. Farley wrote:
 On Fri, 21 Oct 2011, Doug Barton wrote:
 
 On 10/21/2011 06:54, Gleb Smirnoff wrote:

 +It is not possible to guard allocations that really expect
 theirselves to be

 s/theirselves/themselves/  Running this through aspell should have
 caught this. :)
 
 ispell says it is OK. 

That's why I specifically said aspell. :)  It tends to do a better job
identifying technically-acceptable-but-not-mainstream usage.


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-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r226624 - stable/8/sys/dev/usb/wlan

2011-10-21 Thread Adrian Chadd
Author: adrian
Date: Sat Oct 22 01:29:35 2011
New Revision: 226624
URL: http://svn.freebsd.org/changeset/base/226624

Log:
  Merge r226465 (below message) and r226467 (subsequent compile fixes).
  
  Fix an issue with 11g beacon frames which looks to be a limitation
  on the largest multi-write size.
  
  From the submitter:
  
  ==
  I looked further into the magic 88-byte threshold after which the bug
  occurs.  It turns out that figure included the 24-byte tx_desc, and up
  to 64 bytes of beacon frame (header+data).
  
  rum_write_multi doesn't seem happy with writing 64 bytes at a time to
  the MAC register.  If I break it up into separate calls (e.g. bytes
  0-63, then bytes 64-65, written at the appropriate offset) I see the
  proper beacon frames being transmitted now.
  ==
  
  Submitted by: Steven Chamberlain ste...@pyro.eu.org

Modified:
  stable/8/sys/dev/usb/wlan/if_rum.c

Modified: stable/8/sys/dev/usb/wlan/if_rum.c
==
--- stable/8/sys/dev/usb/wlan/if_rum.c  Fri Oct 21 22:28:15 2011
(r226623)
+++ stable/8/sys/dev/usb/wlan/if_rum.c  Sat Oct 22 01:29:35 2011
(r226624)
@@ -1407,20 +1407,27 @@ rum_write_multi(struct rum_softc *sc, ui
 {
struct usb_device_request req;
usb_error_t error;
+   int offset;
 
req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
req.bRequest = RT2573_WRITE_MULTI_MAC;
USETW(req.wValue, 0);
-   USETW(req.wIndex, reg);
-   USETW(req.wLength, len);
 
-   error = rum_do_request(sc, req, buf);
-   if (error != 0) {
-   device_printf(sc-sc_dev,
-   could not multi write MAC register: %s\n,
-   usbd_errstr(error));
+   /* write at most 64 bytes at a time */
+   for (offset = 0; offset  len; offset += 64) {
+   USETW(req.wIndex, reg + offset);
+   USETW(req.wLength, MIN(len - offset, 64));
+
+   error = rum_do_request(sc, req, (char *)buf + offset);
+   if (error != 0) {
+   device_printf(sc-sc_dev,
+   could not multi write MAC register: %s\n,
+   usbd_errstr(error));
+   return (error);
+   }
}
-   return (error);
+
+   return (USB_ERR_NORMAL_COMPLETION);
 }
 
 static void
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r226625 - head/lib/libpam/libpam

2011-10-21 Thread Dag-Erling Smorgrav
Author: des
Date: Sat Oct 22 04:39:12 2011
New Revision: 226625
URL: http://svn.freebsd.org/changeset/base/226625

Log:
  openpam_static.c isn't auto-generated.

Modified:
  head/lib/libpam/libpam/Makefile

Modified: head/lib/libpam/libpam/Makefile
==
--- head/lib/libpam/libpam/Makefile Sat Oct 22 01:29:35 2011
(r226624)
+++ head/lib/libpam/libpam/Makefile Sat Oct 22 04:39:12 2011
(r226625)
@@ -55,6 +55,7 @@ SRCS= openpam_borrow_cred.c \
openpam_readline.c \
openpam_restore_cred.c \
openpam_set_option.c \
+   openpam_static.c \
openpam_ttyconv.c \
pam_acct_mgmt.c \
pam_authenticate.c \
@@ -153,15 +154,11 @@ MODULE_DIR=   ../modules
 .include ${.CURDIR}/${MODULE_DIR}/modules.inc
 STATIC_MODULES=${MODULES:C/.*/${MODULE_DIR}\/\/lib.a/}
 STATICOBJS+=   openpam_static_modules.o
-CLEANFILES+=   openpam_static.o \
-   openpam_static_modules.o
+CLEANFILES+=   openpam_static_modules.o
 
 openpam_static_modules.o: openpam_static.o ${STATIC_MODULES}
${LD} -o ${.TARGET} -r --whole-archive ${.ALLSRC}
 
-# Can't put openpam_static.c in SRCS but want .o in .depend.
-DPSRCS=openpam_static.c
-
 # Headers
 INCS=  ${HEADERS} ${ADD_HEADERS}
 INCSDIR=   ${INCLUDEDIR}/security
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org