11
13
#include <inttypes.h>
12
14
#include <assert.h>
15
19
* @defgroup Definitions Definitions
16
20
* @addtogroup Definitions
22
* For interoperabibily with C++ we have to have this.
24
* Put at the beginning and end of headerfiles.
22
* @brief Declarations of the types and macros that are used extensively
28
* For interoperability with C++ we have to have this.
30
* Put at the beginning of header files.
37
* Put at end of header files.
27
42
#define S_BEGIN_DECLS extern "C" {
28
43
#define S_END_DECLS }
31
46
#define S_END_DECLS
32
47
#endif /*__cplusplus*/
51
/* ***************************** GENERIC MACROS ***************************** */
58
* Mark function as deprecated.
62
* Supress compiler warning that variable is unused.
66
* Macro to align memory to 8 bit.
70
* Macro to align memory to 16 bit.
34
72
#if defined(__GNUC__)
35
73
#define S_DEPRECATED __attribute__((deprecated))
36
74
#define S_UNUSED __attribute__((unused))
49
87
#define S_ALIGNED_16
92
* The stupid atomic value.
52
94
#if __STDC_NO_ATOMICS__
53
95
#define __S_ATOMIC__ volatile
55
97
#define __S_ATOMIC__ __Atomic
102
* Mark function as exported. This makes the function available from outside a
103
* library on some platforms.
109
* Mark function as hidden. This hides a function so it is not exposed to the
110
* outside of the library.
59
116
* Copied from: https://gcc.gnu.org/wiki/Visibility .. with modifications.
93
* FALSE has the absolute value of 0, it is used in as a way to represet a false
94
* value. A "not" value.
144
* FALSE has the absolute value of 0, it is used in as a way to represent a
145
* false value. A "not" value.
99
* TRUE represets a value that is true. A value that is "not false".
152
* TRUE represents a value that is true. A value that is "not false".
101
156
#define TRUE !FALSE
159
* Stupid macro to create a hash of a pointer.
103
161
#define S_POINTER_TO_HASH_T(p) ((hash_t)(unsigned long) p)
106
164
* @defgroup Types Type declarations
107
165
* @addtogroup Types
167
* @brief The typedefs that make up the types that are used in libssts.
139
199
* uchar is the representation for use with wide unicode strings and what not.
141
* The rationell for using char32_t as the unicode wide char instead of
142
* wchar_t is that wchar_t's size depends on the imprementation, compiler,
201
* The rationale for using char32_t as the unicode wide char instead of
202
* wchar_t is that wchar_t's size depends on the implementation, compiler,
145
205
* To make the wide strings actually work as they should, even over network or
151
211
typedef char32_t suchar;
154
* To prevent intercomatability problems we def long as int64_t.
214
* To prevent interchangeability problems we def long as int64_t.
156
216
typedef int64_t slong;
159
* To prevent intercomatability problems we def int as int32_t.
219
* To prevent interchangeability problems we def int as int32_t.
161
221
typedef int32_t sint;
164
* To prevent intercomatability problems we def short as int16_t.
224
* To prevent interchangeability problems we def short as int16_t.
166
226
typedef int16_t sshort;
169
* To prevent intercomatability problems we def byte as int8_t.
229
* To prevent interchangeability problems we def byte as int8_t.
171
231
typedef int8_t sbyte;
175
235
************************************* */
178
* To prevent intercomatability problems we def ulong as uint64_t.
238
* To prevent interchangeability problems we def ulong as uint64_t.
180
240
typedef uint64_t sulong;
183
* To prevent intercomatability problems we def uint as uint32_t.
243
* To prevent interchangeability problems we def uint as uint32_t.
185
245
typedef uint32_t suint;
188
* To prevent intercomatability problems we def ushort as uint16_t.
248
* To prevent interchangeability problems we def ushort as uint16_t.
190
250
typedef uint16_t sushort;
193
* To prevent intercomatability problems we def ubyte as uint8_t.
253
* To prevent interchangeability problems we def ubyte as uint8_t.
195
255
typedef uint8_t subyte;
229
S_TYPE_UCHAR, /**< char32_t/uchar */
235
S_TYPE_WSTRING, /**< Plarform specific wchar_t */
236
S_TYPE_USTRING, /**< char32_t String.*/
283
S_TYPE_NONE = 0, /**< Not a type. */
284
S_TYPE_INT, /**< @ref sint */
285
S_TYPE_LONG, /**< @ref slong */
286
S_TYPE_SHORT, /**< @ref sshort */
287
S_TYPE_CHAR, /**< @ref schar */
288
S_TYPE_WCHAR, /**< @deprecated wide char (wchar_t) */
289
S_TYPE_UCHAR, /**< @ref suchar */
290
S_TYPE_UINT, /**< @ref suint */
291
S_TYPE_ULONG, /**< @ref sulong */
292
S_TYPE_USHORT, /**< @ref sushort */
293
S_TYPE_BOOLEAN, /**< @ref sboolean */
294
S_TYPE_STRING, /**< a string of @ref schar s */
295
S_TYPE_WSTRING, /**< @deprecated Platform specific wchar_t string */
296
S_TYPE_USTRING, /**< a string of @ref suchar s */
297
S_TYPE_UNUSED_0, /**< */
298
S_TYPE_UNUSED_1, /**< */
299
S_TYPE_UNUSED_2, /**< */
300
S_TYPE_POINTER, /**< @ref spointer */
301
S_TYPE_OBJECT, /**< @ref SObject */
302
S_TYPE_INVALID /** Invalid type. */
281
341
s_type_get_name (SType k);
283
/* Colour definitions for console prints */
284
#define RESET "\033[0m"
285
#define BLACK "\033[30m" /* Black */
286
#define RED "\033[31m" /* Red */
287
#define GREEN "\033[32m" /* Green */
288
#define YELLOW "\033[33m" /* Yellow */
289
#define BLUE "\033[34m" /* Blue */
290
#define MAGENTA "\033[35m" /* Magenta */
291
#define CYAN "\033[36m" /* Cyan */
292
#define WHITE "\033[37m" /* White */
293
#define BOLDBLACK "\033[1m\033[30m" /* Bold Black */
294
#define BOLDRED "\033[1m\033[31m" /* Bold Red */
295
#define BOLDGREEN "\033[1m\033[32m" /* Bold Green */
296
#define BOLDYELLOW "\033[1m\033[33m" /* Bold Yellow */
297
#define BOLDBLUE "\033[1m\033[34m" /* Bold Blue */
298
#define BOLDMAGENTA "\033[1m\033[35m" /* Bold Magenta */
299
#define BOLDCYAN "\033[1m\033[36m" /* Bold Cyan */
300
#define BOLDWHITE "\033[1m\033[37m" /* Bold White */
344
* @defgroup Colours Colours
345
* @addtogroup Colours
347
* @brief Printing colours for terminal/console printing.
349
* Here is a list of macros for use when printing to the console.
350
* @ref S_COLOR_RESET is used to reset the colours back to their original
353
* An example on how to use them can be found in utils.h:
355
#define s_err_print(p, ...)\
356
fprintf (stderr, S_COLOR_RED "[ERR] " p S_COLOR_RESET "\n", ##__VA_ARGS__)
360
#define S_COLOR_RESET "\033[0m" /**< Reset */
361
#define S_COLOR_BLACK "\033[30m" /**< Black */
362
#define S_COLOR_RED "\033[31m" /**< Red */
363
#define S_COLOR_GREEN "\033[32m" /**< Green */
364
#define S_COLOR_YELLOW "\033[33m" /**< Yellow */
365
#define S_COLOR_BLUE "\033[34m" /**< Blue */
366
#define S_COLOR_MAGENTA "\033[35m" /**< Magenta */
367
#define S_COLOR_CYAN "\033[36m" /**< Cyan */
368
#define S_COLOR_WHITE "\033[37m" /**< White */
369
#define S_COLOR_BOLDBLACK "\033[1m\033[30m" /**< Bold Black */
370
#define S_COLOR_BOLDRED "\033[1m\033[31m" /**< Bold Red */
371
#define S_COLOR_BOLDGREEN "\033[1m\033[32m" /**< Bold Green */
372
#define S_COLOR_BOLDYELLOW "\033[1m\033[33m" /**< Bold Yellow */
373
#define S_COLOR_BOLDBLUE "\033[1m\033[34m" /**< Bold Blue */
374
#define S_COLOR_BOLDMAGENTA "\033[1m\033[35m" /**< Bold Magenta */
375
#define S_COLOR_BOLDCYAN "\033[1m\033[36m" /**< Bold Cyan */
376
#define S_COLOR_BOLDWHITE "\033[1m\033[37m" /**< Bold White */
384
/* We include this last so it does not create any problems.
385
* We want people only to have to include defs.h and not mm.h anyway.
387
* It should be considered a continuation of defs.h.