diff options
| author | Krasimir Angelov <kr.angelov@gmail.com> | 2017-09-13 10:23:28 +0200 |
|---|---|---|
| committer | Krasimir Angelov <kr.angelov@gmail.com> | 2017-09-13 10:23:28 +0200 |
| commit | df992c31fdf191c88a5f8cd5ac462e5537523316 (patch) | |
| tree | 1a2550952101cd577c5332f201b6405c14932d74 /src/runtime/c/gu/out.c | |
| parent | 3e55aa442452d6a38a67466cb2ef30e1ce736bb5 (diff) | |
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.
Diffstat (limited to 'src/runtime/c/gu/out.c')
| -rw-r--r-- | src/runtime/c/gu/out.c | 24 |
1 files changed, 24 insertions, 0 deletions
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 <gu/seq.h> #include <gu/out.h> #include <gu/utf8.h> +#include <gu/bits.h> #include <stdio.h> 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; |
