-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdefines.h
83 lines (75 loc) · 1.76 KB
/
defines.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* Compile-time configuration for ramfuck.
*
* Override defaults by modifying this file or using `-D` compile-time flags.
*/
#ifndef DEFINES_H_INCLUDED
#define DEFINES_H_INCLUDED
/* Define ADDR_BITS to specify the maximum address size in bits (32 or 64) */
#if 0
# define ADDR_BITS 64
#endif
/* Define NO_64BIT_VALUES to exclude s64/u64 value support */
#if 0
# define NO_64BIT_VALUES
#endif
/* Define NO_FLOAT_VALUES to exclude f32/f64 value support */
#if 0
# define NO_FLOAT_VALUES
#endif
/*
* Internal definitions and configuration sanity checking.
*/
#ifndef ADDR_BITS
# ifdef NO_64BIT_VALUES
# define ADDR_BITS 32
# else
# define ADDR_BITS 64
# endif
#elif ADDR_BITS == 64
# ifdef NO_64_BIT_VALUES
# error "ADDR_BITS=64 unsupported when NO_64BIT_VALUES is defined"
# endif
# define _LARGE_FILE 1
# define _LARGEFILE_SOURCE 1
# ifndef _FILE_OFFSET_BITS
# define _FILE_OFFSET_BITS 64
# endif
#elif ADDR_BITS != 32
# error "unsupported ADDR_BITS (expected 32 or 64)"
#endif
#include <inttypes.h>
#include <stdint.h>
#if ADDR_BITS == 32
typedef uint32_t addr_t;
# define ADDR_MAX UINT32_MAX
# define PRIaddr PRIx32
# define PRIaddru PRIu32
# define SCNaddr SCNx32
#elif ADDR_BITS == 64
typedef uint64_t addr_t;
# define ADDR_MAX UINT64_MAX
# define PRIaddr PRIx64
# define PRIaddru PRIu64
# define SCNaddr SCNx64
#endif
#ifdef NO_64BIT_VALUES
typedef int32_t smax_t;
typedef uint32_t umax_t;
# define PRIsmax PRId32
# define PRIumax PRIu32
# define PRIxmax PRIx32
# define SMAX_MIN INT32_MIN
# define SMAX_MAX INT32_MAX
# define UMAX_MAX UINT32_MAX
#else
typedef int64_t smax_t;
typedef uint64_t umax_t;
# define PRIsmax PRId64
# define PRIumax PRIu64
# define PRIxmax PRIx64
# define SMAX_MIN INT64_MIN
# define SMAX_MAX INT64_MAX
# define UMAX_MAX UINT64_MAX
#endif
#endif