Hi again,

the patch below updates libpciaccess to version 0.17.
Most of the changes are for other operating systems.
There is a minor library version bump because a new function
pci_device_disable() has been added (not implemented for OpenBSD).

Fix a small leak in pci_system_openbsd_destroy() while there.

comments? oks?

Index: ChangeLog
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/ChangeLog,v
retrieving revision 1.11
diff -u -p -u -r1.11 ChangeLog
--- ChangeLog   30 Aug 2021 12:13:33 -0000      1.11
+++ ChangeLog   7 Nov 2022 12:32:08 -0000
@@ -1,3 +1,324 @@
+commit 935f0b4d6983f77c4f35e6d492f9f2c2d1ed57f9
+Author: Alan Coopersmith <alan.coopersm...@oracle.com>
+Date:   Mon Oct 17 18:41:02 2022 -0700
+
+    libpciaccess 0.17
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com>
+
+commit d193fa690415333420b435edb5782789a6f3ea57
+Author: Samuel Thibault <samuel.thiba...@ens-lyon.org>
+Date:   Tue Aug 23 19:27:27 2022 +0200
+
+    hurd: Fix pci_device_hurd_map_legacy
+    
+    It was not passing a proper region number to pci_device_hurd_map_range,
+    and that would not make sense anyway since the rom is not a region for
+    instance, and the video memory, interrupt vector etc. aren't a region or
+    the rom.
+    
+    So this uses pci_device_hurd_map_range for the rom, and
+    pci_system_x86_map_dev_mem for non-rom. Unfortunately pci-arbiter
+    currently cannot get the rom_base from libpciaccess, so we can only
+    guess that we are trying to map a rom.
+
+commit 361356b08003f5e3c606e16eeb6a17fe02ff2726
+Author: Moritz Fischer <mori...@google.com>
+Date:   Mon Mar 8 12:02:33 2021 -0800
+
+    Add pci_device_disable() function
+    
+    This implements a pci_device_disable() function, currently only for
+    the linux_sysfs() backend.
+    
+    This mirrors the implementation for pci_device_enable()
+    
+    Signed-off-by: Moritz Fischer <mori...@google.com>
+
+commit a8abf913ad6b60492ef7b6ae512c4f879604a6a7
+Author: zhanghongtao <zhanghongta...@huawei.com>
+Date:   Mon Aug 1 16:20:28 2022 +0800
+
+    Delete redundant symbols ';'
+    
+    Signed-off-by: zhanghongtao <zhanghongta...@huawei.com>
+
+commit ab475c645ff9fc40e18af739eb4b81a5eb7f783c
+Author: zhanghongtao <zhanghongta...@huawei.com>
+Date:   Mon Aug 1 16:13:40 2022 +0800
+
+    Add header protection macro in linux_devmem.h
+    
+    Signed-off-by: zhanghongtao <zhanghongta...@huawei.com>
+
+commit b8de959615449fdf5b58ef08d881a77d397e86e2
+Author: zhanghongtao <zhanghongta...@huawei.com>
+Date:   Mon Aug 1 15:53:57 2022 +0800
+
+    pci_sys set NULL after free
+    
+    Signed-off-by: zhanghongtao <zhanghongta...@huawei.com>
+
+commit f93c0dae5a837404a48ea7f3609c6c5c30691a7b
+Author: zhanghongtao <zhanghongta...@huawei.com>
+Date:   Mon Aug 1 15:28:14 2022 +0800
+
+    Add parentheses to the macro definition
+    
+    Signed-off-by: zhanghongtao <zhanghongta...@huawei.com>
+
+commit 1fa5d4bdfcc6fea44f9abf353d25f3a5d013f5d7
+Author: Satadru Pramanik <sata...@umich.edu>
+Date:   Tue Jun 21 20:44:30 2022 +0000
+
+    Add support for building on macOS w/o X11, using endian code from 
"portable_endian.h"...
+
+commit 22a93f8b9b4a79eefbdd0b2c412526f6141ac7a8
+Author: Alan Coopersmith <alan.coopersm...@oracle.com>
+Date:   Wed Apr 6 11:46:45 2022 -0700
+
+    configure.ac: Use pkg-config to find zlib dependency info
+    
+    Matches what we already do in meson.build
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com>
+
+commit 0ae62706c34e4abc581d4c42ce9807e2898fac1d
+Author: Alan Coopersmith <alan.coopersm...@oracle.com>
+Date:   Wed Apr 6 16:30:51 2022 -0700
+
+    gitlab CI: stop requiring Signed-off-by in commits
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com>
+
+commit 831b467b2e3876c4e0c307d1e3eae2746ce805a7
+Author: Chester Gillon <chester.gil...@metronet.co.uk>
+Date:   Sun Sep 5 13:37:56 2021 +0100
+
+    Obtain correct value of is_64 and is_prefetchable PCI device fields
+    
+    Correct setting of the is_64 and is_prefetchable pci_device fields in
+    pci_device_linux_sysfs_probe().
+    The pci_device struct defines is_64 and is_prefetchable as single bits,
+    but the previous code was attempting to store the result of a bit-masked
+    field in a single bit which always resulted in is_64 and is_prefetchable
+    being zero regardless of the actual capabilities of the PCI device.
+    
+    Fixes: #15
+    
+    Signed-off-by: Chester Gillon <chester.gil...@metronet.co.uk>
+
+commit 28d6dd72e5d6fa907dbccd310cc516e7012a60bd
+Author: Alan Coopersmith <alan.coopersm...@oracle.com>
+Date:   Sat Apr 2 16:00:56 2022 -0700
+
+    gitlab CI: add a basic build test for both autotools and meson
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com>
+
+commit 465aecdce47040a211fddc29186a4b1aa2ad5648
+Author: Alan Coopersmith <alan.coopersm...@oracle.com>
+Date:   Sat Apr 2 15:27:10 2022 -0700
+
+    meson: install man page in mandir/man1/, not mandir/1/
+    
+    But don't install it by default, since neither meson nor autotools
+    installs the scanpci program by default
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com>
+
+commit 5cf85c28ad5f0811d53e5d70eac384dfe8e86cd6
+Author: Alan Coopersmith <alan.coopersm...@oracle.com>
+Date:   Sat Apr 2 14:54:06 2022 -0700
+
+    Fix spelling/wording issues
+    
+    Found by using:
+        codespell --builtin clear,rare,usage,informal,code,names
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com>
+
+commit 9ad16d4da14905abfac50e41105dd1ceba877b07
+Author: Alan Coopersmith <alan.coopersm...@oracle.com>
+Date:   Sat Apr 2 14:44:13 2022 -0700
+
+    Build xz tarballs instead of bzip2
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com>
+
+commit 21aa2bf6edda711cc4a883e89fd4d3c337c76d6b
+Author: Joan Lledó  <jlle...@member.fsf.org>
+Date:   Sat Mar 12 19:28:04 2022 +0100
+
+    Hurd: Fix initialization order
+    
+    This allows non-root programs to to rely on /servers/bus/pci
+    
+    Message-Id: <20220312182804.9318-2-jlle...@mailfence.com>
+    
+    Reviewed-by: Samuel Thibault <samuel.thiba...@ens-lyon.org>
+
+commit 4ef1660667425c0f171949aacae9d07b10a40d7f
+Author: Damien Zammit <dam...@zamaudio.com>
+Date:   Tue Feb 15 06:44:23 2022 +0000
+
+    hurd: Don't necessarily look up _SERVERS_BUS_PCI
+    
+    This allows the fallback mechanism in the hurd create method to be
+    used in the map range method by reusing the mach port that
+    corresponds to the root of the pci filesystem.
+    
+    Message-Id: <20220215064411.68671-1-dam...@zamaudio.com>
+    
+    Reviewed-by: Samuel Thibault <samuel.thiba...@ens-lyon.org>
+
+commit 740d2f29700af38b01ca68e3e834db164cc1b789
+Author: Samuel Thibault <samuel.thiba...@ens-lyon.org>
+Date:   Sun Jan 9 01:09:04 2022 +0100
+
+    hurd: Restore initialization order
+    
+    3e0d1cde0187 ("hurd: Implement device memory mapping") was making
+    root-running processes insist on using the pci device, and never try the
+    fs-provided translator. This reverts back to trying the pci device
+    first, but completely, and then revert to the fs-provided translator.
+
+commit 3e0d1cde01872d605c267c61094e44315a3e7467
+Author: Joan Lledó  <jlle...@member.fsf.org>
+Date:   Wed Jan 5 13:08:01 2022 +0100
+
+    hurd: Implement device memory mapping
+    
+    * src/hurd_pci.c:
+            * Implement device memory mapping functions
+                    * pci_device_hurd_map_range
+                    * pci_device_hurd_unmap_range
+                    * pci_device_hurd_map_legacy
+                    * pci_device_hurd_unmap_legacy
+    * src/x86_pci.h:
+            * Remove unused declarations
+                    * pci_device_x86_map_range()
+                    * pci_device_x86_unmap_range()
+                    * pci_device_x86_map_legacy()
+                    * pci_device_x86_unmap_legacy()
+    * src/x86_pci.c:
+            * Fix port leaks
+            * Make mapping function static again
+            * map_dev_mem(): use device_map() support for offsets
+    Message-Id: <20220105120802.14008-2-jlle...@mailfence.com>
+    
+    Reviewed-by: Samuel Thibault <samuel.thiba...@ens-lyon.org>
+
+commit 9c01fdd7c02d8b9b5003e659ebca0b3643bd47c4
+Author: Damien Zammit <dam...@zamaudio.com>
+Date:   Wed Apr 7 18:29:13 2021 +1000
+
+    x86: Sort devices by B/D/F due to recursive scan
+
+commit 50e7de7a81be35bb4e5799cb5562d18683c05ade
+Author: Damien Zammit <dam...@zamaudio.com>
+Date:   Sun Mar 7 10:32:33 2021 +1100
+
+    hurd: device_open(pci), /servers/bus/pci fallback
+    
+    Reviewed-by: Samuel Thibault <samuel.thiba...@ens-lyon.org>
+
+commit b4bde8fe4e2872be8d0c527f5c9e155603f5d01f
+Author: Petr Ovtchenkov <p...@void-ptr.info>
+Date:   Wed Dec 2 10:52:28 2020 +0300
+
+    missed library installation in meson
+    
+    Signed-off-by: Petr Ovtchenkov <p...@void-ptr.info>
+    Reviewed-by: Dylan Baker <dy...@pnwbakers.com>
+
+commit f51e2f1e96db2acd426ac3f6bb066f314a7eee46
+Author: Dylan Baker <dy...@pnwbakers.com>
+Date:   Sun Oct 25 11:14:56 2020 -0700
+
+    autoconf: Add meson files to dist tarball
+    
+    Reviewed-by: Eric Anholt <e...@anholt.net>
+
+commit 89fcd717a60e7a6440b56ff7c82b5eeb80b92a2f
+Author: Dylan Baker <dy...@pnwbakers.com>
+Date:   Wed Sep 19 16:15:41 2018 -0700
+
+    Add a meson build system
+    
+    I believe this is correct and complete, but I could have missed
+    something on non-linux OSes.
+    
+    Reviewed-by: Eric Anholt <e...@anholt.net>
+
+commit 1ebcfe918a0da46a5b7ab44fc3ec0e6c65f98043
+Author: Samuel Thibault <samuel.thiba...@ens-lyon.org>
+Date:   Thu Sep 10 00:20:33 2020 +0200
+
+    hurd: Fix map_dev_mem from non-zero address
+    
+    device_map needs to create a big-enough object so it can then be mapped.
+    
+    Signed-off-by: Samuel Thibault <samuel.thiba...@ens-lyon.org>
+
+commit b82b779247b2adb164afed85a7e06cf3ca0d8ade
+Author: Samuel Thibault <samuel.thiba...@ens-lyon.org>
+Date:   Thu Sep 10 00:19:41 2020 +0200
+
+    hurd: Fix letting map_dev_mem map anywhere
+    
+    Signed-off-by: Samuel Thibault <samuel.thiba...@ens-lyon.org>
+
+commit 790ef9888a23fc257a66e742baf3b162b8c1f7c5
+Author: Samuel Thibault <samuel.thiba...@ens-lyon.org>
+Date:   Thu Sep 10 00:18:12 2020 +0200
+
+    hurd: Add missing round up size in map_dev_mem
+    
+    Signed-off-by: Samuel Thibault <samuel.thiba...@ens-lyon.org>
+
+commit 3e5ae795a265b8843c09cba310a5582c909f97a4
+Author: Damien Zammit <dam...@zamaudio.com>
+Date:   Sat Aug 22 22:31:11 2020 +1000
+
+    x86: Remove probe during create, other backends don't do this
+
+commit 9effa77676207d547dc869ecb8c342869e14ef70
+Author: Damien Zammit <dam...@zamaudio.com>
+Date:   Fri May 8 10:22:34 2020 +1000
+
+    x86: Remove mapping of regions during probe - otherwise remapping later 
fails
+
+commit b37ffbd94b4a270e62b752bdced882ce12b7610c
+Author: Damien Zammit <dam...@zamaudio.com>
+Date:   Fri May 8 10:19:23 2020 +1000
+
+    x86: Use gnumach device instead of /dev/mem on GNU systems && factorise 
ifdefs
+
+commit 6c0eebdf3a72d372de9aa1226ce889bdf56440b0
+Author: Damien Zammit <dam...@zamaudio.com>
+Date:   Sun Mar 15 12:42:51 2020 +1100
+
+    hurd_pci: Use __pci_conf_ variants of pci_conf_
+
+commit 1a7dab7b7c36b73d2a2d7e8b5c288c71542de11e
+Author: Fabrice Fontaine <fontaine.fabr...@gmail.com>
+Date:   Fri Oct 25 19:03:32 2019 +0200
+
+    pciaccess.pc.in: add Libs.Private
+    
+    Add Libs.Private in pciaccess.pc.in so applications that wants to link
+    statically with pciaccess will know that they have to link with its
+    dependencies such as -lz
+    
+    Signed-off-by: Fabrice Fontaine <fontaine.fabr...@gmail.com>
+
+commit 73901e7f7c03a5cdea317fd3d36feb978ef34a02
+Author: Joan Lledó  <jlle...@member.fsf.org>
+Date:   Sun Nov 24 11:17:30 2019 +0100
+
+    Hurd: avoid using the deprecated RPC pci_get_ndevs()
+
 commit fbd1f0fe79ba25b72635f8e36a6c33d7e0ca19f6
 Author: Adam Jackson <a...@redhat.com>
 Date:   Wed Jul 17 12:24:48 2019 -0400
@@ -3152,7 +3473,7 @@ Date:   Fri Mar 24 16:57:17 2006 +0000
         everything now.
 
 commit d890ded5312dc88455fd332e03a4f212ba587e9d
-Author: Kristian Høgsberg <k...@redhat.com>
+Author: Kristian Høgsberg  <k...@redhat.com>
 Date:   Mon Mar 20 20:13:34 2006 +0000
 
     Add scanpci as a noinst target.
Index: Makefile.am
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/Makefile.am,v
retrieving revision 1.7
diff -u -p -u -r1.7 Makefile.am
--- Makefile.am 30 Aug 2021 12:13:33 -0000      1.7
+++ Makefile.am 7 Nov 2022 12:32:08 -0000
@@ -42,4 +42,7 @@ ChangeLog:
 
 dist-hook: ChangeLog INSTALL
 
-EXTRA_DIST = README.md
+EXTRA_DIST = \
+       README.md \
+       meson.build \
+       meson_options.txt
Index: Makefile.bsd-wrapper
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/Makefile.bsd-wrapper,v
retrieving revision 1.6
diff -u -p -u -r1.6 Makefile.bsd-wrapper
--- Makefile.bsd-wrapper        13 Aug 2013 07:07:21 -0000      1.6
+++ Makefile.bsd-wrapper        7 Nov 2022 12:32:08 -0000
@@ -1,6 +1,6 @@
 # $OpenBSD: Makefile.bsd-wrapper,v 1.6 2013/08/13 07:07:21 guenther Exp $
 
-SHARED_LIBS=   pciaccess 2.0
+SHARED_LIBS=   pciaccess 2.1
 
 CONFIGURE_ARGS+= --with-pciids-path=${X11BASE}/share
 
Index: Makefile.in
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/Makefile.in,v
retrieving revision 1.11
diff -u -p -u -r1.11 Makefile.in
--- Makefile.in 30 Aug 2021 12:13:33 -0000      1.11
+++ Makefile.in 7 Nov 2022 12:32:08 -0000
@@ -191,9 +191,9 @@ am__relativize = \
     dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
   done; \
   reldir="$$dir2"
-DIST_ARCHIVES = $(distdir).tar.gz $(distdir).tar.bz2
+DIST_ARCHIVES = $(distdir).tar.gz $(distdir).tar.xz
 GZIP_ENV = --best
-DIST_TARGETS = dist-bzip2 dist-gzip
+DIST_TARGETS = dist-xz dist-gzip
 distuninstallcheck_listfiles = find . -type f -print
 am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
   | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
@@ -286,6 +286,8 @@ STRICT_CFLAGS = @STRICT_CFLAGS@
 STRIP = @STRIP@
 VERSION = @VERSION@
 XORG_MAN_PAGE = @XORG_MAN_PAGE@
+ZLIB_CFLAGS = @ZLIB_CFLAGS@
+ZLIB_LIBS = @ZLIB_LIBS@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -330,6 +332,7 @@ pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
@@ -347,7 +350,11 @@ SUBDIRS = include man src scanpci
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = pciaccess.pc
 MAINTAINERCLEANFILES = ChangeLog INSTALL
-EXTRA_DIST = README.md
+EXTRA_DIST = \
+       README.md \
+       meson.build \
+       meson_options.txt
+
 all: config.h
        $(MAKE) $(AM_MAKEFLAGS) all-recursive
 
@@ -640,6 +647,7 @@ distdir: $(DISTFILES)
 dist-gzip: distdir
        tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c 
>$(distdir).tar.gz
        $(am__post_remove_distdir)
+
 dist-bzip2: distdir
        tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c 
>$(distdir).tar.bz2
        $(am__post_remove_distdir)
@@ -647,7 +655,6 @@ dist-bzip2: distdir
 dist-lzip: distdir
        tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} 
>$(distdir).tar.lz
        $(am__post_remove_distdir)
-
 dist-xz: distdir
        tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c 
>$(distdir).tar.xz
        $(am__post_remove_distdir)
Index: README.md
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/README.md,v
retrieving revision 1.1
diff -u -p -u -r1.1 README.md
--- README.md   30 Aug 2021 12:13:33 -0000      1.1
+++ README.md   7 Nov 2022 12:32:08 -0000
@@ -16,7 +16,7 @@ Xorg mailing list:
 
   https://lists.x.org/mailman/listinfo/xorg
 
-The master development code repository can be found at:
+The primary development code repository can be found at:
 
   https://gitlab.freedesktop.org/xorg/lib/libpciaccess
 
Index: aclocal.m4
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/aclocal.m4,v
retrieving revision 1.12
diff -u -p -u -r1.12 aclocal.m4
--- aclocal.m4  30 Aug 2021 12:13:33 -0000      1.12
+++ aclocal.m4  7 Nov 2022 12:32:08 -0000
@@ -19,9 +19,9 @@ You have another version of autoconf.  I
 If you have problems, you may need to regenerate the build system entirely.
 To do so, use the procedure documented by the package, typically 
'autoreconf'.])])
 
-dnl pkg.m4 - Macros to locate and utilise pkg-config.   -*- Autoconf -*-
-dnl serial 11 (pkg-config-0.29.1)
-dnl
+# pkg.m4 - Macros to locate and utilise pkg-config.   -*- Autoconf -*-
+# serial 12 (pkg-config-0.29.2)
+
 dnl Copyright © 2004 Scott James Remnant <sc...@netsplit.com>.
 dnl Copyright © 2012-2015 Dan Nicholson <dbn.li...@gmail.com>
 dnl
@@ -62,7 +62,7 @@ dnl
 dnl See the "Since" comment for each macro you use to see what version
 dnl of the macros you require.
 m4_defun([PKG_PREREQ],
-[m4_define([PKG_MACROS_VERSION], [0.29.1])
+[m4_define([PKG_MACROS_VERSION], [0.29.2])
 m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
     [m4_fatal([pkg.m4 version $1 or higher is required but 
]PKG_MACROS_VERSION[ found])])
 ])dnl PKG_PREREQ
@@ -163,7 +163,7 @@ AC_ARG_VAR([$1][_CFLAGS], [C compiler fl
 AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
 
 pkg_failed=no
-AC_MSG_CHECKING([for $1])
+AC_MSG_CHECKING([for $2])
 
 _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
 _PKG_CONFIG([$1][_LIBS], [libs], [$2])
@@ -173,11 +173,11 @@ and $1[]_LIBS to avoid the need to call 
 See the pkg-config man page for more details.])
 
 if test $pkg_failed = yes; then
-       AC_MSG_RESULT([no])
+        AC_MSG_RESULT([no])
         _PKG_SHORT_ERRORS_SUPPORTED
         if test $_pkg_short_errors_supported = yes; then
                $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors 
--cflags --libs "$2" 2>&1`
-        else 
+        else
                $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs 
"$2" 2>&1`
         fi
        # Put the nasty error message in config.log where it belongs
@@ -194,7 +194,7 @@ installed software in a non-standard pre
 _PKG_TEXT])[]dnl
         ])
 elif test $pkg_failed = untried; then
-       AC_MSG_RESULT([no])
+        AC_MSG_RESULT([no])
        m4_default([$4], [AC_MSG_FAILURE(
 [The pkg-config script could not be found or is too old.  Make sure it
 is in your PATH or set the PKG_CONFIG environment variable to the full
Index: compile
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/compile,v
retrieving revision 1.4
diff -u -p -u -r1.4 compile
--- compile     30 Aug 2021 12:13:33 -0000      1.4
+++ compile     7 Nov 2022 12:32:08 -0000
@@ -3,7 +3,7 @@
 
 scriptversion=2018-03-07.03; # UTC
 
-# Copyright (C) 1999-2018 Free Software Foundation, Inc.
+# Copyright (C) 1999-2021 Free Software Foundation, Inc.
 # Written by Tom Tromey <tro...@cygnus.com>.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -53,7 +53,7 @@ func_file_conv ()
          MINGW*)
            file_conv=mingw
            ;;
-         CYGWIN*)
+         CYGWIN* | MSYS*)
            file_conv=cygwin
            ;;
          *)
@@ -67,7 +67,7 @@ func_file_conv ()
        mingw/*)
          file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
          ;;
-       cygwin/*)
+       cygwin/* | msys/*)
          file=`cygpath -m "$file" || echo "$file"`
          ;;
        wine/*)
Index: configure
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/configure,v
retrieving revision 1.15
diff -u -p -u -r1.15 configure
--- configure   30 Aug 2021 12:13:33 -0000      1.15
+++ configure   7 Nov 2022 12:32:09 -0000
@@ -1,8 +1,8 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for libpciaccess 0.16.
+# Generated by GNU Autoconf 2.69 for libpciaccess 0.17.
 #
-# Report bugs to <https://gitlab.freedesktop.org/xorg/lib/libpciaccess/issues>.
+# Report bugs to 
<https://gitlab.freedesktop.org/xorg/lib/libpciaccess/-/issues>.
 #
 #
 # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -275,7 +275,7 @@ fi
     $as_echo "$0: be upgraded to zsh 4.3.4 or later."
   else
     $as_echo "$0: Please tell bug-autoc...@gnu.org and
-$0: https://gitlab.freedesktop.org/xorg/lib/libpciaccess/issues
+$0: https://gitlab.freedesktop.org/xorg/lib/libpciaccess/-/issues
 $0: about your system, including any error possibly output
 $0: before this message. Then install a modern shell, or
 $0: manually run the script under such a shell if you do
@@ -591,9 +591,9 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='libpciaccess'
 PACKAGE_TARNAME='libpciaccess'
-PACKAGE_VERSION='0.16'
-PACKAGE_STRING='libpciaccess 0.16'
-PACKAGE_BUGREPORT='https://gitlab.freedesktop.org/xorg/lib/libpciaccess/issues'
+PACKAGE_VERSION='0.17'
+PACKAGE_STRING='libpciaccess 0.17'
+PACKAGE_BUGREPORT='https://gitlab.freedesktop.org/xorg/lib/libpciaccess/-/issues'
 PACKAGE_URL=''
 
 # Factoring default headers for most tests.
@@ -652,6 +652,8 @@ FREEBSD_FALSE
 FREEBSD_TRUE
 LINUX_FALSE
 LINUX_TRUE
+ZLIB_LIBS
+ZLIB_CFLAGS
 PCIIDS_PATH
 AM_BACKSLASH
 AM_DEFAULT_VERBOSITY
@@ -771,6 +773,7 @@ infodir
 docdir
 oldincludedir
 includedir
+runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
@@ -821,7 +824,9 @@ CPPFLAGS
 CPP
 PKG_CONFIG
 PKG_CONFIG_PATH
-PKG_CONFIG_LIBDIR'
+PKG_CONFIG_LIBDIR
+ZLIB_CFLAGS
+ZLIB_LIBS'
 
 
 # Initialize some variables set by options.
@@ -860,6 +865,7 @@ datadir='${datarootdir}'
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1112,6 +1118,15 @@ do
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
+  -runstatedir | --runstatedir | --runstatedi | --runstated \
+  | --runstate | --runstat | --runsta | --runst | --runs \
+  | --run | --ru | --r)
+    ac_prev=runstatedir ;;
+  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+  | --run=* | --ru=* | --r=*)
+    runstatedir=$ac_optarg ;;
+
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1249,7 +1264,7 @@ fi
 for ac_var in  exec_prefix prefix bindir sbindir libexecdir datarootdir \
                datadir sysconfdir sharedstatedir localstatedir includedir \
                oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-               libdir localedir mandir
+               libdir localedir mandir runstatedir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
@@ -1362,7 +1377,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures libpciaccess 0.16 to adapt to many kinds of systems.
+\`configure' configures libpciaccess 0.17 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1402,6 +1417,7 @@ Fine tuning of the installation director
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
@@ -1432,7 +1448,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of libpciaccess 0.16:";;
+     short | recursive ) echo "Configuration of libpciaccess 0.17:";;
    esac
   cat <<\_ACEOF
 
@@ -1491,11 +1507,13 @@ Some influential environment variables:
               directories to add to pkg-config's search path
   PKG_CONFIG_LIBDIR
               path overriding pkg-config's built-in search path
+  ZLIB_CFLAGS C compiler flags for ZLIB, overriding pkg-config
+  ZLIB_LIBS   linker flags for ZLIB, overriding pkg-config
 
 Use these variables to override the choices made by `configure' or to help
 it to find libraries and programs with nonstandard names/locations.
 
-Report bugs to <https://gitlab.freedesktop.org/xorg/lib/libpciaccess/issues>.
+Report bugs to <https://gitlab.freedesktop.org/xorg/lib/libpciaccess/-/issues>.
 _ACEOF
 ac_status=$?
 fi
@@ -1558,7 +1576,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-libpciaccess configure 0.16
+libpciaccess configure 0.17
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1717,9 +1735,9 @@ $as_echo "$as_me: WARNING: $2: see the A
 $as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" 
>&2;}
     { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the 
compiler's result" >&5
 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
-( $as_echo "## 
-------------------------------------------------------------------------- ##
-## Report this to https://gitlab.freedesktop.org/xorg/lib/libpciaccess/issues 
##
-## -------------------------------------------------------------------------- 
##"
+( $as_echo "## 
---------------------------------------------------------------------------- ##
+## Report this to 
https://gitlab.freedesktop.org/xorg/lib/libpciaccess/-/issues ##
+## 
---------------------------------------------------------------------------- ##"
      ) | sed "s/^/$as_me: WARNING:     /" >&2
     ;;
 esac
@@ -1973,7 +1991,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by libpciaccess $as_me 0.16, which was
+It was created by libpciaccess $as_me 0.17, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2801,7 +2819,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='libpciaccess'
- VERSION='0.16'
+ VERSION='0.17'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -17730,6 +17748,126 @@ AM_BACKSLASH='\'
 
 
 
+
+
+
+
+
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+       if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a 
program name with args.
+set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a 
path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" 
>&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+if test -n "$PKG_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
+$as_echo "$PKG_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_path_PKG_CONFIG"; then
+  ac_pt_PKG_CONFIG=$PKG_CONFIG
+  # Extract the first word of "pkg-config", so it can be a program name with 
args.
+set dummy pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $ac_pt_PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the 
test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" 
>&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
+if test -n "$ac_pt_PKG_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
+$as_echo "$ac_pt_PKG_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_pt_PKG_CONFIG" = x; then
+    PKG_CONFIG=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not 
prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" 
>&2;}
+ac_tool_warned=yes ;;
+esac
+    PKG_CONFIG=$ac_pt_PKG_CONFIG
+  fi
+else
+  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
+fi
+
+fi
+if test -n "$PKG_CONFIG"; then
+       _pkg_min_version=0.9.0
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at 
least version $_pkg_min_version" >&5
+$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " 
>&6; }
+       if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+               { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+       else
+               { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+               PKG_CONFIG=""
+       fi
+fi
+
 pciids_path=/usr/share/hwdata
 
 # Check whether --with-pciids-path was given.
@@ -17777,57 +17915,101 @@ if test "${with_zlib+set}" = set; then :
 fi
 
 if test "x$use_zlib" = xyes; then
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gzopen in -lz" >&5
-$as_echo_n "checking for gzopen in -lz... " >&6; }
-if ${ac_cv_lib_z_gzopen+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lz  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
 
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char gzopen ();
-int
-main ()
-{
-return gzopen ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_z_gzopen=yes
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for zlib" >&5
+$as_echo_n "checking for zlib... " >&6; }
+
+if test -n "$ZLIB_CFLAGS"; then
+    pkg_cv_ZLIB_CFLAGS="$ZLIB_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists 
--print-errors \"zlib\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "zlib") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_ZLIB_CFLAGS=`$PKG_CONFIG --cflags "zlib" 2>/dev/null`
+                     test "x$?" != "x0" && pkg_failed=yes
 else
-  ac_cv_lib_z_gzopen=no
+  pkg_failed=yes
 fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+ else
+    pkg_failed=untried
+fi
+if test -n "$ZLIB_LIBS"; then
+    pkg_cv_ZLIB_LIBS="$ZLIB_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists 
--print-errors \"zlib\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "zlib") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_ZLIB_LIBS=`$PKG_CONFIG --libs "zlib" 2>/dev/null`
+                     test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_gzopen" >&5
-$as_echo "$ac_cv_lib_z_gzopen" >&6; }
-if test "x$ac_cv_lib_z_gzopen" = xyes; then :
-  PCIACCESS_LIBS="$PCIACCESS_LIBS -lz"
+
+
+
+if test $pkg_failed = yes; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
 else
-  as_fn_error $? "Check for zlib library failed" "$LINENO" 5
+        _pkg_short_errors_supported=no
 fi
+        if test $_pkg_short_errors_supported = yes; then
+               ZLIB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors 
--cflags --libs "zlib" 2>&1`
+        else
+               ZLIB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs 
"zlib" 2>&1`
+        fi
+       # Put the nasty error message in config.log where it belongs
+       echo "$ZLIB_PKG_ERRORS" >&5
 
-       ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" 
"$ac_includes_default"
-if test "x$ac_cv_header_zlib_h" = xyes; then :
+       as_fn_error $? "Package requirements (zlib) were not met:
 
-$as_echo "#define HAVE_ZLIB 1" >>confdefs.h
+$ZLIB_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+Alternatively, you may set the environment variables ZLIB_CFLAGS
+and ZLIB_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details." "$LINENO" 5
+elif test $pkg_failed = untried; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+       { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "The pkg-config script could not be found or is too old.  Make 
sure it
+is in your PATH or set the PKG_CONFIG environment variable to the full
+path to pkg-config.
+
+Alternatively, you may set the environment variables ZLIB_CFLAGS
+and ZLIB_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details.
 
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.
+See \`config.log' for more details" "$LINENO" 5; }
 else
-  as_fn_error $? "Check for zlib.h header file failed" "$LINENO" 5
+       ZLIB_CFLAGS=$pkg_cv_ZLIB_CFLAGS
+       ZLIB_LIBS=$pkg_cv_ZLIB_LIBS
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
 fi
+       PCIACCESS_CFLAGS="$PCIACCESS_CFLAGS $ZLIB_CFLAGS"
+       PCIACCESS_LIBS="$PCIACCESS_LIBS $ZLIB_LIBS"
 
+$as_echo "#define HAVE_ZLIB 1" >>confdefs.h
 
 fi
 
@@ -18756,7 +18938,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_wri
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by libpciaccess $as_me 0.16, which was
+This file was extended by libpciaccess $as_me 0.17, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -18816,13 +18998,13 @@ $config_headers
 Configuration commands:
 $config_commands
 
-Report bugs to <https://gitlab.freedesktop.org/xorg/lib/libpciaccess/issues>."
+Report bugs to 
<https://gitlab.freedesktop.org/xorg/lib/libpciaccess/-/issues>."
 
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; 
s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-libpciaccess config.status 0.16
+libpciaccess config.status 0.17
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
Index: configure.ac
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/configure.ac,v
retrieving revision 1.15
diff -u -p -u -r1.15 configure.ac
--- configure.ac        30 Aug 2021 12:13:33 -0000      1.15
+++ configure.ac        7 Nov 2022 12:32:09 -0000
@@ -23,13 +23,14 @@
 
 # Initialize Autoconf
 AC_PREREQ([2.60])
-AC_INIT([libpciaccess],[0.16],
-        
[https://gitlab.freedesktop.org/xorg/lib/libpciaccess/issues],[libpciaccess])
+AC_INIT([libpciaccess],[0.17],
+        [https://gitlab.freedesktop.org/xorg/lib/libpciaccess/-/issues],
+        [libpciaccess])
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_AUX_DIR([.])
 
 # Initialize Automake
-AM_INIT_AUTOMAKE([foreign dist-bzip2])
+AM_INIT_AUTOMAKE([foreign dist-xz])
 AC_USE_SYSTEM_EXTENSIONS
 
 # Initialize libtool
@@ -40,6 +41,7 @@ m4_ifndef([XORG_MACROS_VERSION],
           [m4_fatal([must install xorg-macros 1.8 or later before running 
autoconf/autogen])])
 XORG_MACROS_VERSION(1.8)
 XORG_DEFAULT_OPTIONS
+PKG_PROG_PKG_CONFIG
 
 pciids_path=/usr/share/hwdata
 AC_ARG_WITH(pciids-path, AS_HELP_STRING([--with-pciids-path=PCIIDS_PATH],
@@ -59,12 +61,10 @@ AC_ARG_WITH(zlib, AS_HELP_STRING([--with
        [Enable zlib support to read gzip compressed pci.ids]),
        [use_zlib="$withval"])
 if test "x$use_zlib" = xyes; then
-       AC_CHECK_LIB(z, gzopen,
-       [PCIACCESS_LIBS="$PCIACCESS_LIBS -lz"],
-       [AC_MSG_ERROR(Check for zlib library failed)])
-       AC_CHECK_HEADER([zlib.h],
-       [AC_DEFINE(HAVE_ZLIB, 1, [Use zlib to read gzip compressed pci.ids])],
-       [AC_MSG_ERROR(Check for zlib.h header file failed)])
+       PKG_CHECK_MODULES([ZLIB], [zlib])
+       PCIACCESS_CFLAGS="$PCIACCESS_CFLAGS $ZLIB_CFLAGS"
+       PCIACCESS_LIBS="$PCIACCESS_LIBS $ZLIB_LIBS"
+       AC_DEFINE(HAVE_ZLIB, 1, [Use zlib to read gzip compressed pci.ids])
 fi
 
 case $host_os in
Index: meson.build
===================================================================
RCS file: meson.build
diff -N meson.build
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ meson.build 7 Nov 2022 12:32:09 -0000
@@ -0,0 +1,134 @@
+# Copyright © 2018-2020 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+project(
+  'libpciaccess',
+  ['c'],
+  version : '0.17',
+  license : 'MIT',
+  meson_version : '>= 0.48.0',
+  default_options : ['buildtype=debugoptimized'],
+)
+
+c = meson.get_compiler('c')
+
+add_project_arguments(
+  c.get_supported_arguments(
+    '-Wpointer-arith',
+    '-Wmissing-declarations',
+    '-Wformat=2',
+    '-Wstrict-prototypes',
+    '-Wmissing-prototypes',
+    '-Wnested-externs',
+    '-Wbad-function-cast',
+    '-Wold-style-definition',
+    '-Wdeclaration-after-statement',
+    '-Wunused',
+    '-Wuninitialized',
+    '-Wshadow',
+    '-Wmissing-noreturn',
+    '-Wmissing-format-attribute',
+    '-Wredundant-decls',
+    '-Wlogical-op',
+    '-Werror=implicit',
+    '-Werror=nonnull',
+    '-Werror=init-self',
+    '-Werror=main',
+    '-Werror=missing-braces',
+    '-Werror=sequence-point',
+    '-Werror=return-type',
+    '-Werror=trigraphs',
+    '-Werror=array-bounds',
+    '-Werror=write-strings',
+    '-Werror=address',
+    '-Werror=int-to-pointer-cast',
+  ),
+  language : 'c'
+)
+
+config = configuration_data()
+
+config.set_quoted(
+  'PCIIDS_PATH',
+  join_paths(get_option('prefix'), get_option('datadir'), 
get_option('pci-ids'))
+)
+if get_option('linux-rom-fallback')
+  config.set('LINUX_ROM', 1)
+endif
+
+dep_zlib = dependency('zlib', required : get_option('zlib'))
+if dep_zlib.found()
+  config.set('HAVE_ZLIB', 1)
+endif
+
+extra_libs = []
+if host_machine.system() == 'netbsd'
+  extra_libs += c.find_library('pci')
+  if host_machine.cpu_family() == 'x86'
+    extra_libs += c.find_library('i386')
+  elif host_machine.cpu_family() == 'x86_64'
+    extra_libs += c.find_library('x86_64')
+  elif host_machine.cpu_family() == 'alpha'  # TODO
+    extra_libs += c.find_library('alpha')
+  endif
+elif host_machine.system() == 'sunos'
+  extra_libs += c.find_library('devinfo')
+endif
+
+if host_machine.system() == 'netbsd'
+  _prefix = ''
+  if c.check_header('machine/sysarch.h')
+    _prefix = '''
+      #include <sys/types.h>
+      #include <machine/sysarch.h>
+    '''
+  endif
+
+  if c.check_header('machine/mtrr.h', prefix : _prefix)
+    config.set('HAVE_MTRR', 1)
+  endif
+elif c.check_header('asm/mtrr.h')
+  config.set('HAVE_MTRR', 1)
+endif
+
+foreach h : ['err.h', 'stdint.h', 'string.h', 'strings.h', 'inttypes.h']
+  if c.check_header(h)
+    config.set('HAVE_' + h.to_upper().underscorify(), 1)
+  endif
+endforeach
+
+config_h = configure_file(
+  configuration : config,
+  output : 'config.h',
+)
+add_project_arguments('-DHAVE_CONFIG_H', language : ['c'])
+
+install_headers('include/pciaccess.h')
+inc_include = include_directories('.', 'include')
+
+subdir('src')
+subdir('scanpci')
+subdir('man')
+
+pkg = import('pkgconfig')
+pkg.generate(
+  libpciaccess,
+  description : 'Library providing generic access to the PCI bus and devices',
+)
Index: meson_options.txt
===================================================================
RCS file: meson_options.txt
diff -N meson_options.txt
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ meson_options.txt   7 Nov 2022 12:32:09 -0000
@@ -0,0 +1,37 @@
+# Copyright © 2020 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+option(
+  'pci-ids',
+  type : 'string',
+  value : 'hwdata',
+  description : 'path to pci ids. If relative is assumed relative to 
$datadir.',
+)
+option(
+  'linux-rom-fallback',
+  type : 'boolean',
+  value : false,
+  description : 'Enable support for falling back to /dev/mem for roms',
+)
+option(
+  'zlib',
+  type : 'feature',
+  description : 'Enable zlib support to read gzip compressed pci.ids.',
+)
Index: pciaccess.pc.in
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/pciaccess.pc.in,v
retrieving revision 1.1.1.1
diff -u -p -u -r1.1.1.1 pciaccess.pc.in
--- pciaccess.pc.in     5 Jun 2007 20:08:56 -0000       1.1.1.1
+++ pciaccess.pc.in     7 Nov 2022 12:32:09 -0000
@@ -8,3 +8,4 @@ Description: Library providing generic a
 Version: @PACKAGE_VERSION@
 Cflags: -I${includedir}
 Libs: -L${libdir} -lpciaccess
+Libs.Private: @PCIACCESS_LIBS@
Index: include/Makefile.in
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/include/Makefile.in,v
retrieving revision 1.4
diff -u -p -u -r1.4 Makefile.in
--- include/Makefile.in 11 Oct 2016 22:15:42 -0000      1.4
+++ include/Makefile.in 7 Nov 2022 12:32:09 -0000
@@ -203,6 +203,8 @@ STRICT_CFLAGS = @STRICT_CFLAGS@
 STRIP = @STRIP@
 VERSION = @VERSION@
 XORG_MAN_PAGE = @XORG_MAN_PAGE@
+ZLIB_CFLAGS = @ZLIB_CFLAGS@
+ZLIB_LIBS = @ZLIB_LIBS@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -247,6 +249,7 @@ pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
Index: include/pciaccess.h
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/include/pciaccess.h,v
retrieving revision 1.7
diff -u -p -u -r1.7 pciaccess.h
--- include/pciaccess.h 21 May 2018 20:02:28 -0000      1.7
+++ include/pciaccess.h 7 Nov 2022 12:32:09 -0000
@@ -143,6 +143,7 @@ const char *pci_device_get_vendor_name(c
 const char *pci_device_get_subvendor_name(const struct pci_device *dev);
 
 void pci_device_enable(struct pci_device *dev);
+void pci_device_disable(struct pci_device *dev);
 
 int pci_device_cfg_read    (struct pci_device *dev, void *data,
     pciaddr_t offset, pciaddr_t size, pciaddr_t *bytes_read);
@@ -383,7 +384,7 @@ struct pci_device {
     /**
      * Storage for user data.  Users of the library can store arbitrary
      * data in this pointer.  The library will not use it for any purpose.
-     * It is the user's responsability to free this memory before destroying
+     * It is the user's responsibility to free this memory before destroying
      * the \c pci_device structure.
      */
     intptr_t user_data;
@@ -513,7 +514,7 @@ struct pci_pcmcia_bridge_info {
 int  pci_device_vgaarb_init         (void);
 void pci_device_vgaarb_fini         (void);
 int  pci_device_vgaarb_set_target   (struct pci_device *dev);
-/* use the targetted device */
+/* use the targeted device */
 int  pci_device_vgaarb_decodes      (int new_vga_rsrc);
 int  pci_device_vgaarb_lock         (void);
 int  pci_device_vgaarb_trylock      (void);
Index: man/Makefile.am
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/man/Makefile.am,v
retrieving revision 1.1
diff -u -p -u -r1.1 Makefile.am
--- man/Makefile.am     6 Nov 2011 21:35:46 -0000       1.1
+++ man/Makefile.am     7 Nov 2022 12:32:09 -0000
@@ -24,7 +24,10 @@
 appman_PRE = scanpci.man
 noinst_DATA = $(appman_PRE:man=$(APP_MAN_SUFFIX))
 
-EXTRA_DIST = $(appman_PRE)
+EXTRA_DIST = \
+       $(appman_PRE) \
+       meson.build
+
 CLEANFILES = $(noinst_DATA)
 
 # String replacements in MAN_SUBSTS now come from xorg-macros.m4 via configure
Index: man/Makefile.in
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/man/Makefile.in,v
retrieving revision 1.4
diff -u -p -u -r1.4 Makefile.in
--- man/Makefile.in     11 Oct 2016 22:15:42 -0000      1.4
+++ man/Makefile.in     7 Nov 2022 12:32:09 -0000
@@ -195,6 +195,8 @@ STRICT_CFLAGS = @STRICT_CFLAGS@
 STRIP = @STRIP@
 VERSION = @VERSION@
 XORG_MAN_PAGE = @XORG_MAN_PAGE@
+ZLIB_CFLAGS = @ZLIB_CFLAGS@
+ZLIB_LIBS = @ZLIB_LIBS@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -239,6 +241,7 @@ pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
@@ -249,7 +252,10 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 appman_PRE = scanpci.man
 noinst_DATA = $(appman_PRE:man=$(APP_MAN_SUFFIX))
-EXTRA_DIST = $(appman_PRE)
+EXTRA_DIST = \
+       $(appman_PRE) \
+       meson.build
+
 CLEANFILES = $(noinst_DATA)
 
 # String replacements in MAN_SUBSTS now come from xorg-macros.m4 via configure
Index: man/meson.build
===================================================================
RCS file: man/meson.build
diff -N man/meson.build
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ man/meson.build     7 Nov 2022 12:32:09 -0000
@@ -0,0 +1,32 @@
+# Copyright © 2020 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+custom_target(
+  'scanpci.1',
+  input : 'scanpci.man',
+  output : 'scanpci.1',
+  command : [
+    find_program('sed'), '-e', 's/__xorgversion__/X Version 11/', '@INPUT@',
+  ],
+  capture : true,
+  install : false,
+  install_dir : join_paths(get_option('prefix'), get_option('mandir'), 'man1'),
+)
+
Index: scanpci/Makefile.am
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/scanpci/Makefile.am,v
retrieving revision 1.2
diff -u -p -u -r1.2 Makefile.am
--- scanpci/Makefile.am 3 Jan 2014 09:44:25 -0000       1.2
+++ scanpci/Makefile.am 7 Nov 2022 12:32:09 -0000
@@ -27,3 +27,5 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I
 LDADD =  $(top_builddir)/src/libpciaccess.la
 
 scanpci_SOURCES = scanpci.c
+
+EXTRA_DIST = meson.build
\ No newline at end of file
Index: scanpci/Makefile.in
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/scanpci/Makefile.in,v
retrieving revision 1.4
diff -u -p -u -r1.4 Makefile.in
--- scanpci/Makefile.in 11 Oct 2016 22:15:42 -0000      1.4
+++ scanpci/Makefile.in 7 Nov 2022 12:32:09 -0000
@@ -229,6 +229,8 @@ STRICT_CFLAGS = @STRICT_CFLAGS@
 STRIP = @STRIP@
 VERSION = @VERSION@
 XORG_MAN_PAGE = @XORG_MAN_PAGE@
+ZLIB_CFLAGS = @ZLIB_CFLAGS@
+ZLIB_LIBS = @ZLIB_LIBS@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -273,6 +275,7 @@ pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
@@ -284,6 +287,7 @@ top_srcdir = @top_srcdir@
 AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src
 LDADD = $(top_builddir)/src/libpciaccess.la
 scanpci_SOURCES = scanpci.c
+EXTRA_DIST = meson.build
 all: all-am
 
 .SUFFIXES:
Index: scanpci/meson.build
===================================================================
RCS file: scanpci/meson.build
diff -N scanpci/meson.build
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ scanpci/meson.build 7 Nov 2022 12:32:09 -0000
@@ -0,0 +1,25 @@
+# Copyright © 2018-2020 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+scanpci = executable(
+  'scanpci',
+  'scanpci.c',
+  dependencies : [dep_pciaccess],
+)
Index: src/Makefile.am
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/src/Makefile.am,v
retrieving revision 1.12
diff -u -p -u -r1.12 Makefile.am
--- src/Makefile.am     30 Aug 2021 12:13:33 -0000      1.12
+++ src/Makefile.am     7 Nov 2022 12:32:09 -0000
@@ -76,3 +76,5 @@ libpciaccess_la_SOURCES = common_bridge.
 libpciaccess_la_LIBADD = $(PCIACCESS_LIBS)
 
 libpciaccess_la_LDFLAGS = -version-number 0:11:1 -no-undefined
+
+EXTRA_DIST = meson.build
\ No newline at end of file
Index: src/Makefile.in
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/src/Makefile.in,v
retrieving revision 1.14
diff -u -p -u -r1.14 Makefile.in
--- src/Makefile.in     30 Aug 2021 12:13:33 -0000      1.14
+++ src/Makefile.in     7 Nov 2022 12:32:09 -0000
@@ -286,6 +286,8 @@ STRICT_CFLAGS = @STRICT_CFLAGS@
 STRIP = @STRIP@
 VERSION = @VERSION@
 XORG_MAN_PAGE = @XORG_MAN_PAGE@
+ZLIB_CFLAGS = @ZLIB_CFLAGS@
+ZLIB_LIBS = @ZLIB_LIBS@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -330,6 +332,7 @@ pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
@@ -369,6 +372,7 @@ libpciaccess_la_SOURCES = common_bridge.
 
 libpciaccess_la_LIBADD = $(PCIACCESS_LIBS)
 libpciaccess_la_LDFLAGS = -version-number 0:11:1 -no-undefined
+EXTRA_DIST = meson.build
 all: all-am
 
 .SUFFIXES:
Index: src/common_interface.c
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/src/common_interface.c,v
retrieving revision 1.11
diff -u -p -u -r1.11 common_interface.c
--- src/common_interface.c      21 May 2018 20:02:28 -0000      1.11
+++ src/common_interface.c      7 Nov 2022 12:32:09 -0000
@@ -70,6 +70,24 @@
 # define HTOLE_32(x)   (x)
 #endif /* Solaris */
 
+#elif defined(__APPLE__)
+#include <libkern/OSByteOrder.h>
+
+#define htobe16(x) OSSwapHostToBigInt16(x)
+#define htole16(x) OSSwapHostToLittleInt16(x)
+#define be16toh(x) OSSwapBigToHostInt16(x)
+#define le16toh(x) OSSwapLittleToHostInt16(x)
+
+#define htobe32(x) OSSwapHostToBigInt32(x)
+#define htole32(x) OSSwapHostToLittleInt32(x)
+#define be32toh(x) OSSwapBigToHostInt32(x)
+#define le32toh(x) OSSwapLittleToHostInt32(x)
+
+#define htobe64(x) OSSwapHostToBigInt64(x)
+#define htole64(x) OSSwapHostToLittleInt64(x)
+#define be64toh(x) OSSwapBigToHostInt64(x)
+#define le64toh(x) OSSwapLittleToHostInt64(x)
+
 #else
 
 #include <sys/endian.h>
@@ -656,6 +674,16 @@ pci_device_enable(struct pci_device *dev
 
     if (pci_sys->methods->enable)
        pci_sys->methods->enable(dev);
+}
+
+void
+pci_device_disable(struct pci_device *dev)
+{
+       if (dev == NULL)
+               return;
+
+       if (pci_sys->methods->disable)
+               pci_sys->methods->disable(dev);
 }
 
 /**
Index: src/common_io.c
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/src/common_io.c,v
retrieving revision 1.4
diff -u -p -u -r1.4 common_io.c
--- src/common_io.c     21 May 2018 20:02:28 -0000      1.4
+++ src/common_io.c     7 Nov 2022 12:32:09 -0000
@@ -13,7 +13,7 @@
  * Software.
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTIBILITY,
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
  * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER
  * IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF OR IN
Index: src/freebsd_pci.c
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/src/freebsd_pci.c,v
retrieving revision 1.9
diff -u -p -u -r1.9 freebsd_pci.c
--- src/freebsd_pci.c   30 Aug 2021 12:13:33 -0000      1.9
+++ src/freebsd_pci.c   7 Nov 2022 12:32:09 -0000
@@ -663,12 +663,14 @@ pci_system_freebsd_create( void )
 
     if ( ioctl( pcidev, PCIOCGETCONF, &pciconfio ) == -1) {
        free( pci_sys );
+       pci_sys = NULL;
        close( pcidev );
        return errno;
     }
 
     if (pciconfio.status == PCI_GETCONF_ERROR ) {
        free( pci_sys );
+       pci_sys = NULL;
        close( pcidev );
        return EINVAL;
     }
Index: src/hurd_pci.c
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/src/hurd_pci.c,v
retrieving revision 1.1
diff -u -p -u -r1.1 hurd_pci.c
--- src/hurd_pci.c      30 Aug 2021 12:13:33 -0000      1.1
+++ src/hurd_pci.c      7 Nov 2022 12:32:09 -0000
@@ -33,9 +33,12 @@
 #include <sys/mman.h>
 #include <string.h>
 #include <strings.h>
+#include <mach.h>
 #include <hurd.h>
 #include <hurd/pci.h>
 #include <hurd/paths.h>
+#include <hurd/fs.h>
+#include <device/device.h>
 
 #include "x86_pci.h"
 #include "pciaccess.h"
@@ -52,8 +55,11 @@
 
 /* File names */
 #define FILE_CONFIG_NAME "config"
+#define FILE_REGION_NAME "region"
 #define FILE_ROM_NAME "rom"
 
+#define LEGACY_REGION -1
+
 /* Level in the fs tree */
 typedef enum {
     LEVEL_NONE,
@@ -65,6 +71,7 @@ typedef enum {
 
 struct pci_system_hurd {
     struct pci_system system;
+    mach_port_t root;
 };
 
 static int
@@ -146,8 +153,167 @@ pci_device_hurd_probe(struct pci_device 
     return 0;
 }
 
+static void
+pci_system_hurd_destroy(void)
+{
+    struct pci_system_hurd *pci_sys_hurd = (struct pci_system_hurd *)pci_sys;
+
+    x86_disable_io();
+    mach_port_deallocate(mach_task_self(), pci_sys_hurd->root);
+}
+
+static int
+pci_device_hurd_map_range(struct pci_device *dev,
+    struct pci_device_mapping *map)
+{
+#if 0
+    struct pci_device_private *d = (struct pci_device_private *)dev;
+#endif
+    struct pci_system_hurd *pci_sys_hurd = (struct pci_system_hurd *)pci_sys;
+    int err = 0;
+    file_t file = MACH_PORT_NULL;
+    memory_object_t robj, wobj, pager;
+    vm_offset_t offset;
+    vm_prot_t prot = VM_PROT_READ;
+    const struct pci_mem_region *region;
+    const struct pci_mem_region rom_region = {
+#if 0
+    /* FIXME: We should be doing this: */
+        .base_addr = d->rom_base,
+    /* But currently pci-arbiter cannot get rom_base from libpciaccess, so we
+       are here assuming the caller is mapping from the rom base */
+#else
+        .base_addr = map->base,
+#endif
+        .size = dev->rom_size,
+    };
+    int flags = O_RDONLY;
+    char server[NAME_MAX];
+
+    if (map->flags & PCI_DEV_MAP_FLAG_WRITABLE) {
+        prot |= VM_PROT_WRITE;
+        flags = O_RDWR;
+    }
+
+    if (map->region != LEGACY_REGION) {
+      region = &dev->regions[map->region];
+      snprintf(server, NAME_MAX, "%04x/%02x/%02x/%01u/%s%01u",
+              dev->domain, dev->bus, dev->dev, dev->func,
+              FILE_REGION_NAME, map->region);
+    } else {
+      region = &rom_region;
+      snprintf(server, NAME_MAX, "%04x/%02x/%02x/%01u/%s",
+              dev->domain, dev->bus, dev->dev, dev->func,
+              FILE_ROM_NAME);
+      if (map->base < region->base_addr ||
+         map->base + map->size > region->base_addr + region->size)
+       return EINVAL;
+    }
+
+    file = file_name_lookup_under (pci_sys_hurd->root, server, flags, 0);
+    if (! MACH_PORT_VALID (file)) {
+        return errno;
+    }
+
+    err = io_map (file, &robj, &wobj);
+    mach_port_deallocate (mach_task_self(), file);
+    if (err)
+        return err;
+
+    switch (prot & (VM_PROT_READ|VM_PROT_WRITE)) {
+    case VM_PROT_READ:
+        pager = robj;
+        if (wobj != MACH_PORT_NULL)
+            mach_port_deallocate (mach_task_self(), wobj);
+        break;
+    case VM_PROT_READ|VM_PROT_WRITE:
+        if (robj == wobj) {
+            if (robj == MACH_PORT_NULL)
+                return EPERM;
+
+            pager = wobj;
+            /* Remove extra reference.  */
+            mach_port_deallocate (mach_task_self (), pager);
+        }
+        else {
+            if (robj != MACH_PORT_NULL)
+                mach_port_deallocate (mach_task_self (), robj);
+            if (wobj != MACH_PORT_NULL)
+                mach_port_deallocate (mach_task_self (), wobj);
+
+            return EPERM;
+        }
+        break;
+    default:
+        return EINVAL;
+    }
+
+    offset = map->base - region->base_addr;
+    err = vm_map (mach_task_self (), (vm_address_t *)&map->memory, map->size,
+                  0, 1,
+                  pager, /* a memory object proxy containing only the region */
+                  offset, /* offset from region start */
+                  0, prot, VM_PROT_ALL, VM_INHERIT_SHARE);
+    mach_port_deallocate (mach_task_self(), pager);
+
+    return err;
+}
+
+static int
+pci_device_hurd_unmap_range(struct pci_device *dev,
+    struct pci_device_mapping *map)
+{
+    int err;
+    err = pci_device_generic_unmap_range(dev, map);
+    map->memory = NULL;
+
+    return err;
+}
+
+static int
+pci_device_hurd_map_legacy(struct pci_device *dev, pciaddr_t base,
+    pciaddr_t size, unsigned map_flags, void **addr)
+{
+    struct pci_device_mapping map;
+    int err;
+
+    if (base >= 0xC0000 && base < 0x100000) {
+      /* FIXME: We would rather know for sure from d->rom_base whether this is
+         the ROM or not but currently pci-arbiter cannot get rom_base from
+         libpciaccess, so we are here assuming the caller is mapping from the
+         rom base */
+      map.base = base;
+      map.size = size;
+      map.flags = map_flags;
+      map.region = LEGACY_REGION;
+      err = pci_device_hurd_map_range(dev, &map);
+      *addr = map.memory;
+
+      if (!err)
+       return 0;
+    }
+
+    /* This is probably not the ROM, this is probably something like VRam or
+       the interrupt table, just map it by hand.  */
+    return pci_system_x86_map_dev_mem(addr, base, size, !!(map_flags & 
PCI_DEV_MAP_FLAG_WRITABLE));
+}
+
+static int
+pci_device_hurd_unmap_legacy(struct pci_device *dev, void *addr,
+    pciaddr_t size)
+{
+    struct pci_device_mapping map;
+
+    map.size = size;
+    map.flags = 0;
+    map.region = LEGACY_REGION;
+    map.memory = addr;
+
+    return pci_device_hurd_unmap_range(dev, &map);
+}
+
 /*
- * Read `nbytes' bytes from `reg' in device's configuretion space
+ * Read `nbytes' bytes from `reg' in device's configuration space
  * and store them in `buf'.
  *
  * It's assumed that `nbytes' bytes are allocated in `buf'
@@ -162,7 +328,7 @@ pciclient_cfg_read(mach_port_t device_po
 
     data = buf;
     nread = *nbytes;
-    err = pci_conf_read(device_port, reg, &data, &nread, *nbytes);
+    err = __pci_conf_read(device_port, reg, &data, &nread, *nbytes);
     if (err)
         return err;
 
@@ -189,7 +355,7 @@ pciclient_cfg_write(mach_port_t device_p
     int err;
     size_t nwrote;
 
-    err = pci_conf_write(device_port, reg, buf, *nbytes, &nwrote);
+    err = __pci_conf_write(device_port, reg, buf, *nbytes, &nwrote);
 
     if (!err)
         *nbytes = nwrote;
@@ -295,32 +461,54 @@ pci_device_hurd_read_rom(struct pci_devi
  * Deallocate the port before destroying the device.
  */
 static void
-pci_device_hurd_destroy(struct pci_device *dev)
+pci_device_hurd_destroy_device(struct pci_device *dev)
 {
     struct pci_device_private *d = (struct pci_device_private*) dev;
 
     mach_port_deallocate (mach_task_self (), d->device_port);
 }
 
+static struct dirent64 *
+simple_readdir(mach_port_t port, uint32_t *first_entry)
+{
+    char *data;
+    int nentries = 0;
+    vm_size_t size;
+
+    dir_readdir (port, &data, &size, *first_entry, 1, 0, &nentries);
+
+    if (nentries == 0) {
+        return NULL;
+    }
+
+    *first_entry = *first_entry + 1;
+    return (struct dirent64 *)data;
+}
+
 /* Walk through the FS tree to see what is allowed for us */
 static int
-enum_devices(const char *parent, struct pci_device_private **device,
-                int domain, int bus, int dev, int func, tree_level lev)
+enum_devices(mach_port_t pci_port, const char *parent, int domain,
+             int bus, int dev, int func, tree_level lev)
 {
     int err, ret;
-    DIR *dir;
-    struct dirent *entry;
+    struct dirent64 *entry = NULL;
     char path[NAME_MAX];
     char server[NAME_MAX];
-    uint32_t reg;
+    uint32_t reg, count = 0;
     size_t toread;
-    mach_port_t device_port;
+    mach_port_t cwd_port, device_port;
+    struct pci_device_private *d, *devices;
 
-    dir = opendir(parent);
-    if (!dir)
-        return errno;
+    if (lev > LEVEL_FUNC + 1) {
+        return 0;
+    }
+    cwd_port = file_name_lookup_under (pci_port, parent,
+                                       O_DIRECTORY | O_RDONLY | O_EXEC, 0);
+    if (cwd_port == MACH_PORT_NULL) {
+        return 0;
+    }
 
-    while ((entry = readdir(dir)) != 0) {
+    while ((entry = simple_readdir(cwd_port, &count)) != NULL) {
         snprintf(path, NAME_MAX, "%s/%s", parent, entry->d_name);
         if (entry->d_type == DT_DIR) {
             if (!strncmp(entry->d_name, ".", NAME_MAX)
@@ -329,8 +517,9 @@ enum_devices(const char *parent, struct 
 
             errno = 0;
             ret = strtol(entry->d_name, 0, 16);
-            if (errno)
+            if (errno) {
                 return errno;
+            }
 
             /*
              * We found a valid directory.
@@ -350,79 +539,104 @@ enum_devices(const char *parent, struct 
                 func = ret;
                 break;
             default:
-                return -1;
+                return 0;
             }
 
-            err = enum_devices(path, device, domain, bus, dev, func, lev+1);
-            if (err == EPERM)
-                continue;
-        }
-        else {
+            err = enum_devices(pci_port, path, domain, bus, dev, func, lev+1);
+            if (err && err != EPERM && err != EACCES) {
+                return 0;
+            }
+        } else {
             if (strncmp(entry->d_name, FILE_CONFIG_NAME, NAME_MAX))
                 /* We are looking for the config file */
                 continue;
 
             /* We found an available virtual device, add it to our list */
-            snprintf(server, NAME_MAX, "%s/%04x/%02x/%02x/%01u/%s",
-                     _SERVERS_BUS_PCI, domain, bus, dev, func,
+            snprintf(server, NAME_MAX, "./%04x/%02x/%02x/%01u/%s",
+                     domain, bus, dev, func,
                      entry->d_name);
-            device_port = file_name_lookup(server, 0, 0);
-            if (device_port == MACH_PORT_NULL)
-                return errno;
+            device_port = file_name_lookup_under(pci_port, server, O_RDONLY, 
0);
+            if (device_port == MACH_PORT_NULL) {
+                return 0;
+            }
 
             toread = sizeof(reg);
             err = pciclient_cfg_read(device_port, PCI_VENDOR_ID, (char*)&reg,
                                      &toread);
-            if (err)
+            if (err) {
+                mach_port_deallocate (mach_task_self (), device_port);
                 return err;
-            if (toread != sizeof(reg))
+            }
+            if (toread != sizeof(reg)) {
+                mach_port_deallocate (mach_task_self (), device_port);
                 return -1;
+            }
+
+            devices = realloc(pci_sys->devices, (pci_sys->num_devices + 1)
+                              * sizeof(struct pci_device_private));
+            if (!devices) {
+                mach_port_deallocate (mach_task_self (), device_port);
+                return ENOMEM;
+            }
 
-            (*device)->base.domain = domain;
-            (*device)->base.bus = bus;
-            (*device)->base.dev = dev;
-            (*device)->base.func = func;
-            (*device)->base.vendor_id = PCI_VENDOR(reg);
-            (*device)->base.device_id = PCI_DEVICE(reg);
+            d = devices + pci_sys->num_devices;
+            memset(d, 0, sizeof(struct pci_device_private));
+
+            d->base.domain = domain;
+            d->base.bus = bus;
+            d->base.dev = dev;
+            d->base.func = func;
+            d->base.vendor_id = PCI_VENDOR(reg);
+            d->base.device_id = PCI_DEVICE(reg);
 
             toread = sizeof(reg);
             err = pciclient_cfg_read(device_port, PCI_CLASS, (char*)&reg,
                                      &toread);
-            if (err)
+            if (err) {
+                mach_port_deallocate (mach_task_self (), device_port);
                 return err;
-            if (toread != sizeof(reg))
+            }
+            if (toread != sizeof(reg)) {
+                mach_port_deallocate (mach_task_self (), device_port);
                 return -1;
+            }
 
-            (*device)->base.device_class = reg >> 8;
-            (*device)->base.revision = reg & 0xFF;
+            d->base.device_class = reg >> 8;
+            d->base.revision = reg & 0xFF;
 
             toread = sizeof(reg);
             err = pciclient_cfg_read(device_port, PCI_SUB_VENDOR_ID,
                                      (char*)&reg, &toread);
-            if (err)
+            if (err) {
+                mach_port_deallocate (mach_task_self (), device_port);
                 return err;
-            if (toread != sizeof(reg))
+            }
+            if (toread != sizeof(reg)) {
+                mach_port_deallocate (mach_task_self (), device_port);
                 return -1;
+            }
 
-            (*device)->base.subvendor_id = PCI_VENDOR(reg);
-            (*device)->base.subdevice_id = PCI_DEVICE(reg);
+            d->base.subvendor_id = PCI_VENDOR(reg);
+            d->base.subdevice_id = PCI_DEVICE(reg);
 
-            (*device)->device_port = device_port;
+            d->device_port = device_port;
 
-            (*device)++;
+            pci_sys->devices = devices;
+            pci_sys->num_devices++;
         }
     }
+    mach_port_deallocate (mach_task_self (), cwd_port);
 
     return 0;
 }
 
 static const struct pci_system_methods hurd_pci_methods = {
-    .destroy = pci_system_x86_destroy,
-    .destroy_device = pci_device_hurd_destroy,
+    .destroy = pci_system_hurd_destroy,
+    .destroy_device = pci_device_hurd_destroy_device,
     .read_rom = pci_device_hurd_read_rom,
     .probe = pci_device_hurd_probe,
-    .map_range = pci_device_x86_map_range,
-    .unmap_range = pci_device_x86_unmap_range,
+    .map_range = pci_device_hurd_map_range,
+    .unmap_range = pci_device_hurd_unmap_range,
     .read = pci_device_hurd_read,
     .write = pci_device_hurd_write,
     .fill_capabilities = pci_fill_capabilities_generic,
@@ -434,24 +648,35 @@ static const struct pci_system_methods h
     .write32 = pci_device_x86_write32,
     .write16 = pci_device_x86_write16,
     .write8 = pci_device_x86_write8,
-    .map_legacy = pci_device_x86_map_legacy,
-    .unmap_legacy = pci_device_x86_unmap_legacy,
+    .map_legacy = pci_device_hurd_map_legacy,
+    .unmap_legacy = pci_device_hurd_unmap_legacy,
 };
 
+/* Get the name of the server using libpciaccess if any */
+extern char *netfs_server_name;
+#pragma weak netfs_server_name
+
 _pci_hidden int
 pci_system_hurd_create(void)
 {
-    struct pci_device_private *device;
     int err;
     struct pci_system_hurd *pci_sys_hurd;
-    size_t ndevs;
-    mach_port_t pci_server_port;
+    mach_port_t device_master;
+    mach_port_t pci_port = MACH_PORT_NULL;
+    mach_port_t root = MACH_PORT_NULL;
+
+    if (&netfs_server_name && netfs_server_name
+        && !strcmp(netfs_server_name, "pci-arbiter")) {
+      /* We are a PCI arbiter, try the x86 way */
+      err = pci_system_x86_create();
+      if (!err)
+          return 0;
+    }
 
-    /* If we can open pci cfg io ports on hurd,
-     * we are the arbiter, therefore try x86 method first */
-    err = pci_system_x86_create();
-    if (!err)
-        return 0;
+    /*
+     * From this point on, we are either a client or a nested arbiter.
+     * Both will connect to a master arbiter.
+     */
 
     pci_sys_hurd = calloc(1, sizeof(struct pci_system_hurd));
     if (pci_sys_hurd == NULL) {
@@ -462,35 +687,36 @@ pci_system_hurd_create(void)
 
     pci_sys->methods = &hurd_pci_methods;
 
-    pci_server_port = file_name_lookup(_SERVERS_BUS_PCI, 0, 0);
-    if (!pci_server_port) {
-        /* Fall back to x86 access method */
-        return pci_system_x86_create();
+    pci_sys->num_devices = 0;
+
+    err = get_privileged_ports (NULL, &device_master);
+
+    if(!err && device_master != MACH_PORT_NULL) {
+        err = device_open (device_master, D_READ, "pci", &pci_port);
+       mach_port_deallocate (mach_task_self (), device_master);
     }
 
-    /* The server gives us the number of available devices for us */
-    err = pci_get_ndevs (pci_server_port, &ndevs);
-    if (err) {
-        mach_port_deallocate (mach_task_self (), pci_server_port);
-        /* Fall back to x86 access method */
-        return pci_system_x86_create();
-    }
-    mach_port_deallocate (mach_task_self (), pci_server_port);
-
-    pci_sys->num_devices = ndevs;
-    pci_sys->devices = calloc(ndevs, sizeof(struct pci_device_private));
-    if (pci_sys->devices == NULL) {
-        x86_disable_io();
-        free(pci_sys_hurd);
-        pci_sys = NULL;
-        return ENOMEM;
+    if (!err && pci_port != MACH_PORT_NULL) {
+        root = file_name_lookup_under (pci_port, ".", O_DIRECTORY | O_RDONLY | 
O_EXEC, 0);
+        device_close (pci_port);
+        mach_port_deallocate (mach_task_self (), pci_port);
     }
 
-    device = pci_sys->devices;
-    err = enum_devices(_SERVERS_BUS_PCI, &device, -1, -1, -1, -1,
-                       LEVEL_DOMAIN);
-    if (err)
-        return pci_system_x86_create();
+    if (root == MACH_PORT_NULL) {
+        root = file_name_lookup (_SERVERS_BUS_PCI, O_RDONLY, 0);
+    }
+
+    if (root == MACH_PORT_NULL) {
+        pci_system_cleanup();
+        return errno;
+    }
+
+    pci_sys_hurd->root = root;
+    err = enum_devices (root, ".", -1, -1, -1, -1, LEVEL_DOMAIN);
+    if (err) {
+        pci_system_cleanup();
+        return err;
+    }
 
     return 0;
 }
Index: src/linux_devmem.h
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/src/linux_devmem.h,v
retrieving revision 1.2
diff -u -p -u -r1.2 linux_devmem.h
--- src/linux_devmem.h  9 Mar 2012 21:02:10 -0000       1.2
+++ src/linux_devmem.h  7 Nov 2022 12:32:09 -0000
@@ -30,5 +30,10 @@
  * \author Ian Romanick <i...@us.ibm.com>
  */
 
+#ifndef LINUX_DEVMEM_H
+#define LINUX_DEVMEM_H
+
 extern int pci_device_linux_devmem_read_rom(struct pci_device *dev,
                                            void *buffer);
+
+#endif
Index: src/linux_sysfs.c
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/src/linux_sysfs.c,v
retrieving revision 1.9
diff -u -p -u -r1.9 linux_sysfs.c
--- src/linux_sysfs.c   30 Aug 2021 12:13:33 -0000      1.9
+++ src/linux_sysfs.c   7 Nov 2022 12:32:09 -0000
@@ -336,9 +336,9 @@ pci_device_linux_sysfs_probe( struct pci
                    dev->regions[i].size = (high_addr
                                            - dev->regions[i].base_addr) + 1;
 
-                   dev->regions[i].is_IO = (flags & 0x01);
-                   dev->regions[i].is_64 = (flags & 0x04);
-                   dev->regions[i].is_prefetchable = (flags & 0x08);
+                   dev->regions[i].is_IO = (flags & 0x01) != 0;
+                   dev->regions[i].is_64 = (flags & 0x04) != 0;
+                   dev->regions[i].is_prefetchable = (flags & 0x08) != 0;
                }
            }
 
@@ -742,7 +742,7 @@ pci_device_linux_sysfs_unmap_range(struc
     return err;
 }
 
-static void pci_device_linux_sysfs_enable(struct pci_device *dev)
+static void pci_device_linux_sysfs_set_enable(struct pci_device *dev, int 
enable)
 {
     char name[256];
     int fd;
@@ -758,10 +758,20 @@ static void pci_device_linux_sysfs_enabl
     if (fd == -1)
        return;
 
-    write( fd, "1", 1 );
+    write( fd, enable ? "1" : "0" , 1 );
     close(fd);
 }
 
+static void pci_device_linux_sysfs_enable(struct pci_device *dev)
+{
+       return pci_device_linux_sysfs_set_enable(dev, 1);
+}
+
+static void pci_device_linux_sysfs_disable(struct pci_device *dev)
+{
+       return pci_device_linux_sysfs_set_enable(dev, 0);
+}
+
 static int pci_device_linux_sysfs_boot_vga(struct pci_device *dev)
 {
     char name[256];
@@ -981,7 +991,7 @@ pci_device_linux_sysfs_map_legacy(struct
     int ret=0;
 
     if (map_flags & PCI_DEV_MAP_FLAG_WRITABLE) {
-       flags = O_RDWR; /* O_RDWR != O_WRONLY | O_RDONLY */;
+       flags = O_RDWR; /* O_RDWR != O_WRONLY | O_RDONLY */
        prot |= PROT_WRITE;
     }
 
@@ -1042,6 +1052,7 @@ static const struct pci_system_methods l
 
     .fill_capabilities = pci_fill_capabilities_generic,
     .enable = pci_device_linux_sysfs_enable,
+    .disable = pci_device_linux_sysfs_disable,
     .boot_vga = pci_device_linux_sysfs_boot_vga,
     .has_kernel_driver = pci_device_linux_sysfs_has_kernel_driver,
 
Index: src/meson.build
===================================================================
RCS file: src/meson.build
diff -N src/meson.build
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ src/meson.build     7 Nov 2022 12:32:09 -0000
@@ -0,0 +1,68 @@
+# Copyright © 2020 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+host = host_machine.system()
+_pci_access_host_files = []
+if host == 'linux'
+  _pci_access_host_files += ['linux_sysfs.c', 'linux_devmem.c', 
'common_vgaarb.c']
+elif host == 'freebsd'
+  _pci_access_host_files += ['freebsd_pci.c', 'common_vgaarb_stub.c']
+elif host == 'netbsd'
+  _pci_access_host_files += ['netbsd_pci.c', 'common_vgaarb_stub.c']
+elif host == 'openbsd'
+  _pci_access_host_files += ['openbsd_pci.c']  # VGA arbiter code is in 
netbsd_pci.c
+elif host == 'cygwin'
+  _pci_access_host_files += ['x86_pci.c', 'common_vgaarb_stub.c']
+elif host == 'sunos'
+  _pci_access_host_files += ['solx_devfs.c', 'common_vgaarb_stub.c']
+elif host == 'gnu'
+  _pci_access_host_files += ['hurd_pci.c', 'x86_pci.c', 'common_vgaarb_stub.c']
+endif
+
+inc_src = include_directories('.')
+
+libpciaccess = shared_library(
+  'pciaccess',
+  [
+    'common_bridge.c',
+    'common_iterator.c',
+    'common_init.c',
+    'common_interface.c',
+    'common_io.c',
+    'common_capability.c',
+    'common_device_name.c',
+    'common_map.c',
+    _pci_access_host_files,
+    config_h,
+  ],
+  include_directories : inc_include,
+  dependencies : [dep_zlib, extra_libs],
+  version : '0.11.1',
+  install : true,
+)
+
+dep_pciaccess = declare_dependency(
+  link_with : libpciaccess,
+  include_directories : [include_directories('.'), inc_include]
+)
+
+if meson.version().version_compare('>= 0.54.0')
+  meson.override_dependency('pciaccess', dep_pciaccess)
+endif
Index: src/netbsd_pci.c
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/src/netbsd_pci.c,v
retrieving revision 1.7
diff -u -p -u -r1.7 netbsd_pci.c
--- src/netbsd_pci.c    21 May 2018 20:02:28 -0000      1.7
+++ src/netbsd_pci.c    7 Nov 2022 12:32:09 -0000
@@ -942,6 +942,7 @@ pci_system_netbsd_create(void)
                for (i = 0; i < nbuses; i++)
                        close(buses[i].fd);
                free(pci_sys);
+               pci_sys = NULL;
                return ENOMEM;
        }
 
Index: src/openbsd_pci.c
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/src/openbsd_pci.c,v
retrieving revision 1.28
diff -u -p -u -r1.28 openbsd_pci.c
--- src/openbsd_pci.c   3 Sep 2021 07:19:13 -0000       1.28
+++ src/openbsd_pci.c   7 Nov 2022 12:32:09 -0000
@@ -338,6 +338,8 @@ pci_system_openbsd_destroy(void)
        for (domain = 0; domain < ndomains; domain++)
                close(pcifd[domain]);
        ndomains = 0;
+       free(pci_sys);
+       pci_sys = NULL;
 }
 
 static int
@@ -598,29 +600,31 @@ pci_device_openbsd_unmap_legacy(struct p
 }
 
 static const struct pci_system_methods openbsd_pci_methods = {
-       pci_system_openbsd_destroy,
-       NULL,
-       pci_device_openbsd_read_rom,
-       pci_device_openbsd_probe,
-       pci_device_openbsd_map_range,
-       pci_device_openbsd_unmap_range,
-       pci_device_openbsd_read,
-       pci_device_openbsd_write,
-       pci_fill_capabilities_generic,
-       NULL,
-       pci_device_openbsd_boot_vga,
-       NULL,
-       NULL,
-       pci_device_openbsd_open_legacy_io,
-       NULL,
-       pci_device_openbsd_read32,
-       pci_device_openbsd_read16,
-       pci_device_openbsd_read8,
-       pci_device_openbsd_write32,
-       pci_device_openbsd_write16,
-       pci_device_openbsd_write8,
-       pci_device_openbsd_map_legacy,
-       pci_device_openbsd_unmap_legacy
+       .destroy = pci_system_openbsd_destroy,
+       .destroy_device = NULL,
+       .read_rom = pci_device_openbsd_read_rom,
+       .probe = pci_device_openbsd_probe,
+       .map_range = pci_device_openbsd_map_range,
+       .unmap_range = pci_device_openbsd_unmap_range,
+
+       .read = pci_device_openbsd_read,
+       .write = pci_device_openbsd_write,
+
+       .fill_capabilities = pci_fill_capabilities_generic,
+
+       .boot_vga = pci_device_openbsd_boot_vga,
+
+       .open_legacy_io = pci_device_openbsd_open_legacy_io,
+
+       .read32 = pci_device_openbsd_read32,
+       .read16 = pci_device_openbsd_read16,
+       .read8 = pci_device_openbsd_read8,
+       .write32 = pci_device_openbsd_write32,
+       .write16 = pci_device_openbsd_write16,
+       .write8 = pci_device_openbsd_write8,
+
+       .map_legacy = pci_device_openbsd_map_legacy,
+       .unmap_legacy = pci_device_openbsd_unmap_legacy
 };
 
 int
Index: src/pci_tools.h
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/src/pci_tools.h,v
retrieving revision 1.4
diff -u -p -u -r1.4 pci_tools.h
--- src/pci_tools.h     6 Nov 2011 21:35:46 -0000       1.4
+++ src/pci_tools.h     7 Nov 2022 12:32:09 -0000
@@ -165,7 +165,7 @@ typedef struct pcitool_intr_get {
 #define        PCITOOL_IGET_SIZE(num_devs) \
        (sizeof (pcitool_intr_get_t) - \
        sizeof (pcitool_intr_dev_t) + \
-       (num_devs * sizeof (pcitool_intr_dev_t)))
+       ((num_devs) * sizeof (pcitool_intr_dev_t)))
 
 /*
  * Size and endian fields for acc_attr bitmask.
@@ -175,12 +175,12 @@ typedef struct pcitool_intr_get {
 #define        PCITOOL_ACC_ATTR_SIZE_2         0x1
 #define        PCITOOL_ACC_ATTR_SIZE_4         0x2
 #define        PCITOOL_ACC_ATTR_SIZE_8         0x3
-#define        PCITOOL_ACC_ATTR_SIZE(x)        (1 << (x & 
PCITOOL_ACC_ATTR_SIZE_MASK))
+#define        PCITOOL_ACC_ATTR_SIZE(x)        (1 << ((x) & 
PCITOOL_ACC_ATTR_SIZE_MASK))
 
 #define        PCITOOL_ACC_ATTR_ENDN_MASK      0x100
 #define        PCITOOL_ACC_ATTR_ENDN_LTL       0x0
 #define        PCITOOL_ACC_ATTR_ENDN_BIG       0x100
-#define        PCITOOL_ACC_IS_BIG_ENDIAN(x)    (x & PCITOOL_ACC_ATTR_ENDN_BIG)
+#define        PCITOOL_ACC_IS_BIG_ENDIAN(x)    ((x) & 
PCITOOL_ACC_ATTR_ENDN_BIG)
 
 /*
  * Data structure to read and write to pci device registers.
Index: src/pciaccess_private.h
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/src/pciaccess_private.h,v
retrieving revision 1.9
diff -u -p -u -r1.9 pciaccess_private.h
--- src/pciaccess_private.h     30 Aug 2021 12:13:33 -0000      1.9
+++ src/pciaccess_private.h     7 Nov 2022 12:32:09 -0000
@@ -76,6 +76,7 @@ struct pci_system_methods {
 
     int (*fill_capabilities)( struct pci_device * dev );
     void (*enable)( struct pci_device *dev );
+    void (*disable)( struct pci_device *dev );
     int (*boot_vga)( struct pci_device *dev );
     int (*has_kernel_driver)( struct pci_device *dev );
     struct pci_io_handle *(*open_device_io)( struct pci_io_handle *handle,
Index: src/x86_pci.c
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/src/x86_pci.c,v
retrieving revision 1.6
diff -u -p -u -r1.6 x86_pci.c
--- src/x86_pci.c       30 Aug 2021 12:13:33 -0000      1.6
+++ src/x86_pci.c       7 Nov 2022 12:32:09 -0000
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2018 Damien Zammit
  * Copyright (c) 2017 Joan Lledó
- * Copyright (c) 2009, 2012 Samuel Thibault
+ * Copyright (c) 2009, 2012, 2020 Samuel Thibault
  * Heavily inspired from the freebsd, netbsd, and openbsd backends
  * (C) Copyright Eric Anholt 2006
  * (C) Copyright IBM Corporation 2006
@@ -211,6 +211,108 @@ outl(uint32_t value, uint16_t port)
 
 #endif
 
+static int cmp_devices(const void *dev1, const void *dev2)
+{
+    const struct pci_device *d1 = dev1;
+    const struct pci_device *d2 = dev2;
+
+    if (d1->bus != d2->bus) {
+        return (d1->bus > d2->bus) ? 1 : -1;
+    }
+
+    if (d1->dev != d2->dev) {
+        return (d1->dev > d2->dev) ? 1 : -1;
+    }
+
+    return (d1->func > d2->func) ? 1 : -1;
+}
+
+static void
+sort_devices(void)
+{
+    qsort(pci_sys->devices, pci_sys->num_devices,
+          sizeof (pci_sys->devices[0]), &cmp_devices);
+}
+
+#if defined(__GNU__)
+#include <mach.h>
+#include <hurd.h>
+#include <device/device.h>
+#endif
+
+int
+pci_system_x86_map_dev_mem(void **dest, size_t mem_offset, size_t mem_size, 
int write)
+{
+#if defined(__GNU__)
+    int err;
+    mach_port_t master_device;
+    mach_port_t devmem;
+    mach_port_t pager;
+    dev_mode_t mode = D_READ;
+    vm_prot_t prot = VM_PROT_READ;
+    int pagesize;
+
+    if (get_privileged_ports (NULL, &master_device)) {
+        *dest = 0;
+        return EPERM;
+    }
+
+    if (write) {
+        mode |= D_WRITE;
+        prot |= VM_PROT_WRITE;
+    }
+
+    err = device_open (master_device, mode, "mem", &devmem);
+    mach_port_deallocate (mach_task_self (), master_device);
+    if (err)
+        return err;
+
+    pagesize = getpagesize();
+    if (mem_size % pagesize)
+        mem_size += pagesize - (mem_size % pagesize);
+
+    err = device_map (devmem, prot, mem_offset, mem_size, &pager, 0);
+    device_close (devmem);
+    mach_port_deallocate (mach_task_self (), devmem);
+    if (err)
+        return err;
+
+    err = vm_map (mach_task_self (), (vm_address_t *)dest, mem_size,
+                  (vm_address_t) 0, /* mask */
+                  1, /* anywhere? */
+                  pager, 0,
+                  0, /* copy */
+                  prot, VM_PROT_ALL, VM_INHERIT_SHARE);
+    mach_port_deallocate (mach_task_self (), pager);
+    if (err)
+        return err;
+
+    return err;
+#else
+    int prot = PROT_READ;
+    int flags = O_RDONLY;
+    int memfd;
+
+    if (write) {
+        prot |= PROT_WRITE;
+       flags = O_RDWR;
+    }
+    memfd = open("/dev/mem", flags | O_CLOEXEC);
+    if (memfd == -1)
+       return errno;
+
+    *dest = mmap(NULL, mem_size, prot, MAP_SHARED, memfd, mem_offset);
+    if (*dest == MAP_FAILED) {
+       close(memfd);
+       *dest = NULL;
+       return errno;
+    }
+
+    close(memfd);
+    return 0;
+#endif
+}
+
 static int
 pci_system_x86_conf1_probe(void)
 {
@@ -437,25 +539,15 @@ pci_nfuncs(struct pci_device *dev, uint8
 static error_t
 pci_device_x86_read_rom(struct pci_device *dev, void *buffer)
 {
-    void *bios;
-    int memfd;
+    void *bios = NULL;
     struct pci_device_private *d = (struct pci_device_private *)dev;
 
-    memfd = open("/dev/mem", O_RDONLY | O_CLOEXEC);
-    if (memfd == -1)
-       return errno;
-
-    bios = mmap(NULL, dev->rom_size, PROT_READ, MAP_SHARED, memfd, 
d->rom_base);
-    if (bios == MAP_FAILED) {
-       close(memfd);
-       return errno;
-    }
+    int err;
+    if ( (err = pci_system_x86_map_dev_mem(&bios, d->rom_base, dev->rom_size, 
0)) )
+        return err;
 
     memcpy(buffer, bios, dev->rom_size);
-
     munmap(bios, dev->rom_size);
-    close(memfd);
-
     return 0;
 }
 
@@ -515,7 +607,6 @@ pci_device_x86_region_probe (struct pci_
     error_t err;
     uint8_t offset;
     uint32_t reg, addr, testval;
-    int memfd;
 
     offset = PCI_BAR_ADDR_0 + 0x4 * reg_num;
 
@@ -573,9 +664,6 @@ pci_device_x86_region_probe (struct pci_
             if (err)
                 return err;
         }
-
-        /* Clear the map pointer */
-        dev->regions[reg_num].memory = 0;
     }
     else if (dev->regions[reg_num].size > 0)
     {
@@ -592,23 +680,11 @@ pci_device_x86_region_probe (struct pci_
             if (err)
                 return err;
         }
-
-        /* Map the region in our space */
-        memfd = open ("/dev/mem", O_RDWR | O_CLOEXEC);
-        if (memfd == -1)
-            return errno;
-
-        dev->regions[reg_num].memory =
-         mmap (NULL, dev->regions[reg_num].size, PROT_READ | PROT_WRITE, 
MAP_SHARED,
-               memfd, dev->regions[reg_num].base_addr);
-        if (dev->regions[reg_num].memory == MAP_FAILED)
-        {
-            dev->regions[reg_num].memory = 0;
-            close (memfd);
-            return errno;
-        }
     }
 
+    /* Clear the map pointer */
+    dev->regions[reg_num].memory = 0;
+
     return 0;
 }
 
@@ -772,10 +848,6 @@ pci_system_x86_scan_bus (uint8_t bus)
 
             d->base.device_class = reg >> 8;
 
-            err = pci_device_x86_probe (&d->base);
-            if (err)
-                return err;
-
             pci_sys->devices = devices;
             pci_sys->num_devices++;
 
@@ -841,32 +913,27 @@ pci_device_x86_unmap_range(struct pci_de
 
 #else
 
-int
+static int
 pci_device_x86_map_range(struct pci_device *dev,
     struct pci_device_mapping *map)
 {
-    int memfd = open("/dev/mem", O_RDWR | O_CLOEXEC);
-    int prot = PROT_READ;
-
-    if (memfd == -1)
-       return errno;
-
-    if (map->flags & PCI_DEV_MAP_FLAG_WRITABLE)
-       prot |= PROT_WRITE;
+    int err;
+    if ( (err = pci_system_x86_map_dev_mem(&map->memory, map->base, map->size,
+                            map->flags & PCI_DEV_MAP_FLAG_WRITABLE)))
+        return err;
 
-    map->memory = mmap(NULL, map->size, prot, MAP_SHARED, memfd, map->base);
-    if (map->memory == MAP_FAILED) {
-       close(memfd);
-       return errno;
-    }
     return 0;
 }
 
-int
+static int
 pci_device_x86_unmap_range(struct pci_device *dev,
     struct pci_device_mapping *map)
 {
-    return pci_device_generic_unmap_range(dev, map);
+    int err;
+    err = pci_device_generic_unmap_range(dev, map);
+    map->memory = NULL;
+
+    return err;
 }
 
 #endif
@@ -1037,7 +1104,7 @@ pci_device_x86_write8(struct pci_io_hand
     outb(data, reg + handle->base);
 }
 
-int
+static int
 pci_device_x86_map_legacy(struct pci_device *dev, pciaddr_t base,
     pciaddr_t size, unsigned map_flags, void **addr)
 {
@@ -1053,7 +1120,7 @@ pci_device_x86_map_legacy(struct pci_dev
     return err;
 }
 
-int
+static int
 pci_device_x86_unmap_legacy(struct pci_device *dev, void *addr,
     pciaddr_t size)
 {
@@ -1162,10 +1229,15 @@ pci_system_x86_create(void)
     if (err)
     {
         x86_disable_io ();
+        if (pci_sys->num_devices)
+        {
+            free (pci_sys->devices);
+        }
         free (pci_sys);
         pci_sys = NULL;
         return err;
     }
 
+    sort_devices ();
     return 0;
 }
Index: src/x86_pci.h
===================================================================
RCS file: /cvs/OpenBSD/xenocara/lib/libpciaccess/src/x86_pci.h,v
retrieving revision 1.1
diff -u -p -u -r1.1 x86_pci.h
--- src/x86_pci.h       30 Aug 2021 12:13:33 -0000      1.1
+++ src/x86_pci.h       7 Nov 2022 12:32:09 -0000
@@ -63,10 +63,6 @@
 int x86_enable_io(void);
 int x86_disable_io(void);
 void pci_system_x86_destroy(void);
-int pci_device_x86_map_range(struct pci_device *dev,
-    struct pci_device_mapping *map);
-int pci_device_x86_unmap_range(struct pci_device *dev,
-    struct pci_device_mapping *map);
 struct pci_io_handle *pci_device_x86_open_legacy_io(struct pci_io_handle *ret,
     struct pci_device *dev, pciaddr_t base, pciaddr_t size);
 void pci_device_x86_close_io(struct pci_device *dev,
@@ -80,9 +76,7 @@ void pci_device_x86_write16(struct pci_i
                       uint16_t data);
 void pci_device_x86_write8(struct pci_io_handle *handle, uint32_t reg,
                       uint8_t data);
-int pci_device_x86_map_legacy(struct pci_device *dev, pciaddr_t base,
-    pciaddr_t size, unsigned map_flags, void **addr);
-int pci_device_x86_unmap_legacy(struct pci_device *dev, void *addr,
-    pciaddr_t size);
+int pci_system_x86_map_dev_mem(void **dest, size_t mem_offset, size_t mem_size,
+    int write);
 
 #endif /* X86_PCI_H */

-- 
Matthieu Herrb


Reply via email to