Backport from sid to buster
[hcoop/debian/mlton.git] / runtime / basis / coerce.c
CommitLineData
7f918cf1
CE
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) \
14coerce (name, Word##S##from, to) \
15coerce (name, Word##U##from, to)
16
17#define allWordCoerce(size) \
18bothFromWordCoerce(rnd, size, Real32) \
19bothFromWordCoerce(rnd, size, Real64)
20
21allWordCoerce(8)
22allWordCoerce(16)
23allWordCoerce(32)
24allWordCoerce(64)
25
26#undef allWordCoerce
27#undef bothToWordCoerce
28#undef bothFromWordCoerce
29
30#undef coerce