aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Smith <dannysmith@users.sourceforge.net>2006-06-26 00:53:34 +0000
committerDanny Smith <dannysmith@users.sourceforge.net>2006-06-26 00:53:34 +0000
commit1dcd64ff551b3065150862d772f511aaa4ed3a07 (patch)
tree44e2011769f3522ad52e30079b6d7a1a4017c9bc
parentb4e8ed00986b3118f12d498d2d21faef7d1db58a (diff)
downloadnewlib-1dcd64ff551b3065150862d772f511aaa4ed3a07.zip
newlib-1dcd64ff551b3065150862d772f511aaa4ed3a07.tar.gz
newlib-1dcd64ff551b3065150862d772f511aaa4ed3a07.tar.bz2
* mingwex/wcrtomb.c (wcsrtombs): Fix src end-pointer thinko.
* mingwex/math/lgamma.c: (LOGPI) Avoid type punning. (LS2PI): Likewise. * mingwex/math/sf_erf.c (erff): Initialize z. (erfcf): Likewise. * mingwex/math/tgamma.c (SQTPI): Avoid type punning.
-rw-r--r--winsup/mingw/ChangeLog9
-rw-r--r--winsup/mingw/mingwex/math/lgamma.c42
-rw-r--r--winsup/mingw/mingwex/math/sf_erf.c3
-rw-r--r--winsup/mingw/mingwex/math/tgamma.c11
-rwxr-xr-xwinsup/mingw/mingwex/wcrtomb.c18
5 files changed, 55 insertions, 28 deletions
diff --git a/winsup/mingw/ChangeLog b/winsup/mingw/ChangeLog
index eda9363..039cc33 100644
--- a/winsup/mingw/ChangeLog
+++ b/winsup/mingw/ChangeLog
@@ -1,3 +1,12 @@
+2006-06-26 Danny Smith <dannysmith@users.sourceforge.net>
+
+ * mingwex/wcrtomb.c (wcsrtombs): Fix src end-pointer thinko.
+ * mingwex/math/lgamma.c: (LOGPI) Avoid type punning.
+ (LS2PI): Likewise.
+ * mingwex/math/sf_erf.c (erff): Initialize z.
+ (erfcf): Likewise.
+ * mingwex/math/tgamma.c (SQTPI): Avoid type punning.
+
2006-06-23 Danny Smith <dannysmith@users.sourceforge.net>
* include/sys/time.h (struct timezone): Define.
diff --git a/winsup/mingw/mingwex/math/lgamma.c b/winsup/mingw/mingwex/math/lgamma.c
index f850949..b569f9a 100644
--- a/winsup/mingw/mingwex/math/lgamma.c
+++ b/winsup/mingw/mingwex/math/lgamma.c
@@ -189,15 +189,20 @@ static const unsigned short C[] = {
0xe14a,0x6a11,0xce4b,0xc13e
};
/* log( sqrt( 2*pi ) ) */
-static const unsigned short LS2P[] = {
-0xbeb5,0xc864,0x67f1,0x3fed
-};
-#define LS2PI *(double *)LS2P
+static const union
+{
+ unsigned short s[4];
+ double d;
+} ls2p = {{0xbeb5,0xc864,0x67f1,0x3fed}};
+#define LS2PI (ls2p.d)
#define MAXLGM 2.556348e305
-static const unsigned short LPI[4] = {
-0xa1bd,0x48e7,0x50d0,0x3ff2,
-};
-#define LOGPI *(double *)LPI
+/* log (pi) */
+static const union
+{
+ unsigned short s[4];
+ double d;
+} lpi = {{0xa1bd,0x48e7,0x50d0,0x3ff2}};
+#define LOGPI (lpi.d)
#endif
#ifdef MIEEE
@@ -225,15 +230,20 @@ static const unsigned short C[] = {
0xc13e,0xce4b,0x6a11,0xe14a
};
/* log( sqrt( 2*pi ) ) */
-static const unsigned short LS2P[] = {
-0x3fed,0x67f1,0xc864,0xbeb5
-};
-#define LS2PI *(double *)LS2P
+static const union
+{
+ unsigned short s[4];
+ double d;
+} ls2p = {{0x3fed,0x67f1,0xc864,0xbeb5}};
+#define LS2PI ls2p.d
#define MAXLGM 2.556348e305
-static unsigned short LPI[4] = {
-0x3ff2,0x50d0,0x48e7,0xa1bd,
-};
-#define LOGPI *(double *)LPI
+/* log (pi) */
+static const union
+{
+ unsigned short s[4];
+ double d;
+} lpi = {{0x3ff2, 0x50d0, 0x48e7, 0xa1bd}};
+#define LOGPI (lpi.d)
#endif
diff --git a/winsup/mingw/mingwex/math/sf_erf.c b/winsup/mingw/mingwex/math/sf_erf.c
index 1fca80e..2188539 100644
--- a/winsup/mingw/mingwex/math/sf_erf.c
+++ b/winsup/mingw/mingwex/math/sf_erf.c
@@ -190,6 +190,8 @@ sb7 = -2.2440952301e+01; /* 0xc1b38712 */
S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
sb5+s*(sb6+s*sb7))))));
}
+
+ z = x;
__trunc_float_word (&z);
r = __ieee754_expf(-z*z-(float)0.5625)*__ieee754_expf((z-x)*(z+x)+R/S);
if(hx>=0) return one-r/x; else return r/x-one;
@@ -252,6 +254,7 @@ sb7 = -2.2440952301e+01; /* 0xc1b38712 */
S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
sb5+s*(sb6+s*sb7))))));
}
+ z = x;
__trunc_float_word (&z);
r = __ieee754_expf(-z*z-(float)0.5625)*
__ieee754_expf((z-x)*(z+x)+R/S);
diff --git a/winsup/mingw/mingwex/math/tgamma.c b/winsup/mingw/mingwex/math/tgamma.c
index d04a5f4..6a11fb2 100644
--- a/winsup/mingw/mingwex/math/tgamma.c
+++ b/winsup/mingw/mingwex/math/tgamma.c
@@ -188,10 +188,13 @@ static const unsigned short STIR[20] = {
0x5986,0x5555,0x5555,0x3fb5,
};
#define MAXSTIR 143.01608
-static const unsigned short SQT[4] = {
-0x2706,0x1ff6,0x0d93,0x4004,
-};
-#define SQTPI *(double *)SQT
+
+static const union
+{
+ unsigned short s[4];
+ double d;
+} sqt = {0x2706,0x1ff6,0x0d93,0x4004};
+#define SQTPI (sqt.d)
#endif
#if MIEEE
static const unsigned short STIR[20] = {
diff --git a/winsup/mingw/mingwex/wcrtomb.c b/winsup/mingw/mingwex/wcrtomb.c
index f94feb2..aed21d4 100755
--- a/winsup/mingw/mingwex/wcrtomb.c
+++ b/winsup/mingw/mingwex/wcrtomb.c
@@ -53,40 +53,42 @@ size_t wcsrtombs (char *dst, const wchar_t **src, size_t len,
size_t n = 0;
const unsigned int cp = get_cp_from_locale();
const unsigned int mb_max = MB_CUR_MAX;
-
+ const wchar_t *pwc = *src;
+
if (src == NULL || *src == NULL) /* undefined behavior */
return 0;
if (dst != NULL)
{
- const wchar_t ** saved_src = src;
- while (n < len)
+ while (n < len)
{
- if ((ret = __wcrtomb_cp (dst, **src, cp, mb_max)) <= 0)
+ if ((ret = __wcrtomb_cp (dst, *pwc, cp, mb_max)) <= 0)
return (size_t) -1;
n += ret;
dst += ret;
if (*(dst - 1) == '\0')
{
- *saved_src = (wchar_t*) NULL;;
+ *src = (wchar_t*) NULL;;
return (n - 1);
}
- *src++;
+ pwc++;
}
+ *src = pwc;
}
else
{
char byte_bucket [MB_LEN_MAX];
while (n < len)
{
- if ((ret = __wcrtomb_cp (byte_bucket, **src, cp, mb_max))
+ if ((ret = __wcrtomb_cp (byte_bucket, *pwc, cp, mb_max))
<= 0)
return (size_t) -1;
n += ret;
if (byte_bucket [ret - 1] == '\0')
return (n - 1);
- *src++;
+ pwc++;
}
}
+
return n;
}