From df992c31fdf191c88a5f8cd5ac462e5537523316 Mon Sep 17 00:00:00 2001 From: Krasimir Angelov Date: Wed, 13 Sep 2017 10:23:28 +0200 Subject: added gu_out_u16be, gu_out_u64be and gu_out_f64be in libgu. The later is using gu_encode_double which is probably still wrong. Corrected gu_in_le and gu_in_f64be. --- src/runtime/c/gu/out.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/runtime/c/gu/out.c') diff --git a/src/runtime/c/gu/out.c b/src/runtime/c/gu/out.c index 7a287cadb..f3edbe1e4 100644 --- a/src/runtime/c/gu/out.c +++ b/src/runtime/c/gu/out.c @@ -1,6 +1,7 @@ #include #include #include +#include #include static bool @@ -168,8 +169,31 @@ gu_out_is_buffered(GuOut* out); extern inline bool gu_out_try_u8_(GuOut* restrict out, uint8_t u); +GU_API void +gu_out_u16be(GuOut* out, uint16_t u, GuExn* err) +{ + gu_out_u8(out, (u>>8) && 0xFF, err); + gu_out_u8(out, u && 0xFF, err); +} +GU_API void +gu_out_u64be(GuOut* out, uint64_t u, GuExn* err) +{ + gu_out_u8(out, (u>>56) && 0xFF, err); + gu_out_u8(out, (u>>48) && 0xFF, err); + gu_out_u8(out, (u>>40) && 0xFF, err); + gu_out_u8(out, (u>>32) && 0xFF, err); + gu_out_u8(out, (u>>24) && 0xFF, err); + gu_out_u8(out, (u>>16) && 0xFF, err); + gu_out_u8(out, (u>>8) && 0xFF, err); + gu_out_u8(out, u && 0xFF, err); +} +GU_API void +gu_out_f64be(GuOut* out, double d, GuExn* err) +{ + gu_out_u64be(out, gu_encode_double(d), err); +} typedef struct GuBufferedOutStream GuBufferedOutStream; -- cgit v1.2.3