Skip to content

Commit

Permalink
tracing: Use alignof__(struct {type b;}) instead of offsetof()
Browse files Browse the repository at this point in the history
Simplify:

  #define ALIGN_STRUCTFIELD(type) ((int)(offsetof(struct {char a; type b;}, b)))

with

  #define  ALIGN_STRUCTFIELD(type) __alignof__(struct {type b;})

Which works just the same.

Link: https://lore.kernel.org/all/a7d202457150472588df0bd3b7334b3f@AcuMS.aculab.com/
Link: https://lkml.kernel.org/r/20220802154412.513c50e3@gandalf.local.home

Suggested-by: David Laight <David.Laight@ACULAB.COM>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
  • Loading branch information
Steven Rostedt (Google) committed Aug 2, 2022
1 parent 2f63e5d commit 09794a5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/trace/stages/stage4_event_fields.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/* Stage 4 definitions for creating trace events */

#define ALIGN_STRUCTFIELD(type) ((int)(offsetof(struct {char a; type b;}, b)))
#define ALIGN_STRUCTFIELD(type) ((int)(__alignof__(struct {type b;})))

#undef __field_ext
#define __field_ext(_type, _item, _filter_type) { \
Expand Down

0 comments on commit 09794a5

Please sign in to comment.