From 0789b36738c362c186e53655759bdae5437c4cc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= Date: Thu, 24 Mar 2022 20:16:23 +0000 Subject: [PATCH 1/3] Mark as `inline` functions implemented in `src/serialize.h` Also, remove duplicate definitions from `src/staticdata.c` and include `serialize.h` in there. --- src/serialize.h | 22 +++++++++++----------- src/staticdata.c | 20 +------------------- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/src/serialize.h b/src/serialize.h index 817591b989f93..69aaeb4c39787 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -67,54 +67,54 @@ extern "C" { #define LAST_TAG 57 #define write_uint8(s, n) ios_putc((n), (s)) -#define read_uint8(s) ((uint8_t)ios_getc(s)) -#define write_int8(s, n) write_uint8(s, n) -#define read_int8(s) read_uint8(s) +#define read_uint8(s) ((uint8_t)ios_getc((s))) +#define write_int8(s, n) write_uint8((s), (n)) +#define read_int8(s) read_uint8((s)) /* read and write in host byte order */ -static void write_int32(ios_t *s, int32_t i) JL_NOTSAFEPOINT +static inline void write_int32(ios_t *s, int32_t i) JL_NOTSAFEPOINT { ios_write(s, (char*)&i, 4); } -static int32_t read_int32(ios_t *s) JL_NOTSAFEPOINT +static inline int32_t read_int32(ios_t *s) JL_NOTSAFEPOINT { int32_t x = 0; ios_read(s, (char*)&x, 4); return x; } -static uint64_t read_uint64(ios_t *s) JL_NOTSAFEPOINT +static inline uint64_t read_uint64(ios_t *s) JL_NOTSAFEPOINT { uint64_t x = 0; ios_read(s, (char*)&x, 8); return x; } -static void write_int64(ios_t *s, int64_t i) JL_NOTSAFEPOINT +static inline void write_int64(ios_t *s, int64_t i) JL_NOTSAFEPOINT { ios_write(s, (char*)&i, 8); } -static void write_uint16(ios_t *s, uint16_t i) JL_NOTSAFEPOINT +static inline void write_uint16(ios_t *s, uint16_t i) JL_NOTSAFEPOINT { ios_write(s, (char*)&i, 2); } -static uint16_t read_uint16(ios_t *s) JL_NOTSAFEPOINT +static inline uint16_t read_uint16(ios_t *s) JL_NOTSAFEPOINT { int16_t x = 0; ios_read(s, (char*)&x, 2); return x; } -static void write_uint32(ios_t *s, uint32_t i) JL_NOTSAFEPOINT +static inline void write_uint32(ios_t *s, uint32_t i) JL_NOTSAFEPOINT { ios_write(s, (char*)&i, 4); } -static uint32_t read_uint32(ios_t *s) JL_NOTSAFEPOINT +static inline uint32_t read_uint32(ios_t *s) JL_NOTSAFEPOINT { uint32_t x = 0; ios_read(s, (char*)&x, 4); diff --git a/src/staticdata.c b/src/staticdata.c index 4eeef024139c5..e8ce9601527ad 100644 --- a/src/staticdata.c +++ b/src/staticdata.c @@ -64,6 +64,7 @@ done by `get_item_for_reloc`. #include "julia_internal.h" #include "builtin_proto.h" #include "processor.h" +#include "serialize.h" #ifndef _OS_WINDOWS_ #include @@ -364,25 +365,6 @@ typedef enum { // if a larger size is required, will need to add support for writing larger relocations in many cases below #define RELOC_TAG_OFFSET 29 - -/* read and write in host byte order */ - -#define write_uint8(s, n) ios_putc((n), (s)) -#define read_uint8(s) ((uint8_t)ios_getc((s))) - -static void write_uint32(ios_t *s, uint32_t i) JL_NOTSAFEPOINT -{ - ios_write(s, (char*)&i, 4); -} - -static uint32_t read_uint32(ios_t *s) JL_NOTSAFEPOINT -{ - uint32_t x = 0; - ios_read(s, (char*)&x, 4); - return x; -} - - // --- Static Compile --- static void *jl_sysimg_handle = NULL; From 04f8d5675a81401db3e340d7c183f3c3c8a68dd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= Date: Thu, 31 Mar 2022 18:36:06 +0100 Subject: [PATCH 2/3] Turn macros into inlined functions --- src/serialize.h | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/serialize.h b/src/serialize.h index 69aaeb4c39787..bca495228211e 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -66,13 +66,28 @@ extern "C" { #define LAST_TAG 57 -#define write_uint8(s, n) ios_putc((n), (s)) -#define read_uint8(s) ((uint8_t)ios_getc((s))) -#define write_int8(s, n) write_uint8((s), (n)) -#define read_int8(s) read_uint8((s)) - /* read and write in host byte order */ +static inline void write_uint8(ios_t *s, uint8_t n) JL_NOTSAFEPOINT +{ + ios_putc(n, s); +} + +static inline uint8_t read_uint8(ios_t *s) JL_NOTSAFEPOINT +{ + return (uint8_t)ios_getc(s); +} + +static inline void write_int8(ios_t *s, int8_t n) JL_NOTSAFEPOINT +{ + ios_putc(n, s); +} + +static inline int8_t read_int8(ios_t *s) JL_NOTSAFEPOINT +{ + return (int8_t)ios_getc(s); +} + static inline void write_int32(ios_t *s, int32_t i) JL_NOTSAFEPOINT { ios_write(s, (char*)&i, 4); From 9ed80331ade344c7530536ebd0ef4b99e7430b38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= Date: Fri, 1 Apr 2022 13:08:40 +0100 Subject: [PATCH 3/3] Revert "Turn macros into inlined functions" This breaks analyzegc --- src/serialize.h | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/src/serialize.h b/src/serialize.h index bca495228211e..69aaeb4c39787 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -66,27 +66,12 @@ extern "C" { #define LAST_TAG 57 -/* read and write in host byte order */ - -static inline void write_uint8(ios_t *s, uint8_t n) JL_NOTSAFEPOINT -{ - ios_putc(n, s); -} - -static inline uint8_t read_uint8(ios_t *s) JL_NOTSAFEPOINT -{ - return (uint8_t)ios_getc(s); -} +#define write_uint8(s, n) ios_putc((n), (s)) +#define read_uint8(s) ((uint8_t)ios_getc((s))) +#define write_int8(s, n) write_uint8((s), (n)) +#define read_int8(s) read_uint8((s)) -static inline void write_int8(ios_t *s, int8_t n) JL_NOTSAFEPOINT -{ - ios_putc(n, s); -} - -static inline int8_t read_int8(ios_t *s) JL_NOTSAFEPOINT -{ - return (int8_t)ios_getc(s); -} +/* read and write in host byte order */ static inline void write_int32(ios_t *s, int32_t i) JL_NOTSAFEPOINT {