This repository has been archived by the owner on Oct 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
base.h
57 lines (42 loc) · 1.66 KB
/
base.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
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
#define _LIBSEVEN_EXTERN_C extern "C" {
#define _LIBSEVEN_EXTERN_C_END }
#else
#define _LIBSEVEN_EXTERN_C
#define _LIBSEVEN_EXTERN_C_END
#endif
#define _LIBSEVEN_STR(s) #s
#define _LIBSEVEN_STR2(s) _LIBSEVEN_STR(s)
#define _LIBSEVEN_NORETURN __attribute__((__noreturn__))
#define _LIBSEVEN_ALIGN4 __attribute__((__aligned__(4)))
#define LIBSEVEN_VERSION_MAJOR 0
#define LIBSEVEN_VERSION_MINOR 17
#define LIBSEVEN_VERSION_PATCH 1
#define LIBSEVEN_VERSION \
_LIBSEVEN_STR2(LIBSEVEN_VERSION_MAJOR) "." \
_LIBSEVEN_STR2(LIBSEVEN_VERSION_MINOR) "." \
_LIBSEVEN_STR2(LIBSEVEN_VERSION_PATCH)
#ifdef __BINDGEN__
#define VOLADDR(addr, type) (type volatile *)(addr)
#define VOLARRAY(addr, type, size) (type volatile (*)[size](addr)
#define MEMADDR(addr, type) (type *)(addr)
#define MEMARRAY(addr, type, size) (type (*)[size])(addr)
#else
#define VOLADDR(addr, type) (*(type volatile (*))(addr))
#define VOLARRAY(addr, type, size) (*(type volatile (*)[size])(addr))
#define MEMADDR(addr, type) (*(type (*))(addr))
#define MEMARRAY(addr, type, size) (*(type (*)[size])(addr))
#endif
#define BIT(n) (1 << (n))
#define BITS(n) (BIT(n) - 1)
#define BITFIELD(name, value) \
(((value) & BITS(BF_##name##_LENGTH)) << (BF_##name##_OFFSET))