[LTP] [RFC PATCH 1/2] realtime: Use offsetof() macro from <stddef.h>

Petr Vorel pvorel@suse.cz
Thu Jul 11 12:43:57 CEST 2024


offsetof() macro from <stddef.h> which uses __builtin_offsetof() should
be equivalent to the LTP custom implementation.

The replacement is required due sched_football.c rewrite into new API
(LTP library uses <stddef.h>, thus there is a redefinition).

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/realtime/include/list.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/testcases/realtime/include/list.h b/testcases/realtime/include/list.h
index f87d602e4a..01159e34fc 100644
--- a/testcases/realtime/include/list.h
+++ b/testcases/realtime/include/list.h
@@ -39,6 +39,8 @@
 #ifndef _LINUX_LIST_H
 #define _LINUX_LIST_H
 
+#include <stddef.h>
+
 /*
  * These are non-NULL pointers that will result in page faults
  * under normal circumstances, used to verify that nobody uses
@@ -241,7 +243,6 @@ static inline void list_splice_init(struct list_head *list,
 	}
 }
 
-#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
 /**
  * container_of - cast a member of a structure out to the containing structure
  * @ptr:	the pointer to the member.
-- 
2.45.2



More information about the ltp mailing list