stddef.h 827 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_STDDEF_H
  3. #define _LINUX_STDDEF_H
  4. #include <uapi/linux/stddef.h>
  5. #undef NULL
  6. #define NULL ((void *)0)
  7. enum {
  8. false = 0,
  9. true = 1
  10. };
  11. #undef offsetof
  12. #ifdef __compiler_offsetof
  13. #define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
  14. #else
  15. #define offsetof(TYPE, MEMBER) ((size_t)&((TYPE *)0)->MEMBER)
  16. #endif
  17. /**
  18. * sizeof_field(TYPE, MEMBER)
  19. *
  20. * @TYPE: The structure containing the field of interest
  21. * @MEMBER: The field to return the size of
  22. */
  23. #define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER))
  24. /**
  25. * offsetofend(TYPE, MEMBER)
  26. *
  27. * @TYPE: The type of the structure
  28. * @MEMBER: The member within the structure to get the end offset of
  29. */
  30. #define offsetofend(TYPE, MEMBER) \
  31. (offsetof(TYPE, MEMBER) + sizeof_field(TYPE, MEMBER))
  32. #endif