macros: underflow, overflow, wombling free....

I can see this happening elsewhere, we'll need to use these in
other parts where struct members are of varying signage...
This commit is contained in:
Alastair Poole 2020-07-09 20:23:14 +01:00
parent a46f2718ca
commit 8f2a25ccfb
2 changed files with 14 additions and 9 deletions

View File

@ -62,6 +62,7 @@
#endif #endif
#include "machine.h" #include "machine.h"
#include "macros.h"
#if defined(__OpenBSD__) #if defined(__OpenBSD__)
# define CPU_STATES 6 # define CPU_STATES 6
@ -69,15 +70,6 @@
# define CPU_STATES 5 # define CPU_STATES 5
#endif #endif
#define U64(n) (uint64_t) n
#define I64(n) (int64_t) n
#define U32(n) (uint32_t) n
#define I32(n) (int32_t) n
#define U16(n) (uint16_t) n
#define I16(n) (int16_t) n
#define U8(n) (uint8_t) n
#define I8(n) (int8_t) n
#if defined(__linux__) #if defined(__linux__)
static char * static char *
file_contents(const char *path) file_contents(const char *path)

13
src/bin/system/macros.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef __MACROS_H__
#define __MACROS_H__
#define U64(n) (uint64_t) n
#define I64(n) (int64_t) n
#define U32(n) (uint32_t) n
#define I32(n) (int32_t) n
#define U16(n) (uint16_t) n
#define I16(n) (int16_t) n
#define U8(n) (uint8_t) n
#define I8(n) (int8_t) n
#endif