Skip to content

Commit a73eb9d

Browse files
committed
clean up compipler macros
1 parent 3f2fbc6 commit a73eb9d

File tree

3 files changed

+8
-92
lines changed

3 files changed

+8
-92
lines changed

cores/nRF5/compiler_macro.h

Lines changed: 3 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -36,92 +36,13 @@
3636
*/
3737
/******************************************************************************/
3838

39-
/** \ingroup Group_Compiler
40-
* \defgroup Group_GCC GNU GCC
41-
* @{
42-
*/
43-
4439
#ifndef _COMPILER_MACRO_H_
4540
#define _COMPILER_MACRO_H_
4641

47-
#define STRING_(x) #x // stringify without expand
48-
#define XSTRING_(x) STRING_(x) // expand then stringify
49-
#define STRING_CONCAT_(a, b) a##b // concat without expand
50-
#define XSTRING_CONCAT_(a, b) STRING_CONCAT_(a, b) // expand then concat
51-
52-
#define ALIGN_OF(x) __alignof__(x)
53-
54-
/// Normally, the compiler places the objects it generates in sections like data or bss & function in text. Sometimes, however, you need additional sections, or you need certain particular variables to appear in special sections, for example to map to special hardware. The section attribute specifies that a variable (or function) lives in a particular section
55-
#define ATTR_SECTION(section) __attribute__ ((#section))
56-
57-
/// If this attribute is used on a function declaration and a call to such a function is not eliminated through dead code elimination or other optimizations, an error that includes message is diagnosed. This is useful for compile-time checking
58-
#define ATTR_ERROR(Message) __attribute__ ((error(Message)))
59-
60-
/// If this attribute is used on a function declaration and a call to such a function is not eliminated through dead code elimination or other optimizations, a warning that includes message is diagnosed. This is useful for compile-time checking
61-
#define ATTR_WARNING(Message) __attribute__ ((warning(Message)))
62-
63-
/**
64-
* \defgroup Group_VariableAttr Variable Attributes
65-
* @{
66-
*/
67-
68-
/// This attribute specifies a minimum alignment for the variable or structure field, measured in bytes
69-
#define ATTR_ALIGNED(Bytes) __attribute__ ((aligned(Bytes)))
70-
71-
/// The packed attribute specifies that a variable or structure field should have the smallest possible alignment—one byte for a variable, and one bit for a field, unless you specify a larger value with the aligned attribute
72-
#define ATTR_PACKED __attribute__ ((packed))
73-
74-
#define ATTR_PREPACKED
75-
76-
#define ATTR_PACKED_STRUCT(x) x __attribute__ ((packed))
77-
/** @} */
78-
79-
/**
80-
* \defgroup Group_FuncAttr Function Attributes
81-
* @{
82-
*/
83-
84-
/// Generally, functions are not inlined unless optimization is specified. For functions declared inline, this attribute inlines the function even if no optimization level is specified
85-
#define ATTR_ALWAYS_INLINE __attribute__ ((always_inline))
86-
87-
/// The nonnull attribute specifies that some function parameters should be non-null pointers. f the compiler determines that a null pointer is passed in an argument slot marked as non-null, and the -Wnonnull option is enabled, a warning is issued. All pointer arguments are marked as non-null
88-
#define ATTR_NON_NULL __attribute__ ((nonull))
89-
90-
#define ATTR_NO_RETURN __attribute__ ((noreturn))
91-
92-
/// Many functions have no effects except the return value and their return value depends only on the parameters and/or global variables. Such a function can be subject to common subexpression elimination and loop optimization just as an arithmetic operator would be. These functions should be declared with the attribute pure
93-
#define ATTR_PURE __attribute__ ((pure))
94-
95-
/// Many functions do not examine any values except their arguments, and have no effects except the return value. Basically this is just slightly more strict class than the pure attribute below, since function is not allowed to read global memory.
96-
/// Note that a function that has pointer arguments and examines the data pointed to must not be declared const. Likewise, a function that calls a non-const function usually must not be const. It does not make sense for a const function to return void
97-
#define ATTR_CONST __attribute__ ((const))
98-
99-
/// The deprecated attribute results in a warning if the function is used anywhere in the source file. This is useful when identifying functions that are expected to be removed in a future version of a program. The warning also includes the location of the declaration of the deprecated function, to enable users to easily find further information about why the function is deprecated, or what they should do instead. Note that the warnings only occurs for uses
100-
#define ATTR_DEPRECATED __attribute__ ((deprecated))
101-
102-
/// Same as the deprecated attribute with optional message in the warning
103-
#define ATTR_DEPRECATED_MESS(mess) __attribute__ ((deprecated(mess)))
104-
105-
/// The weak attribute causes the declaration to be emitted as a weak symbol rather than a global. This is primarily useful in defining library functions that can be overridden in user code
106-
#define ATTR_WEAK __attribute__ ((weak))
107-
108-
/// The alias attribute causes the declaration to be emitted as an alias for another symbol, which must be specified
109-
#define ATTR_ALIAS(func) __attribute__ ((alias(#func)))
110-
111-
/// The weakref attribute marks a declaration as a weak reference. It is equivalent with weak + alias attribute, but require function is static
112-
#define ATTR_WEAKREF(func) __attribute__ ((weakref(#func)))
113-
114-
/// The warn_unused_result attribute causes a warning to be emitted if a caller of the function with this attribute does not use its return value. This is useful for functions where not checking the result is either a security problem or always a bug
115-
#define ATTR_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
116-
117-
/// This attribute, attached to a function, means that code must be emitted for the function even if it appears that the function is not referenced. This is useful, for example, when the function is referenced only in inline assembly.
118-
#define ATTR_USED __attribute__ ((used))
119-
120-
/// This attribute, attached to a function, means that the function is meant to be possibly unused. GCC does not produce a warning for this function.
121-
#define ATTR_UNUSED __attribute__ ((unused))
42+
#include "common/tusb_compiler.h"
12243

123-
#define ATTR_OPTIMIZE(n) __attribute__ ((optimize(XSTRING_(O##n))))
44+
#define ATTR_PACKED TU_ATTR_PACKED
45+
#define ATTR_WEAK TU_ATTR_WEAK
12446

12547
#endif /* _COMPILER_MACRO_H_ */
12648

127-
/// @}

cores/nRF5/verify.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,7 @@ extern "C"
5050
//--------------------------------------------------------------------+
5151
// Compile-time Assert
5252
//--------------------------------------------------------------------+
53-
#if defined __COUNTER__ && __COUNTER__ != __COUNTER__
54-
#define _VERIFY_COUNTER __COUNTER__
55-
#else
56-
#define _VERIFY_COUNTER __LINE__
57-
#endif
58-
59-
#define VERIFY_STATIC(const_expr) enum { XSTRING_CONCAT_(static_verify_, _VERIFY_COUNTER) = 1/(!!(const_expr)) }
53+
#define VERIFY_STATIC(const_expr) TU_VERIFY_STATIC(const_expr, "Assert failed")
6054

6155
//--------------------------------------------------------------------+
6256
// VERIFY Helper

libraries/Bluefruit52Lib/src/services/BLEHidGeneric.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,16 @@ extern hid_keycode_to_ascii_t const hid_keycode_to_ascii[128];
6464

6565

6666
/// HID Consumer Control Report
67-
typedef ATTR_PACKED_STRUCT(struct)
67+
typedef struct ATTR_PACKED
6868
{
6969
uint16_t usage_value; ///< Usage value of the pressed control
7070
} hid_consumer_control_report_t;
7171

7272
/// Gamepad report
73-
typedef ATTR_PACKED_STRUCT(struct)
73+
typedef struct ATTR_PACKED
7474
{
75-
ATTR_PACKED_STRUCT(struct){
75+
struct ATTR_PACKED
76+
{
7677
uint8_t x : 2;
7778
uint8_t y : 2;
7879
uint8_t : 4;

0 commit comments

Comments
 (0)