Skip to content

Commit

Permalink
Mark as inline functions implemented in src/serialize.h (#44739)
Browse files Browse the repository at this point in the history
* Mark as `inline` functions implemented in `src/serialize.h`

Also, remove duplicate definitions from `src/staticdata.c` and include
`serialize.h` in there.
  • Loading branch information
giordano authored Apr 1, 2022
1 parent 05340a8 commit 081ae64
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 30 deletions.
22 changes: 11 additions & 11 deletions src/serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
20 changes: 1 addition & 19 deletions src/staticdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <dlfcn.h>
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 081ae64

Please sign in to comment.