Loading...
Searching...
No Matches
attributes.h File Reference

Define function attributes. More...

+ Include dependency graph for attributes.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ARCH_PRINTF_FUNCTION(_fmt, _firstArg)
 Macro used to indicate a function takes a printf-like specification.
 
#define ARCH_SCANF_FUNCTION(_fmt, _firstArg)
 Macro used to indicate a function takes a scanf-like specification.
 
#define ARCH_NOINLINE
 Macro used to indicate that a function should never be inlined.
 
#define ARCH_UNUSED_ARG
 Macro used to indicate a function parameter may be unused.
 
#define ARCH_UNUSED_FUNCTION
 Macro used to indicate a function may be unused.
 
#define ARCH_USED_FUNCTION
 Macro used to indicate that a function's code must always be emitted even if not required.
 
#define ARCH_CONSTRUCTOR(_name, _priority)
 Macro to begin the definition of a function that should be executed by the dynamic loader when the dynamic object (library or program) is loaded.
 
#define ARCH_DESTRUCTOR(_name, _priority)
 Macro to begin the definition of a function that should be executed by the dynamic loader when the dynamic object (library or program) is unloaded.
 
#define ARCH_EMPTY_BASES
 Macro to begin the definition of a class that is using private inheritance to take advantage of the empty base optimization.
 
#define ARCH_NO_SANITIZE_ADDRESS_FUNCTION
 Macro used to indicate that a function should not be instrumented with address santizers.
 
#define _ARCH_CAT_NOEXPAND(a, b)   a ## b
 
#define _ARCH_CAT(a, b)   _ARCH_CAT_NOEXPAND(a, b)
 
#define _ARCH_ENSURE_PER_LIB_INIT(T, prefix)    static Arch_PerLibInit<T> _ARCH_CAT(prefix, __COUNTER__)
 

Detailed Description

Define function attributes.

This file allows you to define architecture-specific or compiler-specific options to be used outside lib/arch.

Definition in file attributes.h.

Macro Definition Documentation

◆ _ARCH_CAT

#define _ARCH_CAT (   a,
 
)    _ARCH_CAT_NOEXPAND(a, b)

Definition at line 249 of file attributes.h.

◆ _ARCH_CAT_NOEXPAND

#define _ARCH_CAT_NOEXPAND (   a,
 
)    a ## b

Definition at line 248 of file attributes.h.

◆ _ARCH_ENSURE_PER_LIB_INIT

#define _ARCH_ENSURE_PER_LIB_INIT (   T,
  prefix 
)     static Arch_PerLibInit<T> _ARCH_CAT(prefix, __COUNTER__)

Definition at line 250 of file attributes.h.

◆ ARCH_CONSTRUCTOR

#define ARCH_CONSTRUCTOR (   _name,
  _priority 
)

Macro to begin the definition of a function that should be executed by the dynamic loader when the dynamic object (library or program) is loaded.

_priority is used to order the execution of constructors. Valid values are integers in the range [0,255]. Constructors with lower numbers are run first. It is unspecified if these functions are run before or after dynamic initialization of non-local variables.

_name is the name of the function and must be unique across all invocations of ARCH_CONSTRUCTOR in the same translation unit.

Definition at line 124 of file attributes.h.

◆ ARCH_DESTRUCTOR

#define ARCH_DESTRUCTOR (   _name,
  _priority 
)

Macro to begin the definition of a function that should be executed by the dynamic loader when the dynamic object (library or program) is unloaded.

_priority is used to order the execution of destructors. Valid values are integers in the range [0,255]. Destructors with higher numbers are run first. It is unspecified if these functions are run before or after dynamically initialized non-local variables.

_name is the name of the function and must be unique across all invocations of ARCH_CONSTRUCTOR in the same translation unit.

Definition at line 139 of file attributes.h.

◆ ARCH_EMPTY_BASES

#define ARCH_EMPTY_BASES

Macro to begin the definition of a class that is using private inheritance to take advantage of the empty base optimization.

Some compilers require an explicit tag.

In C++20, usage of private inheritance may be able to be retired with the [[no_unique_address]] tag.

Definition at line 147 of file attributes.h.

◆ ARCH_NO_SANITIZE_ADDRESS_FUNCTION

#define ARCH_NO_SANITIZE_ADDRESS_FUNCTION

Macro used to indicate that a function should not be instrumented with address santizers.

In general, this attribute should be used sparingly. Its purpose is mostly for tests that when built with address sanitizer will trigger a false-positive, meaning the test is checking something that address sanitizer is trying to catch.

Its important to understand that this attribute will only disable address sanitizer instrumentation for the function it's applied to. Any sanitized functions called from the target function will still be instrumented.

This attribute is used as follows:

...
}
#define ARCH_NO_SANITIZE_ADDRESS_FUNCTION
Macro used to indicate that a function should not be instrumented with address santizers.
Definition: attributes.h:170

Definition at line 170 of file attributes.h.

◆ ARCH_NOINLINE

#define ARCH_NOINLINE

Macro used to indicate that a function should never be inlined.

This attribute is used as follows:

void Func(T1 arg1, T2 arg2) ARCH_NOINLINE;
#define ARCH_NOINLINE
Macro used to indicate that a function should never be inlined.
Definition: attributes.h:60

Definition at line 60 of file attributes.h.

◆ ARCH_PRINTF_FUNCTION

#define ARCH_PRINTF_FUNCTION (   _fmt,
  _firstArg 
)

Macro used to indicate a function takes a printf-like specification.

This attribute is used as follows:

void PrintFunc(T1 arg1, T2 arg2, const char* fmt, ...)
#define ARCH_PRINTF_FUNCTION(_fmt, _firstArg)
Macro used to indicate a function takes a printf-like specification.
Definition: attributes.h:36

This indicates that the third argument is the format string, and that the fourth argument is where the var-args corresponding to the format string begin.

Definition at line 36 of file attributes.h.

◆ ARCH_SCANF_FUNCTION

#define ARCH_SCANF_FUNCTION (   _fmt,
  _firstArg 
)

Macro used to indicate a function takes a scanf-like specification.

This attribute is used as follows:

void ScanFunc(T1 arg1, T2 arg2, const char* fmt, ...)

This indicates that the third argument is the format string, and that the fourth argument is where the var-args corresponding to the format string begin.

Definition at line 50 of file attributes.h.

◆ ARCH_UNUSED_ARG

#define ARCH_UNUSED_ARG

Macro used to indicate a function parameter may be unused.

In general, avoid this attribute if possible. Mostly this attribute should be used when the set of arguments to a function is described as part of a macro. The usage is:

void Func(T1 arg1, ARCH_UNUSED_ARG T2 arg2, ARCH_UNUSED_ARG T3 arg3, T4 arg4) {
...
}
#define ARCH_UNUSED_ARG
Macro used to indicate a function parameter may be unused.
Definition: attributes.h:74

Definition at line 74 of file attributes.h.

◆ ARCH_UNUSED_FUNCTION

#define ARCH_UNUSED_FUNCTION

Macro used to indicate a function may be unused.

In general, avoid this attribute if possible. Mostly this attribute should be used when you need to keep a function around (for some good reason), but it is not used in the rest of the code. The usage is:

ARCH_UNUSED_FUNCTION void Func() {
...
}
#define ARCH_UNUSED_FUNCTION
Macro used to indicate a function may be unused.
Definition: attributes.h:89

Definition at line 89 of file attributes.h.

◆ ARCH_USED_FUNCTION

#define ARCH_USED_FUNCTION

Macro used to indicate that a function's code must always be emitted even if not required.

This attribute is especially useful with templated registration functions, which might not be present in the linked binary if they are not used (or the compiler optimizes away their use.)

The usage is:

template <typename T>
struct TraitsClass {
static void RegistryFunction() ARCH_USED_FUNCTION {
...
}
};
#define ARCH_USED_FUNCTION
Macro used to indicate that a function's code must always be emitted even if not required.
Definition: attributes.h:109

Definition at line 109 of file attributes.h.