]> granicus.if.org Git - yasm/commitdiff
Change order of arguments for get_ and check_ functions to better match other
authorPeter Johnson <peter@tortall.net>
Mon, 15 Oct 2001 04:34:11 +0000 (04:34 -0000)
committerPeter Johnson <peter@tortall.net>
Mon, 15 Oct 2001 04:34:11 +0000 (04:34 -0000)
functions (floatnum * as first arg).

svn path=/trunk/yasm/; revision=281

libyasm/floatnum.c
libyasm/floatnum.h
libyasm/tests/floatnum_test.c
src/floatnum.c
src/floatnum.h
src/tests/floatnum_test.c

index e251cfb3b63f3d9e04ece22c1e7d2e28556693cf..103e569ec9f3faae968e4f5bdd1dacc9fb179a5d 100644 (file)
@@ -494,11 +494,11 @@ floatnum_calc(floatnum *acc, ExprOp op, floatnum *operand)
 }
 
 int
-floatnum_get_int(unsigned long *ret_val, const floatnum *flt)
+floatnum_get_int(const floatnum *flt, unsigned long *ret_val)
 {
     unsigned char t[4];
 
-    if (floatnum_get_sized(t, flt, 4))
+    if (floatnum_get_sized(flt, t, 4))
        return 1;
 
     LOAD_LONG(*ret_val, &t[0]);
@@ -517,7 +517,7 @@ floatnum_get_int(unsigned long *ret_val, const floatnum *flt)
  * Returns 0 on success, 1 if overflow, -1 if underflow.
  */
 static int
-floatnum_get_common(unsigned char *ptr, const floatnum *flt, int byte_size,
+floatnum_get_common(const floatnum *flt, unsigned char *ptr, int byte_size,
                    int mant_bits, int implicit1, int exp_bits)
 {
     int exponent = flt->exponent;
@@ -626,15 +626,15 @@ floatnum_get_common(unsigned char *ptr, const floatnum *flt, int byte_size,
  * s = sign (for mantissa)
  */
 int
-floatnum_get_sized(unsigned char *ptr, const floatnum *flt, size_t size)
+floatnum_get_sized(const floatnum *flt, unsigned char *ptr, size_t size)
 {
     switch (size) {
        case 4:
-           return floatnum_get_common(ptr, flt, 4, 23, 1, 8);
+           return floatnum_get_common(flt, ptr, 4, 23, 1, 8);
        case 8:
-           return floatnum_get_common(ptr, flt, 8, 52, 1, 11);
+           return floatnum_get_common(flt, ptr, 8, 52, 1, 11);
        case 10:
-           return floatnum_get_common(ptr, flt, 10, 64, 0, 15);
+           return floatnum_get_common(flt, ptr, 10, 64, 0, 15);
        default:
            InternalError(__LINE__, __FILE__,
                          _("Invalid float conversion size"));
@@ -669,19 +669,19 @@ floatnum_print(const floatnum *flt)
     free(str);
 
     /* 32-bit (single precision) format */
-    printf("32-bit: %d: ", floatnum_get_sized(out, flt, 4));
+    printf("32-bit: %d: ", floatnum_get_sized(flt, out, 4));
     for (i=0; i<4; i++)
        printf("%02x ", out[i]);
     printf("\n");
 
     /* 64-bit (double precision) format */
-    printf("64-bit: %d: ", floatnum_get_sized(out, flt, 8));
+    printf("64-bit: %d: ", floatnum_get_sized(flt, out, 8));
     for (i=0; i<8; i++)
        printf("%02x ", out[i]);
     printf("\n");
 
     /* 80-bit (extended precision) format */
-    printf("80-bit: %d: ", floatnum_get_sized(out, flt, 10));
+    printf("80-bit: %d: ", floatnum_get_sized(flt, out, 10));
     for (i=0; i<10; i++)
        printf("%02x ", out[i]);
     printf("\n");
index 4963e79a536ea3f4a33b618d3a99963730fefdb9..1e1389514e8d53c8e4a293c33c0e323e54ef0e5b 100644 (file)
@@ -72,12 +72,12 @@ void floatnum_calc(floatnum *acc, ExprOp op, floatnum *operand);
 /* Essentially a convert to single-precision and return as 32-bit value.
  * The 32-bit value is a "standard" C value (eg, of unknown endian).
  */
-int floatnum_get_int(unsigned long *ret_val, const floatnum *flt);
+int floatnum_get_int(const floatnum *flt, unsigned long *ret_val);
 
 /* ptr will point to the Intel-format little-endian byte string after a
  * successful call (eg, [0] should be the first byte output to the file).
  */
-int floatnum_get_sized(unsigned char *ptr, const floatnum *flt, size_t size);
+int floatnum_get_sized(const floatnum *flt, unsigned char *ptr, size_t size);
 
 /* Basic check to see if size is even valid for flt conversion (doesn't
  * actually check for underflow/overflow but rather checks for size=4,8,10).
index 78ef88e8b3e86922861aa5227f1cdb42262d16e6..84a4bdadcf64f9d9b04daf33852f3ac80ddaddc2 100644 (file)
@@ -287,7 +287,7 @@ START_TEST(test_get_single_normalized)
 
     for (i=0; i<num; i++) {
        get_common_setup(vals, i);
-       fail_unless(floatnum_get_sized(outval, flt, 4) == vals[i].ret32,
+       fail_unless(floatnum_get_sized(flt, outval, 4) == vals[i].ret32,
                    ret_msg);
        fail_unless(get_common_check_result(4, outval, vals[i].result32) == 0,
                    result_msg);
@@ -303,7 +303,7 @@ START_TEST(test_get_single_normalized_edgecase)
 
     for (i=0; i<num; i++) {
        get_common_setup(vals, i);
-       fail_unless(floatnum_get_sized(outval, flt, 4) == vals[i].ret32,
+       fail_unless(floatnum_get_sized(flt, outval, 4) == vals[i].ret32,
                    ret_msg);
        fail_unless(get_common_check_result(4, outval, vals[i].result32) == 0,
                    result_msg);
@@ -323,7 +323,7 @@ START_TEST(test_get_double_normalized)
 
     for (i=0; i<num; i++) {
        get_common_setup(vals, i);
-       fail_unless(floatnum_get_sized(outval, flt, 8) == vals[i].ret64,
+       fail_unless(floatnum_get_sized(flt, outval, 8) == vals[i].ret64,
                    ret_msg);
        fail_unless(get_common_check_result(8, outval, vals[i].result64) == 0,
                    result_msg);
@@ -339,7 +339,7 @@ START_TEST(test_get_double_normalized_edgecase)
 
     for (i=0; i<num; i++) {
        get_common_setup(vals, i);
-       fail_unless(floatnum_get_sized(outval, flt, 8) == vals[i].ret64,
+       fail_unless(floatnum_get_sized(flt, outval, 8) == vals[i].ret64,
                    ret_msg);
        fail_unless(get_common_check_result(8, outval, vals[i].result64) == 0,
                    result_msg);
@@ -359,7 +359,7 @@ START_TEST(test_get_extended_normalized)
 
     for (i=0; i<num; i++) {
        get_common_setup(vals, i);
-       fail_unless(floatnum_get_sized(outval, flt, 10) == vals[i].ret80,
+       fail_unless(floatnum_get_sized(flt, outval, 10) == vals[i].ret80,
                    ret_msg);
        fail_unless(get_common_check_result(10, outval, vals[i].result80) == 0,
                    result_msg);
@@ -375,7 +375,7 @@ START_TEST(test_get_extended_normalized_edgecase)
 
     for (i=0; i<num; i++) {
        get_common_setup(vals, i);
-       fail_unless(floatnum_get_sized(outval, flt, 10) == vals[i].ret80,
+       fail_unless(floatnum_get_sized(flt, outval, 10) == vals[i].ret80,
                    ret_msg);
        fail_unless(get_common_check_result(10, outval, vals[i].result80) == 0,
                    result_msg);
index e251cfb3b63f3d9e04ece22c1e7d2e28556693cf..103e569ec9f3faae968e4f5bdd1dacc9fb179a5d 100644 (file)
@@ -494,11 +494,11 @@ floatnum_calc(floatnum *acc, ExprOp op, floatnum *operand)
 }
 
 int
-floatnum_get_int(unsigned long *ret_val, const floatnum *flt)
+floatnum_get_int(const floatnum *flt, unsigned long *ret_val)
 {
     unsigned char t[4];
 
-    if (floatnum_get_sized(t, flt, 4))
+    if (floatnum_get_sized(flt, t, 4))
        return 1;
 
     LOAD_LONG(*ret_val, &t[0]);
@@ -517,7 +517,7 @@ floatnum_get_int(unsigned long *ret_val, const floatnum *flt)
  * Returns 0 on success, 1 if overflow, -1 if underflow.
  */
 static int
-floatnum_get_common(unsigned char *ptr, const floatnum *flt, int byte_size,
+floatnum_get_common(const floatnum *flt, unsigned char *ptr, int byte_size,
                    int mant_bits, int implicit1, int exp_bits)
 {
     int exponent = flt->exponent;
@@ -626,15 +626,15 @@ floatnum_get_common(unsigned char *ptr, const floatnum *flt, int byte_size,
  * s = sign (for mantissa)
  */
 int
-floatnum_get_sized(unsigned char *ptr, const floatnum *flt, size_t size)
+floatnum_get_sized(const floatnum *flt, unsigned char *ptr, size_t size)
 {
     switch (size) {
        case 4:
-           return floatnum_get_common(ptr, flt, 4, 23, 1, 8);
+           return floatnum_get_common(flt, ptr, 4, 23, 1, 8);
        case 8:
-           return floatnum_get_common(ptr, flt, 8, 52, 1, 11);
+           return floatnum_get_common(flt, ptr, 8, 52, 1, 11);
        case 10:
-           return floatnum_get_common(ptr, flt, 10, 64, 0, 15);
+           return floatnum_get_common(flt, ptr, 10, 64, 0, 15);
        default:
            InternalError(__LINE__, __FILE__,
                          _("Invalid float conversion size"));
@@ -669,19 +669,19 @@ floatnum_print(const floatnum *flt)
     free(str);
 
     /* 32-bit (single precision) format */
-    printf("32-bit: %d: ", floatnum_get_sized(out, flt, 4));
+    printf("32-bit: %d: ", floatnum_get_sized(flt, out, 4));
     for (i=0; i<4; i++)
        printf("%02x ", out[i]);
     printf("\n");
 
     /* 64-bit (double precision) format */
-    printf("64-bit: %d: ", floatnum_get_sized(out, flt, 8));
+    printf("64-bit: %d: ", floatnum_get_sized(flt, out, 8));
     for (i=0; i<8; i++)
        printf("%02x ", out[i]);
     printf("\n");
 
     /* 80-bit (extended precision) format */
-    printf("80-bit: %d: ", floatnum_get_sized(out, flt, 10));
+    printf("80-bit: %d: ", floatnum_get_sized(flt, out, 10));
     for (i=0; i<10; i++)
        printf("%02x ", out[i]);
     printf("\n");
index 4963e79a536ea3f4a33b618d3a99963730fefdb9..1e1389514e8d53c8e4a293c33c0e323e54ef0e5b 100644 (file)
@@ -72,12 +72,12 @@ void floatnum_calc(floatnum *acc, ExprOp op, floatnum *operand);
 /* Essentially a convert to single-precision and return as 32-bit value.
  * The 32-bit value is a "standard" C value (eg, of unknown endian).
  */
-int floatnum_get_int(unsigned long *ret_val, const floatnum *flt);
+int floatnum_get_int(const floatnum *flt, unsigned long *ret_val);
 
 /* ptr will point to the Intel-format little-endian byte string after a
  * successful call (eg, [0] should be the first byte output to the file).
  */
-int floatnum_get_sized(unsigned char *ptr, const floatnum *flt, size_t size);
+int floatnum_get_sized(const floatnum *flt, unsigned char *ptr, size_t size);
 
 /* Basic check to see if size is even valid for flt conversion (doesn't
  * actually check for underflow/overflow but rather checks for size=4,8,10).
index 78ef88e8b3e86922861aa5227f1cdb42262d16e6..84a4bdadcf64f9d9b04daf33852f3ac80ddaddc2 100644 (file)
@@ -287,7 +287,7 @@ START_TEST(test_get_single_normalized)
 
     for (i=0; i<num; i++) {
        get_common_setup(vals, i);
-       fail_unless(floatnum_get_sized(outval, flt, 4) == vals[i].ret32,
+       fail_unless(floatnum_get_sized(flt, outval, 4) == vals[i].ret32,
                    ret_msg);
        fail_unless(get_common_check_result(4, outval, vals[i].result32) == 0,
                    result_msg);
@@ -303,7 +303,7 @@ START_TEST(test_get_single_normalized_edgecase)
 
     for (i=0; i<num; i++) {
        get_common_setup(vals, i);
-       fail_unless(floatnum_get_sized(outval, flt, 4) == vals[i].ret32,
+       fail_unless(floatnum_get_sized(flt, outval, 4) == vals[i].ret32,
                    ret_msg);
        fail_unless(get_common_check_result(4, outval, vals[i].result32) == 0,
                    result_msg);
@@ -323,7 +323,7 @@ START_TEST(test_get_double_normalized)
 
     for (i=0; i<num; i++) {
        get_common_setup(vals, i);
-       fail_unless(floatnum_get_sized(outval, flt, 8) == vals[i].ret64,
+       fail_unless(floatnum_get_sized(flt, outval, 8) == vals[i].ret64,
                    ret_msg);
        fail_unless(get_common_check_result(8, outval, vals[i].result64) == 0,
                    result_msg);
@@ -339,7 +339,7 @@ START_TEST(test_get_double_normalized_edgecase)
 
     for (i=0; i<num; i++) {
        get_common_setup(vals, i);
-       fail_unless(floatnum_get_sized(outval, flt, 8) == vals[i].ret64,
+       fail_unless(floatnum_get_sized(flt, outval, 8) == vals[i].ret64,
                    ret_msg);
        fail_unless(get_common_check_result(8, outval, vals[i].result64) == 0,
                    result_msg);
@@ -359,7 +359,7 @@ START_TEST(test_get_extended_normalized)
 
     for (i=0; i<num; i++) {
        get_common_setup(vals, i);
-       fail_unless(floatnum_get_sized(outval, flt, 10) == vals[i].ret80,
+       fail_unless(floatnum_get_sized(flt, outval, 10) == vals[i].ret80,
                    ret_msg);
        fail_unless(get_common_check_result(10, outval, vals[i].result80) == 0,
                    result_msg);
@@ -375,7 +375,7 @@ START_TEST(test_get_extended_normalized_edgecase)
 
     for (i=0; i<num; i++) {
        get_common_setup(vals, i);
-       fail_unless(floatnum_get_sized(outval, flt, 10) == vals[i].ret80,
+       fail_unless(floatnum_get_sized(flt, outval, 10) == vals[i].ret80,
                    ret_msg);
        fail_unless(get_common_check_result(10, outval, vals[i].result80) == 0,
                    result_msg);