mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
shm: verify the system supports FALLOC_FL_PUNCH_HOLE
This commit is contained in:
parent
3b9be09b06
commit
7404ace40c
1 changed files with 12 additions and 0 deletions
12
shm.c
12
shm.c
|
|
@ -25,6 +25,9 @@
|
|||
|
||||
static tll(struct buffer) buffers;
|
||||
|
||||
static bool can_punch_hole = false;
|
||||
static bool can_punch_hole_initialized = false;
|
||||
|
||||
static void
|
||||
buffer_destroy(struct buffer *buf)
|
||||
{
|
||||
|
|
@ -226,6 +229,12 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie)
|
|||
goto err;
|
||||
}
|
||||
|
||||
if (!can_punch_hole_initialized) {
|
||||
can_punch_hole_initialized = true;
|
||||
can_punch_hole = fallocate(
|
||||
pool_fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 1) == 0;
|
||||
}
|
||||
|
||||
/* Push to list of available buffers, but marked as 'busy' */
|
||||
tll_push_back(
|
||||
buffers,
|
||||
|
|
@ -274,6 +283,9 @@ shm_scroll(struct wl_shm *shm, struct buffer *buf, int rows)
|
|||
assert(buf->real_mmapped);
|
||||
assert(buf->fd >= 0);
|
||||
|
||||
if (!can_punch_hole)
|
||||
return false;
|
||||
|
||||
LOG_DBG("scrolling %d rows (%d bytes)", rows, rows * buf->stride);
|
||||
|
||||
assert(rows > 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue