diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2010-11-10 17:10:07 +0100 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2010-11-10 17:10:07 +0100 |
commit | 3cb7c05906b8eb8e884013b441f352256fded011 (patch) | |
tree | 4061936126e43746ed5d6157ead0eb778b256beb /nios2sim-ng.h | |
parent | 32f507ce5f66dd9c89a45854688f46bde33c5e3d (diff) |
First bunch of rework, stil work in progress
Diffstat (limited to 'nios2sim-ng.h')
-rw-r--r-- | nios2sim-ng.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/nios2sim-ng.h b/nios2sim-ng.h new file mode 100644 index 0000000..7a3d711 --- /dev/null +++ b/nios2sim-ng.h @@ -0,0 +1,47 @@ +/* + * + */ + +#ifndef _NIOS2SIM_NG_H_ +#define _NIOS2SIM_NG_H_ + +#include <stdlib.h> +#include <stdint.h> + +#include "compiler.h" + +#define __round_mask(x, y) ((__typeof__(x))((y) - 1)) +#define round_up(x, y) ((((x) - 1) | __round_mask(x, y)) + 1) + +#define err(fmt, args...) fprintf(stderr, "Error: " fmt, ##args) +#define warn(fmt, args...) fprintf(stderr, "Warning: " fmt, ##args) +#define info(fmt, args...) fprintf(stdout, fmt, ##args) +#ifdef DEBUG +# define dbg(fmt, args...) fprintf(stdout, fmt, ##args) +#else +# define dbg(fmt, args...) +#endif + +static inline size_t size_scale(size_t size) +{ + if (size > 1024 * 1024) + size /= 1024 * 1024; + else if (size > 1024) + size /= 1024; + + return size; +} + +static inline char *size_postfix(size_t size) +{ + char *ret = ""; + + if (size > 1024 * 1024) + ret = "M"; + else if (size > 1024) + ret = "K"; + + return ret; +} + +#endif /* _NIOS2SIM_NG_H_ */ |