Projectname large_stringclasses 15
values | Filepath large_stringlengths 4 106 ⌀ | Function large_stringlengths 11 3.45k | Label list |
|---|---|---|---|
Linux Kernel | tools/testing/selftests/nolibc/nolibc-test.c |
static int expect_ne(int expr, int llen, int val) {
int ret = !(expr != val);
llen += printf(" = %d ", expr);
pad_spc(llen, 40, ret ? "[FAIL]\n" : " [OK]\n");
return ret;
}
#define EXPECT_GE(cond, expr, val) \
do { ... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/nolibc/nolibc-test.c |
static int expect_le(int expr, int llen, int val) {
int ret = !(expr <= val);
llen += printf(" = %d ", expr);
pad_spc(llen, 40, ret ? "[FAIL]\n" : " [OK]\n");
return ret;
}
#define EXPECT_LT(cond, expr, val) \
do { ... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/nolibc/nolibc-test.c |
static int expect_syszr(int expr, int llen) {
int ret = 0;
if (expr) {
ret = 1;
llen += printf(" = %d %s ", expr, errorname(errno));
llen += pad_spc(llen, 40, "[FAIL]\n");
} else {
llen += printf(" = %d ", expr);
llen += pad_spc(llen, 40, " [OK]\n");
}
return ret;
}
#define EXPECT_SYSEQ... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/nolibc/nolibc-test.c |
static int expect_ptrzr(const void *expr, int llen) {
int ret = 0;
llen += printf(" = <%p> ", expr);
if (expr) {
ret = 1;
llen += pad_spc(llen, 40, "[FAIL]\n");
} else {
llen += pad_spc(llen, 40, " [OK]\n");
}
return ret;
}
#define EXPECT_PTRNZ(cond, expr) ... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/nolibc/nolibc-test.c |
static int expect_strnz(const char *expr, int llen) {
int ret = 0;
llen += printf(" = <%s> ", expr);
if (!expr) {
ret = 1;
llen += pad_spc(llen, 40, "[FAIL]\n");
} else {
llen += pad_spc(llen, 40, " [OK]\n");
}
return ret;
}
#define EXPECT_STREQ(cond, expr, cmp) ... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/nolibc/nolibc-test.c |
static int expect_streq(const char *expr, int llen, const char *cmp) {
int ret = 0;
llen += printf(" = <%s> ", expr);
if (strcmp(expr, cmp) != 0) {
ret = 1;
llen += pad_spc(llen, 40, "[FAIL]\n");
} else {
llen += pad_spc(llen, 40, " [OK]\n");
}
return ret;
}
#define EXPECT_STRNE(cond, expr, c... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/nolibc/nolibc-test.c | int prepare(void) {
struct stat stat_buf;
if (stat("/dev/.", &stat_buf) == 0 || mkdir("/dev", 0755) == 0) {
if (stat("/dev/console", &stat_buf) != 0 ||
stat("/dev/null", &stat_buf) != 0) {
/* try devtmpfs first, otherwise fall back to manual creation */
if (mount("/dev", "/dev", "devtmpfs",... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/nsfs/pidns.c |
static int child(void *args) {
prctl(PR_SET_PDEATHSIG, SIGKILL);
while (1)
sleep(1);
exit(0);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/openat2/helpers.c |
int raw_openat2(int dfd, const char *path, void *how, size_t size) {
int ret = syscall(__NR_openat2, dfd, path, how, size);
return ret >= 0 ? ret : -errno;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/openat2/helpers.c |
int sys_renameat2(int olddirfd, const char *oldpath, int newdirfd,
const char *newpath, unsigned int flags) {
int ret =
syscall(__NR_renameat2, olddirfd, oldpath, newdirfd, newpath, flags);
return ret >= 0 ? ret : -errno;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/openat2/helpers.c |
int touchat(int dfd, const char *path) {
int fd = openat(dfd, path, O_CREAT, 0700);
if (fd >= 0)
close(fd);
return fd;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/openat2/rename_attack_test.c | int setup_testdir(void) {
int dfd;
char dirname[] = "/tmp/ksft-openat2-rename-attack.XXXXXX";
if (!mkdtemp(dirname))
ksft_exit_fail_msg("setup_testdir: failed to create tmpdir\n");
dfd = open(dirname, O_PATH | O_DIRECTORY);
if (dfd < 0)
ksft_exit_fail_msg("setup_testdir: failed to open tmpdir\n");
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/openat2/rename_attack_test.c | pid_t spawn_attack(int dirfd, char *a, char *b) {
pid_t child = fork();
if (child != 0)
return child;
E_prctl(PR_SET_PDEATHSIG, SIGKILL);
/* Swap @a and @b. */
for (;;)
renameat2(dirfd, a, dirfd, b, RENAME_EXCHANGE);
exit(1);
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/openat2/rename_attack_test.c |
const char *flagname(int resolve) {
switch (resolve) {
case RESOLVE_IN_ROOT:
return "RESOLVE_IN_ROOT";
case RESOLVE_BENEATH:
return "RESOLVE_BENEATH";
}
return "(unknown)";
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/perf_events/sigtrap_threads.c | static void sigtrap_handler(int signum, siginfo_t *info, void *ucontext) {
if (info->si_code != TRAP_PERF) {
fprintf(stderr, "%s: unexpected si_code %d\n", __func__, info->si_code);
return;
}
if (!__atomic_fetch_add(&ctx.signal_count, 1, __ATOMIC_RELAXED))
ctx.first_siginfo = *info;
__atomic_fetch_... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/pidfd/pidfd.h |
static inline int wait_for_pid(pid_t pid) {
int status, ret;
again:
ret = waitpid(pid, &status, 0);
if (ret == -1) {
if (errno == EINTR)
goto again;
ksft_print_msg("waitpid returned -1, errno=%d\n", errno);
return -1;
}
if (!WIFEXITED(status)) {
ksft_print_msg("waitpid !WIFEXITED, WI... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/pidfd/pidfd.h |
static inline int sys_pidfd_getfd(int pidfd, int fd, int flags) {
return syscall(__NR_pidfd_getfd, pidfd, fd, flags);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/pidfd/pidfd_fdinfo_test.c | static void error_report(struct error *err, const char *test_name) {
switch (err->code) {
case PIDFD_ERROR:
ksft_exit_fail_msg("%s test: Fatal: %s\n", test_name, err->msg);
break;
case PIDFD_FAIL:
ksft_test_result_error("%s test: %s\n", test_name, err->msg);
break;
case PIDFD_SKIP:
/* wil... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/pidfd/pidfd_fdinfo_test.c |
static inline int child_join_close(struct child *child, struct error *err) {
child_close(child);
return child_join(child, err);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/pidfd/pidfd_fdinfo_test.c |
static int verify_fdinfo(int pidfd, struct error *err, const char *prefix,
size_t prefix_len, const char *expect, ...) {
char buffer[512] = {
0,
};
char path[512] = {
0,
};
va_list args;
FILE *f;
char *line = NULL;
size_t n = 0;
int found = 0;
int r;
va_start... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/pidfd/pidfd_fdinfo_test.c | static void test_pidfd_fdinfo_nspid(void) {
struct child a, b;
struct error err = {
0,
};
const char *test_name = "pidfd check for NSpid in fdinfo";
a = clone_newns(child_fdinfo_nspid_test, NULL, &err);
error_check(&err, test_name);
/* Pass the pidfd representing the first child to the
* second... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/pidfd/pidfd_fdinfo_test.c | static void test_pidfd_dead_fdinfo(void) {
struct child a;
struct error err = {
0,
};
const char *test_name = "pidfd check fdinfo for dead process";
a = clone_newns(child_fdinfo_nspid_test, NULL, &err);
error_check(&err, test_name);
child_join(&a, &err);
verify_fdinfo(a.fd, &err, "Pid:", 4, "\t-... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/pidfd/pidfd_getfd_test.c |
static int sys_kcmp(pid_t pid1, pid_t pid2, int type, unsigned long idx1,
unsigned long idx2) {
return syscall(__NR_kcmp, pid1, pid2, type, idx1, idx2);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/pidfd/pidfd_getfd_test.c | static int __child(int sk, int memfd) {
int ret;
char buf;
ret = prctl(PR_SET_PDEATHSIG, SIGKILL);
if (ret) {
fprintf(stderr, "%s: Child could not set DEATHSIG\n", strerror(errno));
return -1;
}
ret = send(sk, &memfd, sizeof(memfd), 0);
if (ret != sizeof(memfd)) {
fprintf(stderr, "%s: Child ... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/pidfd/pidfd_getfd_test.c | int main(void) {
fprintf(stderr, "__NR_pidfd_getfd undefined. The pidfd_getfd syscall is "
"unavailable. Test aborting\n");
return KSFT_SKIP;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/pidfd/pidfd_open_test.c |
static int safe_int(const char *numstr, int *converted) {
char *err = NULL;
long sli;
errno = 0;
sli = strtol(numstr, &err, 0);
if (errno == ERANGE && (sli == LONG_MAX || sli == LONG_MIN))
return -ERANGE;
if (errno != 0 && sli == 0)
return -EINVAL;
if (err == numstr || *err != '\0')
return... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/pidfd/pidfd_open_test.c |
static char *trim_whitespace_in_place(char *buffer) {
buffer += char_left_gc(buffer, strlen(buffer));
buffer[char_right_gc(buffer, strlen(buffer))] = '\0';
return buffer;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/pidfd/pidfd_open_test.c |
static pid_t get_pid_from_fdinfo_file(int pidfd, const char *key,
size_t keylen) {
int ret;
char path[512];
FILE *f;
size_t n = 0;
pid_t result = -1;
char *line = NULL;
snprintf(path, sizeof(path), "/proc/self/fdinfo/%d", pidfd);
f = fopen(path, "re");
if (!f)
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/pidfd/pidfd_setns_test.c |
pid_t create_child(int *pidfd, unsigned flags) {
struct __clone_args args = {
.flags = CLONE_PIDFD | flags,
.exit_signal = SIGCHLD,
.pidfd = ptr_to_u64(pidfd),
};
return sys_clone3(&args, sizeof(struct clone_args));
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/pidfd/pidfd_setns_test.c |
static bool switch_timens(void) {
int fd, ret;
if (unshare(CLONE_NEWTIME))
return false;
fd = open("/proc/self/ns/time_for_children", O_RDONLY | O_CLOEXEC);
if (fd < 0)
return false;
ret = setns(fd, CLONE_NEWTIME);
close(fd);
return ret == 0;
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/pidfd/pidfd_setns_test.c |
static ssize_t read_nointr(int fd, void *buf, size_t count) {
ssize_t ret;
do {
ret = read(fd, buf, count);
} while (ret < 0 && errno == EINTR);
return ret;
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/pidfd/pidfd_setns_test.c |
static int preserve_ns(const int pid, const char *ns) {
int ret;
char path[50];
ret = snprintf(path, sizeof(path), "/proc/%d/ns/%s", pid, ns);
if (ret < 0 || (size_t)ret >= sizeof(path))
return -EIO;
return open(path, O_RDONLY | O_CLOEXEC);
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/pidfd/pidfd_test.c | static int test_pidfd_send_signal_exited_fail(void) {
int pidfd, ret, saved_errno;
char buf[256];
pid_t pid;
const char *test_name = "pidfd_send_signal signal exited process";
if (!have_pidfd_send_signal) {
ksft_test_result_skip(
"%s test: pidfd_send_signal() syscall not supported\n", test_name);... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/pidfd/pidfd_test.c |
static void poll_pidfd(const char *test_name, int pidfd) {
int c;
int epoll_fd = epoll_create1(EPOLL_CLOEXEC);
struct epoll_event event, events[MAX_EVENTS];
if (epoll_fd == -1)
ksft_exit_fail_msg("%s test: Failed to create epoll file descriptor "
"(errno %d)\n",
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/pidfd/pidfd_test.c | static int child_poll_leader_exit_test(void *args) {
pthread_t t1, t2;
ksft_print_msg("Child: starting. pid %d tid %d\n", getpid(),
syscall(SYS_gettid));
pthread_create(&t1, NULL, test_pidfd_poll_leader_exit_thread, NULL);
pthread_create(&t2, NULL, test_pidfd_poll_leader_exit_thread, NULL);
... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/pidfd/pidfd_test.c | static void test_pidfd_poll_leader_exit(int use_waitpid) {
int pid, pidfd = 0;
int status, ret = 0;
const char *test_name =
"pidfd_poll check for premature notification on non-empty"
"group leader exit";
child_exit_secs = mmap(NULL, sizeof *child_exit_secs, PROT_READ | PROT_WRITE,
... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/pidfd/pidfd_wait.c |
static pid_t sys_clone3(struct clone_args *args) {
return syscall(__NR_clone3, args, sizeof(struct clone_args));
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/alignment/alignment_handler.c |
void sighandler(int sig, siginfo_t *info, void *ctx) {
ucontext_t *ucp = ctx;
if (!testing) {
signal(sig, SIG_DFL);
kill(0, sig);
}
gotsig = sig;
#ifdef __powerpc64__
if (prefixes_enabled) {
u32 inst = *(u32 *)ucp->uc_mcontext.gp_regs[PT_NIP];
ucp->uc_mcontext.gp_regs[PT_NIP] += ((inst >> 26... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/alignment/alignment_handler.c |
static bool can_open_cifile(void) {
int fd;
fd = open(cipath, O_RDWR);
if (fd < 0)
return false;
close(fd);
return true;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/alignment/alignment_handler.c |
int test_alignment_handler_integer_prefix(void) {
int rc = 0;
SKIP_IF(!can_open_cifile());
SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_3_1));
printf("Integer: PREFIX\n");
LOAD_MLS_PREFIX_TEST(PLBZ);
LOAD_MLS_PREFIX_TEST(PLHZ);
LOAD_MLS_PREFIX_TEST(PLHA);
LOAD_MLS_PREFIX_TEST(PLWZ);
LOAD_8LS_PREFIX_TEST(... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/alignment/alignment_handler.c | int test_alignment_handler_vmx(void) {
int rc = 0;
SKIP_IF(!can_open_cifile());
SKIP_IF(!have_hwcap(PPC_FEATURE_HAS_ALTIVEC));
printf("VMX\n");
LOAD_VMX_XFORM_TEST(lvx);
/*
* FIXME: These loads only load part of the register, so our
* testing method doesn't work. Also they don't take alignment
*... | [
0,
1
] |
Linux Kernel | tools/testing/selftests/powerpc/alignment/alignment_handler.c |
int test_alignment_handler_fp_206(void) {
int rc = 0;
SKIP_IF(!can_open_cifile());
SKIP_IF(!have_hwcap(PPC_FEATURE_ARCH_2_06));
printf("Floating point: 2.06\n");
LOAD_FLOAT_XFORM_TEST(lfiwzx);
return rc;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/alignment/alignment_handler.c |
void usage(char *prog) {
printf("Usage: %s [options] [path [offset]]\n", prog);
printf(" -d Enable debug error output\n");
printf("\n");
printf("This test requires a POWER8, POWER9 or POWER10 CPU ");
printf("and either a usable framebuffer at /dev/fb0 or ");
printf("the path to usable cache inhibited memo... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/alignment/copy_first_unaligned.c | void signal_action_handler(int signal_num, siginfo_t *info, void *ptr) {
ucontext_t *ctx = ptr;
#ifdef __powerpc64__
unsigned int *pc = (unsigned int *)ctx->uc_mcontext.gp_regs[PT_NIP];
#else
unsigned int *pc = (unsigned int *)ctx->uc_mcontext.uc_regs->gregs[PT_NIP];
#endif
if ((*pc & instruction_mask) == expe... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/alignment/copy_first_unaligned.c | int test_copy_first_unaligned(void) {
SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_3_00));
/* Register our signal handler with SIGBUS */
setup_signal_handler();
/* +1 makes buf unaligned */
copy_first(cacheline_buf + 1);
/* We should not get here */
return 1;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/benchmarks/context_switch.c |
static void start_thread_on(void *(*fn)(void *), void *arg, unsigned long cpu) {
int rc;
pthread_t tid;
cpu_set_t cpuset;
pthread_attr_t attr;
CPU_ZERO(&cpuset);
CPU_SET(cpu, &cpuset);
rc = pthread_attr_init(&attr);
if (rc) {
errno = rc;
perror("pthread_attr_init");
exit(1);
}
rc = p... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/benchmarks/context_switch.c |
static void start_process_on(void *(*fn)(void *), void *arg,
unsigned long cpu) {
int pid, ncpus;
cpu_set_t *cpuset;
size_t size;
pid = fork();
if (pid == -1) {
perror("fork");
exit(1);
}
if (pid)
return;
ncpus = get_nprocs();
size = CPU_ALLOC_SIZE(ncpus);
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/benchmarks/context_switch.c |
static void sigalrm_handler(int junk) {
unsigned long i = iterations;
printf("%ld\n", i - iterations_prev);
iterations_prev = i;
if (--timeout == 0)
kill(0, SIGUSR1);
alarm(1);
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/benchmarks/context_switch.c |
static void pipe_setup(int cpu1, int cpu2) {
if (pipe(pipe_fd1) || pipe(pipe_fd2))
exit(1);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/benchmarks/context_switch.c |
static void yield_setup(int cpu1, int cpu2) {
if (cpu1 != cpu2) {
fprintf(stderr, "Both threads must be on the same CPU for yield test\n");
exit(1);
}
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/benchmarks/context_switch.c |
static unsigned long xchg(unsigned long *p, unsigned long val) {
return __atomic_exchange_n(p, val, __ATOMIC_SEQ_CST);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/benchmarks/context_switch.c |
static int mutex_lock(unsigned long *m) {
int c;
int flags = FUTEX_WAIT;
if (!processes)
flags |= FUTEX_PRIVATE_FLAG;
c = cmpxchg(m, 0, 1);
if (!c)
return 0;
if (c == 1)
c = xchg(m, 2);
while (c) {
sys_futex(m, flags, 2, NULL, NULL, 0);
c = xchg(m, 2);
}
return 0;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/benchmarks/context_switch.c |
static int mutex_unlock(unsigned long *m) {
int flags = FUTEX_WAKE;
if (!processes)
flags |= FUTEX_PRIVATE_FLAG;
if (*m == 2)
*m = 0;
else if (xchg(m, 0) == 1)
return 0;
sys_futex(m, flags, 1, NULL, NULL, 0);
return 0;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/benchmarks/context_switch.c |
static void *futex_thread2(void *arg) {
while (1) {
mutex_unlock(m2);
mutex_lock(m1);
}
return NULL;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/benchmarks/fork.c |
static void set_cpu(int cpu) {
cpu_set_t cpuset;
if (cpu == -1)
return;
CPU_ZERO(&cpuset);
CPU_SET(cpu, &cpuset);
if (sched_setaffinity(0, sizeof(cpuset), &cpuset)) {
perror("sched_setaffinity");
exit(1);
}
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/benchmarks/fork.c |
static void start_process_on(void *(*fn)(void *), void *arg, int cpu) {
int pid;
pid = fork();
if (pid == -1) {
perror("fork");
exit(1);
}
if (pid)
return;
set_cpu(cpu);
fn(arg);
exit(0);
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/benchmarks/fork.c |
static void run_exec(void) {
char *const argv[] = {"./exec_target", NULL};
if (execve("./exec_target", argv, NULL) == -1) {
perror("execve");
exit(1);
}
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/benchmarks/fork.c |
static void bench_vfork(void) {
while (1) {
pid_t pid = vfork();
if (pid == -1) {
perror("fork");
exit(1);
}
if (pid == 0) {
if (do_exec)
run_exec();
_exit(0);
}
pid = waitpid(pid, NULL, 0);
if (pid == -1) {
perror("waitpid");
exit(1);
}
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/benchmarks/fork.c | int main(int argc, char *argv[]) {
signed char c;
while (1) {
int option_index = 0;
c = getopt_long(argc, argv, "", options, &option_index);
if (c == -1)
break;
switch (c) {
case 0:
if (options[option_index].flag != 0)
break;
usage();
exit(1);
break;
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/benchmarks/futex_bench.c |
int test_futex(void) {
struct timespec ts_start, ts_end;
unsigned long i = ITERATIONS;
clock_gettime(CLOCK_MONOTONIC, &ts_start);
while (i--) {
unsigned int addr = 0;
futex(&addr, FUTEX_WAKE, 1, NULL, NULL, 0);
}
clock_gettime(CLOCK_MONOTONIC, &ts_end);
printf("time = %.6f\n", ts_end.tv_sec -... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/benchmarks/futex_bench.c |
int main(void) {
test_harness_set_timeout(300);
return test_harness(test_futex, "futex_bench");
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/benchmarks/mmap_bench.c |
static void usage(void) {
printf("mmap_bench <--pgfault> <--iterations count>\n");
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/benchmarks/null_syscall.c |
static inline unsigned long mftb(void) {
unsigned long low;
asm volatile("mftb %0" : "=r"(low));
return low;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/benchmarks/null_syscall.c |
static void sigalrm_handler(int unused) { soak_done = 1; } | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/benchmarks/null_syscall.c | static void get_proc_frequency(void) {
FILE *f;
char line[128];
char *p, *end;
unsigned long v;
double d;
char *override;
cpu_soak_usecs(0.25 * 1000000);
f = fopen("/proc/cpuinfo", "r");
if (f == NULL)
return;
timebase_frequency = 0;
while (fgets(line, sizeof(line), f) != NULL) {
if (s... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/cache_shape/cache_shape.c | static int test_cache_shape() {
static char buffer[4096];
ElfW(auxv_t) * p;
int found;
FAIL_IF(read_auxv(buffer, sizeof(buffer)));
found = 0;
p = find_auxv_entry(AT_L1I_CACHESIZE, buffer);
if (p) {
found++;
print_size("L1I ", (uint32_t)p->a_un.a_val);
}
p = find_auxv_entry(AT_L1I_CACHEGEOM... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/copyloops/exc_validate.c |
static void setup_segv_handler(void) {
struct sigaction action;
memset(&action, 0, sizeof(action));
action.sa_sigaction = segv_handler;
action.sa_flags = SA_SIGINFO;
sigaction(SIGSEGV, &action, NULL);
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/copyloops/exc_validate.c |
int main(void) { return test_harness(test_copy_exception, str(COPY_LOOP)); } | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/copyloops/memmove_validate.c |
size_t max(size_t a, size_t b) {
if (a >= b)
return a;
return b;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/copyloops/memmove_validate.c |
static int testcase_run(void) {
size_t i, src_off, dst_off, len;
char *usermap = memalign(BUF_LEN, BUF_LEN);
char *kernelmap = memalign(BUF_LEN, BUF_LEN);
assert(usermap != NULL);
assert(kernelmap != NULL);
memset(usermap, 0, BUF_LEN);
memset(kernelmap, 0, BUF_LEN);
for (i = 0; i < BUF_LEN; i++) {
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/dscr/dscr.h |
inline void set_dscr_usr(unsigned long val) {
asm volatile("mtspr %1,%0" : : "r"(val), "i"(SPRN_DSCR));
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/dscr/dscr.h |
void set_default_dscr(unsigned long val) {
int fd = -1, ret;
char buf[16];
if (fd == -1) {
fd = open(DSCR_DEFAULT, O_RDWR);
if (fd == -1) {
perror("open() failed");
exit(1);
}
}
sprintf(buf, "%lx\n", val);
ret = write(fd, buf, strlen(buf));
if (ret == -1) {
perror("write() fa... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/dscr/dscr.h | double uniform_deviate(int seed) { return seed * (1.0 / (RAND_MAX + 1.0)); }
#endif | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/dscr/dscr_default_test.c |
static void *do_test(void *in) {
unsigned long thread = (unsigned long)in;
unsigned long i;
for (i = 0; i < COUNT; i++) {
unsigned long d, cur_dscr, cur_dscr_usr;
unsigned long s1, s2;
s1 = READ_ONCE(sequence);
if (s1 & 1)
continue;
rmb();
d = dscr;
cur_dscr = get_dscr();
... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/dscr/dscr_default_test.c | int dscr_default(void) {
pthread_t threads[THREADS];
unsigned long i, *status[THREADS];
unsigned long orig_dscr_default;
SKIP_IF(!have_hwcap2(PPC_FEATURE2_DSCR));
orig_dscr_default = get_default_dscr();
dscr = 1;
set_default_dscr(dscr);
/* Spawn all testing threads */
for (i = 0; i < THREADS; i++)... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/dscr/dscr_explicit_test.c |
int dscr_explicit(void) {
unsigned long i, dscr = 0;
SKIP_IF(!have_hwcap2(PPC_FEATURE2_DSCR));
srand(getpid());
set_dscr(dscr);
for (i = 0; i < COUNT; i++) {
unsigned long cur_dscr, cur_dscr_usr;
double ret = uniform_deviate(rand());
if (ret < 0.001) {
dscr++;
if (dscr > DSCR_MAX)... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/dscr/dscr_inherit_test.c |
int dscr_inherit(void) {
unsigned long i, dscr = 0;
pid_t pid;
SKIP_IF(!have_hwcap2(PPC_FEATURE2_DSCR));
srand(getpid());
set_dscr(dscr);
for (i = 0; i < COUNT; i++) {
unsigned long cur_dscr, cur_dscr_usr;
dscr++;
if (dscr > DSCR_MAX)
dscr = 0;
if (i % 2 == 0)
set_dscr_usr(... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/dscr/dscr_sysfs_test.c |
static int check_cpu_dscr_default(char *file, unsigned long val) {
char buf[10];
int fd, rc;
fd = open(file, O_RDWR);
if (fd == -1) {
perror("open() failed");
return 1;
}
rc = read(fd, buf, sizeof(buf));
if (rc == -1) {
perror("read() failed");
return 1;
}
close(fd);
buf[rc] = '\... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/include/pkeys.h |
int sys_pkey_alloc(unsigned long flags, unsigned long rights) {
return syscall(__NR_pkey_alloc, flags, rights);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/include/pkeys.h |
int sys_pkey_free(int pkey) { return syscall(__NR_pkey_free, pkey); } | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/include/subunit.h |
static inline void test_success(char *name) { printf("success: %s\n", name); } | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/include/subunit.h |
static inline void test_set_git_version(char *value) {
printf("tags: git_version:%s\n", value);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/include/utils.h | static inline bool have_hwcap2(unsigned long ftr2) {
return ((unsigned long)get_auxv_entry(AT_HWCAP2) & ftr2) == ftr2;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/math/fpu_denormal.c |
int main(int argc, char *argv[]) {
return test_harness(test_denormal_fpu, "fpu_denormal");
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/math/fpu_preempt.c |
int main(int argc, char *argv[]) {
return test_harness(test_preempt_fpu, "fpu_preempt");
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/math/fpu_signal.c | void signal_fpu_sig(int sig, siginfo_t *info, void *context) {
int i;
ucontext_t *uc = context;
mcontext_t *mc = &uc->uc_mcontext;
for (i = 14; i < 32; i++) {
if (mc->fp_regs[i] != darray[i - 14]) {
bad_context = true;
break;
}
}
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/math/fpu_syscall.c | int syscall_fpu(void) {
pid_t fork_pid;
int i;
int ret;
int child_ret;
for (i = 0; i < 1000; i++) {
ret = test_fpu(darray, &fork_pid);
if (fork_pid == -1)
return -1;
if (fork_pid == 0)
exit(ret);
waitpid(fork_pid, &child_ret, 0);
if (ret || child_ret)
return 1;
}
re... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/math/mma.c |
static int mma(void) {
int i;
int rc = 0;
uint16_t x[] = {1, 0, 2, 0, 3, 0, 4, 0};
uint16_t y[] = {1, 0, 2, 0, 3, 0, 4, 0};
uint32_t z[4 * 4];
uint32_t exp[4 * 4] = {1, 2, 3, 4, 2, 4, 6, 8, 3, 6, 9, 12, 4, 8, 12, 16};
SKIP_IF_MSG(!have_hwcap2(PPC_FEATURE2_ARCH_3_1), "Need ISAv3.1");
SKIP_IF_MSG(!have_... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/math/vmx_preempt.c | int test_preempt_vmx(void) {
int i, rc, threads;
pthread_t *tids;
SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_2_07));
threads = sysconf(_SC_NPROCESSORS_ONLN) * THREAD_FACTOR;
tids = malloc(threads * sizeof(pthread_t));
FAIL_IF(!tids);
running = true;
threads_starting = threads;
for (i = 0; i < threads; ... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/math/vmx_signal.c | void signal_vmx_sig(int sig, siginfo_t *info, void *context) {
int i;
ucontext_t *uc = context;
mcontext_t *mc = &uc->uc_mcontext;
for (i = 20; i < 32; i++) {
if (memcmp(mc->v_regs->vrregs[i], &varray[i - 20], 16)) {
int j;
/*
* Shouldn't printf() in a signal handler, however, this is a
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/math/vmx_signal.c |
void *signal_vmx_c(void *p) {
int i, j;
long rc;
struct sigaction act;
act.sa_sigaction = signal_vmx_sig;
act.sa_flags = SA_SIGINFO;
rc = sigaction(SIGUSR1, &act, NULL);
if (rc)
return p;
srand(pthread_self());
for (i = 0; i < 12; i++)
for (j = 0; j < 4; j++)
varray[i][j] = rand();
... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/math/vmx_signal.c |
int main(int argc, char *argv[]) {
return test_harness(test_signal_vmx, "vmx_signal");
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/math/vsx_preempt.c |
long vsx_memcmp(vector int *a) {
vector int zero = {0, 0, 0, 0};
int i;
FAIL_IF(a != varray);
for (i = 0; i < 12; i++) {
if (memcmp(&a[i + 12], &zero, sizeof(vector int)) == 0) {
fprintf(stderr, "Detected zero from the VSX reg %d\n", i + 12);
return 2;
}
}
if (memcmp(a, &a[12], 12 * ... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/math/vsx_preempt.c |
int main(int argc, char *argv[]) {
return test_harness(test_preempt_vsx, "vsx_preempt");
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/mce/inject-ra-err.c |
static void sigbus_handler(int n, siginfo_t *info, void *ctxt_v) {
ucontext_t *ctxt = (ucontext_t *)ctxt_v;
struct pt_regs *regs = ctxt->uc_mcontext.regs;
faulted = true;
regs->nip += 4;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/mm/bad_accesses.c |
static void segv_handler(int n, siginfo_t *info, void *ctxt_v) {
fault_code = info->si_code;
fault_addr = (unsigned long)info->si_addr;
siglongjmp(setjmp_env, 1);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/mm/exec_prot.c | static bool is_fault_expected(int fault_code) {
if (fault_code == SEGV_ACCERR)
return true;
if (fault_code == SEGV_PKUERR && pkeys_supported)
return true;
return false;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/mm/exec_prot.c | static void trap_handler(int signum, siginfo_t *sinfo, void *ctx) {
if (sinfo->si_addr != (void *)fault_addr)
sigsafe_err("got a fault for an unexpected address\n");
_exit(1);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/mm/exec_prot.c | static void segv_handler(int signum, siginfo_t *sinfo, void *ctx) {
fault_code = sinfo->si_code;
if (sinfo->si_addr != (void *)fault_addr) {
sigsafe_err("got a fault for an unexpected address\n");
_exit(1);
}
/* Check if too many faults have occurred for a single test case */
if (!remaining_faults) ... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/powerpc/mm/hugetlb_vs_thp_test.c | static int test_body(void) {
void *addr;
char *p;
addr = (void *)0xa0000000;
p = mmap(addr, SIZE, PROT_READ | PROT_WRITE,
MAP_HUGETLB | MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
if (p != MAP_FAILED) {
if (munmap(addr, SIZE)) {
perror("munmap");
return 1;
}
}
p = mmap(addr, SI... | [
1,
0
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.