• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2022 Beken Corporation
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #define __BK_INLINE                     static inline
18 
19 /// function returns struct in registers (4 words max, var with gnuarm)
20 #if !defined(__VIR)
21 #define __VIR                        __value_in_regs
22 #endif
23 
24 /// function has no side effect and return depends only on arguments
25 #if !defined(__PURE)
26 #define __PURE                       __pure
27 #endif
28 
29 /// Align instantiated lvalue or struct member on 4 bytes
30 #if !defined(__ALIGN4)
31 #define __ALIGN4                     __attribute__((aligned(4)))
32 #endif
33 
34 #define __MODULE__                   __BASE_FILE__
35 
36 /// define the BLE IRQ handler attribute for this compiler
37 #define __BLEIRQ
38 
39 /// define size of an empty array (used to declare structure with an array size not defined)
40 #define __ARRAY_EMPTY
41 
42 /// define the static keyword for this compiler
43 #define __STATIC static
44 
45 /// Pack a structure field
46 #define __PACKED16                   __attribute__( ( packed ) )
47 #if !defined(__PACKED)
48 #define __PACKED                     __attribute__( ( packed ) )
49 #endif
50 #ifndef __packed
51 #define __packed                     __attribute__((packed))
52 #endif
53 
54 #define __BK_SECTION(x)                 __attribute__((section(x)))
55 
56 #ifndef likely
57 #define likely(x)                    __builtin_expect(!!(x), 1)
58 #endif
59 #ifndef unlikely
60 #define unlikely(x)                  __builtin_expect(!!(x), 0)
61 #endif
62 
63 /* XXX: move to right place */
64 #if (CONFIG_FULLY_HOSTED)
65 /* host packed */
66 #undef __hpacked
67 #define __hpacked                    __attribute__((packed))
68 #else
69 #define __hpacked
70 #endif
71 
72 #define __bk_deprecated                 __attribute__((deprecated))
73 #define __bk_weak                       __attribute__((weak))
74 #define __bk_must_check                 __attribute__((warn_unused_result))
75 
76 /* Are two types/vars the same type (ignoring qualifiers)? */
77 #ifndef __same_type
78 # define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
79 #endif
80 
81 /* &a[0] degrades to a pointer: a different type from an array */
82 #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
83 
84