summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2021-10-22 15:35:53 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2022-01-14 16:17:29 +0000
commita48d9f1900d48eb7222ade05df10df73097b8cca (patch)
treef3494c5706729097c42b3eeb61b661ac9f0a63d0 /lib/libc
parent526f94cc0ee105f6d3fded2d49fb0fa67155a4a6 (diff)
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/aarch64/sys/Makefile.inc3
-rw-r--r--lib/libc/arm/sys/Makefile.inc3
-rw-r--r--lib/libc/gen/Symbol.map1
-rw-r--r--lib/libc/gen/sched_getcpu_gen.c36
-rw-r--r--lib/libc/include/libc_private.h1
-rw-r--r--lib/libc/mips/sys/Makefile.inc3
-rw-r--r--lib/libc/powerpc/sys/Makefile.inc4
-rw-r--r--lib/libc/powerpc64/sys/Makefile.inc4
-rw-r--r--lib/libc/riscv/sys/Makefile.inc3
-rw-r--r--lib/libc/sys/Makefile.inc3
-rw-r--r--lib/libc/x86/sys/Makefile.inc3
11 files changed, 57 insertions, 7 deletions
diff --git a/lib/libc/aarch64/sys/Makefile.inc b/lib/libc/aarch64/sys/Makefile.inc
index 623a06b7faf8..97aff8ba92fe 100644
--- a/lib/libc/aarch64/sys/Makefile.inc
+++ b/lib/libc/aarch64/sys/Makefile.inc
@@ -2,7 +2,8 @@
MIASM:= ${MIASM:Nfreebsd[467]_*}
-SRCS+= __vdso_gettc.c
+SRCS+= __vdso_gettc.c \
+ sched_getcpu_gen.c
MDASM= cerror.S \
syscall.S \
diff --git a/lib/libc/arm/sys/Makefile.inc b/lib/libc/arm/sys/Makefile.inc
index be6a58f8aaf5..c6e854e7954a 100644
--- a/lib/libc/arm/sys/Makefile.inc
+++ b/lib/libc/arm/sys/Makefile.inc
@@ -1,6 +1,7 @@
# $FreeBSD$
-SRCS+= __vdso_gettc.c
+SRCS+= __vdso_gettc.c \
+ sched_getcpu_gen.c
MDASM= Ovfork.S cerror.S syscall.S
diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map
index a52131b34476..5554c32ab4f2 100644
--- a/lib/libc/gen/Symbol.map
+++ b/lib/libc/gen/Symbol.map
@@ -441,6 +441,7 @@ FBSD_1.7 {
posix_spawn_file_actions_addfchdir_np;
sched_getaffinity;
sched_setaffinity;
+ sched_getcpu;
};
FBSDprivate_1.0 {
diff --git a/lib/libc/gen/sched_getcpu_gen.c b/lib/libc/gen/sched_getcpu_gen.c
new file mode 100644
index 000000000000..ef1bebc2915a
--- /dev/null
+++ b/lib/libc/gen/sched_getcpu_gen.c
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2021 The FreeBSD Foundation
+ *
+ * This software were developed by Konstantin Belousov <kib@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sched.h>
+#include "libc_private.h"
+
+int
+sched_getcpu(void)
+{
+ return (__sys_sched_getcpu());
+}
diff --git a/lib/libc/include/libc_private.h b/lib/libc/include/libc_private.h
index 5a524c0211d1..61c1eb438142 100644
--- a/lib/libc/include/libc_private.h
+++ b/lib/libc/include/libc_private.h
@@ -371,6 +371,7 @@ __ssize_t __sys_recv(int, void *, __size_t, int);
__ssize_t __sys_recvfrom(int, void *, __size_t, int, struct sockaddr *,
__socklen_t *);
__ssize_t __sys_recvmsg(int, struct msghdr *, int);
+int __sys_sched_getcpu(void);
int __sys_select(int, struct fd_set *, struct fd_set *,
struct fd_set *, struct timeval *);
__ssize_t __sys_sendmsg(int, const struct msghdr *, int);
diff --git a/lib/libc/mips/sys/Makefile.inc b/lib/libc/mips/sys/Makefile.inc
index d7cc70d01b07..fa6d9b32739d 100644
--- a/lib/libc/mips/sys/Makefile.inc
+++ b/lib/libc/mips/sys/Makefile.inc
@@ -1,6 +1,7 @@
# $FreeBSD$
-SRCS+= trivial-vdso_tc.c
+SRCS+= trivial-vdso_tc.c \
+ sched_getcpu_gen.c
MDASM= Ovfork.S cerror.S syscall.S
diff --git a/lib/libc/powerpc/sys/Makefile.inc b/lib/libc/powerpc/sys/Makefile.inc
index 99a141b5cb1e..6f07795b8870 100644
--- a/lib/libc/powerpc/sys/Makefile.inc
+++ b/lib/libc/powerpc/sys/Makefile.inc
@@ -1,4 +1,6 @@
# $FreeBSD$
-SRCS+= __vdso_gettc.c
+SRCS+= __vdso_gettc.c \
+ sched_getcpu_gen.c
+
MDASM+= cerror.S
diff --git a/lib/libc/powerpc64/sys/Makefile.inc b/lib/libc/powerpc64/sys/Makefile.inc
index 99a141b5cb1e..6f07795b8870 100644
--- a/lib/libc/powerpc64/sys/Makefile.inc
+++ b/lib/libc/powerpc64/sys/Makefile.inc
@@ -1,4 +1,6 @@
# $FreeBSD$
-SRCS+= __vdso_gettc.c
+SRCS+= __vdso_gettc.c \
+ sched_getcpu_gen.c
+
MDASM+= cerror.S
diff --git a/lib/libc/riscv/sys/Makefile.inc b/lib/libc/riscv/sys/Makefile.inc
index b322cece382c..2eb12bf11cad 100644
--- a/lib/libc/riscv/sys/Makefile.inc
+++ b/lib/libc/riscv/sys/Makefile.inc
@@ -1,6 +1,7 @@
# $FreeBSD$
-SRCS+= __vdso_gettc.c
+SRCS+= __vdso_gettc.c \
+ sched_getcpu_gen.c
MDASM= cerror.S \
syscall.S \
diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc
index 33e87e513b05..5c30f7d6b796 100644
--- a/lib/libc/sys/Makefile.inc
+++ b/lib/libc/sys/Makefile.inc
@@ -36,6 +36,9 @@ SRCS+= \
SRCS+= getdents.c lstat.c mknod.c stat.c
+NOASM+= sched_getcpu.o
+PSEUDO+= _sched_getcpu.o
+
SRCS+= fstat.c fstatat.c fstatfs.c getfsstat.c statfs.c
NOASM+= fstat.o fstatat.o fstatfs.o getfsstat.o statfs.o
PSEUDO+= _fstat.o _fstatat.o _fstatfs.o _getfsstat.o _statfs.o
diff --git a/lib/libc/x86/sys/Makefile.inc b/lib/libc/x86/sys/Makefile.inc
index 41e0d1a8ad66..8aa4948a3295 100644
--- a/lib/libc/x86/sys/Makefile.inc
+++ b/lib/libc/x86/sys/Makefile.inc
@@ -4,7 +4,8 @@
SRCS+= \
__vdso_gettc.c \
- pkru.c
+ pkru.c \
+ sched_getcpu_gen.c
MAN+= \
pkru.3