1.1 --- a/templates/native/float.c Thu Nov 04 23:44:29 2021 +0100
1.2 +++ b/templates/native/float.c Tue Aug 29 01:46:23 2023 +0200
1.3 @@ -1,6 +1,6 @@
1.4 /* Native functions for floating point operations.
1.5
1.6 -Copyright (C) 2016, 2017, 2018, 2019 Paul Boddie <paul@boddie.org.uk>
1.7 +Copyright (C) 2016, 2017, 2018, 2019, 2023 Paul Boddie <paul@boddie.org.uk>
1.8
1.9 This program is free software; you can redistribute it and/or modify it under
1.10 the terms of the GNU General Public License as published by the Free Software
1.11 @@ -65,54 +65,54 @@
1.12
1.13 /* Floating point operations. Exceptions are raised in the signal handler. */
1.14
1.15 -__attr __fn_native_float_float_add(__attr __self, __attr self, __attr other)
1.16 +__attr __fn_native_float_float_add(__attr __result, __attr __self, __attr self, __attr other)
1.17 {
1.18 /* self and other interpreted as float */
1.19 double i = __TOFLOAT(self);
1.20 double j = __TOFLOAT(other);
1.21 - return __new_float(i + j);
1.22 + return __new_float(__result, i + j);
1.23 }
1.24
1.25 -__attr __fn_native_float_float_sub(__attr __self, __attr self, __attr other)
1.26 +__attr __fn_native_float_float_sub(__attr __result, __attr __self, __attr self, __attr other)
1.27 {
1.28 /* self and other interpreted as float */
1.29 double i = __TOFLOAT(self);
1.30 double j = __TOFLOAT(other);
1.31 - return __new_float(i - j);
1.32 + return __new_float(__result, i - j);
1.33 }
1.34
1.35 -__attr __fn_native_float_float_mul(__attr __self, __attr self, __attr other)
1.36 +__attr __fn_native_float_float_mul(__attr __result, __attr __self, __attr self, __attr other)
1.37 {
1.38 /* self and other interpreted as float */
1.39 double i = __TOFLOAT(self);
1.40 double j = __TOFLOAT(other);
1.41 - return __new_float(i * j);
1.42 + return __new_float(__result, i * j);
1.43 }
1.44
1.45 -__attr __fn_native_float_float_div(__attr __self, __attr self, __attr other)
1.46 +__attr __fn_native_float_float_div(__attr __result, __attr __self, __attr self, __attr other)
1.47 {
1.48 /* self and other interpreted as float */
1.49 double i = __TOFLOAT(self);
1.50 double j = __TOFLOAT(other);
1.51 - return __new_float(i / j);
1.52 + return __new_float(__result, i / j);
1.53 }
1.54
1.55 -__attr __fn_native_float_float_mod(__attr __self, __attr self, __attr other)
1.56 +__attr __fn_native_float_float_mod(__attr __result, __attr __self, __attr self, __attr other)
1.57 {
1.58 /* self and other interpreted as float */
1.59 double i = __TOFLOAT(self);
1.60 double j = __TOFLOAT(other);
1.61 - return __new_float(fmod(i, j));
1.62 + return __new_float(__result, fmod(i, j));
1.63 }
1.64
1.65 -__attr __fn_native_float_float_neg(__attr __self, __attr self)
1.66 +__attr __fn_native_float_float_neg(__attr __result, __attr __self, __attr self)
1.67 {
1.68 /* self interpreted as float */
1.69 double i = __TOFLOAT(self);
1.70 - return __new_float(-i);
1.71 + return __new_float(__result, -i);
1.72 }
1.73
1.74 -__attr __fn_native_float_float_pow(__attr __self, __attr self, __attr other)
1.75 +__attr __fn_native_float_float_pow(__attr __result, __attr __self, __attr self, __attr other)
1.76 {
1.77 /* self and other interpreted as float */
1.78 double i = __TOFLOAT(self);
1.79 @@ -128,10 +128,10 @@
1.80 __raise_overflow_error();
1.81
1.82 /* Return the result. */
1.83 - return __new_float(result);
1.84 + return __new_float(__result, result);
1.85 }
1.86
1.87 -__attr __fn_native_float_float_le(__attr __self, __attr self, __attr other)
1.88 +__attr __fn_native_float_float_le(__attr __result, __attr __self, __attr self, __attr other)
1.89 {
1.90 /* self and other interpreted as float */
1.91 double i = __TOFLOAT(self);
1.92 @@ -141,7 +141,7 @@
1.93 return i <= j ? __builtins___boolean_True : __builtins___boolean_False;
1.94 }
1.95
1.96 -__attr __fn_native_float_float_lt(__attr __self, __attr self, __attr other)
1.97 +__attr __fn_native_float_float_lt(__attr __result, __attr __self, __attr self, __attr other)
1.98 {
1.99 /* self and other interpreted as float */
1.100 double i = __TOFLOAT(self);
1.101 @@ -151,7 +151,7 @@
1.102 return i < j ? __builtins___boolean_True : __builtins___boolean_False;
1.103 }
1.104
1.105 -__attr __fn_native_float_float_ge(__attr __self, __attr self, __attr other)
1.106 +__attr __fn_native_float_float_ge(__attr __result, __attr __self, __attr self, __attr other)
1.107 {
1.108 /* self and other interpreted as float */
1.109 double i = __TOFLOAT(self);
1.110 @@ -161,7 +161,7 @@
1.111 return i >= j ? __builtins___boolean_True : __builtins___boolean_False;
1.112 }
1.113
1.114 -__attr __fn_native_float_float_gt(__attr __self, __attr self, __attr other)
1.115 +__attr __fn_native_float_float_gt(__attr __result, __attr __self, __attr self, __attr other)
1.116 {
1.117 /* self and other interpreted as float */
1.118 double i = __TOFLOAT(self);
1.119 @@ -171,7 +171,7 @@
1.120 return i > j ? __builtins___boolean_True : __builtins___boolean_False;
1.121 }
1.122
1.123 -__attr __fn_native_float_float_eq(__attr __self, __attr self, __attr other)
1.124 +__attr __fn_native_float_float_eq(__attr __result, __attr __self, __attr self, __attr other)
1.125 {
1.126 /* self and other interpreted as float */
1.127 double i = __TOFLOAT(self);
1.128 @@ -181,7 +181,7 @@
1.129 return i == j ? __builtins___boolean_True : __builtins___boolean_False;
1.130 }
1.131
1.132 -__attr __fn_native_float_float_ne(__attr __self, __attr self, __attr other)
1.133 +__attr __fn_native_float_float_ne(__attr __result, __attr __self, __attr self, __attr other)
1.134 {
1.135 /* self and other interpreted as float */
1.136 double i = __TOFLOAT(self);
1.137 @@ -191,7 +191,7 @@
1.138 return i != j ? __builtins___boolean_True : __builtins___boolean_False;
1.139 }
1.140
1.141 -__attr __fn_native_float_float_str(__attr __self, __attr self)
1.142 +__attr __fn_native_float_float_str(__attr __result, __attr __self, __attr self)
1.143 {
1.144 /* self interpreted as float */
1.145 double i = __TOFLOAT(self);
1.146 @@ -200,7 +200,7 @@
1.147 return format_number(i, 64);
1.148 }
1.149
1.150 -__attr __fn_native_float_float_int(__attr __self, __attr self)
1.151 +__attr __fn_native_float_float_int(__attr __result, __attr __self, __attr self)
1.152 {
1.153 /* self interpreted as float */
1.154 double i = __TOFLOAT(self);