Fix: implicit declarations caused by buffer size checks.
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Tue, 16 Oct 2018 19:23:22 +0000 (15:23 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 17 Oct 2018 04:27:12 +0000 (00:27 -0400)
commit7502f47afaf537bbb67050b17ea095bb3976bf91
tree1e2958cbd929380161a05b75ca325b5d3c0cafd5
parent1f0ab1eb0409d23de5f67cc588c3ea4cee4d10e0
Fix: implicit declarations caused by buffer size checks.

Issue
=====
Three kernel functions used in the following commit are unavailable on
some supported kernels:

commit 1f0ab1eb0409d23de5f67cc588c3ea4cee4d10e0
Prevent allocation of buffers if exceeding available memory

* si_mem_available() was added in kernel 4.6 with commit d02bd27.
* {set, clear}_current_oom_origin() were added in kernel 3.8 with commit:
  e1e12d2f

Solution
========
Add wrappers around these functions such that older kernels will build
with these functions defined as NOP or trivial return value.

wrapper_check_enough_free_pages() uses the si_mem_available() kernel
function to compute if the number pages requested passed as parameter is
smaller than the number of pages available on the machine. If the
si_mem_available() kernel function is unavailable, we always return
true.

wrapper_set_current_oom_origin() function wraps the
set_current_oom_origin() kernel function when it is available.
If set_current_oom_origin() is unavailable the wrapper is empty.

wrapper_clear_current_oom_origin() function wraps the
clear_current_oom_origin() kernel function when it is available.
If clear_current_oom_origin() is unavailable the wrapper is empty.

Drawbacks
=========
None.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lib/ringbuffer/ring_buffer_backend.c
wrapper/mm.h [new file with mode: 0644]
This page took 0.027762 seconds and 4 git commands to generate.