Merge pull request #5004 from OlegHahm/core_kernel_macros_attributs_merge

core: merge kernel_macros.h and attributes.h into kernel_defines.h
pr/gpio
René Kijewski 7 years ago
commit 818d703810

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

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

@ -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_ */
/** @} */

@ -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 */
/**
* @}
*/

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

@ -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"

@ -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"

@ -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"

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

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

@ -28,20 +28,21 @@
* @}
*/
#include <stdint.h>
#include <stdio.h>
#include "kernel_defines.h"
#include "cpu.h"
#include "sched.h"
#include "thread.h"
#include "ucontext.h"
#include "x86_interrupts.h"
#include "x86_memory.h"
#include "x86_ports.h"
#include "x86_registers.h"
#include "x86_threading.h"
#include <attributes.h>
#include <cpu.h>
#include <sched.h>
#include <thread.h>
#include <ucontext.h>
#include <stdint.h>
#include <stdio.h>
#define ASM_FUN_ATTRIBUTES \
__attribute__((noinline)) \

@ -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"

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

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

@ -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" {

@ -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