Contiki-NG
Loading...
Searching...
No Matches
cc.h File Reference

Default definitions of C compiler quirk work-arounds. More...

#include "contiki.h"

Go to the source code of this file.

Macros

#define ASSUME(c)
 Configure if the C compiler supports taking hints from the user about invariants, e.g.
#define CC_NORETURN
 Configure if the C compiler supports functions that are not meant to return e.g.
#define CC_MUST_BE_ARRAY(array)
 Returns 0 if the provided variable is an array and raises an error if not.
#define CC_ARRAY_LENGTH(array)
 Counts the number of elements of an array.
#define CC_CONSTRUCTOR(prio)
 Configure if the C compiler supports marking functions as constructors e.g.
#define CC_DESTRUCTOR(prio)
 Configure if the C compiler supports marking functions as destructors e.g.
#define CC_DEPRECATED(msg)
 Configure if the C compiler supports marking functions as deprecated e.g.
#define CC_ACCESS_NOW(type, variable)
 This macro ensures that the access to a non-volatile variable can not be reordered or optimized by the compiler.
#define CC_CONCAT(s1, s2)
 A C preprocessing macro for concatenating two preprocessor tokens.
#define CC_CONCAT3(s1, s2, s3)
 A C preprocessing macro for concatenating three preprocessor tokens.

Detailed Description

Default definitions of C compiler quirk work-arounds.

Author
Adam Dunkels adam@.nosp@m.dunk.nosp@m.els.c.nosp@m.om

This file is used for making use of extra functionality of some C compilers used for Contiki, and defining work-arounds for various quirks and problems with some other C compilers.

Definition in file cc.h.

Macro Definition Documentation

◆ ASSUME

#define ASSUME ( c)

Configure if the C compiler supports taking hints from the user about invariants, e.g.

with attribute((assume(hint))).

Definition at line 91 of file cc.h.

◆ CC_ACCESS_NOW

#define CC_ACCESS_NOW ( type,
variable )
Value:
(*(volatile type *)&(variable))

This macro ensures that the access to a non-volatile variable can not be reordered or optimized by the compiler.

See also https://lwn.net/Articles/508991/ - In Linux the macro is called ACCESS_ONCE The type must be passed, because the typeof-operator is a gcc extension

Definition at line 168 of file cc.h.

Referenced by ringbuf_get(), and ringbuf_put().

◆ CC_ARRAY_LENGTH

#define CC_ARRAY_LENGTH ( array)
Value:
((sizeof(array) / sizeof((array)[0])) \
#define CC_MUST_BE_ARRAY(array)
Returns 0 if the provided variable is an array and raises an error if not.
Definition cc.h:114

Counts the number of elements of an array.

Parameters
arrayThe array.
Returns
The number of elements of the array.

Definition at line 122 of file cc.h.

◆ CC_CONCAT

#define CC_CONCAT ( s1,
s2 )
Value:
CC_CONCAT2(s1, s2)

A C preprocessing macro for concatenating two preprocessor tokens.

We need use two macros (CC_CONCAT and CC_CONCAT2) in order to allow concatenation of two #defined macros.

Definition at line 198 of file cc.h.

◆ CC_CONSTRUCTOR

#define CC_CONSTRUCTOR ( prio)

Configure if the C compiler supports marking functions as constructors e.g.

with attribute((constructor(prio))).

Lower priority runs before higher priority. Priorities 0-100 are reserved.

Definition at line 134 of file cc.h.

◆ CC_DEPRECATED

#define CC_DEPRECATED ( msg)

Configure if the C compiler supports marking functions as deprecated e.g.

with attribute((deprecated))

Definition at line 156 of file cc.h.

◆ CC_DESTRUCTOR

#define CC_DESTRUCTOR ( prio)

Configure if the C compiler supports marking functions as destructors e.g.

with attribute((destructor(prio))).

Lower priority runs before higher priority. Priorities 0-100 are reserved.

Definition at line 146 of file cc.h.

◆ CC_NORETURN

#define CC_NORETURN

Configure if the C compiler supports functions that are not meant to return e.g.

with attribute((noreturn))

Definition at line 105 of file cc.h.