From 5c48f617d99f6d4788bed5fb6d52a31de7c534ae Mon Sep 17 00:00:00 2001 From: midipix Date: Sat, 4 Feb 2017 17:42:53 -0500 Subject: internals: added little endian object generation helper functions. --- project/headers.mk | 1 + src/internal/mdso_object_impl.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/internal/mdso_object_impl.h diff --git a/project/headers.mk b/project/headers.mk index 7c5de62..7fb8763 100644 --- a/project/headers.mk +++ b/project/headers.mk @@ -12,5 +12,6 @@ INTERNAL_HEADERS = \ $(PROJECT_DIR)/src/internal/perk/perk_structs.h \ $(PROJECT_DIR)/src/internal/$(PACKAGE)_driver_impl.h \ $(PROJECT_DIR)/src/internal/$(PACKAGE)_errinfo_impl.h \ + $(PROJECT_DIR)/src/internal/$(PACKAGE)_object_impl.h \ ALL_HEADERS = $(API_HEADERS) $(INTERNAL_HEADERS) diff --git a/src/internal/mdso_object_impl.h b/src/internal/mdso_object_impl.h new file mode 100644 index 0000000..b329ef9 --- /dev/null +++ b/src/internal/mdso_object_impl.h @@ -0,0 +1,33 @@ +/****************************************************************/ +/* mdso: midipix dso scavenger */ +/* Copyright (C) 2015--2017 Z. Gilboa */ +/* Released under GPLv2 and GPLv3; see COPYING.MDSO. */ +/****************************************************************/ + +#include + +static inline void mdso_obj_write_short(unsigned char * ch, uint16_t val) +{ + ch[0] = val; + ch[1] = val >> 8; +} + +static inline void mdso_obj_write_long(unsigned char * ch, uint32_t val) +{ + ch[0] = val; + ch[1] = val >> 8; + ch[2] = val >> 16; + ch[3] = val >> 24; +} + +static inline void mdso_obj_write_quad(unsigned char * ch, uint64_t val) +{ + ch[0] = val; + ch[1] = val >> 8; + ch[2] = val >> 16; + ch[3] = val >> 24; + ch[4] = val >> 32; + ch[5] = val >> 40; + ch[6] = val >> 48; + ch[7] = val >> 56; +} -- cgit v1.2.3