logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

stddef.h (1896B)


  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. #ifndef _LINUX_STDDEF_H
  3. #define _LINUX_STDDEF_H
  4. #ifndef __always_inline
  5. #define __always_inline __inline__
  6. #endif
  7. /**
  8. * __struct_group() - Create a mirrored named and anonyomous struct
  9. *
  10. * @TAG: The tag name for the named sub-struct (usually empty)
  11. * @NAME: The identifier name of the mirrored sub-struct
  12. * @ATTRS: Any struct attributes (usually empty)
  13. * @MEMBERS: The member declarations for the mirrored structs
  14. *
  15. * Used to create an anonymous union of two structs with identical layout
  16. * and size: one anonymous and one named. The former's members can be used
  17. * normally without sub-struct naming, and the latter can be used to
  18. * reason about the start, end, and size of the group of struct members.
  19. * The named struct can also be explicitly tagged for layer reuse, as well
  20. * as both having struct attributes appended.
  21. */
  22. #define __struct_group(TAG, NAME, ATTRS, MEMBERS...) \
  23. union { \
  24. struct { MEMBERS } ATTRS; \
  25. struct TAG { MEMBERS } ATTRS NAME; \
  26. } ATTRS
  27. #ifdef __cplusplus
  28. /* sizeof(struct{}) is 1 in C++, not 0, can't use C version of the macro. */
  29. #define __DECLARE_FLEX_ARRAY(T, member) \
  30. T member[0]
  31. #else
  32. /**
  33. * __DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union
  34. *
  35. * @TYPE: The type of each flexible array element
  36. * @NAME: The name of the flexible array member
  37. *
  38. * In order to have a flexible array member in a union or alone in a
  39. * struct, it needs to be wrapped in an anonymous struct with at least 1
  40. * named member, but that member can be empty.
  41. */
  42. #define __DECLARE_FLEX_ARRAY(TYPE, NAME) \
  43. struct { \
  44. struct { } __empty_ ## NAME; \
  45. TYPE NAME[]; \
  46. }
  47. #endif
  48. #ifndef __counted_by
  49. #define __counted_by(m)
  50. #endif
  51. #ifndef __counted_by_le
  52. #define __counted_by_le(m)
  53. #endif
  54. #ifndef __counted_by_be
  55. #define __counted_by_be(m)
  56. #endif
  57. #endif /* _LINUX_STDDEF_H */