From a367e84b001d045939bfbbbf7665b46428946e4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20O=2E=20Sel=C3=A5sdal?= Date: Sat, 3 Jan 2015 01:51:18 +0100 Subject: [PATCH] Move UC_INLINE to utils.h --- include/ucore/mbuf.h | 13 ------------- include/ucore/pack.h | 13 +------------ include/ucore/tailq.h | 15 ++------------- include/ucore/utils.h | 11 +++++++++++ 4 files changed, 14 insertions(+), 38 deletions(-) diff --git a/include/ucore/mbuf.h b/include/ucore/mbuf.h index 27cc959..f6a1767 100644 --- a/include/ucore/mbuf.h +++ b/include/ucore/mbuf.h @@ -4,17 +4,6 @@ #include #include "tailq.h" -#ifndef UC_INLINE -#ifdef __GNUC__ -# ifdef __clang__ -# define UC_INLINE inline __attribute__((always_inline)) -# else -# define UC_INLINE inline __attribute__((always_inline,flatten)) -# endif -#else -# define UC_INLINE inline -#endif -#endif /** @file * mbuf - A managed message/memory buffer. @@ -220,6 +209,4 @@ static UC_INLINE uint8_t *uc_mbuf_head(struct MBuf* mbuf) return mbuf->head; } -#undef UC_INLINE - #endif diff --git a/include/ucore/pack.h b/include/ucore/pack.h index 6553b7e..889adcc 100644 --- a/include/ucore/pack.h +++ b/include/ucore/pack.h @@ -2,18 +2,7 @@ #define UC_PACK_H_ #include - -#ifndef UC_INLINE -#ifdef __GNUC__ -# ifdef __clang__ -# define UC_INLINE inline __attribute__((always_inline)) -# else -# define UC_INLINE inline __attribute__((always_inline,flatten)) -# endif -#else -# define UC_INLINE inline -#endif -#endif +#include "utils.h" /** @file * Functions for serializing/de-serializing integers to and from diff --git a/include/ucore/tailq.h b/include/ucore/tailq.h index a4ebd6f..ae6da60 100644 --- a/include/ucore/tailq.h +++ b/include/ucore/tailq.h @@ -1,17 +1,8 @@ #ifndef UC_TAILQ_H_ #define UC_TAILQ_H_ -#ifndef UC_INLINE -#ifdef __GNUC__ -# ifdef __clang__ -# define UC_INLINE inline __attribute__((always_inline)) -# else -# define UC_INLINE inline __attribute__((always_inline,flatten)) -# endif -#else -# define UC_INLINE inline -#endif -#endif +#include "utils.h" + /** * Doubly Linked List. * It is used either as @@ -253,6 +244,4 @@ static UC_INLINE void uc_tailq_move_tail(struct TailQ *entry, struct TailQ *head (ptr) = (prv),\ (prv) = UC_TAILQ_CONTAINER(UC_TAILQ_NEXT(&(ptr)->member), typeof(*ptr), member)) -#undef UC_INLINE - #endif diff --git a/include/ucore/utils.h b/include/ucore/utils.h index 44511ff..9811e1b 100644 --- a/include/ucore/utils.h +++ b/include/ucore/utils.h @@ -120,5 +120,16 @@ const typeof( ((const type *)0)->member ) *__mptr = (ptr); \ */ #define UC_UNUSED(x) x __attribute__((unused)) + +#ifdef __GNUC__ +# ifdef __clang__ +# define UC_INLINE inline __attribute__((always_inline)) +# else +# define UC_INLINE inline __attribute__((always_inline,flatten)) +# endif +#else +# define UC_INLINE inline +#endif + #endif