resource.h revision 1.4
1/* $NetBSD: resource.h,v 1.4 2020/05/24 19:46:26 christos Exp $ */ 2 3/* 4 * Copyright (C) Internet Systems Consortium, Inc. ("ISC") 5 * 6 * This Source Code Form is subject to the terms of the Mozilla Public 7 * License, v. 2.0. If a copy of the MPL was not distributed with this 8 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 * 10 * See the COPYRIGHT file distributed with this work for additional 11 * information regarding copyright ownership. 12 */ 13 14#ifndef ISC_RESOURCE_H 15#define ISC_RESOURCE_H 1 16 17/*! \file isc/resource.h */ 18 19#include <isc/lang.h> 20#include <isc/types.h> 21 22#define ISC_RESOURCE_UNLIMITED ((isc_resourcevalue_t)UINT64_MAX) 23 24ISC_LANG_BEGINDECLS 25 26isc_result_t 27isc_resource_setlimit(isc_resource_t resource, isc_resourcevalue_t value); 28/*%< 29 * Set the maximum limit for a system resource. 30 * 31 * Notes: 32 *\li If 'value' exceeds the maximum possible on the operating system, 33 * it is silently limited to that maximum -- or to "infinity", if 34 * the operating system has that concept. #ISC_RESOURCE_UNLIMITED 35 * can be used to explicitly ask for the maximum. 36 * 37 * Requires: 38 *\li 'resource' is a valid member of the isc_resource_t enumeration. 39 * 40 * Returns: 41 *\li #ISC_R_SUCCESS Success. 42 *\li #ISC_R_NOTIMPLEMENTED 'resource' is not a type known by the OS. 43 *\li #ISC_R_NOPERM The calling process did not have adequate permission 44 * to change the resource limit. 45 */ 46 47isc_result_t 48isc_resource_getlimit(isc_resource_t resource, isc_resourcevalue_t *value); 49/*%< 50 * Get the maximum limit for a system resource. 51 * 52 * Notes: 53 *\li 'value' is set to the maximum limit. 54 * 55 *\li #ISC_RESOURCE_UNLIMITED is the maximum value of isc_resourcevalue_t. 56 * 57 *\li On many (all?) Unix systems, RLIM_INFINITY is a valid value that is 58 * significantly less than #ISC_RESOURCE_UNLIMITED, but which in practice 59 * behaves the same. 60 * 61 *\li The current ISC libdns configuration file parser assigns a value 62 * of UINT32_MAX for a size_spec of "unlimited" and ISC_UNIT32_MAX - 1 63 * for "default", the latter of which is supposed to represent "the 64 * limit that was in force when the server started". Since these are 65 * valid values in the middle of the range of isc_resourcevalue_t, 66 * there is the possibility for confusion over what exactly those 67 * particular values are supposed to represent in a particular context -- 68 * discrete integral values or generalized concepts. 69 * 70 * Requires: 71 *\li 'resource' is a valid member of the isc_resource_t enumeration. 72 * 73 * Returns: 74 *\li #ISC_R_SUCCESS Success. 75 *\li #ISC_R_NOTIMPLEMENTED 'resource' is not a type known by the OS. 76 */ 77 78isc_result_t 79isc_resource_getcurlimit(isc_resource_t resource, isc_resourcevalue_t *value); 80/*%< 81 * Same as isc_resource_getlimit(), but returns the current (soft) limit. 82 * 83 * Returns: 84 *\li #ISC_R_SUCCESS Success. 85 *\li #ISC_R_NOTIMPLEMENTED 'resource' is not a type known by the OS. 86 */ 87 88ISC_LANG_ENDDECLS 89 90#endif /* ISC_RESOURCE_H */ 91