You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

stddef.h 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef STDDEF_H
  2. #define STDDEF_H
  3. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  4. #include <stdint.h>
  5. /** EFI headers also define NULL */
  6. #undef NULL
  7. /** Null pointer */
  8. #define NULL ( ( void * ) 0 )
  9. /**
  10. * Get offset of a field within a structure
  11. *
  12. * @v type Structure type
  13. * @v field Field within structure
  14. * @ret offset Offset within structure
  15. */
  16. #if defined ( __GNUC__ ) && ( __GNUC__ > 3 )
  17. #define offsetof( type, field ) __builtin_offsetof ( type, field )
  18. #else
  19. #define offsetof( type, field ) ( ( size_t ) &( ( ( type * ) NULL )->field ) )
  20. #endif
  21. /**
  22. * Get containing structure
  23. *
  24. * @v ptr Pointer to contained field
  25. * @v type Containing structure type
  26. * @v field Field within containing structure
  27. * @ret container Pointer to containing structure
  28. */
  29. #define container_of( ptr, type, field ) ( { \
  30. type *__container; \
  31. const volatile typeof ( __container->field ) *__field = (ptr); \
  32. __container = ( ( ( void * ) __field ) - \
  33. offsetof ( type, field ) ); \
  34. __container; } )
  35. /* __WCHAR_TYPE__ is defined by gcc and will change if -fshort-wchar is used */
  36. #ifndef __WCHAR_TYPE__
  37. #define __WCHAR_TYPE__ uint16_t
  38. #endif
  39. #ifndef __WINT_TYPE__
  40. #define __WINT_TYPE__ int
  41. #endif
  42. typedef __WCHAR_TYPE__ wchar_t;
  43. typedef __WINT_TYPE__ wint_t;
  44. #endif /* STDDEF_H */