sync with OpenBSD -current

This commit is contained in:
purplerain 2024-08-12 06:29:20 +00:00
parent b321f55ead
commit 302c0be22f
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
43 changed files with 456 additions and 132 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: kern_exit.c,v 1.230 2024/08/06 18:41:20 claudio Exp $ */
/* $OpenBSD: kern_exit.c,v 1.231 2024/08/11 15:10:53 mvs Exp $ */
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
/*
@ -151,6 +151,9 @@ exit1(struct proc *p, int xexit, int xsig, int flags)
PS_ISPWAIT);
wakeup(pr->ps_pptr);
}
/* Wait for concurrent `allprocess' loops */
refcnt_finalize(&pr->ps_refcnt, "psdtor");
}
/* unlink ourselves from the active threads */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: kern_fork.c,v 1.261 2024/08/06 08:44:54 claudio Exp $ */
/* $OpenBSD: kern_fork.c,v 1.262 2024/08/11 15:10:53 mvs Exp $ */
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/*
@ -178,6 +178,8 @@ thread_new(struct proc *parent, vaddr_t uaddr)
void
process_initialize(struct process *pr, struct proc *p)
{
refcnt_init(&pr->ps_refcnt);
/* initialize the thread links */
pr->ps_mainproc = p;
TAILQ_INIT(&pr->ps_threads);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: kern_sysctl.c,v 1.436 2024/08/08 15:02:36 bluhm Exp $ */
/* $OpenBSD: kern_sysctl.c,v 1.437 2024/08/11 15:10:53 mvs Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*-
@ -1686,6 +1686,9 @@ sysctl_file(int *name, u_int namelen, char *where, size_t *sizep,
/* not the pid we are looking for */
continue;
}
refcnt_take(&pr->ps_refcnt);
matched = 1;
fdp = pr->ps_fd;
if (pr->ps_textvp)
@ -1702,6 +1705,9 @@ sysctl_file(int *name, u_int namelen, char *where, size_t *sizep,
FILLIT(fp, fdp, i, NULL, pr);
FRELE(fp, p);
}
refcnt_rele_wake(&pr->ps_refcnt);
/* pid is unique, stop searching */
if (arg >= 0)
break;
@ -1721,6 +1727,9 @@ sysctl_file(int *name, u_int namelen, char *where, size_t *sizep,
/* not the uid we are looking for */
continue;
}
refcnt_take(&pr->ps_refcnt);
fdp = pr->ps_fd;
if (fdp->fd_cdir)
FILLIT(NULL, NULL, KERN_FILE_CDIR, fdp->fd_cdir, pr);
@ -1734,6 +1743,8 @@ sysctl_file(int *name, u_int namelen, char *where, size_t *sizep,
FILLIT(fp, fdp, i, NULL, pr);
FRELE(fp, p);
}
refcnt_rele_wake(&pr->ps_refcnt);
}
break;
default:

View file

@ -1,4 +1,4 @@
/* $OpenBSD: kern_timeout.c,v 1.98 2024/08/05 23:51:11 dlg Exp $ */
/* $OpenBSD: kern_timeout.c,v 1.99 2024/08/11 00:49:34 dlg Exp $ */
/*
* Copyright (c) 2001 Thomas Nordin <nordin@openbsd.org>
* Copyright (c) 2000-2001 Artur Grabowski <art@openbsd.org>
@ -332,18 +332,25 @@ timeout_add(struct timeout *new, int to_ticks)
return ret;
}
static inline int
timeout_add_ticks(struct timeout *to, uint64_t to_ticks, int notzero)
{
if (to_ticks > INT_MAX)
to_ticks = INT_MAX;
else if (to_ticks == 0 && notzero)
to_ticks = 1;
return timeout_add(to, (int)to_ticks);
}
int
timeout_add_tv(struct timeout *to, const struct timeval *tv)
{
uint64_t to_ticks;
to_ticks = (uint64_t)hz * tv->tv_sec + tv->tv_usec / tick;
if (to_ticks > INT_MAX)
to_ticks = INT_MAX;
if (to_ticks == 0 && tv->tv_usec > 0)
to_ticks = 1;
return timeout_add(to, (int)to_ticks);
return timeout_add_ticks(to, to_ticks, tv->tv_usec > 0);
}
int
@ -352,37 +359,28 @@ timeout_add_sec(struct timeout *to, int secs)
uint64_t to_ticks;
to_ticks = (uint64_t)hz * secs;
if (to_ticks > INT_MAX)
to_ticks = INT_MAX;
if (to_ticks == 0)
to_ticks = 1;
return timeout_add(to, (int)to_ticks);
return timeout_add_ticks(to, to_ticks, 1);
}
int
timeout_add_msec(struct timeout *to, int msecs)
timeout_add_msec(struct timeout *to, uint64_t msecs)
{
uint64_t to_ticks;
to_ticks = (uint64_t)msecs * 1000 / tick;
if (to_ticks > INT_MAX)
to_ticks = INT_MAX;
if (to_ticks == 0 && msecs > 0)
to_ticks = 1;
to_ticks = msecs * 1000 / tick;
return timeout_add(to, (int)to_ticks);
return timeout_add_ticks(to, to_ticks, msecs > 0);
}
int
timeout_add_usec(struct timeout *to, int usecs)
timeout_add_usec(struct timeout *to, uint64_t usecs)
{
int to_ticks = usecs / tick;
uint64_t to_ticks;
if (to_ticks == 0 && usecs > 0)
to_ticks = 1;
to_ticks = usecs / tick;
return timeout_add(to, to_ticks);
return timeout_add_ticks(to, to_ticks, usecs > 0);
}
int
@ -391,12 +389,8 @@ timeout_add_nsec(struct timeout *to, uint64_t nsecs)
uint64_t to_ticks;
to_ticks = nsecs / (tick * 1000);
if (to_ticks > INT_MAX)
to_ticks = INT_MAX;
if (to_ticks == 0 && nsecs > 0)
to_ticks = 1;
return timeout_add(to, (int)to_ticks);
return timeout_add_ticks(to, to_ticks, nsecs > 0);
}
int

View file

@ -1,4 +1,4 @@
/* $OpenBSD: uipc_socket.c,v 1.342 2024/08/06 20:14:56 mvs Exp $ */
/* $OpenBSD: uipc_socket.c,v 1.343 2024/08/11 00:19:00 jsg Exp $ */
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/*
@ -1581,7 +1581,7 @@ sotask(void *arg)
int sockstream = (so->so_proto->pr_flags & PR_WANTRCVD);
/*
* sblock() on `so_rcv' protects sockets from beind unspliced
* sblock() on `so_rcv' protects sockets from being unspliced
* for UDP case. TCP sockets still rely on solock().
*/