x11/libxshmfence: Detect max page size correctly.

For cross-builds, whatever sysctl answers is wrong -- and even for
native builds, it may be wrong, because on some architectures with
common binary packages, the page size may vary from machine to
machine.  So use MAX_PAGE_SIZE if available, or PAGE_SIZE if not,
from machine/vmparam.h instead.

XXX Should probably also use COHERENCY_UNIT for cache line alignment,
not hard-coded 128.
This commit is contained in:
riastradh 2023-06-28 01:34:36 +00:00
parent ea57b175d6
commit a620db1add
2 changed files with 8 additions and 4 deletions

View File

@ -1,6 +1,7 @@
# $NetBSD: Makefile,v 1.20 2023/06/27 10:36:21 riastradh Exp $
# $NetBSD: Makefile,v 1.21 2023/06/28 01:34:36 riastradh Exp $
DISTNAME= libxshmfence-1.3.2
PKGREVISION= 1
CATEGORIES= x11
MASTER_SITES= ${MASTER_SITE_XORG:=lib/}
EXTRACT_SUFX= .tar.xz
@ -22,8 +23,6 @@ PKGCONFIG_OVERRIDE+= xshmfence.pc.in
.if ${OPSYS} == "NetBSD"
CONFIGURE_ARGS+= --disable-futex
CONFIGURE_ARGS+= --enable-semaphore
LIBXSHM_PAGESIZE!= /sbin/sysctl -n hw.pagesize
CPPFLAGS+= -DLIBXSHM_PAGESIZE=${LIBXSHM_PAGESIZE}
.endif
post-extract:

View File

@ -28,7 +28,12 @@
#define LOCK_ALIGN __attribute__((aligned(128)))
#ifndef LIBXSHM_PAGESIZE
#error unknown machine page size
#include <machine/vmparam.h>
#ifdef MAX_PAGE_SIZE
#define LIBXSHM_PAGESIZE MAX_PAGE_SIZE
#else
#define LIBXSHM_PAGESIZE PAGE_SIZE
#endif
#endif
#define PAGE_ALIGN __attribute__((aligned(LIBXSHM_PAGESIZE)))