]>
Commit | Line | Data |
---|---|---|
28f540f4 | 1 | /* Resource limits. |
dff8da6b | 2 | Copyright (C) 1994-2024 Free Software Foundation, Inc. |
c84142e8 UD |
3 | This file is part of the GNU C Library. |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
c84142e8 UD |
9 | |
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
c84142e8 | 14 | |
41bdb6e2 | 15 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 | 16 | License along with the GNU C Library; if not, see |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
28f540f4 RM |
18 | |
19 | #include <hurd.h> | |
9446e02b | 20 | #include <lock-intern.h> |
28f540f4 | 21 | #include <hurd/resource.h> |
ae49f218 | 22 | #include "set-hooks.h" |
28f540f4 RM |
23 | |
24 | /* This must be given an initializer, or the a.out linking rules will | |
25 | not include the entire file when this symbol is referenced. */ | |
26 | struct rlimit _hurd_rlimits[RLIM_NLIMITS] = { { 0, }, }; | |
27 | ||
28 | /* This must be initialized data for the same reason as above, but this is | |
29 | intentionally initialized to a bogus value to emphasize the point that | |
30 | mutex_init is still required below just in case of unexec. */ | |
31 | struct mutex _hurd_rlimit_lock = { SPIN_LOCK_INITIALIZER, }; | |
32 | ||
ae49f218 | 33 | static void attribute_used_retain |
28f540f4 RM |
34 | init_rlimit (void) |
35 | { | |
36 | int i; | |
37 | ||
38 | __mutex_init (&_hurd_rlimit_lock); | |
39 | ||
40 | for (i = 0; i < RLIM_NLIMITS; ++i) | |
41 | { | |
42 | if (_hurd_rlimits[i].rlim_max == 0) | |
43 | _hurd_rlimits[i].rlim_max = RLIM_INFINITY; | |
44 | if (_hurd_rlimits[i].rlim_cur == 0) | |
8acd0bf2 RM |
45 | #define I(lim, val) case RLIMIT_##lim: _hurd_rlimits[i].rlim_cur = (val); break |
46 | switch (i) | |
47 | { | |
48 | I (NOFILE, 1024); /* Linux 2.2.12 uses this initial value. */ | |
49 | ||
50 | default: | |
51 | _hurd_rlimits[i].rlim_cur = _hurd_rlimits[i].rlim_max; | |
52 | break; | |
53 | } | |
54 | #undef I | |
28f540f4 | 55 | } |
28f540f4 | 56 | } |
ae49f218 | 57 | SET_RELHOOK (_hurd_preinit_hook, init_rlimit); |