Convert all users of fldoff() to offsetof(). fldoff() is bad
because it only takes a struct tag which makes it impossible to use unions, typedefs etc. Define __offsetof() in <machine/ansi.h> Define offsetof() in terms of __offsetof() in <stddef.h> and <sys/types.h> Remove myriad of local offsetof() definitions. Remove includes of <stddef.h> in kernel code. NB: Kernelcode should *never* include from /usr/include ! Make <sys/queue.h> include <machine/ansi.h> to avoid polluting the API. Deprecate <struct.h> with a warning. The warning turns into an error on 01-12-2000 and the file gets removed entirely on 01-01-2001. Paritials reviews by: various. Significant brucifications by: bde
This commit is contained in:
parent
303fd73aa7
commit
46aa3347cb
@ -31,6 +31,8 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)stddef.h 8.1 (Berkeley) 6/2/93
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _STDDEF_H_
|
||||
@ -61,6 +63,6 @@ typedef _BSD_WCHAR_T_ wchar_t;
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#define offsetof(type, member) ((size_t)(&((type *)0)->member))
|
||||
#define offsetof(type, member) __offsetof(type, member)
|
||||
|
||||
#endif /* _STDDEF_H_ */
|
||||
|
@ -31,11 +31,17 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)struct.h 8.1 (Berkeley) 6/2/93
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _STRUCT_H_
|
||||
#define _STRUCT_H_
|
||||
|
||||
#if __GNUC__
|
||||
#warning "this file includes <struct.h> which is deprecated, use <stddef.h> instead"
|
||||
#endif
|
||||
|
||||
/* Offset of the field in the structure. */
|
||||
#define fldoff(name, field) \
|
||||
((int)&(((struct name *)0)->field))
|
||||
|
@ -231,8 +231,6 @@ static vm_offset_t buffer_sva, buffer_eva;
|
||||
vm_offset_t clean_sva, clean_eva;
|
||||
static vm_offset_t pager_sva, pager_eva;
|
||||
|
||||
#define offsetof(type, member) ((size_t)(&((type *)0)->member))
|
||||
|
||||
/*
|
||||
* Hooked into the shutdown chain; if the system is to be halted,
|
||||
* unconditionally drop back to the SRM console.
|
||||
|
@ -105,6 +105,11 @@ typedef struct {
|
||||
#define _BSD_CLK_TCK_ 100
|
||||
#define _BSD_CLOCKS_PER_SEC_ 100
|
||||
|
||||
/*
|
||||
* We define this here since both <stddef.h> and <sys/types.h> needs it.
|
||||
*/
|
||||
#define __offsetof(type, field) ((size_t)(&((type *)0)->field))
|
||||
|
||||
/*
|
||||
* Internal names for basic integral types. Omit the typedef if
|
||||
* not possible for a machine/compiler combination.
|
||||
|
@ -250,8 +250,6 @@ struct cpuhead cpuhead;
|
||||
MUTEX_DECLARE(,sched_lock);
|
||||
MUTEX_DECLARE(,Giant);
|
||||
|
||||
#define offsetof(type, member) ((size_t)(&((type *)0)->member))
|
||||
|
||||
static void
|
||||
cpu_startup(dummy)
|
||||
void *dummy;
|
||||
|
@ -189,7 +189,7 @@ SYSCTL_OPAQUE(_debug, OID_AUTO, tsc_timecounter, CTLFLAG_RD,
|
||||
static struct timecounter i8254_timecounter = {
|
||||
i8254_get_timecount, /* get_timecount */
|
||||
0, /* no poll_pps */
|
||||
~0u, /* counter_mask */
|
||||
0x1ffff, /* counter_mask */
|
||||
0, /* frequency */
|
||||
"i8254" /* name */
|
||||
};
|
||||
|
@ -32,7 +32,7 @@ hint.npx.0.at="nexus"
|
||||
hint.npx.0.port="0x0F0"
|
||||
hint.npx.0.irq="13"
|
||||
hint.apm.0.at="nexus"
|
||||
hint.apm.0.disabled="1"
|
||||
#hint.apm.0.disabled="1"
|
||||
hint.apm.0.flags="0x20"
|
||||
hint.pcic.0.at="isa"
|
||||
# hint.pcic.0.irq="10" # Default to polling
|
||||
|
@ -189,7 +189,7 @@ SYSCTL_OPAQUE(_debug, OID_AUTO, tsc_timecounter, CTLFLAG_RD,
|
||||
static struct timecounter i8254_timecounter = {
|
||||
i8254_get_timecount, /* get_timecount */
|
||||
0, /* no poll_pps */
|
||||
~0u, /* counter_mask */
|
||||
0x1ffff, /* counter_mask */
|
||||
0, /* frequency */
|
||||
"i8254" /* name */
|
||||
};
|
||||
|
@ -27,7 +27,6 @@
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
#include <stddef.h> /* For offsetof */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/queue.h>
|
||||
|
@ -27,7 +27,6 @@
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
#include <stddef.h> /* For offsetof */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/queue.h>
|
||||
|
@ -1124,12 +1124,12 @@ aac_init(struct aac_softc *sc)
|
||||
ip = &sc->aac_common->ac_init;
|
||||
ip->InitStructRevision = AAC_INIT_STRUCT_REVISION;
|
||||
|
||||
ip->AdapterFibsPhysicalAddress = sc->aac_common_busaddr + fldoff(aac_common, ac_fibs);
|
||||
ip->AdapterFibsPhysicalAddress = sc->aac_common_busaddr + offsetof(struct aac_common, ac_fibs);
|
||||
ip->AdapterFibsVirtualAddress = &sc->aac_common->ac_fibs[0];
|
||||
ip->AdapterFibsSize = AAC_ADAPTER_FIBS * sizeof(struct aac_fib);
|
||||
ip->AdapterFibAlign = sizeof(struct aac_fib);
|
||||
|
||||
ip->PrintfBufferAddress = sc->aac_common_busaddr + fldoff(aac_common, ac_printf);
|
||||
ip->PrintfBufferAddress = sc->aac_common_busaddr + offsetof(struct aac_common, ac_printf);
|
||||
ip->PrintfBufferSize = AAC_PRINTF_BUFSIZE;
|
||||
|
||||
ip->HostPhysMemPages = 0; /* not used? */
|
||||
@ -1191,7 +1191,7 @@ aac_init(struct aac_softc *sc)
|
||||
* Give the init structure to the controller.
|
||||
*/
|
||||
if (aac_sync_command(sc, AAC_MONKER_INITSTRUCT,
|
||||
sc->aac_common_busaddr + fldoff(aac_common, ac_init),
|
||||
sc->aac_common_busaddr + offsetof(struct aac_common, ac_init),
|
||||
0, 0, 0, NULL)) {
|
||||
device_printf(sc->aac_dev, "error establishing init structure\n");
|
||||
return(EIO);
|
||||
@ -1266,7 +1266,7 @@ aac_sync_fib(struct aac_softc *sc, u_int32_t command, u_int32_t xferstate,
|
||||
fib->Header.Size = sizeof(struct aac_fib) + datasize;
|
||||
fib->Header.SenderSize = sizeof(struct aac_fib);
|
||||
fib->Header.SenderFibAddress = (u_int32_t)fib;
|
||||
fib->Header.ReceiverFibAddress = sc->aac_common_busaddr + fldoff(aac_common, ac_sync_fib);
|
||||
fib->Header.ReceiverFibAddress = sc->aac_common_busaddr + offsetof(struct aac_common, ac_sync_fib);
|
||||
|
||||
/*
|
||||
* Copy in data.
|
||||
|
@ -336,13 +336,6 @@ struct aac_code_lookup {
|
||||
u_int32_t code;
|
||||
};
|
||||
|
||||
/*
|
||||
* Borrowed from <struct.h>
|
||||
*/
|
||||
/* Offset of the field in the structure. */
|
||||
#define fldoff(name, field) \
|
||||
((int)&(((struct name *)0)->field))
|
||||
|
||||
/********************************************************************************
|
||||
* Queue primitives
|
||||
*
|
||||
|
@ -44,7 +44,6 @@
|
||||
* code retain the above copyright notice and this comment without
|
||||
* modification.
|
||||
*/
|
||||
#include <stddef.h> /* For offsetof */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -28,8 +28,6 @@
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <stddef.h> /* For offsetof() */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
|
@ -54,8 +54,6 @@
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/kernel.h>
|
||||
|
||||
#include <stddef.h> /* For offsetof */
|
||||
|
||||
#include <sys/bus.h>
|
||||
|
||||
#include <machine/bus_memio.h>
|
||||
|
@ -42,9 +42,6 @@
|
||||
|
||||
#include <cam/scsi/scsi_all.h>
|
||||
|
||||
/* XXX: This is not where we should get fldoff() from. */
|
||||
#include <struct.h>
|
||||
|
||||
#include <dev/mly/mlyreg.h>
|
||||
#include <dev/mly/mlyvar.h>
|
||||
#define MLY_DEFINE_TABLES
|
||||
@ -442,9 +439,9 @@ mly_enable_mmbox(struct mly_softc *sc)
|
||||
bzero(&mci, sizeof(mci));
|
||||
mci.sub_ioctl = MDACIOCTL_SETMEMORYMAILBOX;
|
||||
/* set buffer addresses */
|
||||
mci.param.setmemorymailbox.command_mailbox_physaddr = sc->mly_mmbox_busaddr + fldoff(mly_mmbox, mmm_command);
|
||||
mci.param.setmemorymailbox.status_mailbox_physaddr = sc->mly_mmbox_busaddr + fldoff(mly_mmbox, mmm_status);
|
||||
mci.param.setmemorymailbox.health_buffer_physaddr = sc->mly_mmbox_busaddr + fldoff(mly_mmbox, mmm_health);
|
||||
mci.param.setmemorymailbox.command_mailbox_physaddr = sc->mly_mmbox_busaddr + offsetof(struct mly_mmbox, mmm_command);
|
||||
mci.param.setmemorymailbox.status_mailbox_physaddr = sc->mly_mmbox_busaddr + offsetof(struct mly_mmbox, mmm_status);
|
||||
mci.param.setmemorymailbox.health_buffer_physaddr = sc->mly_mmbox_busaddr + offsetof(struct mly_mmbox, mmm_health);
|
||||
|
||||
/* set buffer sizes - abuse of data_size field is revolting */
|
||||
sp = (u_int8_t *)&mci.data_size;
|
||||
|
@ -34,7 +34,6 @@
|
||||
* midi messages, and vice versa.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <dev/sound/midi/midi.h>
|
||||
|
||||
#define TYPEDRANGE(type, x, lower, upper) \
|
||||
|
@ -62,7 +62,6 @@
|
||||
/* #define SYM_DEBUG_GENERIC_SUPPORT */
|
||||
|
||||
#include <pci.h>
|
||||
#include <stddef.h> /* For offsetof */
|
||||
#include <sys/param.h>
|
||||
|
||||
/*
|
||||
@ -393,9 +392,6 @@ static __inline struct sym_quehead *sym_remque_tail(struct sym_quehead *head)
|
||||
/*
|
||||
* These ones should have been already defined.
|
||||
*/
|
||||
#ifndef offsetof
|
||||
#define offsetof(t, m) ((size_t) (&((t *)0)->m))
|
||||
#endif
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
@ -159,10 +159,6 @@
|
||||
#include <isa/isavar.h>
|
||||
#include <isa/pnpvar.h>
|
||||
|
||||
/* somehow offsetof() was lost in FreeBSD 5.0, so declare it */
|
||||
#undef offsetof
|
||||
#define offsetof(type, field) ( (int)( &((type *)0)->field ) )
|
||||
|
||||
#define WDSTOPHYS(wp, a) ( ((u_long)a) - ((u_long)wp->dx) + ((u_long)wp->dx_p) )
|
||||
#define WDSTOVIRT(wp, a) ( ((char *)a) - ((char*)wp->dx_p) + ((char *)wp->dx) )
|
||||
|
||||
|
@ -46,8 +46,6 @@
|
||||
* @(#)ufs_lookup.c 8.6 (Berkeley) 4/1/94
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/namei.h>
|
||||
|
@ -46,8 +46,6 @@
|
||||
* @(#)ufs_lookup.c 8.6 (Berkeley) 4/1/94
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/namei.h>
|
||||
|
@ -32,7 +32,7 @@ hint.npx.0.at="nexus"
|
||||
hint.npx.0.port="0x0F0"
|
||||
hint.npx.0.irq="13"
|
||||
hint.apm.0.at="nexus"
|
||||
hint.apm.0.disabled="1"
|
||||
#hint.apm.0.disabled="1"
|
||||
hint.apm.0.flags="0x20"
|
||||
hint.pcic.0.at="isa"
|
||||
# hint.pcic.0.irq="10" # Default to polling
|
||||
|
@ -250,8 +250,6 @@ struct cpuhead cpuhead;
|
||||
MUTEX_DECLARE(,sched_lock);
|
||||
MUTEX_DECLARE(,Giant);
|
||||
|
||||
#define offsetof(type, member) ((size_t)(&((type *)0)->member))
|
||||
|
||||
static void
|
||||
cpu_startup(dummy)
|
||||
void *dummy;
|
||||
|
@ -189,7 +189,7 @@ SYSCTL_OPAQUE(_debug, OID_AUTO, tsc_timecounter, CTLFLAG_RD,
|
||||
static struct timecounter i8254_timecounter = {
|
||||
i8254_get_timecount, /* get_timecount */
|
||||
0, /* no poll_pps */
|
||||
~0u, /* counter_mask */
|
||||
0x1ffff, /* counter_mask */
|
||||
0, /* frequency */
|
||||
"i8254" /* name */
|
||||
};
|
||||
|
@ -92,6 +92,11 @@
|
||||
#define _BSD_CLK_TCK_ 128
|
||||
#define _BSD_CLOCKS_PER_SEC_ 128
|
||||
|
||||
/*
|
||||
* We define this here since both <stddef.h> and <sys/types.h> needs it.
|
||||
*/
|
||||
#define __offsetof(type, field) ((size_t)(&((type *)0)->field))
|
||||
|
||||
/*
|
||||
* Typedefs for especially magic types. #define's wouldn't work in the
|
||||
* __GNUC__ case, since __attribute__(()) only works in certain contexts.
|
||||
|
@ -189,7 +189,7 @@ SYSCTL_OPAQUE(_debug, OID_AUTO, tsc_timecounter, CTLFLAG_RD,
|
||||
static struct timecounter i8254_timecounter = {
|
||||
i8254_get_timecount, /* get_timecount */
|
||||
0, /* no poll_pps */
|
||||
~0u, /* counter_mask */
|
||||
0x1ffff, /* counter_mask */
|
||||
0, /* frequency */
|
||||
"i8254" /* name */
|
||||
};
|
||||
|
@ -164,8 +164,6 @@ static vm_offset_t buffer_sva, buffer_eva;
|
||||
vm_offset_t clean_sva, clean_eva;
|
||||
static vm_offset_t pager_sva, pager_eva;
|
||||
|
||||
#define offsetof(type, member) ((size_t)(&((type *)0)->member))
|
||||
|
||||
static void
|
||||
cpu_startup(dummy)
|
||||
void *dummy;
|
||||
|
@ -100,6 +100,11 @@
|
||||
#define _BSD_CLK_TCK_ 100
|
||||
#define _BSD_CLOCKS_PER_SEC_ 100
|
||||
|
||||
/*
|
||||
* We define this here since both <stddef.h> and <sys/types.h> needs it.
|
||||
*/
|
||||
#define __offsetof(type, field) ((size_t)(&((type *)0)->field))
|
||||
|
||||
/*
|
||||
* Internal names for basic integral types. Omit the typedef if
|
||||
* not possible for a machine/compiler combination.
|
||||
|
@ -189,7 +189,7 @@ SYSCTL_OPAQUE(_debug, OID_AUTO, tsc_timecounter, CTLFLAG_RD,
|
||||
static struct timecounter i8254_timecounter = {
|
||||
i8254_get_timecount, /* get_timecount */
|
||||
0, /* no poll_pps */
|
||||
~0u, /* counter_mask */
|
||||
0x1ffff, /* counter_mask */
|
||||
0, /* frequency */
|
||||
"i8254" /* name */
|
||||
};
|
||||
|
@ -49,9 +49,6 @@
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/syslog.h>
|
||||
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
static MALLOC_DEFINE(M_KTRACE, "KTRACE", "KTRACE");
|
||||
|
||||
#ifdef KTRACE
|
||||
|
@ -46,8 +46,6 @@
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/bio.h>
|
||||
|
@ -106,10 +106,6 @@ struct sem_undo {
|
||||
* SEMUSZ is properly aligned.
|
||||
*/
|
||||
|
||||
#ifndef offsetof
|
||||
#define offsetof(type, member) ((size_t)(&((type *)0)->member))
|
||||
#endif
|
||||
|
||||
#define SEM_ALIGN(bytes) (((bytes) + (sizeof(long) - 1)) & ~(sizeof(long) - 1))
|
||||
|
||||
/* actual size of an undo structure */
|
||||
|
@ -550,7 +550,6 @@ unp_bind(unp, nam, p)
|
||||
|
||||
if (unp->unp_vnode != NULL)
|
||||
return (EINVAL);
|
||||
#define offsetof(s, e) ((char *)&((s *)0)->e - (char *)((s *)0))
|
||||
namelen = soun->sun_len - offsetof(struct sockaddr_un, sun_path);
|
||||
if (namelen <= 0)
|
||||
return EINVAL;
|
||||
|
@ -308,10 +308,6 @@ stf_getsrcifa6(ifp)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifndef offsetof
|
||||
#define offsetof(s, e) ((int)&((s *)0)->e)
|
||||
#endif
|
||||
|
||||
static int
|
||||
stf_output(ifp, m, dst, rt)
|
||||
struct ifnet *ifp;
|
||||
|
@ -81,10 +81,6 @@ int ip_gif_ttl = 0;
|
||||
SYSCTL_INT(_net_inet_ip, IPCTL_GIF_TTL, gifttl, CTLFLAG_RW,
|
||||
&ip_gif_ttl, 0, "");
|
||||
|
||||
#ifndef offsetof
|
||||
#define offsetof(s, e) ((int)&((s *)0)->e)
|
||||
#endif
|
||||
|
||||
int
|
||||
in_gif_output(ifp, family, m, rt)
|
||||
struct ifnet *ifp;
|
||||
|
@ -45,8 +45,6 @@
|
||||
#include "opt_ipsec.h"
|
||||
#include "opt_pfil_hooks.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/mbuf.h>
|
||||
|
@ -38,8 +38,6 @@
|
||||
#include "opt_ipsec.h"
|
||||
#include "opt_tcpdebug.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
|
@ -39,7 +39,6 @@
|
||||
#include "opt_ipsec.h"
|
||||
#include "opt_tcpdebug.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/callout.h>
|
||||
|
@ -39,7 +39,6 @@
|
||||
#include "opt_ipsec.h"
|
||||
#include "opt_tcpdebug.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/callout.h>
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include "opt_ipsec.h"
|
||||
#include "opt_inet6.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
|
@ -73,10 +73,6 @@ struct ip6q ip6q; /* ip6 reassemble queue */
|
||||
/* FreeBSD tweak */
|
||||
MALLOC_DEFINE(M_FTABLE, "fragment", "fragment reassembly header");
|
||||
|
||||
#ifndef offsetof /* XXX */
|
||||
#define offsetof(type, member) ((size_t)(&((type *)0)->member))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Initialise reassembly queue and fragment identifier.
|
||||
*/
|
||||
|
@ -1061,9 +1061,7 @@ icmp6_mtudisc_update(dst, icmp6, m)
|
||||
* with hostname changes by sethostname(3)
|
||||
*/
|
||||
#define hostnamelen strlen(hostname)
|
||||
#ifndef offsetof /* XXX */
|
||||
#define offsetof(type, member) ((size_t)(&((type *)0)->member))
|
||||
#endif
|
||||
|
||||
static struct mbuf *
|
||||
ni6_input(m, off)
|
||||
struct mbuf *m;
|
||||
|
@ -68,10 +68,6 @@
|
||||
|
||||
#include <net/net_osdep.h>
|
||||
|
||||
#ifndef offsetof
|
||||
#define offsetof(s, e) ((int)&((s *)0)->e)
|
||||
#endif
|
||||
|
||||
int
|
||||
in6_gif_output(ifp, family, m, rt)
|
||||
struct ifnet *ifp;
|
||||
|
@ -129,8 +129,6 @@
|
||||
|
||||
#include <net/net_osdep.h>
|
||||
|
||||
#define offsetof(type, member) ((size_t)(&((type *)0)->member))
|
||||
|
||||
/*
|
||||
* TCP/IP protocol family: IP6, ICMP6, UDP, TCP.
|
||||
*/
|
||||
|
@ -66,8 +66,6 @@
|
||||
|
||||
#include "opt_ipsec.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/proc.h>
|
||||
@ -409,8 +407,6 @@ rip6_output(m, va_alist)
|
||||
int off;
|
||||
u_int16_t *p;
|
||||
|
||||
#define offsetof(type, member) ((size_t)(&((type *)0)->member)) /* XXX */
|
||||
|
||||
/* compute checksum */
|
||||
if (so->so_proto->pr_protocol == IPPROTO_ICMPV6)
|
||||
off = offsetof(struct icmp6_hdr, icmp6_cksum);
|
||||
|
@ -105,9 +105,6 @@
|
||||
|
||||
#include <net/net_osdep.h>
|
||||
|
||||
#ifndef offsetof
|
||||
#define offsetof(type, member) ((size_t)(&((type *)0)->member))
|
||||
#endif
|
||||
#ifndef satosin
|
||||
#define satosin(s) ((struct sockaddr_in *)s)
|
||||
#endif
|
||||
|
@ -264,8 +264,6 @@ struct cpuhead cpuhead;
|
||||
MUTEX_DECLARE(,sched_lock);
|
||||
MUTEX_DECLARE(,Giant);
|
||||
|
||||
#define offsetof(type, member) ((size_t)(&((type *)0)->member))
|
||||
|
||||
static void
|
||||
cpu_startup(dummy)
|
||||
void *dummy;
|
||||
|
@ -264,8 +264,6 @@ struct cpuhead cpuhead;
|
||||
MUTEX_DECLARE(,sched_lock);
|
||||
MUTEX_DECLARE(,Giant);
|
||||
|
||||
#define offsetof(type, member) ((size_t)(&((type *)0)->member))
|
||||
|
||||
static void
|
||||
cpu_startup(dummy)
|
||||
void *dummy;
|
||||
|
@ -170,8 +170,6 @@
|
||||
**==========================================================
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
|
@ -37,6 +37,8 @@
|
||||
#ifndef _SYS_QUEUE_H_
|
||||
#define _SYS_QUEUE_H_
|
||||
|
||||
#include <machine/ansi.h> /* for __offsetof */
|
||||
|
||||
/*
|
||||
* This file defines five types of data structures: singly-linked lists,
|
||||
* singly-linked tail queues, lists, tail queues, and circular queues.
|
||||
@ -108,18 +110,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* XXX: temporary, we need to find the real home of these.
|
||||
*/
|
||||
|
||||
/* Offset of the field in the structure. */
|
||||
#define __qfldoff(name, field) \
|
||||
((int)&(((struct name *)0)->field))
|
||||
|
||||
/* Address of the structure from a field. */
|
||||
#define __qstrbase(name, addr, field) \
|
||||
((struct name *)((char *)(addr) - __qfldoff(name, field)))
|
||||
|
||||
/*
|
||||
* Singly-linked List declarations.
|
||||
*/
|
||||
@ -236,7 +226,8 @@ struct { \
|
||||
#define STAILQ_LAST(head, type, field) \
|
||||
(STAILQ_EMPTY(head) ? \
|
||||
NULL : \
|
||||
__qstrbase(type, (head)->stqh_last, field))
|
||||
((struct type *) \
|
||||
((char *)((head)->stqh_last) - __offsetof(struct type, field))))
|
||||
|
||||
#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
|
||||
|
||||
|
@ -93,15 +93,14 @@ typedef u_int32_t uid_t; /* user id */
|
||||
typedef int boolean_t;
|
||||
typedef u_int64_t uoff_t;
|
||||
typedef struct vm_page *vm_page_t;
|
||||
#endif
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
struct specinfo;
|
||||
|
||||
typedef u_int32_t udev_t; /* device number */
|
||||
typedef struct specinfo *dev_t;
|
||||
|
||||
#define offsetof(type, field) __offsetof(type, field)
|
||||
|
||||
#else /* !_KERNEL */
|
||||
|
||||
typedef u_int32_t dev_t; /* device number */
|
||||
|
Loading…
x
Reference in New Issue
Block a user