summaryrefslogtreecommitdiff
path: root/float.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2016-02-17 20:27:41 -0800
committerH. Peter Anvin <hpa@zytor.com>2016-03-03 15:22:03 -0800
commit215186fe82c461bc1ccef7bed5c1a1a0253bfcc9 (patch)
tree2e1e610ccd0fe722e0a67edf9753ba424e67cf29 /float.c
parent41087068aa3d5ddac8b28cb2bdcacd606f475c08 (diff)
downloadnasm-215186fe82c461bc1ccef7bed5c1a1a0253bfcc9.tar.gz
Get rid of a bunch of unnecessary indirections
We pass around a whole bunch of function pointers in arguments, which then just get stashed in static variables. Clean this mess up and in particular handle the error management in the preprocessor using nasm_set_verror() which already exists. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com> From master branch checkin 130736c0cfcad28ee16cec6c14bb22999d982e5a Resolved Conflicts: nasm.c preproc-nop.c Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'float.c')
-rw-r--r--float.c38
1 files changed, 17 insertions, 21 deletions
diff --git a/float.c b/float.c
index 7a4f8cbe..adf18c5b 100644
--- a/float.c
+++ b/float.c
@@ -51,7 +51,6 @@
* local variables
* -----------------
*/
-static efunc error;
static bool daz = false; /* denormals as zero */
static enum float_round rc = FLOAT_RC_NEAR; /* rounding control */
@@ -183,7 +182,7 @@ static int32_t read_exponent(const char *string, int32_t max)
} else if (*string == '_') {
/* do nothing */
} else {
- error(ERR_NONFATAL|ERR_PASS1,
+ nasm_error(ERR_NONFATAL|ERR_PASS1,
"invalid character in floating-point constant %s: '%c'",
"exponent", *string);
return INT32_MAX;
@@ -220,7 +219,7 @@ static bool ieee_flconvert(const char *string, fp_limb *mant,
if (!seendot) {
seendot = true;
} else {
- error(ERR_NONFATAL|ERR_PASS1,
+ nasm_error(ERR_NONFATAL|ERR_PASS1,
"too many periods in floating-point constant");
return false;
}
@@ -235,7 +234,7 @@ static bool ieee_flconvert(const char *string, fp_limb *mant,
*p++ = *string - '0';
} else {
if (!warned) {
- error(ERR_WARNING|ERR_WARN_FL_TOOLONG|ERR_PASS1,
+ nasm_error(ERR_WARNING|ERR_WARN_FL_TOOLONG|ERR_PASS1,
"floating-point constant significand contains "
"more than %i digits", MANT_DIGITS);
warned = true;
@@ -248,7 +247,7 @@ static bool ieee_flconvert(const char *string, fp_limb *mant,
} else if (*string == '_') {
/* do nothing */
} else {
- error(ERR_NONFATAL|ERR_PASS1,
+ nasm_error(ERR_NONFATAL|ERR_PASS1,
"invalid character in floating-point constant %s: '%c'",
"significand", *string);
return false;
@@ -534,7 +533,7 @@ static bool ieee_flconvert_bin(const char *string, int bits,
if (!seendot)
seendot = true;
else {
- error(ERR_NONFATAL|ERR_PASS1,
+ nasm_error(ERR_NONFATAL|ERR_PASS1,
"too many periods in floating-point constant");
return false;
}
@@ -576,7 +575,7 @@ static bool ieee_flconvert_bin(const char *string, int bits,
} else if (c == '_') {
/* ignore */
} else {
- error(ERR_NONFATAL|ERR_PASS1,
+ nasm_error(ERR_NONFATAL|ERR_PASS1,
"floating-point constant: `%c' is invalid character", c);
return false;
}
@@ -674,7 +673,7 @@ static int to_packed_bcd(const char *str, const char *p,
int tv = -1;
if (fmt != &ieee_80) {
- error(ERR_NONFATAL|ERR_PASS1,
+ nasm_error(ERR_NONFATAL|ERR_PASS1,
"packed BCD requires an 80-bit format");
return 0;
}
@@ -684,7 +683,7 @@ static int to_packed_bcd(const char *str, const char *p,
if (c >= '0' && c <= '9') {
if (tv < 0) {
if (n == 9) {
- error(ERR_WARNING|ERR_PASS1,
+ nasm_error(ERR_WARNING|ERR_PASS1,
"packed BCD truncated to 18 digits");
}
tv = c-'0';
@@ -697,7 +696,7 @@ static int to_packed_bcd(const char *str, const char *p,
} else if (c == '_') {
/* do nothing */
} else {
- error(ERR_NONFATAL|ERR_PASS1,
+ nasm_error(ERR_NONFATAL|ERR_PASS1,
"invalid character `%c' in packed BCD constant", c);
return 0;
}
@@ -734,7 +733,7 @@ static int to_float(const char *str, int s, uint8_t *result,
const char *strend;
if (!str[0]) {
- error(ERR_PANIC,
+ nasm_error(ERR_PANIC,
"internal errror: empty string passed to float_const");
return 0;
}
@@ -762,7 +761,7 @@ static int to_float(const char *str, int s, uint8_t *result,
type = FL_INFINITY;
break;
default:
- error(ERR_NONFATAL|ERR_PASS1,
+ nasm_error(ERR_NONFATAL|ERR_PASS1,
"internal error: unknown FP constant token `%s'\n", str);
type = FL_QNAN;
break;
@@ -810,7 +809,7 @@ static int to_float(const char *str, int s, uint8_t *result,
type = FL_NORMAL;
} else if (exponent > 0) {
if (pass0 == 1)
- error(ERR_WARNING|ERR_WARN_FL_OVERFLOW|ERR_PASS1,
+ nasm_error(ERR_WARNING|ERR_WARN_FL_OVERFLOW|ERR_PASS1,
"overflow in floating-point constant");
type = FL_INFINITY;
} else {
@@ -845,11 +844,11 @@ static int to_float(const char *str, int s, uint8_t *result,
} else {
if (daz || is_zero(mant)) {
/* Flush denormals to zero */
- error(ERR_WARNING|ERR_WARN_FL_UNDERFLOW|ERR_PASS1,
+ nasm_error(ERR_WARNING|ERR_WARN_FL_UNDERFLOW|ERR_PASS1,
"underflow in floating-point constant");
goto zero;
} else {
- error(ERR_WARNING|ERR_WARN_FL_DENORM|ERR_PASS1,
+ nasm_error(ERR_WARNING|ERR_WARN_FL_DENORM|ERR_PASS1,
"denormal floating-point constant");
}
}
@@ -865,7 +864,7 @@ static int to_float(const char *str, int s, uint8_t *result,
ieee_shr(mant, 1);
exponent++;
if (exponent >= (expmax << 1)-1) {
- error(ERR_WARNING|ERR_WARN_FL_OVERFLOW|ERR_PASS1,
+ nasm_error(ERR_WARNING|ERR_WARN_FL_OVERFLOW|ERR_PASS1,
"overflow in floating-point constant");
type = FL_INFINITY;
goto overflow;
@@ -901,11 +900,8 @@ static int to_float(const char *str, int s, uint8_t *result,
return 1; /* success */
}
-int float_const(const char *number, int sign, uint8_t *result,
- int bytes, efunc err)
+int float_const(const char *number, int sign, uint8_t *result, int bytes)
{
- error = err;
-
switch (bytes) {
case 1:
return to_float(number, sign, result, &ieee_8);
@@ -920,7 +916,7 @@ int float_const(const char *number, int sign, uint8_t *result,
case 16:
return to_float(number, sign, result, &ieee_128);
default:
- error(ERR_PANIC, "strange value %d passed to float_const", bytes);
+ nasm_error(ERR_PANIC, "strange value %d passed to float_const", bytes);
return 0;
}
}