UDI_BASE_STRUCT(3udi)


Find base of structure from pointer to member

SYNOPSIS

#include <udi.h>

#define UDI_BASE_STRUCT( \

		memberp, struct_type, member_name) \

			((struct_type *)((char *)(memberp) - \

			   offsetof(struct_type, member_name)))
 

ARGUMENTS memberp is a pointer to a member of a structure.

struct_type is the ISO C data type of the structure.

member_name is the name of the member within the structure.

DESCRIPTION UDI_BASE_STRUCT takes a pointer to a structure member, memberp, and returns a point to the base of the structure.

This has general utility beyond queueing, but is particularly useful with the queueing utilities, when a udi_queue_t is embedded beyond the first member of a structure.

return value This macro returns a pointer to the base of the structure, of type (struct_type *).


UDI Core Specification Contents