+1998-07-23 Ulrich Drepper <drepper@cygnus.com>
+
+ * sysdeps/generic/glob.c: Fix two problems with GLOB_DOOFFS.
+ Reported by bwelling@anomaly.munge.com [PR libc/720].
+
+ * sysdeps/libm-ieee754/k_standard.c: Return NAN for libm not in
+ SVID more for gamma(x) with x interger <= 0.
+ Reported by Stephen L Moshier <moshier@mediaone.net>.
+
+ * math/libm-test.c (gamma_test): Add test for gamma(-1) and gamma(0).
+ Correct test for SVID version of gamma.
+
+ * sysdeps/libm-ieee754/w_gamma.c: Use correct matherr call in SVID
+ emulation mode.
+ * sysdeps/libm-ieee754/w_gammaf.c: Likewise.
+ * sysdeps/libm-ieee754/w_gammal.c: Likewise.
+
+ * string/string.h: Don't use string function optimization for C++
+ as long as we use macros.
+
1998-07-22 23:47 Ulrich Drepper <drepper@cygnus.com>
* posix/fnmatch.c: Fix completely broken range matching.
_LIB_VERSION = _SVID_;
check_isinfp ("gamma (+inf) == +inf", FUNC(gamma) (plus_infty));
- check_isinfp_exc ("gamma (0) == +inf plus divide by zero exception",
- FUNC(gamma) (0), DIVIDE_BY_ZERO_EXCEPTION);
+ check_exc ("gamma (0) == HUGE plus divide by zero exception",
+ FUNC(gamma) (0), HUGE, DIVIDE_BY_ZERO_EXCEPTION);
- check_isinfp_exc ("gamma (x) == +inf plus divide by zero exception for integer x <= 0",
- FUNC(gamma) (-3), DIVIDE_BY_ZERO_EXCEPTION);
+ check_exc ("gamma (x) == HUGE plus divide by zero exception for integer x <= 0",
+ FUNC(gamma) (-3), HUGE, DIVIDE_BY_ZERO_EXCEPTION);
check_isnan_exc ("gamma (-inf) == NaN plus invalid exception",
FUNC(gamma) (minus_infty), INVALID_EXCEPTION);
signgam = 0;
check ("gamma (1) == 0", FUNC(gamma) (1), 0);
- check_int ("gamma (0) sets signgam to 1", signgam, 1);
+ check_int ("gamma (1) sets signgam to 1", signgam, 1);
signgam = 0;
check ("gamma (3) == M_LN2", FUNC(gamma) (3), M_LN2l);
1.29805533264755778568L, CHOOSE(0, 3e-16, 2e-7));
check ("gamma (1.2) == 0.91816...", FUNC(gamma) (1.2), 0.91816874239976061064L);
+ check_isnan_exc ("gamma (0.0) == NaN plus invalid exception",
+ FUNC(gamma) (0.0), INVALID_EXCEPTION);
+ check_isnan_exc ("gamma (-1.0) == NaN plus invalid exception",
+ FUNC(gamma) (-1.0), INVALID_EXCEPTION);
+
_LIB_VERSION = save_lib_version;
}
#if defined __GNUC__ && __GNUC__ >= 2
-# if defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
+# if defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ && !defined __cplusplus
/* When using GNU CC we provide some optimized versions of selected
functions from this header. There are two kinds of optimizations:
appending the results to PGLOB. */
for (i = 0; i < dirs.gl_pathc; ++i)
{
- int oldcount;
+ int old_pathc;
#ifdef SHELL
{
}
#endif /* SHELL. */
- oldcount = pglob->gl_pathc;
+ old_pathc = pglob->gl_pathc;
status = glob_in_dir (filename, dirs.gl_pathv[i],
((flags | GLOB_APPEND)
& ~(GLOB_NOCHECK | GLOB_ERR)),
/* Stick the directory on the front of each name. */
if (prefix_array (dirs.gl_pathv[i],
- &pglob->gl_pathv[oldcount],
- pglob->gl_pathc - oldcount))
+ &pglob->gl_pathv[old_pathc],
+ pglob->gl_pathc - old_pathc))
{
globfree (&dirs);
globfree (pglob);
if (dirlen > 0)
{
/* Stick the directory on the front of each name. */
+ int ignore = oldcount;
+
+ if ((flags & GLOB_DOOFFS) && ignore < pglob->gl_offs)
+ ignore = pglob->gl_offs;
+
if (prefix_array (dirname,
- &pglob->gl_pathv[oldcount],
- pglob->gl_pathc - oldcount))
+ &pglob->gl_pathv[ignore],
+ pglob->gl_pathc - ignore))
{
globfree (pglob);
return GLOB_NOSPACE;
}
if (!(flags & GLOB_NOSORT))
- /* Sort the vector. */
- qsort ((__ptr_t) &pglob->gl_pathv[oldcount],
- pglob->gl_pathc - oldcount,
- sizeof (char *), collated_compare);
+ {
+ /* Sort the vector. */
+ int non_sort = oldcount;
+
+ if ((flags & GLOB_DOOFFS) && pglob->gl_offs > oldcount)
+ non_sort = pglob->gl_offs;
+
+ qsort ((__ptr_t) &pglob->gl_pathv[non_sort],
+ pglob->gl_pathc - non_sort,
+ sizeof (char *), collated_compare);
+ }
return 0;
}
exc.type = SING;
exc.name = type < 100 ? "gamma" : (type < 200
? "gammaf" : "gammal");
- exc.retval = HUGE_VAL;
+ exc.retval = NAN;
if (_LIB_VERSION == _POSIX_)
__set_errno (EDOM);
else if (!matherr(&exc)) {
if (_LIB_VERSION == _SVID_) {
(void) WRITE2("gamma: SING error\n", 18);
+ exc.retval = HUGE_VAL;
}
__set_errno (EDOM);
}
double y;
#ifndef _IEEE_LIBM
if (_LIB_VERSION == _SVID_)
- y = __ieee754_lgamma_r(x,&signgam);
+ {
+ y = __ieee754_lgamma_r(x,&signgam);
+
+ if(!__finite(y)&&__finite(x)) {
+ if(__floor(x)==x&&x<=(double)0.0)
+ /* lgamma pole */
+ return __kernel_standard(x,x,15);
+ else
+ /* lgamma overflow */
+ return __kernel_standard(x,x,14);
+ }
+ }
else
{
#endif
return y;
#else
if(_LIB_VERSION == _IEEE_) return y;
- }
- if(!__finite(y)&&__finite(x)) {
- if(__floor(x)==x&&x<=0.0)
+
+ if(!__finite(y)&&__finite(x)) {
+ if(__floor(x)==x&&x<=0.0)
return __kernel_standard(x,x,41); /* gamma pole */
- else
+ else
return __kernel_standard(x,x,40); /* gamma overflow */
- } else
- return y;
+ }
+ }
+ return y;
#endif
}
weak_alias (__gamma, gamma)
float y;
#ifndef _IEEE_LIBM
if (_LIB_VERSION == _SVID_)
- y = __ieee754_lgammaf_r(x,&signgam);
+ {
+ y = __ieee754_lgammaf_r(x,&signgam);
+
+ if(!__finitef(y)&&__finitef(x)) {
+ if(__floorf(x)==x&&x<=(float)0.0)
+ /* lgammaf pole */
+ return (float)__kernel_standard((double)x,(double)x,115);
+ else
+ /* lgammaf overflow */
+ return (float)__kernel_standard((double)x,(double)x,114);
+ }
+ }
else
{
#endif
return y;
#else
if(_LIB_VERSION == _IEEE_) return y;
+
+ if(!__finitef(y)&&__finitef(x)) {
+ if(__floorf(x)==x&&x<=(float)0.0)
+ /* gammaf pole */
+ return (float)__kernel_standard((double)x,(double)x,141);
+ else
+ /* gammaf overflow */
+ return (float)__kernel_standard((double)x,(double)x,140);
+ }
}
- if(!__finitef(y)&&__finitef(x)) {
- if(__floorf(x)==x&&x<=(float)0.0)
- /* gammaf pole */
- return (float)__kernel_standard((double)x,(double)x,141);
- else
- /* gammaf overflow */
- return (float)__kernel_standard((double)x,(double)x,140);
- } else
- return y;
+ return y;
#endif
}
weak_alias (__gammaf, gammaf)
long double y;
#ifndef _IEEE_LIBM
if (_LIB_VERSION == _SVID_)
- y = __ieee754_lgammal_r(x,&signgam);
+ {
+ y = __ieee754_lgammal_r(x,&signgam);
+
+ if(!__finitel(y)&&__finitel(x)) {
+ if(__floorl(x)==x&&x<=(long double)0.0)
+ /* lgamma pole */
+ return (long double)__kernel_standard((double)x,(double)x,15);
+ else
+ /* lgamma overflow */
+ return (long double)__kernel_standard((double)x,(double)x,14);
+ }
+ }
else
{
#endif
return y;
#else
if(_LIB_VERSION == _IEEE_) return y;
- }
- if(!__finitel(y)&&__finitel(x)) {
- if(__floorl(x)==x&&x<=0.0)
+
+ if(!__finitel(y)&&__finitel(x)) {
+ if(__floorl(x)==x&&x<=0.0)
return __kernel_standard(x,x,241); /* gamma pole */
- else
+ else
return __kernel_standard(x,x,240); /* gamma overflow */
- } else
- return y;
+ }
+ }
+ return y;
#endif
}
weak_alias (__gammal, gammal)