summaryrefslogtreecommitdiff
path: root/cesar/lib/callbacks.h
blob: 8987d4a30f45590e0cf94d291b7749c25072955f (plain)
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
#ifndef lib_callbacks_h
#define lib_callbacks_h
/* Cesar project {{{
 *
 * Copyright (C) 2012 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    lib/callbacks.h
 * \brief   Macro to use to register callbacks.
 * \ingroup lib
 */

#if defined (ECOS) && ECOS && defined (__sparc__)

/**
 * Insert the callback function in the variable in section callback
 * \param  f  the function.
 * \return  the variable to the pointed function.
 */
#  define CALLBACK(f) \
    ({ static typeof (f) * volatile p \
     __attribute__ ((section (".callbacks"))) = &(f); \
     p; })

#else /* !defined (ECOS) && ECOS && (__sparc__) */

/**
 * Return the callback function
 * \param  f  the function.
 * \return  the variable to the pointed function.
 */
# define CALLBACK(f) (f)

#endif

#endif /* lib_callbacks_h */