File: arch_prctl.c

package info (click to toggle)
systemtap 4.8-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 39,000 kB
  • sloc: cpp: 78,785; ansic: 62,419; xml: 49,443; exp: 42,735; sh: 11,254; python: 3,062; perl: 2,252; tcl: 1,305; makefile: 1,072; lisp: 105; awk: 101; asm: 91; java: 56; sed: 16
file content (49 lines) | stat: -rw-r--r-- 1,117 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* COVERAGE: arch_prctl */

#define _GNU_SOURCE
#include <unistd.h>
#include <sys/syscall.h>

#ifdef __NR_arch_prctl

#include <asm/prctl.h>
#include <sys/prctl.h>

// This decl is missing from glibc; it's a deprecated syscall.
#define arch_prctl(x,y) syscall(__NR_arch_prctl,x,y)

int main()
{
    unsigned long fs;
    arch_prctl(ARCH_GET_FS, &fs);
    //staptest// arch_prctl (ARCH_GET_FS, XXXX) = NNNN

    arch_prctl(-1, &fs);
    //staptest// arch_prctl (-1, XXXX) = NNNN (EINVAL)

    // 2 variants: one for get- and one for set- cmds:
    // int arch_prctl(int code, unsigned long addr);
    // int arch_prctl(int code, unsigned long *addr);

    arch_prctl(0, (unsigned long *)-1);
#if __WORDSIZE == 64
    //staptest// arch_prctl (0, 18446744073709551615) = NNNN (EINVAL)
#else
    //staptest// arch_prctl (0, 4294967295) = NNNN (EINVAL)
#endif

    arch_prctl(0, (unsigned long)-1);
#if __WORDSIZE == 64
    //staptest// arch_prctl (0, 18446744073709551615) = NNNN (EINVAL)
#else
    //staptest// arch_prctl (0, 4294967295) = NNNN (EINVAL)
#endif

    return 0;
}
#else
int main()
{
    return 0;
}
#endif