diff options
author | Florian Weimer <fweimer@redhat.com> | 2017-11-27 17:14:29 +0100 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2017-11-27 17:14:29 +0100 |
commit | 4bab02240e9076b49702b30bb8a1d23a0afe58cb (patch) | |
tree | fc60d42e429ae1032be1f0291145232594e1ee4e /manual/memory.texi | |
parent | a23aa5b7272ec4a04578d82399ec2bf536281119 (diff) | |
download | glibc-4bab02240e9076b49702b30bb8a1d23a0afe58cb.zip glibc-4bab02240e9076b49702b30bb8a1d23a0afe58cb.tar.gz glibc-4bab02240e9076b49702b30bb8a1d23a0afe58cb.tar.bz2 |
Implement the mlock2 function
Fallback using mlock is provided if the flags argument is zero.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'manual/memory.texi')
-rw-r--r-- | manual/memory.texi | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/manual/memory.texi b/manual/memory.texi index 3f5dd90..1b431bf 100644 --- a/manual/memory.texi +++ b/manual/memory.texi @@ -3337,6 +3337,36 @@ The calling process is not superuser. The kernel does not provide @code{mlock} capability. @end table +@end deftypefun + +@deftypefun int mlock2 (const void *@var{addr}, size_t @var{len}, unsigned int @var{flags}) +@standards{Linux, sys/mman.h} +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} + +This function is similar to @code{mlock}. If @var{flags} is zero, a +call to @code{mlock2} behaves exactly as the equivalent call to @code{mlock}. + +The @var{flags} argument must be a combination of zero or more of the +following flags: + +@vtable @code +@item MLOCK_ONFAULT +@standards{Linux, sys/mman.h} +Only those pages in the specified address range which are already in +memory are locked immediately. Additional pages in the range are +automatically locked in case of a page fault and allocation of memory. +@end vtable + +Like @code{mlock}, @code{mlock2} returns zero on success and @code{-1} +on failure, setting @code{errno} accordingly. Additional @code{errno} +values defined for @code{mlock2} are: + +@table @code +@item EINVAL +The specified (non-zero) @var{flags} argument is not supported by this +system. +@end table +@end deftypefun You can lock @emph{all} a process' memory with @code{mlockall}. You unlock memory with @code{munlock} or @code{munlockall}. @@ -3346,8 +3376,6 @@ To avoid all page faults in a C program, you have to use from the C code, e.g. the stack and automatic variables, and you wouldn't know what address to tell @code{mlock}. -@end deftypefun - @deftypefun int munlock (const void *@var{addr}, size_t @var{len}) @standards{POSIX.1b, sys/mman.h} @safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} |