Blame hurd/hurdrlimit.c

Packit Service 82fcde
/* Resource limits.
Packit Service 82fcde
   Copyright (C) 1994-2018 Free Software Foundation, Inc.
Packit Service 82fcde
   This file is part of the GNU C Library.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is free software; you can redistribute it and/or
Packit Service 82fcde
   modify it under the terms of the GNU Lesser General Public
Packit Service 82fcde
   License as published by the Free Software Foundation; either
Packit Service 82fcde
   version 2.1 of the License, or (at your option) any later version.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service 82fcde
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 82fcde
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 82fcde
   Lesser General Public License for more details.
Packit Service 82fcde
Packit Service 82fcde
   You should have received a copy of the GNU Lesser General Public
Packit Service 82fcde
   License along with the GNU C Library; if not, see
Packit Service 82fcde
   <http://www.gnu.org/licenses/>.  */
Packit Service 82fcde
Packit Service 82fcde
#include <hurd.h>
Packit Service 82fcde
#include <cthreads.h>
Packit Service 82fcde
#include <hurd/resource.h>
Packit Service 82fcde
Packit Service 82fcde
/* This must be given an initializer, or the a.out linking rules will
Packit Service 82fcde
   not include the entire file when this symbol is referenced. */
Packit Service 82fcde
struct rlimit _hurd_rlimits[RLIM_NLIMITS] = { { 0, }, };
Packit Service 82fcde
Packit Service 82fcde
/* This must be initialized data for the same reason as above, but this is
Packit Service 82fcde
   intentionally initialized to a bogus value to emphasize the point that
Packit Service 82fcde
   mutex_init is still required below just in case of unexec.  */
Packit Service 82fcde
struct mutex _hurd_rlimit_lock = { SPIN_LOCK_INITIALIZER, };
Packit Service 82fcde
Packit Service 82fcde
static void
Packit Service 82fcde
init_rlimit (void)
Packit Service 82fcde
{
Packit Service 82fcde
  int i;
Packit Service 82fcde
Packit Service 82fcde
  __mutex_init (&_hurd_rlimit_lock);
Packit Service 82fcde
Packit Service 82fcde
  for (i = 0; i < RLIM_NLIMITS; ++i)
Packit Service 82fcde
    {
Packit Service 82fcde
      if (_hurd_rlimits[i].rlim_max == 0)
Packit Service 82fcde
	_hurd_rlimits[i].rlim_max = RLIM_INFINITY;
Packit Service 82fcde
      if (_hurd_rlimits[i].rlim_cur == 0)
Packit Service 82fcde
#define I(lim, val) case RLIMIT_##lim: _hurd_rlimits[i].rlim_cur = (val); break
Packit Service 82fcde
	switch (i)
Packit Service 82fcde
	  {
Packit Service 82fcde
	    I (NOFILE, 1024);	/* Linux 2.2.12 uses this initial value.  */
Packit Service 82fcde
Packit Service 82fcde
	  default:
Packit Service 82fcde
	    _hurd_rlimits[i].rlim_cur = _hurd_rlimits[i].rlim_max;
Packit Service 82fcde
	    break;
Packit Service 82fcde
	  }
Packit Service 82fcde
#undef	I
Packit Service 82fcde
    }
Packit Service 82fcde
Packit Service 82fcde
  (void) &init_rlimit;
Packit Service 82fcde
}
Packit Service 82fcde
text_set_element (_hurd_preinit_hook, init_rlimit);