File: arch_prctl.c

package info (click to toggle)
systemtap 3.1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 32,860 kB
  • ctags: 12,513
  • sloc: cpp: 58,610; ansic: 58,189; exp: 37,322; sh: 10,633; xml: 7,771; perl: 2,252; python: 2,066; tcl: 1,305; makefile: 969; lisp: 105; java: 100; awk: 94; asm: 91; sed: 16
file content (43 lines) | stat: -rw-r--r-- 992 bytes parent folder | download | duplicates (2)
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
/* 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) = 0

    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);

    // Also the syscall is x86_64 specific, so __WORDSIZE == 64.

    arch_prctl(0, (unsigned long *)-1);
    //staptest// arch_prctl (0, 18446744073709551615) = NNNN (EINVAL)

    arch_prctl(0, (unsigned long)-1);
    //staptest// arch_prctl (0, 18446744073709551615) = NNNN (EINVAL)

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