On Sun, Dec 28, 2025 at 07:47:41PM +0100, Rafael Sadowski wrote:
> On Sun Dec 28, 2025 at 06:09:43PM +0100, Jeremie Courreges-Anglas wrote:
> > On Sun, Dec 28, 2025 at 05:26:49PM +0100, Rafael Sadowski wrote:
> > > Replace HW_PHYSMEM (deprecated) with HW_PHYSMEM64. This code also
> > > works on Free and NetBSD.
> >
> > FreeBSD doesn't have HW_PHYSMEM64. Also its HW_PHYSMEM uses a long
> > instead of an int, so the current appstream code is only correct-ish
> > on FreeBSD.
>
> This is a trap, however, if one does not look closely:
> https://man.freebsd.org/cgi/man.cgi?query=sysctl&sektion=7&manpath=NetBSD+8.0
FreeBSD's HW_PHYSMEM divergence is indeed error-prone. But the fact
that HW_PHYSMEM remains on NetBSD and OpenBSD also is error-prone.
It's another case of dubious divergence. But I'm not sure what you
mean by pointing at the NetBSD manpage. :)
> > > OK?
> >
> > On OpenBSD and NetBSD HW_PHYSMEM wants an int and HW_PHYSMEM64 wants
> > an int64_t so after the patch the code would be incorrect on 32 bits
> > archs.
> >
>
> Thanks for the input, what about this?
LGTM and compile-tested, ok jca@
> diff --git a/devel/appstream/Makefile b/devel/appstream/Makefile
> index bc8aadbd293..8e6e334d95a 100644
> --- a/devel/appstream/Makefile
> +++ b/devel/appstream/Makefile
> @@ -14,8 +14,8 @@ DISTNAME= AppStream-${V}
> EXTRACT_SUFX= .tar.xz
> PKGNAME-main= ${DISTNAME:L}
> PKGNAME-qt6= appstream-qt6-${V}
> -REVISION-main= 0
> -REVISION-qt6= 0
> +REVISION-main= 1
> +REVISION-qt6= 1
>
> SHARED_LIBS += appstream 1.2 # 1.1.1
> SHARED_LIBS += appstream-compose 1.1 # 1.1.1
> diff --git a/devel/appstream/patches/patch-src_as-system-info_c
> b/devel/appstream/patches/patch-src_as-system-info_c
> index 87ab6781782..da0fa9338ee 100644
> --- a/devel/appstream/patches/patch-src_as-system-info_c
> +++ b/devel/appstream/patches/patch-src_as-system-info_c
> @@ -12,12 +12,22 @@ Index: src/as-system-info.c
> #include <sys/types.h>
> #include <sys/sysctl.h>
> #elif defined(__GNU__)
> -@@ -476,7 +476,7 @@ as_get_physical_memory_total (void)
> +@@ -476,11 +476,15 @@ as_get_physical_memory_total (void)
> if (si.mem_unit > 0)
> return (si.totalram * si.mem_unit) / MB_IN_BYTES;
> return 0;
> -#elif defined(__FreeBSD__) || defined(__NetBSD__)
> +#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
> ++#if defined(__NetBSD__) || defined(__OpenBSD__)
> ++ int64_t physmem;
> ++ int mib[2] = { CTL_HW, HW_PHYSMEM64 };
> ++#elif defined(__FreeBSD__)
> unsigned long physmem;
> - size_t len = sizeof (physmem);
> +- size_t len = sizeof (physmem);
> int mib[2] = { CTL_HW, HW_PHYSMEM };
> +-
> ++#endif
> ++ size_t len = sizeof (physmem);
> + if (sysctl (mib, 2, &physmem, &len, NULL, 0) == -1) {
> + g_warning ("Unable to determine physical memory size: %s",
> g_strerror (errno));
> + return 0;
>
--
jca