2005-04-08 17:01:17 +02:00
|
|
|
#ifndef STDDEF_H
|
|
|
|
#define STDDEF_H
|
|
|
|
|
2015-03-02 15:10:21 +01:00
|
|
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
2009-05-01 16:41:06 +02:00
|
|
|
|
2006-03-23 23:07:21 +01:00
|
|
|
#include <stdint.h>
|
2005-04-08 17:01:17 +02:00
|
|
|
|
2015-03-02 15:10:21 +01:00
|
|
|
/** EFI headers also define NULL */
|
2005-04-08 17:01:17 +02:00
|
|
|
#undef NULL
|
|
|
|
|
2015-03-02 15:10:21 +01:00
|
|
|
/** Null pointer */
|
|
|
|
#define NULL ( ( void * ) 0 )
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get offset of a field within a structure
|
|
|
|
*
|
|
|
|
* @v type Structure type
|
|
|
|
* @v field Field within structure
|
|
|
|
* @ret offset Offset within structure
|
|
|
|
*/
|
|
|
|
#if defined ( __GNUC__ ) && ( __GNUC__ > 3 )
|
|
|
|
#define offsetof( type, field ) __builtin_offsetof ( type, field )
|
2010-11-28 18:26:27 +01:00
|
|
|
#else
|
2015-03-02 15:10:21 +01:00
|
|
|
#define offsetof( type, field ) ( ( size_t ) &( ( ( type * ) NULL )->field ) )
|
2010-11-28 18:26:27 +01:00
|
|
|
#endif
|
2005-04-08 17:01:17 +02:00
|
|
|
|
2015-03-02 15:10:21 +01:00
|
|
|
/**
|
|
|
|
* Get containing structure
|
|
|
|
*
|
|
|
|
* @v ptr Pointer to contained field
|
|
|
|
* @v type Containing structure type
|
|
|
|
* @v field Field within containing structure
|
|
|
|
* @ret container Pointer to containing structure
|
|
|
|
*/
|
|
|
|
#define container_of( ptr, type, field ) ( { \
|
|
|
|
type *__container; \
|
2016-03-18 09:18:31 +01:00
|
|
|
const volatile typeof ( __container->field ) *__field = (ptr); \
|
2015-03-02 15:10:21 +01:00
|
|
|
__container = ( ( ( void * ) __field ) - \
|
|
|
|
offsetof ( type, field ) ); \
|
|
|
|
__container; } )
|
2006-03-23 23:07:21 +01:00
|
|
|
|
2008-10-07 23:27:55 +02:00
|
|
|
/* __WCHAR_TYPE__ is defined by gcc and will change if -fshort-wchar is used */
|
|
|
|
#ifndef __WCHAR_TYPE__
|
2013-04-28 18:43:37 +02:00
|
|
|
#define __WCHAR_TYPE__ uint16_t
|
2008-10-07 23:27:55 +02:00
|
|
|
#endif
|
2013-04-25 15:51:33 +02:00
|
|
|
#ifndef __WINT_TYPE__
|
2013-04-28 18:43:37 +02:00
|
|
|
#define __WINT_TYPE__ int
|
2013-04-25 15:51:33 +02:00
|
|
|
#endif
|
2008-10-07 23:27:55 +02:00
|
|
|
typedef __WCHAR_TYPE__ wchar_t;
|
2012-07-19 14:57:17 +02:00
|
|
|
typedef __WINT_TYPE__ wint_t;
|
2008-10-07 23:27:55 +02:00
|
|
|
|
2005-04-08 17:01:17 +02:00
|
|
|
#endif /* STDDEF_H */
|