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