summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/alpha/alpha/machdep.c2
-rw-r--r--sys/alpha/include/ansi.h5
-rw-r--r--sys/amd64/amd64/machdep.c2
-rw-r--r--sys/amd64/amd64/tsc.c2
-rw-r--r--sys/amd64/conf/GENERIC.hints2
-rw-r--r--sys/amd64/isa/clock.c2
-rw-r--r--sys/cam/scsi/scsi_targ_bh.c1
-rw-r--r--sys/cam/scsi/scsi_target.c1
-rw-r--r--sys/dev/aac/aac.c8
-rw-r--r--sys/dev/aac/aacvar.h7
-rw-r--r--sys/dev/advansys/adwcam.c1
-rw-r--r--sys/dev/ahb/ahb.c2
-rw-r--r--sys/dev/dpt/dpt_scsi.c2
-rw-r--r--sys/dev/mly/mly.c9
-rw-r--r--sys/dev/sound/midi/midisynth.c1
-rw-r--r--sys/dev/sym/sym_hipd.c4
-rw-r--r--sys/dev/wds/wd7000.c4
-rw-r--r--sys/gnu/ext2fs/ext2_lookup.c2
-rw-r--r--sys/gnu/fs/ext2fs/ext2_lookup.c2
-rw-r--r--sys/i386/conf/GENERIC.hints2
-rw-r--r--sys/i386/i386/machdep.c2
-rw-r--r--sys/i386/i386/tsc.c2
-rw-r--r--sys/i386/include/ansi.h5
-rw-r--r--sys/i386/isa/clock.c2
-rw-r--r--sys/ia64/ia64/machdep.c2
-rw-r--r--sys/ia64/include/ansi.h5
-rw-r--r--sys/isa/atrtc.c2
-rw-r--r--sys/kern/kern_ktrace.c3
-rw-r--r--sys/kern/subr_diskslice.c2
-rw-r--r--sys/kern/sysv_sem.c4
-rw-r--r--sys/kern/uipc_usrreq.c1
-rw-r--r--sys/net/if_stf.c4
-rw-r--r--sys/netinet/in_gif.c4
-rw-r--r--sys/netinet/ip_input.c2
-rw-r--r--sys/netinet/tcp_output.c2
-rw-r--r--sys/netinet/tcp_subr.c1
-rw-r--r--sys/netinet/tcp_timewait.c1
-rw-r--r--sys/netinet/udp_usrreq.c1
-rw-r--r--sys/netinet6/frag6.c4
-rw-r--r--sys/netinet6/icmp6.c4
-rw-r--r--sys/netinet6/in6_gif.c4
-rw-r--r--sys/netinet6/in6_proto.c2
-rw-r--r--sys/netinet6/raw_ip6.c4
-rw-r--r--sys/netkey/key.c3
-rw-r--r--sys/pc98/i386/machdep.c2
-rw-r--r--sys/pc98/pc98/machdep.c2
-rw-r--r--sys/pci/ncr.c2
-rw-r--r--sys/sys/queue.h17
-rw-r--r--sys/sys/types.h5
49 files changed, 36 insertions, 119 deletions
diff --git a/sys/alpha/alpha/machdep.c b/sys/alpha/alpha/machdep.c
index 47d9951..0cf74e5 100644
--- a/sys/alpha/alpha/machdep.c
+++ b/sys/alpha/alpha/machdep.c
@@ -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.
diff --git a/sys/alpha/include/ansi.h b/sys/alpha/include/ansi.h
index f9b1f42..9eaf663 100644
--- a/sys/alpha/include/ansi.h
+++ b/sys/alpha/include/ansi.h
@@ -106,6 +106,11 @@ typedef struct {
#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.
*/
diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c
index 62c698b..1d15d39 100644
--- a/sys/amd64/amd64/machdep.c
+++ b/sys/amd64/amd64/machdep.c
@@ -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;
diff --git a/sys/amd64/amd64/tsc.c b/sys/amd64/amd64/tsc.c
index 1ad7bf4..8a84bf8 100644
--- a/sys/amd64/amd64/tsc.c
+++ b/sys/amd64/amd64/tsc.c
@@ -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 */
};
diff --git a/sys/amd64/conf/GENERIC.hints b/sys/amd64/conf/GENERIC.hints
index 652faa9..9603f4b 100644
--- a/sys/amd64/conf/GENERIC.hints
+++ b/sys/amd64/conf/GENERIC.hints
@@ -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
diff --git a/sys/amd64/isa/clock.c b/sys/amd64/isa/clock.c
index 1ad7bf4..8a84bf8 100644
--- a/sys/amd64/isa/clock.c
+++ b/sys/amd64/isa/clock.c
@@ -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 */
};
diff --git a/sys/cam/scsi/scsi_targ_bh.c b/sys/cam/scsi/scsi_targ_bh.c
index d3ceffa..e8da352 100644
--- a/sys/cam/scsi/scsi_targ_bh.c
+++ b/sys/cam/scsi/scsi_targ_bh.c
@@ -27,7 +27,6 @@
*
* $FreeBSD$
*/
-#include <stddef.h> /* For offsetof */
#include <sys/param.h>
#include <sys/queue.h>
diff --git a/sys/cam/scsi/scsi_target.c b/sys/cam/scsi/scsi_target.c
index 686a90a..91a2d3a 100644
--- a/sys/cam/scsi/scsi_target.c
+++ b/sys/cam/scsi/scsi_target.c
@@ -27,7 +27,6 @@
*
* $FreeBSD$
*/
-#include <stddef.h> /* For offsetof */
#include <sys/param.h>
#include <sys/queue.h>
diff --git a/sys/dev/aac/aac.c b/sys/dev/aac/aac.c
index 938db51..87cc9ae 100644
--- a/sys/dev/aac/aac.c
+++ b/sys/dev/aac/aac.c
@@ -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.
diff --git a/sys/dev/aac/aacvar.h b/sys/dev/aac/aacvar.h
index e65dd66..f70cb64 100644
--- a/sys/dev/aac/aacvar.h
+++ b/sys/dev/aac/aacvar.h
@@ -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
*
diff --git a/sys/dev/advansys/adwcam.c b/sys/dev/advansys/adwcam.c
index 95777a6..77c1718 100644
--- a/sys/dev/advansys/adwcam.c
+++ b/sys/dev/advansys/adwcam.c
@@ -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>
diff --git a/sys/dev/ahb/ahb.c b/sys/dev/ahb/ahb.c
index 0388b3e..9fc15a4 100644
--- a/sys/dev/ahb/ahb.c
+++ b/sys/dev/ahb/ahb.c
@@ -28,8 +28,6 @@
* $FreeBSD$
*/
-#include <stddef.h> /* For offsetof() */
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
diff --git a/sys/dev/dpt/dpt_scsi.c b/sys/dev/dpt/dpt_scsi.c
index 7b5fd94..9fa12e5 100644
--- a/sys/dev/dpt/dpt_scsi.c
+++ b/sys/dev/dpt/dpt_scsi.c
@@ -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>
diff --git a/sys/dev/mly/mly.c b/sys/dev/mly/mly.c
index 15073f4..91cec9c 100644
--- a/sys/dev/mly/mly.c
+++ b/sys/dev/mly/mly.c
@@ -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;
diff --git a/sys/dev/sound/midi/midisynth.c b/sys/dev/sound/midi/midisynth.c
index 42a2a7e..0c6dd8a 100644
--- a/sys/dev/sound/midi/midisynth.c
+++ b/sys/dev/sound/midi/midisynth.c
@@ -34,7 +34,6 @@
* midi messages, and vice versa.
*/
-#include <stddef.h>
#include <dev/sound/midi/midi.h>
#define TYPEDRANGE(type, x, lower, upper) \
diff --git a/sys/dev/sym/sym_hipd.c b/sys/dev/sym/sym_hipd.c
index fa6fcc2..45f148a 100644
--- a/sys/dev/sym/sym_hipd.c
+++ b/sys/dev/sym/sym_hipd.c
@@ -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
diff --git a/sys/dev/wds/wd7000.c b/sys/dev/wds/wd7000.c
index abba71d3..c09532a 100644
--- a/sys/dev/wds/wd7000.c
+++ b/sys/dev/wds/wd7000.c
@@ -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) )
diff --git a/sys/gnu/ext2fs/ext2_lookup.c b/sys/gnu/ext2fs/ext2_lookup.c
index 7909a6c..4804ff1 100644
--- a/sys/gnu/ext2fs/ext2_lookup.c
+++ b/sys/gnu/ext2fs/ext2_lookup.c
@@ -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>
diff --git a/sys/gnu/fs/ext2fs/ext2_lookup.c b/sys/gnu/fs/ext2fs/ext2_lookup.c
index 7909a6c..4804ff1 100644
--- a/sys/gnu/fs/ext2fs/ext2_lookup.c
+++ b/sys/gnu/fs/ext2fs/ext2_lookup.c
@@ -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>
diff --git a/sys/i386/conf/GENERIC.hints b/sys/i386/conf/GENERIC.hints
index 652faa9..9603f4b 100644
--- a/sys/i386/conf/GENERIC.hints
+++ b/sys/i386/conf/GENERIC.hints
@@ -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
diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c
index 62c698b..1d15d39 100644
--- a/sys/i386/i386/machdep.c
+++ b/sys/i386/i386/machdep.c
@@ -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;
diff --git a/sys/i386/i386/tsc.c b/sys/i386/i386/tsc.c
index 1ad7bf4..8a84bf8 100644
--- a/sys/i386/i386/tsc.c
+++ b/sys/i386/i386/tsc.c
@@ -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 */
};
diff --git a/sys/i386/include/ansi.h b/sys/i386/include/ansi.h
index 65ab84f..f01fe5e 100644
--- a/sys/i386/include/ansi.h
+++ b/sys/i386/include/ansi.h
@@ -93,6 +93,11 @@
#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.
* This is not in <machine/types.h>, since that has too much namespace
diff --git a/sys/i386/isa/clock.c b/sys/i386/isa/clock.c
index 1ad7bf4..8a84bf8 100644
--- a/sys/i386/isa/clock.c
+++ b/sys/i386/isa/clock.c
@@ -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 */
};
diff --git a/sys/ia64/ia64/machdep.c b/sys/ia64/ia64/machdep.c
index 434f012..0fae551 100644
--- a/sys/ia64/ia64/machdep.c
+++ b/sys/ia64/ia64/machdep.c
@@ -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;
diff --git a/sys/ia64/include/ansi.h b/sys/ia64/include/ansi.h
index c5ef23d..c4e1156 100644
--- a/sys/ia64/include/ansi.h
+++ b/sys/ia64/include/ansi.h
@@ -101,6 +101,11 @@
#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.
*/
diff --git a/sys/isa/atrtc.c b/sys/isa/atrtc.c
index 1ad7bf4..8a84bf8 100644
--- a/sys/isa/atrtc.c
+++ b/sys/isa/atrtc.c
@@ -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 */
};
diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c
index e51f8d1..7d2e75a 100644
--- a/sys/kern/kern_ktrace.c
+++ b/sys/kern/kern_ktrace.c
@@ -49,9 +49,6 @@
#include <sys/malloc.h>
#include <sys/syslog.h>
-
-#include <stddef.h>
-
static MALLOC_DEFINE(M_KTRACE, "KTRACE", "KTRACE");
#ifdef KTRACE
diff --git a/sys/kern/subr_diskslice.c b/sys/kern/subr_diskslice.c
index eed211c..25a88be 100644
--- a/sys/kern/subr_diskslice.c
+++ b/sys/kern/subr_diskslice.c
@@ -46,8 +46,6 @@
* $FreeBSD$
*/
-#include <stddef.h>
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bio.h>
diff --git a/sys/kern/sysv_sem.c b/sys/kern/sysv_sem.c
index 7d78bfd..3d4fbdd 100644
--- a/sys/kern/sysv_sem.c
+++ b/sys/kern/sysv_sem.c
@@ -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 */
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
index 0e028e7..d77b67b 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -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;
diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c
index bfd462a..6b3834d 100644
--- a/sys/net/if_stf.c
+++ b/sys/net/if_stf.c
@@ -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;
diff --git a/sys/netinet/in_gif.c b/sys/netinet/in_gif.c
index bce267c..a27339b 100644
--- a/sys/netinet/in_gif.c
+++ b/sys/netinet/in_gif.c
@@ -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;
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index ed68439..0405b96 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -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>
diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c
index ce5f13b..9ffbf58 100644
--- a/sys/netinet/tcp_output.c
+++ b/sys/netinet/tcp_output.c
@@ -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>
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index 25c9b66..c3616a5 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -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>
diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c
index 25c9b66..c3616a5 100644
--- a/sys/netinet/tcp_timewait.c
+++ b/sys/netinet/tcp_timewait.c
@@ -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>
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index 07b1166..f357905 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -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>
diff --git a/sys/netinet6/frag6.c b/sys/netinet6/frag6.c
index 1bf7e73..d783357 100644
--- a/sys/netinet6/frag6.c
+++ b/sys/netinet6/frag6.c
@@ -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.
*/
diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c
index a5f6326..9dca71e 100644
--- a/sys/netinet6/icmp6.c
+++ b/sys/netinet6/icmp6.c
@@ -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;
diff --git a/sys/netinet6/in6_gif.c b/sys/netinet6/in6_gif.c
index e554f5a..c8c1450 100644
--- a/sys/netinet6/in6_gif.c
+++ b/sys/netinet6/in6_gif.c
@@ -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;
diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c
index 8af642f..87db176 100644
--- a/sys/netinet6/in6_proto.c
+++ b/sys/netinet6/in6_proto.c
@@ -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.
*/
diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c
index a846b3c..95c7d20 100644
--- a/sys/netinet6/raw_ip6.c
+++ b/sys/netinet6/raw_ip6.c
@@ -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);
diff --git a/sys/netkey/key.c b/sys/netkey/key.c
index caa2f93..8e9e356 100644
--- a/sys/netkey/key.c
+++ b/sys/netkey/key.c
@@ -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
diff --git a/sys/pc98/i386/machdep.c b/sys/pc98/i386/machdep.c
index eba5061..591503b 100644
--- a/sys/pc98/i386/machdep.c
+++ b/sys/pc98/i386/machdep.c
@@ -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;
diff --git a/sys/pc98/pc98/machdep.c b/sys/pc98/pc98/machdep.c
index eba5061..591503b 100644
--- a/sys/pc98/pc98/machdep.c
+++ b/sys/pc98/pc98/machdep.c
@@ -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;
diff --git a/sys/pci/ncr.c b/sys/pci/ncr.c
index 77d6940..c30e922 100644
--- a/sys/pci/ncr.c
+++ b/sys/pci/ncr.c
@@ -170,8 +170,6 @@
**==========================================================
*/
-#include <stddef.h>
-
#include <sys/param.h>
#include <sys/time.h>
diff --git a/sys/sys/queue.h b/sys/sys/queue.h
index ee66759..ab232b8 100644
--- a/sys/sys/queue.h
+++ b/sys/sys/queue.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.
@@ -109,18 +111,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.
*/
#define SLIST_HEAD(name, type) \
@@ -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)
diff --git a/sys/sys/types.h b/sys/sys/types.h
index f4bef46..f0c21f2 100644
--- a/sys/sys/types.h
+++ b/sys/sys/types.h
@@ -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 */
OpenPOWER on IntegriCloud