21 lines
561 B
C
21 lines
561 B
C
#ifndef _UTILS_H
|
|
#define _UTILS_H
|
|
|
|
#include <stdio.h>
|
|
|
|
#define ARRAY_SIZE(A) (sizeof(A) / sizeof(A[0]))
|
|
|
|
int file_write(const void *ptr, size_t size, size_t nb, FILE *file);
|
|
|
|
#define file_write_stack_array(A, F) file_write(A, sizeof(A[0]), sizeof(A) / sizeof(A[0]), F)
|
|
|
|
#ifdef BIGENDIAN
|
|
#include <endian.h>
|
|
#define target_host_16b(V) (uint16_t){ htobe16(*(uint16_t *)&V) }
|
|
#define target_host_32b(V) (uint32_t){ htobe32(*(uint32_t *)&V) }
|
|
#else
|
|
#define target_host_16b(V) (*(uint16_t *)&V)
|
|
#define target_host_32b(V) (*(uint32_t *)&V)
|
|
#endif
|
|
|
|
#endif // _UTILS_H
|