Add the opr_containerof macro, which can be used to find the base
address of a structure which contains a member whose location is known.
This formulation is heavily used throughout OpenAFS to determine the
base address of structures containing queue pointers - this provides
a central definition, rather than coding it from scratch each time.
Change-Id: I2a32a214252ad304238f740ad92579e5bb7287be
Reviewed-on: http://gerrit.openafs.org/5836
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
#ifndef OPENAFS_OPR_OPR_H
#define OPENAFS_OPR_OPR_H 1
+/* macros */
+
+#define opr_containerof(ptr, structure, member) \
+ ((structure *)((char *)(ptr)-(char *)(&((structure *)NULL)->member)))
+
/* assert.c */
+
#ifdef AFS_NT40_ENV
# define opr_abort() opr_NTAbort()
extern void opr_NTAbort(void);