Skip to content
Snippets Groups Projects
Commit 5fe4a65b authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Un-revert comments in utils.mlock


These updates and clarifications are still useful.

Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent ee8fd7b7
No related branches found
No related tags found
No related merge requests found
......@@ -34,7 +34,7 @@ except ImportError:
ctypes = None
# Flags for mlockall() (from bits/mman.h)
# Flags for mlockall(2) (from bits/mman.h)
_MCL_CURRENT = 1
_MCL_FUTURE = 2
......@@ -42,10 +42,10 @@ _MCL_FUTURE = 2
def Mlockall(_ctypes=ctypes):
"""Lock current process' virtual address space into RAM.
This is equivalent to the C call mlockall(MCL_CURRENT|MCL_FUTURE),
see mlock(2) for more details. This function requires ctypes module.
This is equivalent to the C call C{mlockall(MCL_CURRENT | MCL_FUTURE)}. See
mlockall(2) for more details. This function requires the C{ctypes} module.
@raises errors.NoCtypesError: if ctypes module is not found
@raises errors.NoCtypesError: If the C{ctypes} module is not found
"""
if _ctypes is None:
......@@ -60,11 +60,11 @@ def Mlockall(_ctypes=ctypes):
logging.error("Cannot set memory lock, ctypes cannot load libc")
return
# Some older version of the ctypes module don't have built-in functionality
# to access the errno global variable, where function error codes are stored.
# By declaring this variable as a pointer to an integer we can then access
# its value correctly, should the mlockall call fail, in order to see what
# the actual error code was.
# The ctypes module before Python 2.6 does not have built-in functionality to
# access the global errno global (which, depending on the libc and build
# options, is per thread), where function error codes are stored. Use GNU
# libc's way to retrieve errno(3) instead, which is to use the pointer named
# "__errno_location" (see errno.h and bits/errno.h).
# pylint: disable=W0212
libc.__errno_location.restype = _ctypes.POINTER(_ctypes.c_int)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment