libsys: make __libsys_interposing static

Access __libsys_interposing with __libc_interposing_slot() in all
cases to support a move of these wrappers back to libc.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D44239
This commit is contained in:
Brooks Davis 2024-03-13 17:31:48 +00:00
parent f7dbbbd176
commit ef5fddd344
51 changed files with 70 additions and 64 deletions

View file

@ -49,7 +49,6 @@ interpos_func_t __libc_interposing[INTERPOS_MAX] = {
interpos_func_t *
__libc_interposing_slot(int interposno)
{
/* XXX: forward compat. Remove after 15.0-RELEASE. */
if (__libc_interposing[interposno] == NULL)
return (__libsys_interposing_slot(interposno));
return (&__libc_interposing[interposno]);

View file

@ -56,7 +56,7 @@ __sleep(unsigned int seconds)
time_to_sleep.tv_sec = seconds;
time_to_sleep.tv_nsec = 0;
if (((int (*)(const struct timespec *, struct timespec *))
(*__libsys_interposing_slot(INTERPOS_nanosleep)))(
(*__libc_interposing_slot(INTERPOS_nanosleep)))(
&time_to_sleep, &time_remaining) != -1)
return (0);
if (errno != EINTR)

View file

@ -46,7 +46,7 @@ __usleep(useconds_t useconds)
time_to_sleep.tv_nsec = (useconds % 1000000) * 1000;
time_to_sleep.tv_sec = useconds / 1000000;
return (((int (*)(const struct timespec *, struct timespec *))
(*__libsys_interposing_slot(INTERPOS_nanosleep)))(&time_to_sleep,
(*__libc_interposing_slot(INTERPOS_nanosleep)))(&time_to_sleep,
NULL));
}

View file

@ -201,7 +201,6 @@ typedef int (*interpos_func_t)(void);
interpos_func_t *__libc_interposing_slot(int interposno);
extern interpos_func_t __libc_interposing[] __hidden;
interpos_func_t *__libsys_interposing_slot(int interposno);
extern interpos_func_t __libsys_interposing[] __hidden;
enum {
INTERPOS_accept,

View file

@ -41,5 +41,5 @@ int
accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
return (((int (*)(int, struct sockaddr *, socklen_t *))
__libsys_interposing[INTERPOS_accept])(s, addr, addrlen));
*(__libc_interposing_slot(INTERPOS_accept)))(s, addr, addrlen));
}

View file

@ -41,5 +41,6 @@ int
accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags)
{
return (((int (*)(int, struct sockaddr *, socklen_t *, int))
__libsys_interposing[INTERPOS_accept4])(s, addr, addrlen, flags));
*(__libc_interposing_slot(INTERPOS_accept4)))
(s, addr, addrlen, flags));
}

View file

@ -42,5 +42,6 @@ aio_suspend(const struct aiocb * const iocbs[], int niocb,
{
return (((int (*)(const struct aiocb * const[], int,
const struct timespec *))
__libsys_interposing[INTERPOS_aio_suspend])(iocbs, niocb, timeout));
*(__libc_interposing_slot(INTERPOS_aio_suspend)))
(iocbs, niocb, timeout));
}

View file

@ -43,6 +43,6 @@ clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp,
{
return (((int (*)(clockid_t, int, const struct timespec *,
struct timespec *))
__libsys_interposing[INTERPOS_clock_nanosleep])(clock_id, flags,
rqtp, rmtp));
*(__libc_interposing_slot(INTERPOS_clock_nanosleep)))
(clock_id, flags, rqtp, rmtp));
}

View file

@ -40,5 +40,5 @@ __weak_reference(__sys_close, __close);
int
close(int fd)
{
return (((int (*)(int))__libsys_interposing[INTERPOS_close])(fd));
return (((int (*)(int))*(__libc_interposing_slot(INTERPOS_close)))(fd));
}

View file

@ -41,5 +41,5 @@ int
connect(int s, const struct sockaddr *addr, socklen_t addrlen)
{
return (((int (*)(int, const struct sockaddr *, socklen_t))
__libsys_interposing[INTERPOS_connect])(s, addr, addrlen));
*(__libc_interposing_slot(INTERPOS_connect)))(s, addr, addrlen));
}

View file

@ -44,7 +44,7 @@ int
__creat(const char *path, mode_t mode)
{
return (((int (*)(int, const char *, int, ...))
__libsys_interposing[INTERPOS_openat])(AT_FDCWD, path, O_WRONLY |
O_CREAT | O_TRUNC, mode));
*(__libc_interposing_slot(INTERPOS_openat)))
(AT_FDCWD, path, O_WRONLY | O_CREAT | O_TRUNC, mode));
}

View file

@ -50,5 +50,5 @@ fcntl(int fd, int cmd, ...)
va_end(args);
return (((int (*)(int, int, ...))
__libsys_interposing[INTERPOS_fcntl])(fd, cmd, arg));
*(__libc_interposing_slot(INTERPOS_fcntl)))(fd, cmd, arg));
}

View file

@ -37,5 +37,6 @@
int
fdatasync(int fd)
{
return (((int (*)(int))__libsys_interposing[INTERPOS_fdatasync])(fd));
return (((int (*)(int))*(__libc_interposing_slot(INTERPOS_fdatasync)))
(fd));
}

View file

@ -39,5 +39,5 @@ __weak_reference(__sys_fork, __fork);
pid_t
fork(void)
{
return (((pid_t (*)(void))__libsys_interposing[INTERPOS_fork])());
return (((pid_t (*)(void))*(__libc_interposing_slot(INTERPOS_fork)))());
}

View file

@ -39,5 +39,5 @@ __weak_reference(__sys_fsync, __fsync);
int
fsync(int fd)
{
return (((int (*)(int))__libsys_interposing[INTERPOS_fsync])(fd));
return (((int (*)(int))*(__libc_interposing_slot(INTERPOS_fsync)))(fd));
}

View file

@ -34,7 +34,7 @@
#define SLOT(a, b) \
[INTERPOS_##a] = (interpos_func_t)b
interpos_func_t __libsys_interposing[INTERPOS_MAX] = {
static interpos_func_t __libsys_interposing[INTERPOS_MAX] = {
SLOT(accept, __sys_accept),
SLOT(accept4, __sys_accept4),
SLOT(aio_suspend, __sys_aio_suspend),

View file

@ -43,6 +43,6 @@ kevent(int kq, const struct kevent *changelist, int nchanges,
{
return (((int (*)(int, const struct kevent *, int,
struct kevent *, int, const struct timespec *))
__libsys_interposing[INTERPOS_kevent])(kq, changelist, nchanges,
eventlist, nevents, timeout));
*(__libc_interposing_slot(INTERPOS_kevent)))
(kq, changelist, nchanges, eventlist, nevents, timeout));
}

View file

@ -63,8 +63,8 @@ lockf(int filedes, int function, off_t size)
case F_TEST:
fl.l_type = F_WRLCK;
if (((int (*)(int, int, ...))
__libsys_interposing[INTERPOS_fcntl])(filedes, F_GETLK, &fl)
== -1)
*(__libc_interposing_slot(INTERPOS_fcntl)))
(filedes, F_GETLK, &fl) == -1)
return (-1);
if (fl.l_type == F_UNLCK || (fl.l_sysid == 0 &&
fl.l_pid == getpid()))
@ -79,5 +79,5 @@ lockf(int filedes, int function, off_t size)
}
return (((int (*)(int, int, ...))
__libsys_interposing[INTERPOS_fcntl])(filedes, cmd, &fl));
*(__libc_interposing_slot(INTERPOS_fcntl)))(filedes, cmd, &fl));
}

View file

@ -41,5 +41,5 @@ int
msync(void *addr, size_t len, int flags)
{
return (((int (*)(void *, size_t, int))
__libsys_interposing[INTERPOS_msync])(addr, len, flags));
*(__libc_interposing_slot(INTERPOS_msync)))(addr, len, flags));
}

View file

@ -40,5 +40,5 @@ int
nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
{
return (((int (*)(const struct timespec *, struct timespec *))
__libsys_interposing[INTERPOS_nanosleep])(rqtp, rmtp));
*(__libc_interposing_slot(INTERPOS_nanosleep)))(rqtp, rmtp));
}

View file

@ -51,6 +51,6 @@ open(const char *path, int flags, ...)
mode = 0;
}
return (((int (*)(int, const char *, int, ...))
__libsys_interposing[INTERPOS_openat])(AT_FDCWD, path, flags,
mode));
*(__libc_interposing_slot(INTERPOS_openat)))
(AT_FDCWD, path, flags, mode));
}

View file

@ -54,5 +54,6 @@ openat(int fd, const char *path, int flags, ...)
mode = 0;
}
return (((int (*)(int, const char *, int, ...))
__libsys_interposing[INTERPOS_openat])(fd, path, flags, mode));
*(__libc_interposing_slot(INTERPOS_openat)))
(fd, path, flags, mode));
}

View file

@ -37,6 +37,7 @@
pid_t
pdfork(int *fdp, int flags)
{
return (((pid_t (*)(int *, int))__libsys_interposing[INTERPOS_pdfork])
return (((pid_t (*)(int *, int))
*(__libc_interposing_slot(INTERPOS_pdfork)))
(fdp, flags));
}

View file

@ -40,5 +40,5 @@ int
poll(struct pollfd pfd[], nfds_t nfds, int timeout)
{
return (((int (*)(struct pollfd *, nfds_t, int))
__libsys_interposing[INTERPOS_poll])(pfd, nfds, timeout));
*(__libc_interposing_slot(INTERPOS_poll)))(pfd, nfds, timeout));
}

View file

@ -41,6 +41,6 @@ ppoll(struct pollfd pfd[], nfds_t nfds, const struct timespec *__restrict
timeout, const sigset_t *__restrict newsigmask)
{
return (((int (*)(struct pollfd *, nfds_t, const struct timespec *,
const sigset_t *)) __libsys_interposing[INTERPOS_ppoll])(pfd, nfds,
timeout, newsigmask));
const sigset_t *))*(__libc_interposing_slot(INTERPOS_ppoll)))
(pfd, nfds, timeout, newsigmask));
}

View file

@ -42,5 +42,5 @@ pselect(int n, fd_set *rs, fd_set *ws, fd_set *es, const struct timespec *t,
{
return (((int (*)(int, fd_set *, fd_set *, fd_set *,
const struct timespec *, const sigset_t *))
__libsys_interposing[INTERPOS_pselect])(n, rs, ws, es, t, s));
*(__libc_interposing_slot(INTERPOS_pselect)))(n, rs, ws, es, t, s));
}

View file

@ -41,5 +41,5 @@ ssize_t
read(int fd, void *buf, size_t nbytes)
{
return (((ssize_t (*)(int, void *, size_t))
__libsys_interposing[INTERPOS_read])(fd, buf, nbytes));
*(__libc_interposing_slot(INTERPOS_read)))(fd, buf, nbytes));
}

View file

@ -42,5 +42,5 @@ ssize_t
readv(int fd, const struct iovec *iov, int iovcnt)
{
return (((ssize_t (*)(int, const struct iovec *, int))
__libsys_interposing[INTERPOS_readv])(fd, iov, iovcnt));
*(__libc_interposing_slot(INTERPOS_readv)))(fd, iov, iovcnt));
}

View file

@ -44,6 +44,6 @@ recv(int s, void *buf, size_t len, int flags)
*/
return (((ssize_t (*)(int, void *, size_t, int,
struct sockaddr *, socklen_t *))
__libsys_interposing[INTERPOS_recvfrom])(s, buf, len, flags,
NULL, NULL));
*(__libc_interposing_slot(INTERPOS_recvfrom)))
(s, buf, len, flags, NULL, NULL));
}

View file

@ -43,6 +43,6 @@ recvfrom(int s, void *buf, size_t len, int flags,
{
return (((ssize_t (*)(int, void *, size_t, int,
struct sockaddr *, socklen_t *))
__libsys_interposing[INTERPOS_recvfrom])(s, buf, len, flags,
from, fromlen));
*(__libc_interposing_slot(INTERPOS_recvfrom)))
(s, buf, len, flags, from, fromlen));
}

View file

@ -41,5 +41,5 @@ ssize_t
recvmsg(int s, struct msghdr *msg, int flags)
{
return (((int (*)(int, struct msghdr *, int))
__libsys_interposing[INTERPOS_recvmsg])(s, msg, flags));
*(__libc_interposing_slot(INTERPOS_recvmsg)))(s, msg, flags));
}

View file

@ -40,5 +40,5 @@ int
select(int n, fd_set *rs, fd_set *ws, fd_set *es, struct timeval *t)
{
return (((int (*)(int, fd_set *, fd_set *, fd_set *, struct timeval *))
__libsys_interposing[INTERPOS_select])(n, rs, ws, es, t));
*(__libc_interposing_slot(INTERPOS_select)))(n, rs, ws, es, t));
}

View file

@ -44,6 +44,6 @@ send(int s, const void *msg, size_t len, int flags)
*/
return (((ssize_t (*)(int, const void *, size_t, int,
const struct sockaddr *, socklen_t))
__libsys_interposing[INTERPOS_sendto])(s, msg, len, flags,
*__libc_interposing_slot(INTERPOS_sendto))(s, msg, len, flags,
NULL, 0));
}

View file

@ -41,5 +41,5 @@ ssize_t
sendmsg(int s, const struct msghdr *msg, int flags)
{
return (((int (*)(int, const struct msghdr *, int))
__libsys_interposing[INTERPOS_sendmsg])(s, msg, flags));
*(__libc_interposing_slot(INTERPOS_sendmsg)))(s, msg, flags));
}

View file

@ -43,6 +43,6 @@ sendto(int s, const void *msg, size_t len, int flags,
{
return (((ssize_t (*)(int, const void *, size_t, int,
const struct sockaddr *, socklen_t))
__libsys_interposing[INTERPOS_sendto])(s, msg, len, flags,
to, tolen));
*(__libc_interposing_slot(INTERPOS_sendto)))
(s, msg, len, flags, to, tolen));
}

View file

@ -43,5 +43,5 @@ int
setcontext(const ucontext_t *uc)
{
return (((int (*)(const ucontext_t *))
__libsys_interposing[INTERPOS_setcontext])(uc));
*(__libc_interposing_slot(INTERPOS_setcontext)))(uc));
}

View file

@ -41,5 +41,5 @@ int
sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
{
return (((int (*)(int, const struct sigaction *, struct sigaction *))
__libsys_interposing[INTERPOS_sigaction])(sig, act, oact));
*(__libc_interposing_slot(INTERPOS_sigaction)))(sig, act, oact));
}

View file

@ -41,5 +41,5 @@ int
sigprocmask(int how, const sigset_t *set, sigset_t *oset)
{
return (((int (*)(int, const sigset_t *, sigset_t *))
__libsys_interposing[INTERPOS_sigprocmask])(how, set, oset));
*(__libc_interposing_slot(INTERPOS_sigprocmask)))(how, set, oset));
}

View file

@ -41,5 +41,5 @@ int
sigsuspend(const sigset_t *set)
{
return (((int (*)(const sigset_t *))
__libsys_interposing[INTERPOS_sigsuspend])(set));
*(__libc_interposing_slot(INTERPOS_sigsuspend)))(set));
}

View file

@ -42,5 +42,5 @@ sigtimedwait(const sigset_t * __restrict set, siginfo_t * __restrict info,
{
return (((int (*)(const sigset_t *, siginfo_t *,
const struct timespec *))
__libsys_interposing[INTERPOS_sigtimedwait])(set, info, t));
*(__libc_interposing_slot(INTERPOS_sigtimedwait)))(set, info, t));
}

View file

@ -33,5 +33,5 @@ int
sigwait(const sigset_t *set, int *sig)
{
return (((int (*)(const sigset_t *, int *))
__libsys_interposing[INTERPOS_sigwait])(set, sig));
*(__libc_interposing_slot(INTERPOS_sigwait)))(set, sig));
}

View file

@ -40,5 +40,5 @@ int
sigwaitinfo(const sigset_t * __restrict set, siginfo_t * __restrict info)
{
return (((int (*)(const sigset_t *, siginfo_t *))
__libsys_interposing[INTERPOS_sigwaitinfo])(set, info));
*(__libc_interposing_slot(INTERPOS_sigwaitinfo)))(set, info));
}

View file

@ -45,5 +45,5 @@ int
swapcontext(ucontext_t *oucp, const ucontext_t *ucp)
{
return (((int (*)(ucontext_t *, const ucontext_t *))
__libsys_interposing[INTERPOS_swapcontext])(oucp, ucp));
*(__libc_interposing_slot(INTERPOS_swapcontext)))(oucp, ucp));
}

View file

@ -44,7 +44,8 @@ pid_t
__wait(int *istat)
{
return (((pid_t (*)(pid_t, int *, int, struct rusage *))
__libsys_interposing[INTERPOS_wait4])(WAIT_ANY, istat, 0, NULL));
*(__libc_interposing_slot(INTERPOS_wait4)))
(WAIT_ANY, istat, 0, NULL));
}
__weak_reference(__wait, wait);

View file

@ -44,8 +44,8 @@ pid_t
__wait3(int *istat, int options, struct rusage *rup)
{
return (((pid_t (*)(pid_t, int *, int, struct rusage *))
__libsys_interposing[INTERPOS_wait4])(WAIT_ANY, istat, options,
rup));
*(__libc_interposing_slot(INTERPOS_wait4)))
(WAIT_ANY, istat, options, rup));
}
__weak_reference(__wait3, wait3);

View file

@ -40,5 +40,6 @@ pid_t
wait4(pid_t pid, int *status, int options, struct rusage *ru)
{
return (((pid_t (*)(pid_t, int *, int, struct rusage *))
__libsys_interposing[INTERPOS_wait4])(pid, status, options, ru));
*(__libc_interposing_slot(INTERPOS_wait4)))
(pid, status, options, ru));
}

View file

@ -42,6 +42,6 @@ wait6(idtype_t idtype, id_t id, int *status, int options, struct __wrusage *ru,
siginfo_t *infop)
{
return (((pid_t (*)(idtype_t, id_t, int *, int, struct __wrusage *,
siginfo_t *))__libsys_interposing[INTERPOS_wait6])(idtype, id,
status, options, ru, infop));
siginfo_t *))*(__libc_interposing_slot(INTERPOS_wait6)))
(idtype, id, status, options, ru, infop));
}

View file

@ -47,8 +47,8 @@ __waitid(idtype_t idtype, id_t id, siginfo_t *info, int flags)
pid_t ret;
ret = ((pid_t (*)(idtype_t, id_t, int *, int, struct __wrusage *,
siginfo_t *))__libsys_interposing[INTERPOS_wait6])(idtype, id,
&status, flags, NULL, info);
siginfo_t *))*(__libc_interposing_slot(INTERPOS_wait6)))
(idtype, id, &status, flags, NULL, info);
/*
* According to SUSv4, waitid() shall not return a PID when a

View file

@ -44,7 +44,8 @@ pid_t
__waitpid(pid_t pid, int *istat, int options)
{
return (((pid_t (*)(pid_t, int *, int, struct rusage *))
__libsys_interposing[INTERPOS_wait4])(pid, istat, options, NULL));
*(__libc_interposing_slot(INTERPOS_wait4)))
(pid, istat, options, NULL));
}
__weak_reference(__waitpid, waitpid);

View file

@ -41,5 +41,5 @@ ssize_t
write(int fd, const void *buf, size_t nbytes)
{
return (((ssize_t (*)(int, const void *, size_t))
__libsys_interposing[INTERPOS_write])(fd, buf, nbytes));
*(__libc_interposing_slot(INTERPOS_write)))(fd, buf, nbytes));
}

View file

@ -42,5 +42,5 @@ ssize_t
writev(int fd, const struct iovec *iov, int iovcnt)
{
return (((ssize_t (*)(int, const struct iovec *, int))
__libsys_interposing[INTERPOS_writev])(fd, iov, iovcnt));
*(__libc_interposing_slot(INTERPOS_writev)))(fd, iov, iovcnt));
}