summaryrefslogtreecommitdiffstats
path: root/freebsd/sys/kern
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-12-09 14:19:03 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-01-10 09:53:34 +0100
commit75b706fde4cbf82bcd41a1cec319778aa0f8eb2d (patch)
treeea39a351a1f6337b5a5dd6036314693adef5ffe6 /freebsd/sys/kern
parentVMSTAT(8): Port to RTEMS (diff)
downloadrtems-libbsd-75b706fde4cbf82bcd41a1cec319778aa0f8eb2d.tar.bz2
Update to FreeBSD head 2016-12-10
Git mirror commit 80c55f08a05ab3b26a73b226ccb56adc3122a55c.
Diffstat (limited to 'freebsd/sys/kern')
-rw-r--r--freebsd/sys/kern/init_main.c42
-rw-r--r--freebsd/sys/kern/kern_condvar.c4
-rw-r--r--freebsd/sys/kern/kern_linker.c38
-rw-r--r--freebsd/sys/kern/kern_mib.c22
-rw-r--r--freebsd/sys/kern/kern_synch.c10
-rw-r--r--freebsd/sys/kern/kern_sysctl.c2
-rw-r--r--freebsd/sys/kern/kern_time.c2
-rw-r--r--freebsd/sys/kern/kern_timeout.c4
-rw-r--r--freebsd/sys/kern/subr_bus.c74
-rw-r--r--freebsd/sys/kern/subr_hash.c2
-rw-r--r--freebsd/sys/kern/subr_pcpu.c2
-rw-r--r--freebsd/sys/kern/subr_prf.c6
-rw-r--r--freebsd/sys/kern/subr_sleepqueue.c6
-rw-r--r--freebsd/sys/kern/subr_taskqueue.c28
-rw-r--r--freebsd/sys/kern/subr_uio.c4
-rw-r--r--freebsd/sys/kern/sys_generic.c2
-rw-r--r--freebsd/sys/kern/sys_socket.c2
-rw-r--r--freebsd/sys/kern/uipc_accf.c2
-rw-r--r--freebsd/sys/kern/uipc_domain.c2
-rw-r--r--freebsd/sys/kern/uipc_mbuf.c6
-rw-r--r--freebsd/sys/kern/uipc_mbuf2.c2
-rw-r--r--freebsd/sys/kern/uipc_sockbuf.c2
-rw-r--r--freebsd/sys/kern/uipc_socket.c5
-rw-r--r--freebsd/sys/kern/uipc_syscalls.c310
-rw-r--r--freebsd/sys/kern/uipc_usrreq.c16
25 files changed, 266 insertions, 329 deletions
diff --git a/freebsd/sys/kern/init_main.c b/freebsd/sys/kern/init_main.c
index 627c01e0..72bab872 100644
--- a/freebsd/sys/kern/init_main.c
+++ b/freebsd/sys/kern/init_main.c
@@ -215,9 +215,9 @@ void
mi_startup(void)
{
- register struct sysinit **sipp; /* system initialization*/
- register struct sysinit **xipp; /* interior loop of sort*/
- register struct sysinit *save; /* bubble*/
+ struct sysinit **sipp; /* system initialization*/
+ struct sysinit **xipp; /* interior loop of sort*/
+ struct sysinit *save; /* bubble*/
#ifdef __rtems__
struct sysinit **sysinit = NULL;
struct sysinit **sysinit_end = NULL;
@@ -339,16 +339,7 @@ restart:
#endif /* __rtems__ */
}
-
#ifndef __rtems__
-/*
- ***************************************************************************
- ****
- **** The following SYSINIT's belong elsewhere, but have not yet
- **** been moved.
- ****
- ***************************************************************************
- */
static void
print_caddr_t(void *data)
{
@@ -442,17 +433,10 @@ struct sysentvec null_sysvec = {
};
/*
- ***************************************************************************
- ****
- **** The two following SYSINIT's are proc0 specific glue code. I am not
- **** convinced that they can not be safely combined, but their order of
- **** operation has been maintained as the same as the original init_main.c
- **** for right now.
- ****
- **** These probably belong in init_proc.c or kern_proc.c, since they
- **** deal with proc0 (the fork template process).
- ****
- ***************************************************************************
+ * The two following SYSINIT's are proc0 specific glue code. I am not
+ * convinced that they can not be safely combined, but their order of
+ * operation has been maintained as the same as the original init_main.c
+ * for right now.
*/
/* ARGSUSED*/
static void
@@ -686,16 +670,6 @@ SYSINIT(random, SI_SUB_RANDOM, SI_ORDER_FIRST, random_init, NULL);
***************************************************************************
*/
-
-/*
- ***************************************************************************
- ****
- **** The following code probably belongs in another file, like
- **** kern/init_init.c.
- ****
- ***************************************************************************
- */
-
/*
* List of paths to try when searching for "init".
*/
@@ -843,7 +817,7 @@ start_init(void *dummy)
}
/*
- * Like kproc_create(), but runs in it's own address space.
+ * Like kproc_create(), but runs in its own address space.
* We do this early to reserve pid 1.
*
* Note special case - do not make it runnable yet. Other work
diff --git a/freebsd/sys/kern/kern_condvar.c b/freebsd/sys/kern/kern_condvar.c
index 239640e2..6358c376 100644
--- a/freebsd/sys/kern/kern_condvar.c
+++ b/freebsd/sys/kern/kern_condvar.c
@@ -407,6 +407,8 @@ cv_signal(struct cv *cvp)
{
int wakeup_swapper;
+ if (cvp->cv_waiters == 0)
+ return;
wakeup_swapper = 0;
sleepq_lock(cvp);
if (cvp->cv_waiters > 0) {
@@ -434,6 +436,8 @@ cv_broadcastpri(struct cv *cvp, int pri)
{
int wakeup_swapper;
+ if (cvp->cv_waiters == 0)
+ return;
/*
* XXX sleepq_broadcast pri argument changed from -1 meaning
* no pri to 0 meaning no pri.
diff --git a/freebsd/sys/kern/kern_linker.c b/freebsd/sys/kern/kern_linker.c
index a115aa96..82a33023 100644
--- a/freebsd/sys/kern/kern_linker.c
+++ b/freebsd/sys/kern/kern_linker.c
@@ -1615,7 +1615,6 @@ restart:
if (error)
panic("cannot add dependency");
}
- lf->userrefs++; /* so we can (try to) kldunload it */
error = linker_file_lookup_set(lf, MDT_SETNAME, &start,
&stop, NULL);
if (!error) {
@@ -1653,6 +1652,8 @@ restart:
goto fail;
}
linker_file_register_modules(lf);
+ if (!TAILQ_EMPTY(&lf->modules))
+ lf->flags |= LINKER_FILE_MODULES;
if (linker_file_lookup_set(lf, "sysinit_set", &si_start,
&si_stop, NULL) == 0)
sysinit_add(si_start, si_stop);
@@ -1670,6 +1671,41 @@ fail:
SYSINIT(preload, SI_SUB_KLD, SI_ORDER_MIDDLE, linker_preload, 0);
/*
+ * Handle preload files that failed to load any modules.
+ */
+static void
+linker_preload_finish(void *arg)
+{
+ linker_file_t lf, nlf;
+
+ sx_xlock(&kld_sx);
+ TAILQ_FOREACH_SAFE(lf, &linker_files, link, nlf) {
+ /*
+ * If all of the modules in this file failed to load, unload
+ * the file and return an error of ENOEXEC. (Parity with
+ * linker_load_file.)
+ */
+ if ((lf->flags & LINKER_FILE_MODULES) != 0 &&
+ TAILQ_EMPTY(&lf->modules)) {
+ linker_file_unload(lf, LINKER_UNLOAD_FORCE);
+ continue;
+ }
+
+ lf->flags &= ~LINKER_FILE_MODULES;
+ lf->userrefs++; /* so we can (try to) kldunload it */
+ }
+ sx_xunlock(&kld_sx);
+}
+
+/*
+ * Attempt to run after all DECLARE_MODULE SYSINITs. Unfortunately they can be
+ * scheduled at any subsystem and order, so run this as late as possible. init
+ * becomes runnable in SI_SUB_KTHREAD_INIT, so go slightly before that.
+ */
+SYSINIT(preload_finish, SI_SUB_KTHREAD_INIT - 100, SI_ORDER_MIDDLE,
+ linker_preload_finish, 0);
+
+/*
* Search for a not-loaded module by name.
*
* Modules may be found in the following locations:
diff --git a/freebsd/sys/kern/kern_mib.c b/freebsd/sys/kern/kern_mib.c
index aa1c5774..63d8b44f 100644
--- a/freebsd/sys/kern/kern_mib.c
+++ b/freebsd/sys/kern/kern_mib.c
@@ -18,7 +18,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -144,9 +144,12 @@ SYSCTL_INT(_kern, KERN_SAVED_IDS, saved_ids, CTLFLAG_RD|CTLFLAG_CAPRD,
char kernelname[MAXPATHLEN] = "/kernel"; /* XXX bloat */
-SYSCTL_STRING(_kern, KERN_BOOTFILE, bootfile, CTLFLAG_RW,
+SYSCTL_STRING(_kern, KERN_BOOTFILE, bootfile, CTLFLAG_RW | CTLFLAG_MPSAFE,
kernelname, sizeof kernelname, "Name of kernel file booted");
+SYSCTL_INT(_kern, KERN_MAXPHYS, maxphys, CTLFLAG_RD | CTLFLAG_CAPRD,
+ SYSCTL_NULL_INT_PTR, MAXPHYS, "Maximum block I/O access size");
+
SYSCTL_INT(_hw, HW_NCPU, ncpu, CTLFLAG_RD|CTLFLAG_CAPRD,
&mp_ncpus, 0, "Number of active CPUs");
@@ -263,8 +266,9 @@ sysctl_hw_machine_arch(SYSCTL_HANDLER_ARGS)
return (error);
}
-SYSCTL_PROC(_hw, HW_MACHINE_ARCH, machine_arch, CTLTYPE_STRING | CTLFLAG_RD,
- NULL, 0, sysctl_hw_machine_arch, "A", "System architecture");
+SYSCTL_PROC(_hw, HW_MACHINE_ARCH, machine_arch, CTLTYPE_STRING | CTLFLAG_RD |
+ CTLFLAG_MPSAFE, NULL, 0, sysctl_hw_machine_arch, "A",
+ "System architecture");
#endif /* __rtems__ */
SYSCTL_STRING(_kern, OID_AUTO, supported_archs, CTLFLAG_RD | CTLFLAG_MPSAFE,
@@ -339,15 +343,15 @@ sysctl_hostname(SYSCTL_HANDLER_ARGS)
}
SYSCTL_PROC(_kern, KERN_HOSTNAME, hostname,
- CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_PRISON | CTLFLAG_MPSAFE,
+ CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_PRISON | CTLFLAG_CAPRD | CTLFLAG_MPSAFE,
(void *)(offsetof(struct prison, pr_hostname)), MAXHOSTNAMELEN,
sysctl_hostname, "A", "Hostname");
SYSCTL_PROC(_kern, KERN_NISDOMAINNAME, domainname,
- CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_PRISON | CTLFLAG_MPSAFE,
+ CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_PRISON | CTLFLAG_CAPRD | CTLFLAG_MPSAFE,
(void *)(offsetof(struct prison, pr_domainname)), MAXHOSTNAMELEN,
sysctl_hostname, "A", "Name of the current YP/NIS domain");
SYSCTL_PROC(_kern, KERN_HOSTUUID, hostuuid,
- CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_PRISON | CTLFLAG_MPSAFE,
+ CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_PRISON | CTLFLAG_CAPRD | CTLFLAG_MPSAFE,
(void *)(offsetof(struct prison, pr_hostuuid)), HOSTUUIDLEN,
sysctl_hostname, "A", "Host UUID");
@@ -407,8 +411,8 @@ SYSCTL_PROC(_kern, KERN_SECURELVL, securelevel,
/* Actual kernel configuration options. */
extern char kernconfstring[];
-SYSCTL_STRING(_kern, OID_AUTO, conftxt, CTLFLAG_RD, kernconfstring, 0,
- "Kernel configuration file");
+SYSCTL_STRING(_kern, OID_AUTO, conftxt, CTLFLAG_RD | CTLFLAG_MPSAFE,
+ kernconfstring, 0, "Kernel configuration file");
#endif
static int
diff --git a/freebsd/sys/kern/kern_synch.c b/freebsd/sys/kern/kern_synch.c
index 6ecedfd2..6a8e7754 100644
--- a/freebsd/sys/kern/kern_synch.c
+++ b/freebsd/sys/kern/kern_synch.c
@@ -17,7 +17,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -191,13 +191,7 @@ _sleep(void *ident, struct lock_object *lock, int priority,
pri = priority;
#endif /* __rtems__ */
- /*
- * If we are already on a sleep queue, then remove us from that
- * sleep queue first. We have to do this to handle recursive
- * sleeps.
- */
- if (TD_ON_SLEEPQ(td))
- sleepq_remove(td, td->td_wchan);
+ KASSERT(!TD_ON_SLEEPQ(td), ("recursive sleep"));
if ((uint8_t *)ident >= &pause_wchan[0] &&
(uint8_t *)ident <= &pause_wchan[MAXCPU - 1])
diff --git a/freebsd/sys/kern/kern_sysctl.c b/freebsd/sys/kern/kern_sysctl.c
index 3bcf6688..07ddded9 100644
--- a/freebsd/sys/kern/kern_sysctl.c
+++ b/freebsd/sys/kern/kern_sysctl.c
@@ -18,7 +18,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/freebsd/sys/kern/kern_time.c b/freebsd/sys/kern/kern_time.c
index 2fb4dd2e..95111932 100644
--- a/freebsd/sys/kern/kern_time.c
+++ b/freebsd/sys/kern/kern_time.c
@@ -12,7 +12,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/freebsd/sys/kern/kern_timeout.c b/freebsd/sys/kern/kern_timeout.c
index 37ec0956..73b55338 100644
--- a/freebsd/sys/kern/kern_timeout.c
+++ b/freebsd/sys/kern/kern_timeout.c
@@ -17,7 +17,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -1059,6 +1059,8 @@ callout_when(sbintime_t sbt, sbintime_t precision, int flags,
spinlock_exit();
#endif
#endif
+ if (cold && to_sbt == 0)
+ to_sbt = sbinuptime();
if ((flags & C_HARDCLOCK) == 0)
to_sbt += tick_sbt;
} else
diff --git a/freebsd/sys/kern/subr_bus.c b/freebsd/sys/kern/subr_bus.c
index 3eb7d7e9..1175456c 100644
--- a/freebsd/sys/kern/subr_bus.c
+++ b/freebsd/sys/kern/subr_bus.c
@@ -30,6 +30,7 @@
__FBSDID("$FreeBSD$");
#include <rtems/bsd/local/opt_bus.h>
+#include <rtems/bsd/local/opt_ddb.h>
#include <rtems/bsd/sys/param.h>
#include <sys/conf.h>
@@ -67,6 +68,8 @@ __FBSDID("$FreeBSD$");
#include <vm/uma.h>
#include <vm/vm.h>
+#include <ddb/ddb.h>
+
SYSCTL_NODE(_hw, OID_AUTO, bus, CTLFLAG_RW, NULL, NULL);
SYSCTL_ROOT_NODE(OID_AUTO, dev, CTLFLAG_RW, NULL, NULL);
@@ -147,6 +150,9 @@ static MALLOC_DEFINE(M_BUS_SC, "bus-sc", "Bus data structures, softc");
static void devctl2_init(void);
#endif /* __rtems__ */
+#define DRIVERNAME(d) ((d)? d->name : "no driver")
+#define DEVCLANAME(d) ((d)? d->name : "no devclass")
+
#ifdef BUS_DEBUG
static int bus_debug = 1;
@@ -155,8 +161,6 @@ SYSCTL_INT(_debug, OID_AUTO, bus_debug, CTLFLAG_RWTUN, &bus_debug, 0,
#define PDEBUG(a) if (bus_debug) {printf("%s:%d: ", __func__, __LINE__), printf a; printf("\n");}
#define DEVICENAME(d) ((d)? device_get_name(d): "no device")
-#define DRIVERNAME(d) ((d)? d->name : "no driver")
-#define DEVCLANAME(d) ((d)? d->name : "no devclass")
/**
* Produce the indenting, indent*2 spaces plus a '.' ahead of that to
@@ -180,8 +184,6 @@ void print_devclass_list(void);
/* Make the compiler ignore the function calls */
#define PDEBUG(a) /* nop */
#define DEVICENAME(d) /* nop */
-#define DRIVERNAME(d) /* nop */
-#define DEVCLANAME(d) /* nop */
#define print_device_short(d,i) /* nop */
#define print_device(d,i) /* nop */
@@ -1981,15 +1983,17 @@ device_delete_child(device_t dev, device_t child)
PDEBUG(("%s from %s", DEVICENAME(child), DEVICENAME(dev)));
- /* remove children first */
+ /* detach parent before deleting children, if any */
+ if ((error = device_detach(child)) != 0)
+ return (error);
+
+ /* remove children second */
while ((grandchild = TAILQ_FIRST(&child->children)) != NULL) {
error = device_delete_child(child, grandchild);
if (error)
return (error);
}
- if ((error = device_detach(child)) != 0)
- return (error);
if (child->devclass)
devclass_delete_device(child->devclass, child);
if (child->parent)
@@ -2180,6 +2184,12 @@ device_probe_child(device_t dev, device_t child)
}
/*
+ * Reset DF_QUIET in case this driver doesn't
+ * end up as the best driver.
+ */
+ device_verbose(child);
+
+ /*
* Probes that return BUS_PROBE_NOWILDCARD or lower
* only match on devices whose driver was explicitly
* specified.
@@ -3008,6 +3018,7 @@ device_detach(device_t dev)
if (!(dev->flags & DF_FIXEDCLASS))
devclass_delete_device(dev->devclass, dev);
+ device_verbose(dev);
dev->state = DS_NOTPRESENT;
(void)device_set_driver(dev, NULL);
device_sysctl_fini(dev);
@@ -5396,6 +5407,7 @@ devctl2_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag,
case DEV_SUSPEND:
case DEV_RESUME:
case DEV_SET_DRIVER:
+ case DEV_CLEAR_DRIVER:
case DEV_RESCAN:
case DEV_DELETE:
error = priv_check(td, PRIV_DRIVER);
@@ -5561,6 +5573,25 @@ devctl2_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag,
error = device_probe_and_attach(dev);
break;
}
+ case DEV_CLEAR_DRIVER:
+ if (!(dev->flags & DF_FIXEDCLASS)) {
+ error = 0;
+ break;
+ }
+ if (device_is_attached(dev)) {
+ if (req->dr_flags & DEVF_CLEAR_DRIVER_DETACH)
+ error = device_detach(dev);
+ else
+ error = EBUSY;
+ if (error)
+ break;
+ }
+
+ dev->flags &= ~DF_FIXEDCLASS;
+ dev->flags |= DF_WILDCARD;
+ devclass_delete_device(dev->devclass, dev);
+ error = device_probe_and_attach(dev);
+ break;
case DEV_RESCAN:
if (!device_is_attached(dev)) {
error = ENXIO;
@@ -5604,4 +5635,33 @@ devctl2_init(void)
make_dev_credf(MAKEDEV_ETERNAL, &devctl2_cdevsw, 0, NULL,
UID_ROOT, GID_WHEEL, 0600, "devctl2");
}
+
+#ifdef DDB
+DB_SHOW_COMMAND(device, db_show_device)
+{
+ device_t dev;
+
+ if (!have_addr)
+ return;
+
+ dev = (device_t)addr;
+
+ db_printf("name: %s\n", device_get_nameunit(dev));
+ db_printf(" driver: %s\n", DRIVERNAME(dev->driver));
+ db_printf(" class: %s\n", DEVCLANAME(dev->devclass));
+ db_printf(" addr: %p\n", dev);
+ db_printf(" parent: %p\n", dev->parent);
+ db_printf(" softc: %p\n", dev->softc);
+ db_printf(" ivars: %p\n", dev->ivars);
+}
+
+DB_SHOW_ALL_COMMAND(devices, db_show_all_devices)
+{
+ device_t dev;
+
+ TAILQ_FOREACH(dev, &bus_data_devices, devlink) {
+ db_show_device((db_expr_t)dev, true, count, modif);
+ }
+}
+#endif
#endif /* __rtems__ */
diff --git a/freebsd/sys/kern/subr_hash.c b/freebsd/sys/kern/subr_hash.c
index 1371a345..425fd34d 100644
--- a/freebsd/sys/kern/subr_hash.c
+++ b/freebsd/sys/kern/subr_hash.c
@@ -17,7 +17,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/freebsd/sys/kern/subr_pcpu.c b/freebsd/sys/kern/subr_pcpu.c
index 4d223899..5c244b42 100644
--- a/freebsd/sys/kern/subr_pcpu.c
+++ b/freebsd/sys/kern/subr_pcpu.c
@@ -16,7 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the author nor the names of any co-contributors
+ * 3. Neither the name of the author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/freebsd/sys/kern/subr_prf.c b/freebsd/sys/kern/subr_prf.c
index 9273cd2a..2aed7f68 100644
--- a/freebsd/sys/kern/subr_prf.c
+++ b/freebsd/sys/kern/subr_prf.c
@@ -17,7 +17,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -80,7 +80,11 @@ __FBSDID("$FreeBSD$");
* Note that stdarg.h and the ANSI style va_start macro is used for both
* ANSI and traditional C compilers.
*/
+#ifdef _KERNEL
#include <machine/stdarg.h>
+#else
+#include <stdarg.h>
+#endif
#ifdef _KERNEL
diff --git a/freebsd/sys/kern/subr_sleepqueue.c b/freebsd/sys/kern/subr_sleepqueue.c
index be8e7721..a42c62f8 100644
--- a/freebsd/sys/kern/subr_sleepqueue.c
+++ b/freebsd/sys/kern/subr_sleepqueue.c
@@ -434,7 +434,7 @@ sleepq_set_timeout_sbt(void *wchan, sbintime_t sbt, sbintime_t pr,
MPASS(TD_ON_SLEEPQ(td));
MPASS(td->td_sleepqueue == NULL);
MPASS(wchan != NULL);
- if (cold)
+ if (cold && td == &thread0)
panic("timed sleep before timers are working");
KASSERT(td->td_sleeptimo == 0, ("td %d %p td_sleeptimo %jx",
td->td_tid, td, (uintmax_t)td->td_sleeptimo));
@@ -1089,9 +1089,9 @@ sleepq_signal(void *wchan, int flags, int pri, int queue)
* been sleeping the longest since threads are always added to
* the tail of sleep queues.
*/
- besttd = NULL;
+ besttd = TAILQ_FIRST(&sq->sq_blocked[queue]);
TAILQ_FOREACH(td, &sq->sq_blocked[queue], td_slpq) {
- if (besttd == NULL || td->td_priority < besttd->td_priority)
+ if (td->td_priority < besttd->td_priority)
besttd = td;
}
#else /* __rtems__ */
diff --git a/freebsd/sys/kern/subr_taskqueue.c b/freebsd/sys/kern/subr_taskqueue.c
index 8580e8fc..5ef8683c 100644
--- a/freebsd/sys/kern/subr_taskqueue.c
+++ b/freebsd/sys/kern/subr_taskqueue.c
@@ -89,6 +89,7 @@ struct taskqueue {
#define TQ_FLAGS_UNLOCKED_ENQUEUE (1 << 2)
#define DT_CALLOUT_ARMED (1 << 0)
+#define DT_DRAIN_IN_PROGRESS (1 << 1)
#ifndef __rtems__
#define TQ_LOCK(tq) \
@@ -334,7 +335,11 @@ taskqueue_enqueue_timeout(struct taskqueue *queue,
#endif /* __rtems__ */
timeout_task->q = queue;
res = timeout_task->t.ta_pending;
- if (ticks == 0) {
+ if (timeout_task->f & DT_DRAIN_IN_PROGRESS) {
+ /* Do nothing */
+ TQ_UNLOCK(queue);
+ res = -1;
+ } else if (ticks == 0) {
taskqueue_enqueue_locked(queue, &timeout_task->t);
/* The lock is released inside. */
} else {
@@ -598,8 +603,24 @@ taskqueue_drain_timeout(struct taskqueue *queue,
struct timeout_task *timeout_task)
{
+ /*
+ * Set flag to prevent timer from re-starting during drain:
+ */
+ TQ_LOCK(queue);
+ KASSERT((timeout_task->f & DT_DRAIN_IN_PROGRESS) == 0,
+ ("Drain already in progress"));
+ timeout_task->f |= DT_DRAIN_IN_PROGRESS;
+ TQ_UNLOCK(queue);
+
callout_drain(&timeout_task->c);
taskqueue_drain(queue, &timeout_task->t);
+
+ /*
+ * Clear flag to allow timer to re-start:
+ */
+ TQ_LOCK(queue);
+ timeout_task->f &= ~DT_DRAIN_IN_PROGRESS;
+ TQ_UNLOCK(queue);
}
static void
@@ -666,6 +687,11 @@ _taskqueue_start_threads(struct taskqueue **tqp, int count, int pri,
} else
tq->tq_tcount++;
}
+ if (tq->tq_tcount == 0) {
+ free(tq->tq_threads, M_TASKQUEUE);
+ tq->tq_threads = NULL;
+ return (ENOMEM);
+ }
#ifndef __rtems__
for (i = 0; i < count; i++) {
if (tq->tq_threads[i] == NULL)
diff --git a/freebsd/sys/kern/subr_uio.c b/freebsd/sys/kern/subr_uio.c
index a319685a..f5dc76e7 100644
--- a/freebsd/sys/kern/subr_uio.c
+++ b/freebsd/sys/kern/subr_uio.c
@@ -22,7 +22,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -556,7 +556,7 @@ fueword32(volatile const void *base, int32_t *val)
int
fueword64(volatile const void *base, int64_t *val)
{
- int32_t res;
+ int64_t res;
res = fuword64(base);
if (res == -1)
diff --git a/freebsd/sys/kern/sys_generic.c b/freebsd/sys/kern/sys_generic.c
index 26cd9d36..d6b3d15b 100644
--- a/freebsd/sys/kern/sys_generic.c
+++ b/freebsd/sys/kern/sys_generic.c
@@ -17,7 +17,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/freebsd/sys/kern/sys_socket.c b/freebsd/sys/kern/sys_socket.c
index f312c8f4..a2537652 100644
--- a/freebsd/sys/kern/sys_socket.c
+++ b/freebsd/sys/kern/sys_socket.c
@@ -12,7 +12,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/freebsd/sys/kern/uipc_accf.c b/freebsd/sys/kern/uipc_accf.c
index 6ecea0eb..7d6bde25 100644
--- a/freebsd/sys/kern/uipc_accf.c
+++ b/freebsd/sys/kern/uipc_accf.c
@@ -252,7 +252,7 @@ do_setopt_accept_filter(struct socket *so, struct sockopt *sopt)
newaf = malloc(sizeof(*newaf), M_ACCF, M_WAITOK |
M_ZERO);
if (afp->accf_create != NULL && afap->af_name[0] != '\0') {
- int len = strlen(afap->af_name) + 1;
+ size_t len = strlen(afap->af_name) + 1;
newaf->so_accept_filter_str = malloc(len, M_ACCF,
M_WAITOK);
strcpy(newaf->so_accept_filter_str, afap->af_name);
diff --git a/freebsd/sys/kern/uipc_domain.c b/freebsd/sys/kern/uipc_domain.c
index 7c0e7085..ab301eb5 100644
--- a/freebsd/sys/kern/uipc_domain.c
+++ b/freebsd/sys/kern/uipc_domain.c
@@ -12,7 +12,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/freebsd/sys/kern/uipc_mbuf.c b/freebsd/sys/kern/uipc_mbuf.c
index db4975ca..571dd3bd 100644
--- a/freebsd/sys/kern/uipc_mbuf.c
+++ b/freebsd/sys/kern/uipc_mbuf.c
@@ -12,7 +12,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -986,7 +986,7 @@ m_devget(char *buf, int totlen, int off, struct ifnet *ifp,
len = MHLEN;
/* Place initial small packet/header at end of mbuf */
- if (m && totlen + off + max_linkhdr <= MLEN) {
+ if (m && totlen + off + max_linkhdr <= MHLEN) {
m->m_data += max_linkhdr;
len -= max_linkhdr;
}
@@ -1338,7 +1338,7 @@ nospace:
/*
* Defragment an mbuf chain, returning at most maxfrags separate
* mbufs+clusters. If this is not possible NULL is returned and
- * the original mbuf chain is left in it's present (potentially
+ * the original mbuf chain is left in its present (potentially
* modified) state. We use two techniques: collapsing consecutive
* mbufs and replacing consecutive mbufs by a cluster.
*
diff --git a/freebsd/sys/kern/uipc_mbuf2.c b/freebsd/sys/kern/uipc_mbuf2.c
index fef1c514..fc5c8e8a 100644
--- a/freebsd/sys/kern/uipc_mbuf2.c
+++ b/freebsd/sys/kern/uipc_mbuf2.c
@@ -43,7 +43,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/freebsd/sys/kern/uipc_sockbuf.c b/freebsd/sys/kern/uipc_sockbuf.c
index f62014bc..a7977141 100644
--- a/freebsd/sys/kern/uipc_sockbuf.c
+++ b/freebsd/sys/kern/uipc_sockbuf.c
@@ -12,7 +12,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/freebsd/sys/kern/uipc_socket.c b/freebsd/sys/kern/uipc_socket.c
index 3f2dba72..c086ee7c 100644
--- a/freebsd/sys/kern/uipc_socket.c
+++ b/freebsd/sys/kern/uipc_socket.c
@@ -15,7 +15,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -1669,7 +1669,8 @@ dontblock:
do {
if (flags & MSG_PEEK) {
if (controlp != NULL) {
- *controlp = m_copy(m, 0, m->m_len);
+ *controlp = m_copym(m, 0, m->m_len,
+ M_NOWAIT);
controlp = &(*controlp)->m_next;
}
m = m->m_next;
diff --git a/freebsd/sys/kern/uipc_syscalls.c b/freebsd/sys/kern/uipc_syscalls.c
index 99ae6392..2d81fc20 100644
--- a/freebsd/sys/kern/uipc_syscalls.c
+++ b/freebsd/sys/kern/uipc_syscalls.c
@@ -12,7 +12,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -94,20 +94,23 @@ static int sockargs(struct mbuf **, char *, socklen_t, int);
/*
* Convert a user file descriptor to a kernel file entry and check if required
* capability rights are present.
+ * If required copy of current set of capability rights is returned.
* A reference on the file entry is held upon returning.
*/
int
getsock_cap(struct thread *td, int fd, cap_rights_t *rightsp,
- struct file **fpp, u_int *fflagp)
+ struct file **fpp, u_int *fflagp, struct filecaps *havecapsp)
{
struct file *fp;
int error;
- error = fget_unlocked(td->td_proc->p_fd, fd, rightsp, &fp, NULL);
+ error = fget_cap(td, fd, rightsp, &fp, havecapsp);
if (error != 0)
return (error);
if (fp->f_type != DTYPE_SOCKET) {
fdrop(fp, td);
+ if (havecapsp != NULL)
+ filecaps_free(havecapsp);
return (ENOTSOCK);
}
if (fflagp != NULL)
@@ -148,7 +151,7 @@ rtems_bsd_getsock(int fd, struct file **fpp, u_int *fflagp)
return (error);
}
-#define getsock_cap(td, fd, rights, fpp, fflagp) rtems_bsd_getsock(fd, fpp, fflagp)
+#define getsock_cap(td, fd, rights, fpp, fflagp, havecapsp) rtems_bsd_getsock(fd, fpp, fflagp)
#endif /* __rtems__ */
/*
@@ -162,13 +165,7 @@ rtems_bsd_getsock(int fd, struct file **fpp, u_int *fflagp)
static
#endif /* __rtems__ */
int
-sys_socket(td, uap)
- struct thread *td;
- struct socket_args /* {
- int domain;
- int type;
- int protocol;
- } */ *uap;
+sys_socket(struct thread *td, struct socket_args *uap)
{
struct socket *so;
struct file *fp;
@@ -239,7 +236,6 @@ socket(int domain, int type, int protocol)
}
#endif /* __rtems__ */
-/* ARGSUSED */
#ifdef __rtems__
static int kern_bindat(struct thread *td, int dirfd, int fd,
struct sockaddr *sa);
@@ -247,13 +243,7 @@ static int kern_bindat(struct thread *td, int dirfd, int fd,
static
#endif /* __rtems__ */
int
-sys_bind(td, uap)
- struct thread *td;
- struct bind_args /* {
- int s;
- caddr_t name;
- int namelen;
- } */ *uap;
+sys_bind(struct thread *td, struct bind_args *uap)
{
struct sockaddr *sa;
int error;
@@ -298,7 +288,7 @@ kern_bindat(struct thread *td, int dirfd, int fd, struct sockaddr *sa)
AUDIT_ARG_FD(fd);
AUDIT_ARG_SOCKADDR(td, dirfd, sa);
error = getsock_cap(td, fd, cap_rights_init(&rights, CAP_BIND),
- &fp, NULL);
+ &fp, NULL, NULL);
if (error != 0)
return (error);
so = fp->f_data;
@@ -321,18 +311,10 @@ kern_bindat(struct thread *td, int dirfd, int fd, struct sockaddr *sa)
return (error);
}
-/* ARGSUSED */
#ifndef __rtems__
static
int
-sys_bindat(td, uap)
- struct thread *td;
- struct bindat_args /* {
- int fd;
- int s;
- caddr_t name;
- int namelen;
- } */ *uap;
+sys_bindat(struct thread *td, struct bindat_args *uap)
{
struct sockaddr *sa;
int error;
@@ -346,14 +328,8 @@ sys_bindat(td, uap)
}
#endif /* __rtems__ */
-/* ARGSUSED */
int
-sys_listen(td, uap)
- struct thread *td;
- struct listen_args /* {
- int s;
- int backlog;
- } */ *uap;
+sys_listen(struct thread *td, struct listen_args *uap)
{
struct socket *so;
struct file *fp;
@@ -362,7 +338,7 @@ sys_listen(td, uap)
AUDIT_ARG_FD(uap->s);
error = getsock_cap(td, uap->s, cap_rights_init(&rights, CAP_LISTEN),
- &fp, NULL);
+ &fp, NULL, NULL);
if (error == 0) {
so = fp->f_data;
#ifdef MAC
@@ -483,6 +459,7 @@ kern_accept4(struct thread *td, int s, struct sockaddr **name,
struct file *headfp, *nfp = NULL;
struct sockaddr *sa = NULL;
struct socket *head, *so;
+ struct filecaps fcaps;
cap_rights_t rights;
u_int fflag;
pid_t pgid;
@@ -493,7 +470,7 @@ kern_accept4(struct thread *td, int s, struct sockaddr **name,
AUDIT_ARG_FD(s);
error = getsock_cap(td, s, cap_rights_init(&rights, CAP_ACCEPT),
- &headfp, &fflag);
+ &headfp, &fflag, &fcaps);
if (error != 0)
return (error);
head = headfp->f_data;
@@ -506,7 +483,8 @@ kern_accept4(struct thread *td, int s, struct sockaddr **name,
if (error != 0)
goto done;
#endif
- error = falloc(td, &nfp, &fd, (flags & SOCK_CLOEXEC) ? O_CLOEXEC : 0);
+ error = falloc_caps(td, &nfp, &fd,
+ (flags & SOCK_CLOEXEC) ? O_CLOEXEC : 0, &fcaps);
if (error != 0)
goto done;
ACCEPT_LOCK();
@@ -615,6 +593,8 @@ noconnection:
* a reference on nfp to the caller on success if they request it.
*/
done:
+ if (nfp == NULL)
+ filecaps_free(&fcaps);
if (fp != NULL) {
if (error == 0) {
*fp = nfp;
@@ -663,7 +643,6 @@ oaccept(td, uap)
#endif /* COMPAT_OLDSOCK */
#endif /* __rtems__ */
-/* ARGSUSED */
#ifdef __rtems__
static int kern_connectat(struct thread *td, int dirfd, int fd,
struct sockaddr *sa);
@@ -671,13 +650,7 @@ static int kern_connectat(struct thread *td, int dirfd, int fd,
static
#endif /* __rtems__ */
int
-sys_connect(td, uap)
- struct thread *td;
- struct connect_args /* {
- int s;
- caddr_t name;
- int namelen;
- } */ *uap;
+sys_connect(struct thread *td, struct connect_args *uap)
{
struct sockaddr *sa;
int error;
@@ -722,7 +695,7 @@ kern_connectat(struct thread *td, int dirfd, int fd, struct sockaddr *sa)
AUDIT_ARG_FD(fd);
AUDIT_ARG_SOCKADDR(td, dirfd, sa);
error = getsock_cap(td, fd, cap_rights_init(&rights, CAP_CONNECT),
- &fp, NULL);
+ &fp, NULL, NULL);
if (error != 0)
return (error);
so = fp->f_data;
@@ -775,16 +748,8 @@ done1:
}
#ifndef __rtems__
-/* ARGSUSED */
int
-sys_connectat(td, uap)
- struct thread *td;
- struct connectat_args /* {
- int fd;
- int s;
- caddr_t name;
- int namelen;
- } */ *uap;
+sys_connectat(struct thread *td, struct connectat_args *uap)
{
struct sockaddr *sa;
int error;
@@ -936,11 +901,7 @@ kern_sendit( struct thread *td, int s, struct msghdr *mp, int flags,
struct mbuf *control, enum uio_seg segflg);
#endif /* __rtems__ */
static int
-sendit(td, s, mp, flags)
- struct thread *td;
- int s;
- struct msghdr *mp;
- int flags;
+sendit(struct thread *td, int s, struct msghdr *mp, int flags)
{
struct mbuf *control;
struct sockaddr *to;
@@ -998,13 +959,8 @@ bad:
}
int
-kern_sendit(td, s, mp, flags, control, segflg)
- struct thread *td;
- int s;
- struct msghdr *mp;
- int flags;
- struct mbuf *control;
- enum uio_seg segflg;
+kern_sendit(struct thread *td, int s, struct msghdr *mp, int flags,
+ struct mbuf *control, enum uio_seg segflg)
{
struct file *fp;
struct uio auio;
@@ -1026,12 +982,12 @@ kern_sendit(td, s, mp, flags, control, segflg)
AUDIT_ARG_SOCKADDR(td, AT_FDCWD, mp->msg_name);
cap_rights_set(&rights, CAP_CONNECT);
}
- error = getsock_cap(td, s, &rights, &fp, NULL);
- if (error != 0)
#endif /* __rtems__ */
- error = getsock_cap(td->td_proc->p_fd, s, rights, &fp, NULL);
- if (error)
+ error = getsock_cap(td, s, &rights, &fp, NULL, NULL);
+ if (error != 0) {
+ m_freem(control);
return (error);
+ }
so = (struct socket *)fp->f_data;
#ifdef KTRACE
@@ -1042,12 +998,16 @@ kern_sendit(td, s, mp, flags, control, segflg)
if (mp->msg_name != NULL) {
error = mac_socket_check_connect(td->td_ucred, so,
mp->msg_name);
- if (error != 0)
+ if (error != 0) {
+ m_freem(control);
goto bad;
+ }
}
error = mac_socket_check_send(td->td_ucred, so);
- if (error != 0)
+ if (error != 0) {
+ m_freem(control);
goto bad;
+ }
#endif
auio.uio_iov = mp->msg_iov;
@@ -1061,6 +1021,7 @@ kern_sendit(td, s, mp, flags, control, segflg)
for (i = 0; i < mp->msg_iovlen; i++, iov++) {
if ((auio.uio_resid += iov->iov_len) < 0) {
error = EINVAL;
+ m_freem(control);
goto bad;
}
}
@@ -1103,16 +1064,7 @@ bad:
static
#endif /* __rtems__ */
int
-sys_sendto(td, uap)
- struct thread *td;
- struct sendto_args /* {
- int s;
- caddr_t buf;
- size_t len;
- int flags;
- caddr_t to;
- int tolen;
- } */ *uap;
+sys_sendto(struct thread *td, struct sendto_args *uap)
{
struct msghdr msg;
struct iovec aiov;
@@ -1167,7 +1119,7 @@ rtems_bsd_sendto(int socket, struct mbuf *m, int flags,
struct socket *so;
int error;
- error = getsock_cap(td->td_proc->p_fd, socket, CAP_WRITE, &fp, NULL);
+ error = getsock_cap(td->td_proc->p_fd, socket, CAP_WRITE, &fp, NULL, NULL);
if (error)
return (error);
so = (struct socket *)fp->f_data;
@@ -1186,14 +1138,7 @@ rtems_bsd_sendto(int socket, struct mbuf *m, int flags,
#ifndef __rtems__
#ifdef COMPAT_OLDSOCK
int
-osend(td, uap)
- struct thread *td;
- struct osend_args /* {
- int s;
- caddr_t buf;
- int len;
- int flags;
- } */ *uap;
+osend(struct thread *td, struct osend_args *uap)
{
struct msghdr msg;
struct iovec aiov;
@@ -1210,13 +1155,7 @@ osend(td, uap)
}
int
-osendmsg(td, uap)
- struct thread *td;
- struct osendmsg_args /* {
- int s;
- caddr_t msg;
- int flags;
- } */ *uap;
+osendmsg(struct thread *td, struct osendmsg_args *uap)
{
struct msghdr msg;
struct iovec *iov;
@@ -1241,13 +1180,7 @@ osendmsg(td, uap)
static
#endif /* __rtems__ */
int
-sys_sendmsg(td, uap)
- struct thread *td;
- struct sendmsg_args /* {
- int s;
- caddr_t msg;
- int flags;
- } */ *uap;
+sys_sendmsg(struct thread *td, struct sendmsg_args *uap)
{
struct msghdr msg;
struct iovec *iov;
@@ -1297,12 +1230,8 @@ sendmsg(int socket, const struct msghdr *message, int flags)
static
#endif /* __rtems__ */
int
-kern_recvit(td, s, mp, fromseg, controlp)
- struct thread *td;
- int s;
- struct msghdr *mp;
- enum uio_seg fromseg;
- struct mbuf **controlp;
+kern_recvit(struct thread *td, int s, struct msghdr *mp, enum uio_seg fromseg,
+ struct mbuf **controlp)
{
struct uio auio;
struct iovec *iov;
@@ -1323,7 +1252,7 @@ kern_recvit(td, s, mp, fromseg, controlp)
AUDIT_ARG_FD(s);
error = getsock_cap(td, s, cap_rights_init(&rights, CAP_RECV),
- &fp, NULL);
+ &fp, NULL, NULL);
if (error != 0)
return (error);
so = fp->f_data;
@@ -1459,11 +1388,7 @@ out:
}
static int
-recvit(td, s, mp, namelenp)
- struct thread *td;
- int s;
- struct msghdr *mp;
- void *namelenp;
+recvit(struct thread *td, int s, struct msghdr *mp, void *namelenp)
{
int error;
@@ -1484,16 +1409,7 @@ recvit(td, s, mp, namelenp)
static
#endif /* __rtems__ */
int
-sys_recvfrom(td, uap)
- struct thread *td;
- struct recvfrom_args /* {
- int s;
- caddr_t buf;
- size_t len;
- int flags;
- struct sockaddr * __restrict from;
- socklen_t * __restrict fromlenaddr;
- } */ *uap;
+sys_recvfrom(struct thread *td, struct recvfrom_args *uap)
{
struct msghdr msg;
struct iovec aiov;
@@ -1551,9 +1467,7 @@ recvfrom(int socket, void *__restrict buffer, size_t length, int flags,
#ifndef __rtems__
#ifdef COMPAT_OLDSOCK
int
-orecvfrom(td, uap)
- struct thread *td;
- struct recvfrom_args *uap;
+orecvfrom(struct thread *td, struct recvfrom_args *uap)
{
uap->flags |= MSG_COMPAT;
@@ -1563,14 +1477,7 @@ orecvfrom(td, uap)
#ifdef COMPAT_OLDSOCK
int
-orecv(td, uap)
- struct thread *td;
- struct orecv_args /* {
- int s;
- caddr_t buf;
- int len;
- int flags;
- } */ *uap;
+orecv(struct thread *td, struct orecv_args *uap)
{
struct msghdr msg;
struct iovec aiov;
@@ -1592,13 +1499,7 @@ orecv(td, uap)
* rights where the control fields are now.
*/
int
-orecvmsg(td, uap)
- struct thread *td;
- struct orecvmsg_args /* {
- int s;
- struct omsghdr *msg;
- int flags;
- } */ *uap;
+orecvmsg(struct thread *td, struct orecvmsg_args *uap)
{
struct msghdr msg;
struct iovec *iov;
@@ -1626,13 +1527,7 @@ orecvmsg(td, uap)
static
#endif /* __rtems__ */
int
-sys_recvmsg(td, uap)
- struct thread *td;
- struct recvmsg_args /* {
- int s;
- struct msghdr *msg;
- int flags;
- } */ *uap;
+sys_recvmsg(struct thread *td, struct recvmsg_args *uap)
{
struct msghdr msg;
struct iovec *uiov, *iov;
@@ -1684,17 +1579,11 @@ recvmsg(int socket, struct msghdr *message, int flags)
}
#endif /* __rtems__ */
-/* ARGSUSED */
#ifdef __rtems__
static
#endif /* __rtems__ */
int
-sys_shutdown(td, uap)
- struct thread *td;
- struct shutdown_args /* {
- int s;
- int how;
- } */ *uap;
+sys_shutdown(struct thread *td, struct shutdown_args *uap)
{
struct socket *so;
struct file *fp;
@@ -1703,7 +1592,7 @@ sys_shutdown(td, uap)
AUDIT_ARG_FD(uap->s);
error = getsock_cap(td, uap->s, cap_rights_init(&rights, CAP_SHUTDOWN),
- &fp, NULL);
+ &fp, NULL, NULL);
if (error == 0) {
so = fp->f_data;
error = soshutdown(so, uap->how);
@@ -1736,7 +1625,6 @@ shutdown(int socket, int how)
}
#endif /* __rtems__ */
-/* ARGSUSED */
#ifdef __rtems__
static int kern_setsockopt( struct thread *td, int s, int level, int name,
void *val, enum uio_seg valseg, socklen_t valsize);
@@ -1744,15 +1632,7 @@ static int kern_setsockopt( struct thread *td, int s, int level, int name,
static
#endif /* __rtems__ */
int
-sys_setsockopt(td, uap)
- struct thread *td;
- struct setsockopt_args /* {
- int s;
- int level;
- int name;
- caddr_t val;
- int valsize;
- } */ *uap;
+sys_setsockopt(struct thread *td, struct setsockopt_args *uap)
{
return (kern_setsockopt(td, uap->s, uap->level, uap->name,
@@ -1784,14 +1664,8 @@ setsockopt(int socket, int level, int option_name, const void *option_value,
#endif /* __rtems__ */
int
-kern_setsockopt(td, s, level, name, val, valseg, valsize)
- struct thread *td;
- int s;
- int level;
- int name;
- void *val;
- enum uio_seg valseg;
- socklen_t valsize;
+kern_setsockopt(struct thread *td, int s, int level, int name, void *val,
+ enum uio_seg valseg, socklen_t valsize)
{
struct socket *so;
struct file *fp;
@@ -1822,7 +1696,7 @@ kern_setsockopt(td, s, level, name, val, valseg, valsize)
AUDIT_ARG_FD(s);
error = getsock_cap(td, s, cap_rights_init(&rights, CAP_SETSOCKOPT),
- &fp, NULL);
+ &fp, NULL, NULL);
if (error == 0) {
so = fp->f_data;
error = sosetopt(so, &sopt);
@@ -1831,7 +1705,6 @@ kern_setsockopt(td, s, level, name, val, valseg, valsize)
return(error);
}
-/* ARGSUSED */
#ifdef __rtems__
static int kern_getsockopt( struct thread *td, int s, int level, int name,
void *val, enum uio_seg valseg, socklen_t *valsize);
@@ -1839,15 +1712,7 @@ static int kern_getsockopt( struct thread *td, int s, int level, int name,
static
#endif /* __rtems__ */
int
-sys_getsockopt(td, uap)
- struct thread *td;
- struct getsockopt_args /* {
- int s;
- int level;
- int name;
- void * __restrict val;
- socklen_t * __restrict avalsize;
- } */ *uap;
+sys_getsockopt(struct thread *td, struct getsockopt_args *uap)
{
socklen_t valsize;
int error;
@@ -1895,14 +1760,8 @@ getsockopt(int socket, int level, int option_name, void *__restrict
* optval can be a userland or userspace. optlen is always a kernel pointer.
*/
int
-kern_getsockopt(td, s, level, name, val, valseg, valsize)
- struct thread *td;
- int s;
- int level;
- int name;
- void *val;
- enum uio_seg valseg;
- socklen_t *valsize;
+kern_getsockopt(struct thread *td, int s, int level, int name, void *val,
+ enum uio_seg valseg, socklen_t *valsize)
{
struct socket *so;
struct file *fp;
@@ -1933,7 +1792,7 @@ kern_getsockopt(td, s, level, name, val, valseg, valsize)
AUDIT_ARG_FD(s);
error = getsock_cap(td, s, cap_rights_init(&rights, CAP_GETSOCKOPT),
- &fp, NULL);
+ &fp, NULL, NULL);
if (error == 0) {
so = fp->f_data;
error = sogetopt(so, &sopt);
@@ -1951,16 +1810,8 @@ kern_getsockname(struct thread *td, int fd, struct sockaddr **sa,
/*
* getsockname1() - Get socket name.
*/
-/* ARGSUSED */
static int
-getsockname1(td, uap, compat)
- struct thread *td;
- struct getsockname_args /* {
- int fdes;
- struct sockaddr * __restrict asa;
- socklen_t * __restrict alen;
- } */ *uap;
- int compat;
+getsockname1(struct thread *td, struct getsockname_args *uap, int compat)
{
struct sockaddr *sa;
socklen_t len;
@@ -2000,7 +1851,7 @@ getsockname(int socket, struct sockaddr *__restrict address,
int error;
if (td != NULL) {
- error = getsockname1(td, &ua);
+ error = getsockname1(td, &ua, 0);
} else {
error = ENOMEM;
}
@@ -2021,7 +1872,7 @@ kern_getsockname(struct thread *td, int fd, struct sockaddr **sa,
AUDIT_ARG_FD(fd);
error = getsock_cap(td, fd, cap_rights_init(&rights, CAP_GETSOCKNAME),
- &fp, NULL);
+ &fp, NULL, NULL);
if (error != 0)
return (error);
so = fp->f_data;
@@ -2051,9 +1902,7 @@ bad:
#ifndef __rtems__
int
-sys_getsockname(td, uap)
- struct thread *td;
- struct getsockname_args *uap;
+sys_getsockname(struct thread *td, struct getsockname_args *uap)
{
return (getsockname1(td, uap, 0));
@@ -2061,9 +1910,7 @@ sys_getsockname(td, uap)
#ifdef COMPAT_OLDSOCK
int
-ogetsockname(td, uap)
- struct thread *td;
- struct getsockname_args *uap;
+ogetsockname(struct thread *td, struct getsockname_args *uap)
{
return (getsockname1(td, uap, 1));
@@ -2079,16 +1926,8 @@ kern_getpeername(struct thread *td, int fd, struct sockaddr **sa,
/*
* getpeername1() - Get name of peer for connected socket.
*/
-/* ARGSUSED */
static int
-getpeername1(td, uap, compat)
- struct thread *td;
- struct getpeername_args /* {
- int fdes;
- struct sockaddr * __restrict asa;
- socklen_t * __restrict alen;
- } */ *uap;
- int compat;
+getpeername1(struct thread *td, struct getpeername_args *uap, int compat)
{
struct sockaddr *sa;
socklen_t len;
@@ -2128,7 +1967,7 @@ getpeername(int socket, struct sockaddr *__restrict address,
int error;
if (td != NULL) {
- error = getpeername1(td, &ua);
+ error = getpeername1(td, &ua, 0);
} else {
error = ENOMEM;
}
@@ -2149,7 +1988,7 @@ kern_getpeername(struct thread *td, int fd, struct sockaddr **sa,
AUDIT_ARG_FD(fd);
error = getsock_cap(td, fd, cap_rights_init(&rights, CAP_GETPEERNAME),
- &fp, NULL);
+ &fp, NULL, NULL);
if (error != 0)
return (error);
so = fp->f_data;
@@ -2184,9 +2023,7 @@ done:
#ifndef __rtems__
int
-sys_getpeername(td, uap)
- struct thread *td;
- struct getpeername_args *uap;
+sys_getpeername(struct thread *td, struct getpeername_args *uap)
{
return (getpeername1(td, uap, 0));
@@ -2194,9 +2031,7 @@ sys_getpeername(td, uap)
#ifdef COMPAT_OLDSOCK
int
-ogetpeername(td, uap)
- struct thread *td;
- struct ogetpeername_args *uap;
+ogetpeername(struct thread *td, struct ogetpeername_args *uap)
{
/* XXX uap should have type `getpeername_args *' to begin with. */
@@ -2242,10 +2077,7 @@ sockargs(struct mbuf **mp, char *buf, socklen_t buflen, int type)
}
int
-getsockaddr(namp, uaddr, len)
- struct sockaddr **namp;
- caddr_t uaddr;
- size_t len;
+getsockaddr(struct sockaddr **namp, caddr_t uaddr, size_t len)
{
struct sockaddr *sa;
int error;
diff --git a/freebsd/sys/kern/uipc_usrreq.c b/freebsd/sys/kern/uipc_usrreq.c
index 7b2d1bc4..159de132 100644
--- a/freebsd/sys/kern/uipc_usrreq.c
+++ b/freebsd/sys/kern/uipc_usrreq.c
@@ -14,7 +14,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -291,8 +291,8 @@ static int unp_connectat(int, struct socket *, struct sockaddr *,
static int unp_connect2(struct socket *so, struct socket *so2, int);
static void unp_disconnect(struct unpcb *unp, struct unpcb *unp2);
#ifndef __rtems__
-static void unp_dispose(struct mbuf *);
-static void unp_dispose_so(struct socket *so);
+static void unp_dispose(struct socket *so);
+static void unp_dispose_mbuf(struct mbuf *);
#endif /* __rtems__ */
static void unp_shutdown(struct unpcb *);
static void unp_drop(struct unpcb *);
@@ -355,7 +355,7 @@ static struct domain localdomain = {
.dom_init = unp_init,
#ifndef __rtems__
.dom_externalize = unp_externalize,
- .dom_dispose = unp_dispose_so,
+ .dom_dispose = unp_dispose,
#endif /* __rtems__ */
.dom_protosw = localsw,
.dom_protoswNPROTOSW = &localsw[nitems(localsw)]
@@ -1164,7 +1164,7 @@ uipc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam,
if (control != NULL && error != 0)
#ifndef __rtems__
- unp_dispose(control);
+ unp_dispose_mbuf(control);
#else /* __rtems__ */
BSD_ASSERT(0);
#endif /* __rtems__ */
@@ -2511,7 +2511,7 @@ unp_gc(__unused void *arg, int pending)
}
static void
-unp_dispose(struct mbuf *m)
+unp_dispose_mbuf(struct mbuf *m)
{
if (m)
@@ -2522,7 +2522,7 @@ unp_dispose(struct mbuf *m)
* Synchronize against unp_gc, which can trip over data as we are freeing it.
*/
static void
-unp_dispose_so(struct socket *so)
+unp_dispose(struct socket *so)
{
struct unpcb *unp;
@@ -2530,7 +2530,7 @@ unp_dispose_so(struct socket *so)
UNP_LIST_LOCK();
unp->unp_gcflag |= UNPGC_IGNORE_RIGHTS;
UNP_LIST_UNLOCK();
- unp_dispose(so->so_rcv.sb_mb);
+ unp_dispose_mbuf(so->so_rcv.sb_mb);
}
static void