eal: introduce macro for always inline
[dpdk.git] / lib / librte_eal / common / include / rte_common.h
index 8dda3e2..a9a7494 100644 (file)
@@ -102,6 +102,11 @@ typedef uint16_t unaligned_uint16_t;
  */
 #define RTE_SET_USED(x) (void)(x)
 
+/**
+ * Force a function to be inlined
+ */
+#define __rte_always_inline inline __attribute__((always_inline))
+
 /*********** Macros for pointer arithmetic ********/
 
 /**
@@ -347,8 +352,11 @@ rte_bsf32(uint32_t v)
  */
 #ifndef container_of
 #define container_of(ptr, type, member)        __extension__ ({                \
-                       typeof(((type *)0)->member) *_ptr = (ptr);      \
-                       (type *)(((char *)_ptr) - offsetof(type, member)); })
+                       const typeof(((type *)0)->member) *_ptr = (ptr); \
+                       __attribute__((unused)) type *_target_ptr =     \
+                               (type *)(ptr);                          \
+                       (type *)(((uintptr_t)_ptr) - offsetof(type, member)); \
+               })
 #endif
 
 #define _RTE_STR(x) #x