Debian Codegraph @

testsuite/systemtap.syscall/prlimit.c

raw
1 /* COVERAGE: prlimit64 */
2
3 // Why wasn't this testing just added to getrlimit.c? If you want to
4 // call prlimit(), you have to have _FILE_OFFSET_BITS defined as
5 // 64. But, when you do that, glibc redefines calls to
6 // getrlimit()/setrlimit() as prlimit64() calls. So, we'll have to
7 // test them separately.
8
9 #define _GNU_SOURCE
10 #define _FILE_OFFSET_BITS 64
11
12 #include <stdio.h>
13 #include <unistd.h>
14 #include <sys/time.h>
15 #include <sys/resource.h>
16 #include <features.h>
17
18 int main()
19 {
20 // glibc support for prlimit() was added in glibc 2.13.
21 #if __GLIBC_PREREQ(2, 13)
22 struct rlimit rlim;
23
24 // Get current cpu limits.
25 prlimit(0, RLIMIT_CPU, NULL, &rlim);
26 //staptest// prlimit64 (0, RLIMIT_CPU, NULL, XXXX) = 0
27
28 // Set new limits (to the same thing).
29 prlimit(0, RLIMIT_CPU, &rlim, NULL);
30 //staptest// prlimit64 (0, RLIMIT_CPU, \[NNNN,NNNN\], 0x0) = 0
31
32 // Limit testing.
33
34 prlimit(-1, RLIMIT_CPU, &rlim, NULL);
35 //staptest// prlimit64 (-1, RLIMIT_CPU, \[NNNN,NNNN\], 0x0) = -NNNN
36
37 prlimit(0, -1, &rlim, NULL);
38 //staptest// prlimit64 (0, RLIM_INFINITY, \[NNNN,NNNN\], 0x0) = -NNNN
39
40 prlimit(0, RLIMIT_CPU, (struct rlimit *)-1, NULL);
41 #ifdef __s390__
42 //staptest// prlimit64 (0, RLIMIT_CPU, 0x[7]?[f]+, 0x0) = -NNNN
43 #else
44 //staptest// prlimit64 (0, RLIMIT_CPU, 0x[f]+, 0x0) = -NNNN
45 #endif
46
47 prlimit(0, RLIMIT_CPU, &rlim, (struct rlimit *)-1);
48 #ifdef __s390__
49 //staptest// prlimit64 (0, RLIMIT_CPU, \[NNNN,NNNN\], 0x[7]?[f]+) = -NNNN
50 #else
51 //staptest// prlimit64 (0, RLIMIT_CPU, \[NNNN,NNNN\], 0x[f]+) = -NNNN
52 #endif
53 #endif
54
55 return 0;
56 }