architecture.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Otto-von-Guericke-Universit├Ąt Magdeburg
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser General
5  * Public License v2.1. See the file LICENSE in the top level directory for more
6  * details.
7  */
8 
24 #ifndef ARCHITECTURE_H
25 #define ARCHITECTURE_H
26 
27 #include <stdint.h>
28 
29 #include "architecture_arch.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /* Provide doxygen doc centrally, instead of in every architecture_arch.h */
36 #ifdef DOXYGEN
37 
42 #define ARCHITECTURE_WORD_BITS <NUM>
43 
48 #define ARCHITECTURE_WORD_BYTES <NUM>
49 
55 typedef uint<num>_t uword_t;
65 typedef int<num>_t sword_t;
66 #elif (ARCHITECTURE_WORD_BITS == 8)
67 #define ARCHITECTURE_WORD_BYTES (1U)
68 typedef uint8_t uword_t;
69 typedef int8_t sword_t;
70 #elif (ARCHITECTURE_WORD_BITS == 16)
71 #define ARCHITECTURE_WORD_BYTES (2U)
72 typedef uint16_t uword_t;
73 typedef int16_t sword_t;
74 #elif (ARCHITECTURE_WORD_BITS == 32)
75 #define ARCHITECTURE_WORD_BYTES (4U)
76 typedef uint32_t uword_t;
77 typedef int32_t sword_t;
78 #else
79 #error "Unsupported word size (check ARCHITECTURE_WORD_BITS in architecture_arch.h)"
80 #endif
81 
91 #define WORD_ALIGNED __attribute__((aligned(ARCHITECTURE_WORD_BYTES)))
92 
96 #define UWORD_MIN 0
97 
101 #define UWORD_MAX ((1ULL << ARCHITECTURE_WORD_BITS) - 1)
102 
106 #define SWORD_MIN (-(1LL << (ARCHITECTURE_WORD_BITS - 1)))
107 
111 #define SWORD_MAX ((1LL << (ARCHITECTURE_WORD_BITS - 1)) - 1)
112 
113 #ifdef __cplusplus
114 }
115 #endif
116 
117 #endif /* ARCHITECTURE_H */
118 
int< num > _t sword_t
Word sized signed integer.
Definition: architecture.h:65
uint< num > _t uword_t
Word sized unsigned integer.
Definition: architecture.h:55