mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-11 04:27:49 -05:00
shm: don’t check for __i386__ and __x86_64__ - there are other architectures out there
Instead, check for __SIZEOF_POINTER__ == 8, since what we’re really interested in is whether we have enough virtual address space or not.
This commit is contained in:
parent
0bb928e02f
commit
0d07ee03f5
1 changed files with 11 additions and 11 deletions
22
shm.c
22
shm.c
|
|
@ -129,7 +129,7 @@ static const struct wl_buffer_listener buffer_listener = {
|
||||||
.release = &buffer_release,
|
.release = &buffer_release,
|
||||||
};
|
};
|
||||||
|
|
||||||
#if !defined(__i386__)
|
#if __SIZEOF_POINTER__ == 8
|
||||||
static size_t
|
static size_t
|
||||||
page_size(void)
|
page_size(void)
|
||||||
{
|
{
|
||||||
|
|
@ -290,12 +290,12 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie,
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__i386__)
|
#if __SIZEOF_POINTER__ == 8
|
||||||
off_t initial_offset = 0;
|
|
||||||
off_t memfd_size = size;
|
|
||||||
#else
|
|
||||||
off_t initial_offset = scrollable && max_pool_size > 0 ? (max_pool_size / 4) & ~(page_size() - 1) : 0;
|
off_t initial_offset = scrollable && max_pool_size > 0 ? (max_pool_size / 4) & ~(page_size() - 1) : 0;
|
||||||
off_t memfd_size = scrollable && max_pool_size > 0 ? max_pool_size : size;
|
off_t memfd_size = scrollable && max_pool_size > 0 ? max_pool_size : size;
|
||||||
|
#else
|
||||||
|
off_t initial_offset = 0;
|
||||||
|
off_t memfd_size = size;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LOG_DBG("memfd-size: %lu, initial offset: %lu", memfd_size, initial_offset);
|
LOG_DBG("memfd-size: %lu, initial offset: %lu", memfd_size, initial_offset);
|
||||||
|
|
@ -307,7 +307,7 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie,
|
||||||
|
|
||||||
if (!can_punch_hole_initialized) {
|
if (!can_punch_hole_initialized) {
|
||||||
can_punch_hole_initialized = true;
|
can_punch_hole_initialized = true;
|
||||||
#if defined(__x86_64__) && defined(FALLOC_FL_PUNCH_HOLE)
|
#if __SIZEOF_POINTER__ == 8 && defined(FALLOC_FL_PUNCH_HOLE)
|
||||||
can_punch_hole = fallocate(
|
can_punch_hole = fallocate(
|
||||||
pool_fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 1) == 0;
|
pool_fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 1) == 0;
|
||||||
|
|
||||||
|
|
@ -412,15 +412,15 @@ err:
|
||||||
bool
|
bool
|
||||||
shm_can_scroll(const struct buffer *buf)
|
shm_can_scroll(const struct buffer *buf)
|
||||||
{
|
{
|
||||||
#if defined(__i386__)
|
#if __SIZEOF_POINTER__ == 8
|
||||||
|
return can_punch_hole && max_pool_size > 0 && buf->scrollable;
|
||||||
|
#else
|
||||||
/* Not enough virtual address space in 32-bit */
|
/* Not enough virtual address space in 32-bit */
|
||||||
return false;
|
return false;
|
||||||
#else
|
|
||||||
return can_punch_hole && max_pool_size > 0 && buf->scrollable;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(FALLOC_FL_PUNCH_HOLE)
|
#if __SIZEOF_POINTER__ == 8 && defined(FALLOC_FL_PUNCH_HOLE)
|
||||||
static bool
|
static bool
|
||||||
wrap_buffer(struct wl_shm *shm, struct buffer *buf, off_t new_offset)
|
wrap_buffer(struct wl_shm *shm, struct buffer *buf, off_t new_offset)
|
||||||
{
|
{
|
||||||
|
|
@ -660,7 +660,7 @@ shm_scroll(struct wl_shm *shm, struct buffer *buf, int rows,
|
||||||
int top_margin, int top_keep_rows,
|
int top_margin, int top_keep_rows,
|
||||||
int bottom_margin, int bottom_keep_rows)
|
int bottom_margin, int bottom_keep_rows)
|
||||||
{
|
{
|
||||||
#if defined(FALLOC_FL_PUNCH_HOLE)
|
#if __SIZEOF_POINTER__ == 8 && defined(FALLOC_FL_PUNCH_HOLE)
|
||||||
if (!shm_can_scroll(buf))
|
if (!shm_can_scroll(buf))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue