diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2013-04-16 10:25:16 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2013-04-16 10:25:16 +0000 |
commit | 7eb805f68dc06101274b13f7c0e1aeeaf0a787a4 (patch) | |
tree | b58c036cad846597ea13109fc42da5f7edeb73cd /newlib/libc/include/sys/cdefs.h | |
parent | 48f81ac6773850952a516c75765376f20d5b5b34 (diff) | |
download | cygnal-7eb805f68dc06101274b13f7c0e1aeeaf0a787a4.tar.gz cygnal-7eb805f68dc06101274b13f7c0e1aeeaf0a787a4.tar.bz2 cygnal-7eb805f68dc06101274b13f7c0e1aeeaf0a787a4.zip |
* libc/sys/rtems/sys/queue.h: Delete file.
* libc/include/sys/cdefs.h (__containerof): New define.
(__DEQUALIFY): Likewise.
* libc/include/sys/queue.h (TRACEBUF_INITIALIZER): Likewise.
(TRACEBUF): Likewise.
(LIST_FOREACH_SAFE): Likewise.
(LIST_PREV): Likewise.
(LIST_SWAP): Likewise.
(QMD_LIST_CHECK_HEAD): Likewise.
(QMD_LIST_CHECK_NEXT): Likewise.
(QMD_LIST_CHECK_PREV): Likewise.
(QMD_SAVELINK): Likewise.
(QMD_TAILQ_CHECK_HEAD): Likewise.
(QMD_TAILQ_CHECK_NEXT): Likewise.
(QMD_TAILQ_CHECK_PREV): Likewise.
(QMD_TAILQ_CHECK_TAIL): Likewise.
(QMD_TRACE_ELEM): Likewise.
(QMD_TRACE_HEAD): Likewise.
(SLIST_FOREACH_PREVPTR): Likewise.
(SLIST_FOREACH_SAFE): Likewise.
(SLIST_REMOVE_AFTER): Likewise.
(SLIST_SWAP): Likewise.
(STAILQ_FOREACH_SAFE): Likewise.
(STAILQ_REMOVE_AFTER): Likewise.
(STAILQ_SWAP): Likewise.
(TAILQ_FOREACH_REVERSE_SAFE): Likewise.
(TAILQ_FOREACH_SAFE): Likewise.
(TAILQ_SWAP): Likewise.
(TRASHIT): Likewise.
(SLIST_REMOVE): Use SLIST_REMOVE_AFTER().
(STAILQ_LAST): Use __containerof().
(STAILQ_REMOVE): Use STAILQ_REMOVE_AFTER().
Diffstat (limited to 'newlib/libc/include/sys/cdefs.h')
-rw-r--r-- | newlib/libc/include/sys/cdefs.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/newlib/libc/include/sys/cdefs.h b/newlib/libc/include/sys/cdefs.h index e3298efaf..253258aa8 100644 --- a/newlib/libc/include/sys/cdefs.h +++ b/newlib/libc/include/sys/cdefs.h @@ -44,6 +44,10 @@ #ifndef _SYS_CDEFS_H #define _SYS_CDEFS_H +#include <sys/features.h> +#include <stddef.h> +#include <stdint.h> + #define __FBSDID(x) /* nothing */ /* * Note: the goal here is not compatibility to K&R C. Since we know that we @@ -101,6 +105,26 @@ # define __ptrvalue /* nothing */ #endif +/* + * Given the pointer x to the member m of the struct s, return + * a pointer to the containing structure. When using GCC, we first + * assign pointer x to a local variable, to check that its type is + * compatible with member m. + */ +#if __GNUC_PREREQ(3, 1) +#define __containerof(x, s, m) ({ \ + const volatile __typeof__(((s *)0)->m) *__x = (x); \ + __DEQUALIFY(s *, (const volatile char *)__x - offsetof(s, m));\ +}) +#else +#define __containerof(x, s, m) \ + __DEQUALIFY(s *, (const volatile char *)(x) - offsetof(s, m)) +#endif + +#ifndef __DEQUALIFY +#define __DEQUALIFY(type, var) ((type)(uintptr_t)(const volatile void *)(var)) +#endif + #ifdef __GNUC__ #define __strong_reference(sym,aliassym) \ extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym))); |