xref: /original-bsd/include/struct.h (revision c3e32dec)
1 /*-
2  * Copyright (c) 1983, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)struct.h	8.1 (Berkeley) 06/02/93
8  */
9 
10 #ifndef _STRUCT_H_
11 #define	_STRUCT_H_
12 
13 /* Offset of the field in the structure. */
14 #define	fldoff(name, field) \
15 	((int)&(((struct name *)0)->field))
16 
17 /* Size of the field in the structure. */
18 #define	fldsiz(name, field) \
19 	(sizeof(((struct name *)0)->field))
20 
21 /* Address of the structure from a field. */
22 #define	strbase(name, addr, field) \
23 	((struct name *)((char *)(addr) - fldoff(name, field)))
24 
25 #endif /* !_STRUCT_H_ */
26