aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2020-12-31 18:26:01 +0000
committerKyle Evans <kevans@FreeBSD.org>2020-12-31 18:26:01 +0000
commit9e1281eabafa4aaf84828e70488c1802717b59af (patch)
treece4478c06c730cd146b4d63a14612d15e99c94e8 /contrib
parentac5f382a9d0a26685b92b49abb845d3b30ea5f91 (diff)
downloadsrc-9e1281eabafa4aaf84828e70488c1802717b59af.tar.gz
src-9e1281eabafa4aaf84828e70488c1802717b59af.zip
libc: tests: hook CPUSET(9) test up to the build
Add shims to map NetBSD's API to CPUSET(9). Obviously the invalid input parts of these tests are relatively useless since we're just testing the shims that aren't used elsewhere, there's still some amount of value in the parts testing valid inputs. Differential Revision: https://reviews.freebsd.org/D27307
Diffstat (limited to 'contrib')
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_cpuset.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_cpuset.c b/contrib/netbsd-tests/lib/libc/gen/t_cpuset.c
index 9eca03bae2b0..56ab7364af2a 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_cpuset.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_cpuset.c
@@ -36,6 +36,46 @@ __RCSID("$NetBSD: t_cpuset.c,v 1.1 2011/11/08 05:47:00 jruoho Exp $");
#include <stdio.h>
#include <sched.h>
+#ifdef __FreeBSD__
+#include <sys/cpuset.h>
+
+#include <stdlib.h>
+
+#define cpuset_create() calloc(1, sizeof(cpuset_t))
+#define cpuset_destroy(cs) free(cs)
+
+static inline int
+cpuset_set(size_t i, cpuset_t *cs)
+{
+
+ if (i > CPU_SETSIZE)
+ return (-1);
+ CPU_SET(i, cs);
+ return (0);
+}
+
+static inline int
+cpuset_clr(size_t i, cpuset_t *cs)
+{
+
+ if (i > CPU_SETSIZE)
+ return (-1);
+ CPU_CLR(i, cs);
+ return (0);
+}
+
+static inline int
+cpuset_isset(size_t i, cpuset_t *cs)
+{
+
+ if (i > CPU_SETSIZE)
+ return (-1);
+ return (CPU_ISSET(i, cs));
+}
+
+#define cpuset_size(cs) sizeof(*cs)
+#endif
+
ATF_TC(cpuset_err);
ATF_TC_HEAD(cpuset_err, tc)
{