Browse Source

core: merged kernel_macros.h and attributes.h

Merged into new kernel_defines.h and updated all includes.
pr/gpio
Oleg Hahm 7 years ago
parent
commit
bdcf8879fd
  1. 2
      core/include/arch/thread_arch.h
  2. 2
      core/include/clist.h
  3. 40
      core/include/kernel_defines.h
  4. 67
      core/include/kernel_macros.h
  5. 2
      core/include/panic.h
  6. 3
      core/include/sched.h
  7. 2
      core/panic.c
  8. 2
      cpu/x86/include/cpu.h
  9. 2
      cpu/x86/include/x86_reboot.h
  10. 2
      cpu/x86/x86_glue.c
  11. 2
      cpu/x86/x86_interrupts.c
  12. 2
      sys/include/net/gnrc/ipv6/netif.h
  13. 2
      sys/include/shell.h
  14. 2
      sys/include/tm.h
  15. 2
      sys/posix/pthread/include/pthread_threading.h
  16. 2
      tests/unittests/tests-ubjson/tests-ubjson.h

2
core/include/arch/thread_arch.h

@ -19,7 +19,7 @@
#ifndef THREAD_ARCH_H
#define THREAD_ARCH_H
#include "attributes.h"
#include "kernel_defines.h"
#ifdef __cplusplus
extern "C" {

2
core/include/clist.h

@ -19,7 +19,7 @@
#ifndef CLIST_H
#define CLIST_H
#include "kernel_macros.h"
#include "kernel_defines.h"
#ifdef __cplusplus
extern "C" {

40
core/include/attributes.h → core/include/kernel_defines.h

@ -11,13 +11,13 @@
* @{
*
* @file
* @brief Compiler attributes/pragmas configuration
* @brief Common macros and compiler attributes/pragmas configuration
*
* @author René Kijewski <rene.kijewski@fu-berlin.de>
*/
#ifndef ATTRIBUTES_H_
#define ATTRIBUTES_H_
#ifndef KERNEL_DEFINES_H_
#define KERNEL_DEFINES_H_
#include <stddef.h>
@ -25,6 +25,38 @@
extern "C" {
#endif
/**
* @def container_of(PTR, TYPE, MEMBER)
* @brief Returns the container of a pointer to a member.
* @details For a struct `TYPE` with a member `MEMBER`,
* given a pointer `PTR` to `TYPE::MEMBER` this function returns a pointer
* to the instance of `TYPE`.
* @details E.g. for `struct my_struct_t { ...; something_t n; ... } my_struct;`,
* `&my_struct == container_of(&my_struct.n, struct my_struct_t, n)`.
* @param[in] PTR pointer to a member
* @param[in] TYPE a type name (a struct or union), container of PTR
* @param[in] MEMBER name of the member of TYPE which PTR points to
* @return Pointer to the container of PTR.
*/
#if __STDC_VERSION__ >= 201112L
# define container_of(PTR, TYPE, MEMBER) \
(_Generic((PTR), \
const __typeof__ (((TYPE *) 0)->MEMBER) *: \
((TYPE *) ((char *) (PTR) - offsetof(TYPE, MEMBER))), \
__typeof__ (((TYPE *) 0)->MEMBER) *: \
((TYPE *) ((char *) (PTR) - offsetof(TYPE, MEMBER))) \
))
#elif defined __GNUC__
# define container_of(PTR, TYPE, MEMBER) \
(__extension__ ({ \
__extension__ const __typeof__ (((TYPE *) 0)->MEMBER) *__m____ = (PTR); \
((TYPE *) ((char *) __m____ - offsetof(TYPE, MEMBER))); \
}))
#else
# define container_of(PTR, TYPE, MEMBER) \
((TYPE *) ((char *) (PTR) - offsetof(TYPE, MEMBER)))
#endif
/**
* @def NORETURN
* @brief The *NORETURN* keyword tells the compiler to assume that the function
@ -86,5 +118,5 @@
}
#endif
#endif /* ATTRIBUTES_H_ */
#endif /* KERNEL_DEFINES_H_ */
/** @} */

67
core/include/kernel_macros.h

@ -1,67 +0,0 @@
/*
* Copyright (C) 2014 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @addtogroup core_util
* @{
*
* @file
* @brief common macros
*
* @author René Kijewski
*/
#ifndef KERNEL_MACROS_H
#define KERNEL_MACROS_H
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @def container_of(PTR, TYPE, MEMBER)
* @brief Returns the container of a pointer to a member.
* @details For a struct `TYPE` with a member `MEMBER`,
* given a pointer `PTR` to `TYPE::MEMBER` this function returns a pointer
* to the instance of `TYPE`.
* @details E.g. for `struct my_struct_t { ...; something_t n; ... } my_struct;`,
* `&my_struct == container_of(&my_struct.n, struct my_struct_t, n)`.
* @param[in] PTR pointer to a member
* @param[in] TYPE a type name (a struct or union), container of PTR
* @param[in] MEMBER name of the member of TYPE which PTR points to
* @return Pointer to the container of PTR.
*/
#if __STDC_VERSION__ >= 201112L
# define container_of(PTR, TYPE, MEMBER) \
(_Generic((PTR), \
const __typeof__ (((TYPE *) 0)->MEMBER) *: \
((TYPE *) ((char *) (PTR) - offsetof(TYPE, MEMBER))), \
__typeof__ (((TYPE *) 0)->MEMBER) *: \
((TYPE *) ((char *) (PTR) - offsetof(TYPE, MEMBER))) \
))
#elif defined __GNUC__
# define container_of(PTR, TYPE, MEMBER) \
(__extension__ ({ \
__extension__ const __typeof__ (((TYPE *) 0)->MEMBER) *__m____ = (PTR); \
((TYPE *) ((char *) __m____ - offsetof(TYPE, MEMBER))); \
}))
#else
# define container_of(PTR, TYPE, MEMBER) \
((TYPE *) ((char *) (PTR) - offsetof(TYPE, MEMBER)))
#endif
#ifdef __cplusplus
}
#endif
#endif /* KERNEL_MACROS_H */
/**
* @}
*/

2
core/include/panic.h

@ -22,7 +22,7 @@
#ifndef PANIC_H
#define PANIC_H
#include "attributes.h"
#include "kernel_defines.h"
#ifdef __cplusplus
extern "C" {

3
core/include/sched.h

@ -81,9 +81,8 @@
#define SCHEDULER_H
#include <stddef.h>
#include "attributes.h"
#include "kernel_defines.h"
#include "bitarithm.h"
#include "attributes.h"
#include "kernel_types.h"
#include "native_sched.h"
#include "clist.h"

2
core/panic.c

@ -25,7 +25,7 @@
#include <stdio.h>
#include "assert.h"
#include "attributes.h"
#include "kernel_defines.h"
#include "cpu.h"
#include "irq.h"
#include "lpm.h"

2
cpu/x86/include/cpu.h

@ -29,7 +29,7 @@
#ifndef CPU_X86_CPU_H_
#define CPU_X86_CPU_H_
#include "attributes.h"
#include "kernel_defines.h"
#include "irq.h"
#include "ucontext.h"
#include "cpu_conf.h"

2
cpu/x86/include/x86_reboot.h

@ -29,7 +29,7 @@
#define CPU__X86__REBOOT__H__
#include <stdbool.h>
#include "attributes.h"
#include "kernel_defines.h"
#ifdef __cplusplus
extern "C" {

2
cpu/x86/x86_glue.c

@ -28,7 +28,7 @@
* @}
*/
#include "attributes.h"
#include "kernel_defines.h"
#include "cpu.h"
#include "sched.h"
#include "x86_uart.h"

2
cpu/x86/x86_interrupts.c

@ -34,7 +34,7 @@
#include "x86_registers.h"
#include "x86_threading.h"
#include <attributes.h>
#include <kernel_defines.h>
#include <cpu.h>
#include <sched.h>
#include <thread.h>

2
sys/include/net/gnrc/ipv6/netif.h

@ -25,7 +25,7 @@
#include <stdint.h>
#include <stdlib.h>
#include "kernel_macros.h"
#include "kernel_defines.h"
#include "kernel_types.h"
#include "mutex.h"
#include "net/ipv6.h"

2
sys/include/shell.h

@ -22,7 +22,7 @@
#include <stdint.h>
#include "attributes.h"
#include "kernel_defines.h"
#ifdef __cplusplus
extern "C" {

2
sys/include/tm.h

@ -21,7 +21,7 @@
#include <sys/time.h>
#include <stdint.h>
#include "attributes.h"
#include "kernel_defines.h"
#ifdef __cplusplus
extern "C" {

2
sys/posix/pthread/include/pthread_threading.h

@ -17,7 +17,7 @@
#ifndef __SYS__POSIX__PTHREAD_THREADING__H
#define __SYS__POSIX__PTHREAD_THREADING__H
#include "attributes.h"
#include "kernel_defines.h"
#ifdef __cplusplus
extern "C" {

2
tests/unittests/tests-ubjson/tests-ubjson.h

@ -30,7 +30,7 @@
#define TESTS_UBJSON_H_
#include "embUnit.h"
#include "kernel_macros.h"
#include "kernel_defines.h"
#include "ubjson.h"

Loading…
Cancel
Save