mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-27 17:40:49 +00:00
merge from gcc
This commit is contained in:
@@ -38,13 +38,15 @@
|
||||
#include <string.h> /* for strcmp */
|
||||
#include <stdio.h> /* for printf if DECCHECK */
|
||||
#include "dconfig.h" /* for GCC definitions */
|
||||
#include "decContext.h" /* context and base types */
|
||||
#include "decContext.h" /* context and base types */
|
||||
#include "decNumberLocal.h" /* decNumber local types, etc. */
|
||||
|
||||
#if DECCHECK
|
||||
/* compile-time endian tester [assumes sizeof(Int)>1] */
|
||||
static const Int mfcone=1; /* constant 1 */
|
||||
static const Flag *mfctop=(const Flag *)&mfcone; /* -> top byte */
|
||||
static const Flag *mfctop=(Flag *)&mfcone; /* -> top byte */
|
||||
#define LITEND *mfctop /* named flag; 1=little-endian */
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* round-for-reround digits */
|
||||
@@ -62,7 +64,7 @@ const uInt DECPOWERS[10]={1, 10, 100, 1000, 10000, 100000, 1000000,
|
||||
/* */
|
||||
/* context is the context structure to be queried */
|
||||
/* mask indicates the bits to be cleared (the status bit that */
|
||||
/* corresponds to each 1 bit in the mask is cleared) */
|
||||
/* corresponds to each 1 bit in the mask is cleared) */
|
||||
/* returns context */
|
||||
/* */
|
||||
/* No error is possible. */
|
||||
@@ -78,9 +80,9 @@ decContext *decContextClearStatus(decContext *context, uInt mask) {
|
||||
/* context is the structure to be initialized */
|
||||
/* kind selects the required set of default values, one of: */
|
||||
/* DEC_INIT_BASE -- select ANSI X3-274 defaults */
|
||||
/* DEC_INIT_DECIMAL32 -- select IEEE 754 defaults, 32-bit */
|
||||
/* DEC_INIT_DECIMAL64 -- select IEEE 754 defaults, 64-bit */
|
||||
/* DEC_INIT_DECIMAL128 -- select IEEE 754 defaults, 128-bit */
|
||||
/* DEC_INIT_DECIMAL32 -- select IEEE 754r defaults, 32-bit */
|
||||
/* DEC_INIT_DECIMAL64 -- select IEEE 754r defaults, 64-bit */
|
||||
/* DEC_INIT_DECIMAL128 -- select IEEE 754r defaults, 128-bit */
|
||||
/* For any other value a valid context is returned, but with */
|
||||
/* Invalid_operation set in the status field. */
|
||||
/* returns a context structure with the appropriate initial values. */
|
||||
@@ -103,11 +105,11 @@ decContext * decContextDefault(decContext *context, Int kind) {
|
||||
break;
|
||||
case DEC_INIT_DECIMAL32:
|
||||
context->digits=7; /* digits */
|
||||
context->emax=96; /* Emax */
|
||||
context->emax=96; /* Emax */
|
||||
context->emin=-95; /* Emin */
|
||||
context->round=DEC_ROUND_HALF_EVEN; /* 0.5 to nearest even */
|
||||
context->traps=0; /* no traps set */
|
||||
context->clamp=1; /* clamp exponents */
|
||||
context->traps=0; /* no traps set */
|
||||
context->clamp=1; /* clamp exponents */
|
||||
#if DECSUBSET
|
||||
context->extended=1; /* set */
|
||||
#endif
|
||||
@@ -117,8 +119,8 @@ decContext * decContextDefault(decContext *context, Int kind) {
|
||||
context->emax=384; /* Emax */
|
||||
context->emin=-383; /* Emin */
|
||||
context->round=DEC_ROUND_HALF_EVEN; /* 0.5 to nearest even */
|
||||
context->traps=0; /* no traps set */
|
||||
context->clamp=1; /* clamp exponents */
|
||||
context->traps=0; /* no traps set */
|
||||
context->clamp=1; /* clamp exponents */
|
||||
#if DECSUBSET
|
||||
context->extended=1; /* set */
|
||||
#endif
|
||||
@@ -128,8 +130,8 @@ decContext * decContextDefault(decContext *context, Int kind) {
|
||||
context->emax=6144; /* Emax */
|
||||
context->emin=-6143; /* Emin */
|
||||
context->round=DEC_ROUND_HALF_EVEN; /* 0.5 to nearest even */
|
||||
context->traps=0; /* no traps set */
|
||||
context->clamp=1; /* clamp exponents */
|
||||
context->traps=0; /* no traps set */
|
||||
context->clamp=1; /* clamp exponents */
|
||||
#if DECSUBSET
|
||||
context->extended=1; /* set */
|
||||
#endif
|
||||
@@ -140,6 +142,15 @@ decContext * decContextDefault(decContext *context, Int kind) {
|
||||
decContextSetStatus(context, DEC_Invalid_operation); /* trap */
|
||||
}
|
||||
|
||||
#if DECCHECK
|
||||
if (LITEND!=DECLITEND) {
|
||||
const char *adj;
|
||||
if (LITEND) adj="little";
|
||||
else adj="big";
|
||||
printf("Warning: DECLITEND is set to %d, but this computer appears to be %s-endian\n",
|
||||
DECLITEND, adj);
|
||||
}
|
||||
#endif
|
||||
return context;} /* decContextDefault */
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
@@ -155,7 +166,7 @@ enum rounding decContextGetRounding(decContext *context) {
|
||||
} /* decContextGetRounding */
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decContextGetStatus -- return current status */
|
||||
/* decContextGetStatus -- return current status */
|
||||
/* */
|
||||
/* context is the context structure to be queried */
|
||||
/* returns status */
|
||||
@@ -170,8 +181,8 @@ uInt decContextGetStatus(decContext *context) {
|
||||
/* decContextRestoreStatus -- restore bits in current status */
|
||||
/* */
|
||||
/* context is the context structure to be updated */
|
||||
/* newstatus is the source for the bits to be restored */
|
||||
/* mask indicates the bits to be restored (the status bit that */
|
||||
/* newstatus is the source for the bits to be restored */
|
||||
/* mask indicates the bits to be restored (the status bit that */
|
||||
/* corresponds to each 1 bit in the mask is set to the value of */
|
||||
/* the correspnding bit in newstatus) */
|
||||
/* returns context */
|
||||
@@ -241,7 +252,7 @@ decContext * decContextSetStatus(decContext *context, uInt status) {
|
||||
/* */
|
||||
/* returns the context structure, unless the string is equal to */
|
||||
/* DEC_Condition_MU or is not recognized. In these cases NULL is */
|
||||
/* returned. */
|
||||
/* returned. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
decContext * decContextSetStatusFromString(decContext *context,
|
||||
const char *string) {
|
||||
@@ -292,7 +303,7 @@ decContext * decContextSetStatusFromString(decContext *context,
|
||||
/* */
|
||||
/* returns the context structure, unless the string is equal to */
|
||||
/* DEC_Condition_MU or is not recognized. In these cases NULL is */
|
||||
/* returned. */
|
||||
/* returned. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
decContext * decContextSetStatusFromStringQuiet(decContext *context,
|
||||
const char *string) {
|
||||
@@ -345,11 +356,11 @@ decContext * decContextSetStatusQuiet(decContext *context, uInt status) {
|
||||
return context;} /* decContextSetStatusQuiet */
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decContextStatusToString -- convert status flags to a string */
|
||||
/* decContextStatusToString -- convert status flags to a string */
|
||||
/* */
|
||||
/* context is a context with valid status field */
|
||||
/* */
|
||||
/* returns a constant string describing the condition. If multiple */
|
||||
/* returns a constant string describing the condition. If multiple */
|
||||
/* (or no) flags are set, a generic constant message is returned. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
const char *decContextStatusToString(const decContext *context) {
|
||||
@@ -374,40 +385,10 @@ const char *decContextStatusToString(const decContext *context) {
|
||||
#if DECSUBSET
|
||||
if (status==DEC_Lost_digits ) return DEC_Condition_LD;
|
||||
#endif
|
||||
if (status==0 ) return DEC_Condition_ZE;
|
||||
if (status==0 ) return DEC_Condition_ZE;
|
||||
return DEC_Condition_MU; /* Multiple errors */
|
||||
} /* decContextStatusToString */
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decContextTestEndian -- test whether DECLITEND is set correctly */
|
||||
/* */
|
||||
/* quiet is 1 to suppress message; 0 otherwise */
|
||||
/* returns 0 if DECLITEND is correct */
|
||||
/* 1 if DECLITEND is incorrect and should be 1 */
|
||||
/* -1 if DECLITEND is incorrect and should be 0 */
|
||||
/* */
|
||||
/* A message is displayed if the return value is not 0 and quiet==0. */
|
||||
/* */
|
||||
/* No error is possible. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
Int decContextTestEndian(Flag quiet) {
|
||||
Int res=0; /* optimist */
|
||||
uInt dle=(uInt)DECLITEND; /* unsign */
|
||||
if (dle>1) dle=1; /* ensure 0 or 1 */
|
||||
|
||||
if (LITEND!=DECLITEND) {
|
||||
const char *adj;
|
||||
if (!quiet) {
|
||||
if (LITEND) adj="little";
|
||||
else adj="big";
|
||||
printf("Warning: DECLITEND is set to %d, but this computer appears to be %s-endian\n",
|
||||
DECLITEND, adj);
|
||||
}
|
||||
res=(Int)LITEND-dle;
|
||||
}
|
||||
return res;
|
||||
} /* decContextTestEndian */
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decContextTestSavedStatus -- test bits in saved status */
|
||||
/* */
|
||||
|
||||
Reference in New Issue
Block a user