]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #19343: Expose FreeBSD-specific APIs in resource module. Original patch by...
authorChristian Heimes <christian@cheimes.de>
Sun, 8 Dec 2013 13:35:55 +0000 (14:35 +0100)
committerChristian Heimes <christian@cheimes.de>
Sun, 8 Dec 2013 13:35:55 +0000 (14:35 +0100)
Doc/library/resource.rst
Lib/test/test_resource.py
Misc/NEWS
Modules/resource.c

index 9bb5848e3a3c39c2aace3575e51a0f1618a497ee..f8112cc0e498c023e531f7bf2e01b5b2cde862e1 100644 (file)
@@ -217,6 +217,34 @@ platform.
 
    .. versionadded:: 3.4
 
+.. data:: RLIMIT_SBSIZE
+
+   The maximum size (in bytes) of socket buffer usage for this user.
+   This limits the amount of network memory, and hence the amount of mbufs,
+   that this user may hold at any time.
+
+   Availability: FreeBSD 9 or later.
+
+   .. versionadded:: 3.4
+
+.. data:: RLIMIT_SWAP
+
+   The maximum size (in bytes) of the swap space that may be reserved or
+   used by all of this user id's processes.
+   This limit is enforced only if bit 1 of the vm.overcommit sysctl is set.
+   Please see :manpage:`tuning(7)` for a complete description of this sysctl.
+
+   Availability: FreeBSD 9 or later.
+
+   .. versionadded:: 3.4
+
+.. data:: RLIMIT_NPTS
+
+   The maximum number of pseudo-terminals created by this user id.
+
+   Availability: FreeBSD 9 or later.
+
+   .. versionadded:: 3.4
 
 Resource Usage
 --------------
index 006198fc410b386865cf135ecd93419d877c7c31..2ecae0fc450a182b8c5bf47f49f86b60f1dcfda7 100644 (file)
@@ -138,6 +138,12 @@ class ResourceTest(unittest.TestCase):
             with contextlib.suppress(AttributeError):
                 self.assertIsInstance(getattr(resource, 'RLIMIT_' + attr), int)
 
+    @support.requires_freebsd_version(9)
+    def test_freebsd_contants(self):
+        for attr in ['SWAP', 'SBSIZE', 'NPTS']:
+            with contextlib.suppress(AttributeError):
+                self.assertIsInstance(getattr(resource, 'RLIMIT_' + attr), int)
+
     @unittest.skipUnless(hasattr(resource, 'prlimit'), 'no prlimit')
     @support.requires_linux_version(2, 6, 36)
     def test_prlimit(self):
index 93cdbf477760fa6128bbce8b6a776e6c128b5ad7..5c10e1a8d5321157176627f87d2a123dbf6eeb83 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -18,6 +18,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #19343: Expose FreeBSD-specific APIs in resource module.  Original
+  patch by Koobs.
+
 - Issue #19506: Use a memoryview to avoid a data copy when piping data
   to stdin within subprocess.Popen.communicate.  5-10% less cpu usage.
 
index c12ce341fee2dd16d7f5c37fba4cebee1513627d..3a1cf094c75e3d1204db2a07724947f984c86577 100644 (file)
@@ -424,6 +424,20 @@ PyInit_resource(void)
     PyModule_AddIntMacro(m, RUSAGE_THREAD);
 #endif
 
+/* FreeBSD specific */
+
+#ifdef RLIMIT_SWAP
+    PyModule_AddIntMacro(m, RLIMIT_SWAP);
+#endif
+
+#ifdef RLIMIT_SBSIZE
+    PyModule_AddIntMacro(m, RLIMIT_SBSIZE);
+#endif
+
+#ifdef RLIMIT_NPTS
+    PyModule_AddIntMacro(m, RLIMIT_NPTS);
+#endif
+
 #if defined(HAVE_LONG_LONG)
     if (sizeof(RLIM_INFINITY) > sizeof(long)) {
         v = PyLong_FromLongLong((PY_LONG_LONG) RLIM_INFINITY);