Skip to content

Instantly share code, notes, and snippets.

@skull-squadron
Last active May 10, 2024 00:30
Show Gist options
  • Save skull-squadron/cd089675a6088b0b8482c005a0e3897a to your computer and use it in GitHub Desktop.
Save skull-squadron/cd089675a6088b0b8482c005a0e3897a to your computer and use it in GitHub Desktop.
C portable C99 byte deser of sized integer types (instead of BSD socket network functions)

Portable network-order deser for C sized integral types

Features

  • Zero dependencies
  • Zero heap allocations
  • Unrolled and inlineable
  • Sensibly debuggable using line-oriented breakpoints
  • Buffer-oriented functions usable in embedded and kernel development
  • Optional 128-bit integer support where __int128 and unsigned __int128 are available

Anti-features

  • Unspecified integer types or detection
  • Floating point or complex types
  • bool
  • Byte-width types

Examples

Buffer-oriented functions

#include "deser_buf.h"

char buf[4];
pack_u32(buf, 12345678);

uint32_t x = unpack_u32(buf);
/* x: 12345678 */

FILE-oriented functions

#include "deser_file.h"

char buf[8];
FILE *f = fopen("/tmp/example.dat", "wb+");
if (!f) abort();
if (write_i64(f, -1) < 0) abort();
rewind(f);
uint64_t x;
if (read_i64(f, &x) < 0) abort();
/* x: -1 */

Pack and unpack a structure

Example
#include "deser_buf.h"

typedef struct {
  int64_t w;
  uint32_t x;
  int16_t y;
  unsigned char z;
} foo_t;

#define FOO_T_PACKED_SIZE (8 + 4 + 2 + 1)

void pack_foo(const foo_t *f, void *dst) {
  unsigned char *out = (unsigned char *)dst;
  
  pack_u64(out, f->w);
  out += sizeof(f->w);
  
  pack_u32(out, f->x);
  out += sizeof(f->x);
  
  pack_u16(out, f->y);
  out += sizeof(f->y);
  
  *out = f->z;
}

void unpack_foo(foo_t *f, const void *src) {
  const unsigned char *in = (const unsigned char *)src;
  
  unpack_u64(in, &f->w);
  in += sizeof(f->w);
  
  unpack_u32(in, &f->x);
  in += sizeof(f->x);
  
  unpack_u16(in, &f->y);
  in += sizeof(f->y);
  
  f->z = *in;
}

License

MIT

/* License: Apache 2.0 */
/* File: deser_buf.c */
#include "deser_buf.h"
#ifdef __SIZEOF_INT128__
void pack_u128(void *dst, unsigned __int128 x) {
unsigned char *out = (unsigned char *)dst;
*out++ = (x >> 120) & 0xFF;
*out++ = (x >> 112) & 0xFF;
*out++ = (x >> 104) & 0xFF;
*out++ = (x >> 96) & 0xFF;
*out++ = (x >> 88) & 0xFF;
*out++ = (x >> 80) & 0xFF;
*out++ = (x >> 72) & 0xFF;
*out++ = (x >> 64) & 0xFF;
*out++ = (x >> 56) & 0xFF;
*out++ = (x >> 48) & 0xFF;
*out++ = (x >> 40) & 0xFF;
*out++ = (x >> 32) & 0xFF;
*out++ = (x >> 24) & 0xFF;
*out++ = (x >> 16) & 0xFF;
*out++ = (x >> 8) & 0xFF;
*out = x & 0xFF;
}
void pack_i128(void *dst, __int128 x) {
unsigned char *out = (unsigned char *)dst;
*out++ = (x >> 120) & 0xFF;
*out++ = (x >> 112) & 0xFF;
*out++ = (x >> 104) & 0xFF;
*out++ = (x >> 96) & 0xFF;
*out++ = (x >> 88) & 0xFF;
*out++ = (x >> 80) & 0xFF;
*out++ = (x >> 72) & 0xFF;
*out++ = (x >> 64) & 0xFF;
*out++ = (x >> 56) & 0xFF;
*out++ = (x >> 48) & 0xFF;
*out++ = (x >> 40) & 0xFF;
*out++ = (x >> 32) & 0xFF;
*out++ = (x >> 24) & 0xFF;
*out++ = (x >> 16) & 0xFF;
*out++ = (x >> 8) & 0xFF;
*out = x & 0xFF;
}
unsigned __int128 unpack_u128(const void *src) {
const unsigned char *in = (const unsigned char *)src;
unsigned __int128 r = (unsigned __int128)(*in++) << 120;
r |= (unsigned __int128)(*in++) << 112;
r |= (unsigned __int128)(*in++) << 104;
r |= (unsigned __int128)(*in++) << 96;
r |= (unsigned __int128)(*in++) << 88;
r |= (unsigned __int128)(*in++) << 80;
r |= (unsigned __int128)(*in++) << 72;
r |= (unsigned __int128)(*in++) << 64;
r |= (unsigned __int128)(*in++) << 56;
r |= (unsigned __int128)(*in++) << 48;
r |= (unsigned __int128)(*in++) << 40;
r |= (unsigned __int128)(*in++) << 32;
r |= (unsigned __int128)(*in++) << 24;
r |= (unsigned __int128)(*in++) << 16;
r |= (unsigned __int128)(*in++) << 8;
r |= (unsigned __int128)(*in);
return (r);
}
#endif /* __SIZEOF_INT128__ */
void pack_u64(void *dst, uint64_t x) {
unsigned char *out = (unsigned char *)dst;
*out++ = (x >> 56) & 0xFF;
*out++ = (x >> 48) & 0xFF;
*out++ = (x >> 40) & 0xFF;
*out++ = (x >> 32) & 0xFF;
*out++ = (x >> 24) & 0xFF;
*out++ = (x >> 16) & 0xFF;
*out++ = (x >> 8) & 0xFF;
*out = x & 0xFF;
}
void pack_i64(void *dst, int64_t x) {
unsigned char *out = (unsigned char *)dst;
*out++ = (x >> 56) & 0xFF;
*out++ = (x >> 48) & 0xFF;
*out++ = (x >> 40) & 0xFF;
*out++ = (x >> 32) & 0xFF;
*out++ = (x >> 24) & 0xFF;
*out++ = (x >> 16) & 0xFF;
*out++ = (x >> 8) & 0xFF;
*out = x & 0xFF;
}
void pack_u32(void *dst, uint32_t x) {
unsigned char *out = (unsigned char *)dst;
*out++ = (x >> 24) & 0xFF;
*out++ = (x >> 16) & 0xFF;
*out++ = (x >> 8) & 0xFF;
*out = x & 0xFF;
}
void pack_i32(void *dst, int32_t x) {
unsigned char *out = (unsigned char *)dst;
*out++ = (x >> 24) & 0xFF;
*out++ = (x >> 16) & 0xFF;
*out++ = (x >> 8) & 0xFF;
*out = x & 0xFF;
}
void pack_u16(void *dst, uint16_t x) {
unsigned char *out = (unsigned char *)dst;
*out++ = (x >> 8) & 0xFF;
*out = x & 0xFF;
}
void pack_i16(void *dst, int16_t x) {
unsigned char *out = (unsigned char *)dst;
*out++ = (x >> 8) & 0xFF;
*out = x & 0xFF;
}
#ifdef __SIZEOF_INT128__
unsigned __int128 unpack_u128(const void *src) {
const unsigned char *in = (const unsigned char *)src;
unsigned __int128 r = (unsigned __int128)(*in++) << 120;
r |= (unsigned __int128)(*in++) << 112;
r |= (unsigned __int128)(*in++) << 104;
r |= (unsigned __int128)(*in++) << 96;
r |= (unsigned __int128)(*in++) << 88;
r |= (unsigned __int128)(*in++) << 80;
r |= (unsigned __int128)(*in++) << 72;
r |= (unsigned __int128)(*in++) << 64;
r |= (unsigned __int128)(*in++) << 56;
r |= (unsigned __int128)(*in++) << 48;
r |= (unsigned __int128)(*in++) << 40;
r |= (unsigned __int128)(*in++) << 32;
r |= (unsigned __int128)(*in++) << 24;
r |= (unsigned __int128)(*in++) << 16;
r |= (unsigned __int128)(*in++) << 8;
r |= (unsigned __int128)(*in);
return (r);
}
__int128 unpack_i128(const void *src) {
const char *in = (const char *)src;
__int128 r = (__int128)(*in++) << 120;
r |= (__int128)(*in++) << 112;
r |= (__int128)(*in++) << 104;
r |= (__int128)(*in++) << 96;
r |= (__int128)(*in++) << 88;
r |= (__int128)(*in++) << 80;
r |= (__int128)(*in++) << 72;
r |= (__int128)(*in++) << 64;
r |= (__int128)(*in++) << 56;
r |= (__int128)(*in++) << 48;
r |= (__int128)(*in++) << 40;
r |= (__int128)(*in++) << 32;
r |= (__int128)(*in++) << 24;
r |= (__int128)(*in++) << 16;
r |= (__int128)(*in++) << 8;
r |= (__int128)(*in);
return (r);
}
#endif /* __SIZEOF_INT128__ */
uint64_t unpack_u64(const void *src) {
const unsigned char *in = (const unsigned char *)src;
uint64_t r = (uint64_t)(*in++) << 56;
r |= (uint64_t)(*in++) << 48;
r |= (uint64_t)(*in++) << 40;
r |= (uint64_t)(*in++) << 32;
r |= (uint64_t)(*in++) << 24;
r |= (uint64_t)(*in++) << 16;
r |= (uint64_t)(*in++) << 8;
r |= (uint64_t)(*in);
return (r)
}
int64_t unpack_i64(const void *src) {
const unsigned char *in = (const unsigned char *)src;
int64_t r = (int64_t)(*in++) << 56;
r |= (int64_t)(*in++) << 48;
r |= (int64_t)(*in++) << 40;
r |= (int64_t)(*in++) << 32;
r |= (int64_t)(*in++) << 24;
r |= (int64_t)(*in++) << 16;
r |= (int64_t)(*in++) << 8;
r |= (int64_t)(*in);
return (r);
}
uint32_t unpack_u32(const void *src) {
const unsigned char *in = (const unsigned char *)src;
uint32_t r = (uint32_t)(*in++) << 24;
r |= (uint32_t)(*in++) << 16;
r |= (uint32_t)(*in++) << 8;
r |= (uint32_t)(*in);
return (r);
}
int32_t unpack_i32(const void *src) {
const unsigned char *in = (const unsigned char *)src;
int32_t r = (int32_t)(*in++) << 24;
r |= (int32_t)(*in++) << 16;
r |= (int32_t)(*in++) << 8;
r |= (int32_t)(*in);
return (r);
}
uint16_t unpack_u16(const void *src) {
const unsigned char *in = (const unsigned char *)src;
uint16_t r = (uint16_t)(*in++) << 8;
r |= (uint16_t)(*in);
return (r);
}
int16_t unpack_i16(const void *src) {
const unsigned char *in = (const unsigned char *)src;
int16_t r = (int16_t)(*in++) << 8;
r |= (int16_t)(*in);
return (r);
}
/* License: Apache 2.0 */
/* File: deser_buf.h */
#ifndef DESER_BUF_H
#define DESER_BUF_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __SIZEOF_INT128__
unsigned __int128 unpack_u128(const void *src);
__int128 unpack_i128(const void *src);
#endif
uint64_t unpack_u64(const void *src);
int64_t unpack_i64(const void *src);
uint32_t unpack_u32(const void *src);
int32_t unpack_i32(const void *src);
uint16_t unpack_u16(const void *src);
int16_t unpack_i16(const void *src);
#ifdef __SIZEOF_INT128__
void pack_u128(void *dst, unsigned __int128 x);
void pack_i128(void *dst, __int128 x);
#endif
void pack_u64(void *dst, uint64_t x);
void pack_i64(void *dst, int64_t x);
void pack_u32(void *dst, uint32_t x);
void pack_i32(void *dst, int32_t x);
void pack_u16(void *dst, uint16_t x);
void pack_i16(void *dst, int16_t x);
#ifdef __cplusplus
}
#endif
#endif /* DESER_BUF_H */
/* License: Apache 2.0 */
/* File: deser_file.c */
#include "deser_file.h"
#ifdef __SIZEOF_INT128__
int read_u128(FILE *f, unsigned __int128 *x) {
unsigned __int128 r;
int cur = fgetc(f);
if (cur < 0) goto error;
r = (unsigned __int128)cur << 120;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (unsigned __int128)cur << 112;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (unsigned __int128)cur << 102;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (unsigned __int128)cur << 96;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (unsigned __int128)cur << 88;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (unsigned __int128)cur << 80;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (unsigned __int128)cur << 72;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (unsigned __int128)cur << 64;
if (cur < 0) goto error;
r |= (unsigned __int128)cur << 56;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (unsigned __int128)cur << 48;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (unsigned __int128)cur << 40;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (unsigned __int128)cur << 32;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (unsigned __int128)cur << 24;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (unsigned __int128)cur << 16;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (unsigned __int128)cur << 8;
cur = fgetc(f);
if (cur < 0) goto error;
*x = r | (unsigned __int128)cur;
return (0);
error:
return (cur);
}
int read_i128(FILE *f, __int128 *x) {
__int128 r;
int cur = fgetc(f);
if (cur < 0) goto error;
r = (__int128)cur << 120;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (__int128)cur << 112;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (__int128)cur << 102;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (__int128)cur << 96;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (__int128)cur << 88;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (__int128)cur << 80;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (__int128)cur << 72;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (__int128)cur << 64;
if (cur < 0) goto error;
r |= (__int128)cur << 56;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (__int128)cur << 48;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (__int128)cur << 40;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (__int128)cur << 32;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (__int128)cur << 24;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (__int128)cur << 16;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (__int128)cur << 8;
cur = fgetc(f);
if (cur < 0) goto error;
*x = r | (__int128)cur;
return (0);
error:
return (cur);
}
#endif /* __SIZEOF_INT128__ */
int read_u64(FILE *f, uint64_t *x) {
uint64_t r;
int cur = fgetc(f);
if (cur < 0) goto error;
r = (uint64_t)cur << 56;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (uint64_t)cur << 48;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (uint64_t)cur << 40;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (uint64_t)cur << 32;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (uint64_t)cur << 24;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (uint64_t)cur << 16;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (uint64_t)cur << 8;
cur = fgetc(f);
if (cur < 0) goto error;
*x = r | (uint64_t)cur;
return (0);
error:
return (cur);
}
int read_i64(FILE *f, int64_t *x) {
int64_t r;
int cur = fgetc(f);
if (cur < 0) goto error;
r = (int64_t)cur << 56;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (int64_t)cur << 48;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (int64_t)cur << 40;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (int64_t)cur << 32;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (int64_t)cur << 24;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (int64_t)cur << 16;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (int64_t)cur << 8;
cur = fgetc(f);
if (cur < 0) goto error;
*x = r | (int64_t)cur;
return (0);
error:
return (cur);
}
int read_u32(FILE *f, uint32_t *x) {
uint32_t r;
int cur = fgetc(f);
if (cur < 0) goto error;
r = (uint32_t)cur << 24;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (uint32_t)cur << 16;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (uint32_t)cur << 8;
cur = fgetc(f);
if (cur < 0) goto error;
*x = r | (uint32_t)cur;
return (0);
error:
return (cur);
}
int read_i32(FILE *f, int32_t *x) {
int32_t r;
int cur = fgetc(f);
if (cur < 0) goto error;
r = (int32_t)cur << 24;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (int32_t)cur << 16;
cur = fgetc(f);
if (cur < 0) goto error;
r |= (int32_t)cur << 8;
cur = fgetc(f);
if (cur < 0) goto error;
*x = r | (int32_t)cur;
return (0);
error:
return (cur);
}
int read_u16(FILE *f, uint16_t *x) {
uint16_t r;
int cur = fgetc(f);
if (cur < 0) goto error;
r = (uint16_t)cur << 8;
cur = fgetc(f);
if (cur < 0) goto error;
*x = r | (uint16_t)cur;
return (0);
error:
return (cur);
}
int read_i16(FILE *f, int16_t *x) {
int16_t r;
int cur = fgetc(f);
if (cur < 0) goto error;
r = (int16_t)cur << 8;
cur = fgetc(f);
if (cur < 0) goto error;
*x = r | (int16_t)cur;
return (0);
error:
return (cur);
}
int write_u64(FILE *f, uint64_t x) {
int err = fputc((x >> 56) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 48) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 40) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 32) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 24) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 16) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 8) & 0xFF, f);
if (err) goto error;
err = fputc(x & 0xFF, f);
if (err) goto error;
return (0);
error:
return (err);
}
#ifdef __SIZEOF_INT128__
int write_u128(FILE *f, unsigned __int128 x) {
int err = fputc((x >> 120) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 112) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 104) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 96) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 88) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 80) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 72) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 64) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 56) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 48) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 40) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 32) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 24) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 16) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 8) & 0xFF, f);
if (err) goto error;
err = fputc(x & 0xFF, f);
if (err) goto error;
return (0);
error:
return (err);
}
int write_i128(FILE *f, __int128 x) {
int err = fputc((x >> 120) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 112) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 104) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 96) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 88) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 80) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 72) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 64) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 56) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 48) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 40) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 32) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 24) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 16) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 8) & 0xFF, f);
if (err) goto error;
err = fputc(x & 0xFF, f);
if (err) goto error;
return (0);
error:
return (err);
}
#endif /* __SIZEOF_INT128__ */
int write_i64(FILE *f, int64_t x) {
int err = fputc((x >> 56) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 48) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 40) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 32) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 24) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 16) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 8) & 0xFF, f);
if (err) goto error;
err = fputc(x & 0xFF, f);
if (err) goto error;
return (0);
error:
return (err);
}
int write_u32(FILE *f, uint32_t x) {
int err = fputc((x >> 24) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 16) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 8) & 0xFF, f);
if (err) goto error;
err = fputc(x & 0xFF, f);
if (err) goto error;
return (0);
error:
return (err);
}
int write_i32(FILE *f, int32_t x) {
int err = fputc((x >> 24) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 16) & 0xFF, f);
if (err) goto error;
err = fputc((x >> 8) & 0xFF, f);
if (err) goto error;
err = fputc(x & 0xFF, f);
if (err) goto error;
return (0);
error:
return (err);
}
int write_u16(FILE *f, uint16_t x) {
int err = fputc((x >> 8) & 0xFF, f);
if (err) goto error;
err = fputc(x & 0xFF, f);
if (err) goto error;
return (0);
error:
return (err);
}
int write_i16(FILE *f, int16_t x) {
int err = fputc((x >> 8) & 0xFF, f);
if (err) goto error;
err = fputc(x & 0xFF, f);
if (err) goto error;
return (0);
error:
return (err);
}
/* License: Apache 2.0 */
/* File: deser_file.h */
#ifndef DESER_FILE_H
#define DESER_FILE_H
#include <stdint.h>
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __SIZEOF_INT128__
int read_u128(FILE *f, unsigned __int128 *x);
int read_i128(FILE *f, __int128 *x);
#endif
int read_u64(FILE *f, uint64_t *x);
int read_i64(FILE *f, int64_t *x);
int read_u32(FILE *f, uint32_t *x);
int read_i32(FILE *f, int32_t *x);
int read_u16(FILE *f, uint16_t *x);
int read_i16(FILE *f, int16_t *x);
#ifdef __SIZEOF_INT128__
int write_u128(FILE *f, unsigned __int128 x);
int write_i128(FILE *f, __int128 x);
#endif
int write_u64(FILE *f, uint64_t x);
int write_i64(FILE *f, int64_t x);
int write_u32(FILE *f, uint32_t x);
int write_i32(FILE *f, int32_t x);
int write_u16(FILE *f, uint16_t x);
int write_i16(FILE *f, int16_t x);
#ifdef __cplusplus
}
#endif
#endif /* DESER_FILE_H */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment