core: merged kernel_macros.h and attributes.h
Merged into new kernel_defines.h and updated all includes.
This commit is contained in:
parent
2c33e69def
commit
bdcf8879fd
@ -19,7 +19,7 @@
|
|||||||
#ifndef THREAD_ARCH_H
|
#ifndef THREAD_ARCH_H
|
||||||
#define THREAD_ARCH_H
|
#define THREAD_ARCH_H
|
||||||
|
|
||||||
#include "attributes.h"
|
#include "kernel_defines.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
#ifndef CLIST_H
|
#ifndef CLIST_H
|
||||||
#define CLIST_H
|
#define CLIST_H
|
||||||
|
|
||||||
#include "kernel_macros.h"
|
#include "kernel_defines.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|||||||
@ -11,13 +11,13 @@
|
|||||||
* @{
|
* @{
|
||||||
*
|
*
|
||||||
* @file
|
* @file
|
||||||
* @brief Compiler attributes/pragmas configuration
|
* @brief Common macros and compiler attributes/pragmas configuration
|
||||||
*
|
*
|
||||||
* @author René Kijewski <rene.kijewski@fu-berlin.de>
|
* @author René Kijewski <rene.kijewski@fu-berlin.de>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef ATTRIBUTES_H_
|
#ifndef KERNEL_DEFINES_H_
|
||||||
#define ATTRIBUTES_H_
|
#define KERNEL_DEFINES_H_
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
@ -25,6 +25,38 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#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
|
* @def NORETURN
|
||||||
* @brief The *NORETURN* keyword tells the compiler to assume that the function
|
* @brief The *NORETURN* keyword tells the compiler to assume that the function
|
||||||
@ -86,5 +118,5 @@
|
|||||||
}
|
}
|
||||||
#endif
|
#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
|
#ifndef PANIC_H
|
||||||
#define PANIC_H
|
#define PANIC_H
|
||||||
|
|
||||||
#include "attributes.h"
|
#include "kernel_defines.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|||||||
@ -81,9 +81,8 @@
|
|||||||
#define SCHEDULER_H
|
#define SCHEDULER_H
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include "attributes.h"
|
#include "kernel_defines.h"
|
||||||
#include "bitarithm.h"
|
#include "bitarithm.h"
|
||||||
#include "attributes.h"
|
|
||||||
#include "kernel_types.h"
|
#include "kernel_types.h"
|
||||||
#include "native_sched.h"
|
#include "native_sched.h"
|
||||||
#include "clist.h"
|
#include "clist.h"
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
#include "attributes.h"
|
#include "kernel_defines.h"
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "irq.h"
|
#include "irq.h"
|
||||||
#include "lpm.h"
|
#include "lpm.h"
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
#ifndef CPU_X86_CPU_H_
|
#ifndef CPU_X86_CPU_H_
|
||||||
#define CPU_X86_CPU_H_
|
#define CPU_X86_CPU_H_
|
||||||
|
|
||||||
#include "attributes.h"
|
#include "kernel_defines.h"
|
||||||
#include "irq.h"
|
#include "irq.h"
|
||||||
#include "ucontext.h"
|
#include "ucontext.h"
|
||||||
#include "cpu_conf.h"
|
#include "cpu_conf.h"
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
#define CPU__X86__REBOOT__H__
|
#define CPU__X86__REBOOT__H__
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "attributes.h"
|
#include "kernel_defines.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|||||||
@ -28,7 +28,7 @@
|
|||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "attributes.h"
|
#include "kernel_defines.h"
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "sched.h"
|
#include "sched.h"
|
||||||
#include "x86_uart.h"
|
#include "x86_uart.h"
|
||||||
|
|||||||
@ -34,7 +34,7 @@
|
|||||||
#include "x86_registers.h"
|
#include "x86_registers.h"
|
||||||
#include "x86_threading.h"
|
#include "x86_threading.h"
|
||||||
|
|
||||||
#include <attributes.h>
|
#include <kernel_defines.h>
|
||||||
#include <cpu.h>
|
#include <cpu.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <thread.h>
|
#include <thread.h>
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "kernel_macros.h"
|
#include "kernel_defines.h"
|
||||||
#include "kernel_types.h"
|
#include "kernel_types.h"
|
||||||
#include "mutex.h"
|
#include "mutex.h"
|
||||||
#include "net/ipv6.h"
|
#include "net/ipv6.h"
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "attributes.h"
|
#include "kernel_defines.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "attributes.h"
|
#include "kernel_defines.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
#ifndef __SYS__POSIX__PTHREAD_THREADING__H
|
#ifndef __SYS__POSIX__PTHREAD_THREADING__H
|
||||||
#define __SYS__POSIX__PTHREAD_THREADING__H
|
#define __SYS__POSIX__PTHREAD_THREADING__H
|
||||||
|
|
||||||
#include "attributes.h"
|
#include "kernel_defines.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|||||||
@ -30,7 +30,7 @@
|
|||||||
#define TESTS_UBJSON_H_
|
#define TESTS_UBJSON_H_
|
||||||
|
|
||||||
#include "embUnit.h"
|
#include "embUnit.h"
|
||||||
#include "kernel_macros.h"
|
#include "kernel_defines.h"
|
||||||
|
|
||||||
#include "ubjson.h"
|
#include "ubjson.h"
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user