Skip to content

Commit ff5bcb7

Browse files
Bjoern A. ZeebBjoern A. Zeeb
authored andcommitted
LinuxKPI: add __struct_size
Use __builtin_object_size() by default. If __builtin_dynamic_object_size() is available use that instead. I would hope that in a future version we can remove the conditional checks but in order to be able to MFC this without checking all compiler versions simply keep it this way for now. Sponsored by: The FreeBSD Foundation (initially) MFC after: 3 days Reviewed by: dumbbell Differential Revision: https://reviews.freebsd.org/D52077
1 parent 3f48a0f commit ff5bcb7

File tree

1 file changed

+6
-0
lines changed
  • sys/compat/linuxkpi/common/include/linux

1 file changed

+6
-0
lines changed

sys/compat/linuxkpi/common/include/linux/compiler.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,10 @@
130130
#define is_signed_type(t) ((t)-1 < (t)1)
131131
#define is_unsigned_type(t) ((t)-1 > (t)1)
132132

133+
#if __has_builtin(__builtin_dynamic_object_size)
134+
#define __struct_size(_s) __builtin_dynamic_object_size(_s, 0)
135+
#else
136+
#define __struct_size(_s) __builtin_object_size(_s, 0)
137+
#endif
138+
133139
#endif /* _LINUXKPI_LINUX_COMPILER_H_ */

0 commit comments

Comments
 (0)