]> granicus.if.org Git - strace/blob - tests/oldselect-efault.c
tests: change the license to GPL-2.0-or-later
[strace] / tests / oldselect-efault.c
1 /*
2  * Copyright (c) 2015-2018 Dmitry V. Levin <ldv@altlinux.org>
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  */
7
8 #include "tests.h"
9 #include <asm/unistd.h>
10
11 #if defined __NR_select && defined __NR__newselect \
12  && __NR_select != __NR__newselect \
13  && !defined __sparc__
14
15 # include <stdint.h>
16 # include <stdio.h>
17 # include <string.h>
18 # include <unistd.h>
19 # include <sys/select.h>
20
21 static const char *errstr;
22
23 static long
24 xselect(const kernel_ulong_t args)
25 {
26         static const kernel_ulong_t dummy = F8ILL_KULONG_MASK | 0xfacefeed;
27         long rc = syscall(__NR_select, args, dummy, dummy, dummy, dummy, dummy);
28         errstr = sprintrc(rc);
29         return rc;
30 }
31
32 int
33 main(void)
34 {
35         unsigned long *const args = tail_alloc(sizeof(*args) * 4);
36         memset(args, 0, sizeof(*args) * 4);
37
38         xselect(0);
39 #ifndef PATH_TRACING_FD
40         printf("select(NULL) = %s\n", errstr);
41 #endif
42
43         xselect((uintptr_t) args);
44 #ifndef PATH_TRACING_FD
45         printf("select(%p) = %s\n", args, errstr);
46 #endif
47
48         puts("+++ exited with 0 +++");
49         return 0;
50 }
51
52 #else
53
54 SKIP_MAIN_UNDEFINED("__NR_select && __NR__newselect"
55                     " && __NR_select != __NR__newselect"
56                     " && !defined __sparc__")
57
58 #endif