1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Helper functions for cse_serger and cse_fpt */
4 #include <commonlib/endian.h>
6 #include "cse_helpers.h"
8 void write_member(struct buffer
*buff
, void *src
, size_t size
)
10 void *dst
= buffer_get(buff
);
14 write_le8(dst
, *(uint8_t *)src
);
17 write_le16(dst
, *(uint16_t *)src
);
20 write_le32(dst
, *(uint32_t *)src
);
23 write_le64(dst
, *(uint64_t *)src
);
26 memcpy(dst
, src
, size
);
30 buffer_seek(buff
, size
);
33 void read_member(struct buffer
*buff
, void *dst
, size_t size
)
35 const void *src
= buffer_get(buff
);
39 *(uint8_t *)dst
= read_le8(src
);
42 *(uint16_t *)dst
= read_le16(src
);
45 *(uint32_t *)dst
= read_le32(src
);
48 *(uint64_t *)dst
= read_le64(src
);
51 memcpy(dst
, src
, size
);
55 buffer_seek(buff
, size
);