mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-19 04:49:25 +08:00
f3b8138239
Add a _REENT_ERRNO() macro to encapsulate the access to the _errno member of struct reent. This will help to replace the structure member with a thread-local storage object in a follow up patch. Replace uses of __errno_r() with _REENT_ERRNO(). Keep __errno_r() macro for potential users outside of Newlib.
44 lines
703 B
C
44 lines
703 B
C
/*
|
|
* return (*acc) scaled by 10**dexp.
|
|
*/
|
|
|
|
#include <_ansi.h>
|
|
#include <reent.h>
|
|
#include "std.h"
|
|
|
|
#define abs(x) (((x) < 0) ? -(x) : (x))
|
|
|
|
double
|
|
__adjust (struct _reent *ptr,
|
|
double *acc,
|
|
int dexp,
|
|
int sign)
|
|
/* *acc the 64 bit accumulator */
|
|
/* dexp decimal exponent */
|
|
/* sign sign flag */
|
|
{
|
|
double r;
|
|
|
|
if (dexp > MAXE)
|
|
{
|
|
_REENT_ERRNO(ptr) = ERANGE;
|
|
return (sign) ? -HUGE_VAL : HUGE_VAL;
|
|
}
|
|
else if (dexp < MINE)
|
|
{
|
|
_REENT_ERRNO(ptr) = ERANGE;
|
|
return 0.0;
|
|
}
|
|
|
|
r = *acc;
|
|
if (sign)
|
|
r = -r;
|
|
if (dexp == 0)
|
|
return r;
|
|
|
|
if (dexp < 0)
|
|
return r / __exp10 (abs (dexp));
|
|
else
|
|
return r * __exp10 (dexp);
|
|
}
|