Debian Codegraph @

share/libc/sys/resource.h

raw
1 /**************************************************************************/
2 /* */
3 /* This file is part of Frama-C. */
4 /* */
5 /* Copyright (C) 2007-2022 */
6 /* CEA (Commissariat à l'énergie atomique et aux énergies */
7 /* alternatives) */
8 /* */
9 /* you can redistribute it and/or modify it under the terms of the GNU */
10 /* Lesser General Public License as published by the Free Software */
11 /* Foundation, version 2.1. */
12 /* */
13 /* It is distributed in the hope that it will be useful, */
14 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
15 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
16 /* GNU Lesser General Public License for more details. */
17 /* */
18 /* See the GNU Lesser General Public License version 2.1 */
19 /* for more details (enclosed in the file licenses/LGPLv2.1). */
20 /* */
21 /**************************************************************************/
22
23 #ifndef __FC_SYS_RESOURCE_H__
24 #define __FC_SYS_RESOURCE_H__
25 #include "../features.h"
26 __PUSH_FC_STDLIB
27 #include "time.h"
28 #include "../__fc_define_id_t.h"
29
30 #define PRIO_PROCESS 0
31 #define PRIO_PGRP 1
32 #define PRIO_USER 2
33
34 __BEGIN_DECLS
35
36 typedef unsigned long rlim_t;
37 struct rlimit {
38 rlim_t rlim_cur;
39 rlim_t rlim_max;
40 };
41
42 struct rusage {
43 struct timeval ru_utime;
44 struct timeval ru_stime;
45 };
46
47 #define RLIM_INFINITY 0xFFFFFFFFul
48 #define RLIM_SAVED_MAX RLIM_INFINITY
49 #define RLIM_SAVED_CUR RLIM_INFINITY
50
51 #define RUSAGE_SELF 0
52 #define RUSAGE_CHILDREN 1
53
54 #define RLIMIT_CORE 0
55 #define RLIMIT_CPU 1
56 #define RLIMIT_DATA 2
57 #define RLIMIT_FSIZE 3
58 #define RLIMIT_NOFILE 4
59 #define RLIMIT_STACK 5
60 #define RLIMIT_AS 6
61
62 /*@ assigns \result \from which,who; */
63 extern int getpriority(int which, id_t who);
64
65 /*@ assigns \result \from which,who,prio; */
66 extern int setpriority(int which, id_t who, int prio);
67
68 /*@
69 requires valid_rlp: \valid(rlp);
70 assigns \result, *rlp \from resource;
71 */
72 extern int getrlimit(int resource, struct rlimit *rlp);
73
74 /*@
75 requires valid_r_usage: \valid(r_usage);
76 assigns *r_usage \from who;
77 assigns \result \from indirect:who;
78 ensures result_ok_or_error: \result == 0 || \result == -1;
79 */
80 extern int getrusage(int who, struct rusage *r_usage);
81
82 /*@
83 requires valid_rlp: \valid_read(rlp);
84 assigns *rlp \from resource;
85 assigns \result \from indirect:resource, indirect:*rlp;
86 ensures result_ok_or_error: \result == 0 || \result == -1;
87 */
88 extern int setrlimit(int resource, const struct rlimit *rlp);
89
90 __END_DECLS
91 __POP_FC_STDLIB
92 #endif