compiler: Provide LIBPLDM_CC_ALWAYS_INLINE
Using it through the code-base reduces some of the source noise, and
gives us a way to control the definition going forward.
Change-Id: I27e76cbae5c45f0efd64b01fb9a8b243a6c8e65d
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
diff --git a/src/msgbuf/platform.h b/src/msgbuf/platform.h
index c52a66d..11f0900 100644
--- a/src/msgbuf/platform.h
+++ b/src/msgbuf/platform.h
@@ -2,6 +2,7 @@
#ifndef PLDM_MSGBUF_PLATFORM_H
#define PLDM_MSGBUF_PLATFORM_H
+#include "../compiler.h"
#include "../msgbuf.h"
#include <libpldm/base.h>
#include <libpldm/platform.h>
@@ -19,14 +20,7 @@
return pldm_msgbuf_validate(ctx);
}
-/*
- * We use __attribute__((always_inline)) below so the compiler has visibility of
- * the switch() at the call site. It is often the case that the size of multiple
- * fields depends on the tag. Inlining thus gives the compiler visibility to
- * hoist one tag-based code-path condition to cover all invocations.
- */
-
-__attribute__((always_inline)) static inline int
+LIBPLDM_CC_ALWAYS_INLINE int
pldm_msgbuf_extract_sensor_data(struct pldm_msgbuf *ctx,
enum pldm_sensor_readings_data_type tag,
union_sensor_data_size *dst)
@@ -54,7 +48,7 @@
* have used the approach used by callers of pldm_msgbuf_extract_sensor_data()
* above
*/
-__attribute__((always_inline)) static inline int
+LIBPLDM_CC_ALWAYS_INLINE int
pldm_msgbuf_extract_sensor_value(struct pldm_msgbuf *ctx,
enum pldm_sensor_readings_data_type tag,
void *val)
@@ -81,10 +75,8 @@
pldm_msgbuf_extract_typecheck(union_range_field_format, \
pldm__msgbuf_extract_range_field_format, \
dst, ctx, tag, (void *)&(dst))
-__attribute__((always_inline)) static inline int
-pldm__msgbuf_extract_range_field_format(struct pldm_msgbuf *ctx,
- enum pldm_range_field_format tag,
- void *rff)
+LIBPLDM_CC_ALWAYS_INLINE int pldm__msgbuf_extract_range_field_format(
+ struct pldm_msgbuf *ctx, enum pldm_range_field_format tag, void *rff)
{
switch (tag) {
case PLDM_RANGE_FIELD_FORMAT_UINT8:
@@ -121,7 +113,7 @@
}
/* This API is bad, but it's because the caller's APIs are also bad */
-__attribute__((always_inline)) static inline int
+LIBPLDM_CC_ALWAYS_INLINE int
pldm_msgbuf_extract_effecter_value(struct pldm_msgbuf *ctx,
enum pldm_effecter_data_size tag, void *dst)
{
@@ -147,7 +139,7 @@
pldm_msgbuf_extract_typecheck(union_effecter_data_size, \
pldm__msgbuf_extract_range_field_format, \
dst, ctx, tag, (void *)&(dst))
-__attribute__((always_inline)) static inline int
+LIBPLDM_CC_ALWAYS_INLINE int
pldm__msgbuf_extract_effecter_data(struct pldm_msgbuf *ctx,
enum pldm_effecter_data_size tag, void *ed)
{