| 1 | #include "platform.h" |
| 2 | |
| 3 | #include "coerce.h" |
| 4 | |
| 5 | /* Real coercions depend on rounding mode and can't be inlined where |
| 6 | * gcc might constant-fold them. |
| 7 | */ |
| 8 | |
| 9 | #define coerce(n, f, t) \ |
| 10 | t f##_##n##To##t (f x) { \ |
| 11 | return (t)x; \ |
| 12 | } |
| 13 | #define bothFromWordCoerce(name, from, to) \ |
| 14 | coerce (name, Word##S##from, to) \ |
| 15 | coerce (name, Word##U##from, to) |
| 16 | |
| 17 | #define allWordCoerce(size) \ |
| 18 | bothFromWordCoerce(rnd, size, Real32) \ |
| 19 | bothFromWordCoerce(rnd, size, Real64) |
| 20 | |
| 21 | allWordCoerce(8) |
| 22 | allWordCoerce(16) |
| 23 | allWordCoerce(32) |
| 24 | allWordCoerce(64) |
| 25 | |
| 26 | #undef allWordCoerce |
| 27 | #undef bothToWordCoerce |
| 28 | #undef bothFromWordCoerce |
| 29 | |
| 30 | #undef coerce |