pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

MesaLib-dfbsd: Update wip/MesaLib-dfbsd to 18.0.2



Module Name:	pkgsrc-wip
Committed By:	David Shao <davshao%gmail.com@localhost>
Pushed By:	dshao
Date:		Mon Apr 30 20:24:03 2018 -0700
Changeset:	90e22cdeaa4fa83ef6c1bf6317ee542d665a163b

Modified Files:
	MesaLib-dfbsd/Makefile
	MesaLib-dfbsd/PLIST
	MesaLib-dfbsd/TODO
	MesaLib-dfbsd/buildlink3.mk
	MesaLib-dfbsd/builtin.mk
	MesaLib-dfbsd/distinfo
	MesaLib-dfbsd/dri.mk
	MesaLib-dfbsd/options.mk
	MesaLib-dfbsd/patches/patch-src_compiler_glsl_glsl__parser__extras.cpp
	MesaLib-dfbsd/patches/patch-src_egl_drivers_dri2_platform__drm.c
	MesaLib-dfbsd/patches/patch-src_egl_drivers_dri2_platform__x11.c
	MesaLib-dfbsd/patches/patch-src_egl_main_eglglobals.c
	MesaLib-dfbsd/patches/patch-src_gallium_auxiliary_pipe-loader_pipe__loader__drm.c
	MesaLib-dfbsd/patches/patch-src_gallium_auxiliary_util_u__network.c
	MesaLib-dfbsd/patches/patch-src_gallium_auxiliary_util_u__network.h
	MesaLib-dfbsd/patches/patch-src_gallium_state__trackers_clover_llvm_invocation.cpp
	MesaLib-dfbsd/patches/patch-src_gallium_state__trackers_clover_llvm_metadata.hpp
	MesaLib-dfbsd/patches/patch-src_gallium_targets_dri_Makefile.in
	MesaLib-dfbsd/patches/patch-src_gallium_winsys_radeon_drm_radeon__drm__winsys.c
	MesaLib-dfbsd/patches/patch-src_glx_apple_apple__glapi.c
	MesaLib-dfbsd/patches/patch-src_glx_glxcurrent.c
	MesaLib-dfbsd/patches/patch-src_glx_glxext.c
	MesaLib-dfbsd/patches/patch-src_intel_tools_aubinator.c
	MesaLib-dfbsd/patches/patch-src_mapi_entry__x86-64__tls.h
	MesaLib-dfbsd/patches/patch-src_mapi_entry__x86__tls.h
	MesaLib-dfbsd/patches/patch-src_mapi_u__current.c
	MesaLib-dfbsd/patches/patch-src_mapi_u__current.h
	MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_i915_intel__screen.c
	MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_i965_intel__screen.c
	MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_i965_intel__tiled__memcpy.c
	MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_swrast_swrast.c
	MesaLib-dfbsd/patches/patch-src_mesa_main_context.c
	MesaLib-dfbsd/patches/patch-src_mesa_main_extensions.c
	MesaLib-dfbsd/patches/patch-src_mesa_main_macros.h
	MesaLib-dfbsd/patches/patch-src_mesa_tnl_t__pipeline.c
	MesaLib-dfbsd/patches/patch-src_util_build__id.c
Added Files:
	MesaLib-dfbsd/patches/patch-configure
	MesaLib-dfbsd/patches/patch-configure.ac
	MesaLib-dfbsd/patches/patch-include_GL_internal_dri__interface.h
	MesaLib-dfbsd/patches/patch-src_amd_vulkan_winsys_amdgpu_radv__amdgpu__cs.c
	MesaLib-dfbsd/patches/patch-src_gallium_drivers_trace_tr__dump.c
	MesaLib-dfbsd/patches/patch-src_gallium_include_pipe_p__config.h
	MesaLib-dfbsd/patches/patch-src_gallium_state__trackers_clover_util_range.hpp
	MesaLib-dfbsd/patches/patch-src_gbm_Makefile.am
	MesaLib-dfbsd/patches/patch-src_gbm_Makefile.in
	MesaLib-dfbsd/patches/patch-src_glx_dri__glx.c
	MesaLib-dfbsd/patches/patch-src_intel_Makefile.in
	MesaLib-dfbsd/patches/patch-src_intel_compiler_brw__fs__bank__conflicts.cpp
	MesaLib-dfbsd/patches/patch-src_intel_vulkan_anv__allocator.c
	MesaLib-dfbsd/patches/patch-src_intel_vulkan_anv__device.c
	MesaLib-dfbsd/patches/patch-src_intel_vulkan_anv__gem.c
	MesaLib-dfbsd/patches/patch-src_intel_vulkan_anv__queue.c
	MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_i965_brw__performance__query.c
	MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_i965_intel__screen.h
	MesaLib-dfbsd/patches/patch-src_util_futex.h
	MesaLib-dfbsd/patches/patch-src_util_os__time.c
	MesaLib-dfbsd/patches/patch-src_util_u__queue.c
	MesaLib-dfbsd/patches/patch-src_util_xmlconfig.c
Removed Files:
	MesaLib-dfbsd/patches/patch-include_c11_threads__posix.h
	MesaLib-dfbsd/patches/patch-src_gallium_winsys_svga_drm_vmw__screen__ioctl.c
	MesaLib-dfbsd/patches/patch-src_mapi_entry.c
	MesaLib-dfbsd/patches/patch-src_mapi_glapi_glapi__gentable.c
	MesaLib-dfbsd/patches/patch-src_mapi_table.h
	MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_Makefile.in
	MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_common_Makefile.in
	MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_common_xmlconfig.c
	MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_i965_brw__sync.c
	MesaLib-dfbsd/patches/patch-src_mesa_x86_assyntax.h
	MesaLib-dfbsd/patches/patch-src_util_u__endian.h

Log Message:
MesaLib-dfbsd: Update wip/MesaLib-dfbsd to 18.0.2

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=90e22cdeaa4fa83ef6c1bf6317ee542d665a163b

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 MesaLib-dfbsd/Makefile                             |   33 +-
 MesaLib-dfbsd/PLIST                                |   59 +-
 MesaLib-dfbsd/TODO                                 |   16 +-
 MesaLib-dfbsd/buildlink3.mk                        |    8 +-
 MesaLib-dfbsd/builtin.mk                           |    6 +-
 MesaLib-dfbsd/distinfo                             |   99 +-
 MesaLib-dfbsd/dri.mk                               |   41 +-
 MesaLib-dfbsd/options.mk                           |  209 ++-
 MesaLib-dfbsd/patches/patch-configure              |   93 ++
 MesaLib-dfbsd/patches/patch-configure.ac           |   71 +
 .../patch-include_GL_internal_dri__interface.h     |   27 +
 .../patches/patch-include_c11_threads__posix.h     |   16 -
 ...src_amd_vulkan_winsys_amdgpu_radv__amdgpu__cs.c |   19 +
 ...atch-src_compiler_glsl_glsl__parser__extras.cpp |    9 +-
 .../patch-src_egl_drivers_dri2_platform__drm.c     |   12 +-
 .../patch-src_egl_drivers_dri2_platform__x11.c     |   34 +-
 .../patches/patch-src_egl_main_eglglobals.c        |   39 +-
 ...llium_auxiliary_pipe-loader_pipe__loader__drm.c |   18 +-
 .../patch-src_gallium_auxiliary_util_u__network.c  |   10 +-
 .../patch-src_gallium_auxiliary_util_u__network.h  |    2 +-
 .../patch-src_gallium_drivers_trace_tr__dump.c     |   50 +
 .../patch-src_gallium_include_pipe_p__config.h     |   31 +
 ...lium_state__trackers_clover_llvm_invocation.cpp |    4 +-
 ...allium_state__trackers_clover_llvm_metadata.hpp |    2 +-
 ...c_gallium_state__trackers_clover_util_range.hpp |   40 +
 .../patch-src_gallium_targets_dri_Makefile.in      |   10 +-
 ...gallium_winsys_radeon_drm_radeon__drm__winsys.c |    8 +-
 ...rc_gallium_winsys_svga_drm_vmw__screen__ioctl.c |   32 -
 MesaLib-dfbsd/patches/patch-src_gbm_Makefile.am    |   12 +
 MesaLib-dfbsd/patches/patch-src_gbm_Makefile.in    |   13 +
 .../patches/patch-src_glx_apple_apple__glapi.c     |    6 +-
 MesaLib-dfbsd/patches/patch-src_glx_dri__glx.c     |   43 +
 MesaLib-dfbsd/patches/patch-src_glx_glxcurrent.c   |    4 +-
 MesaLib-dfbsd/patches/patch-src_glx_glxext.c       |   41 +-
 MesaLib-dfbsd/patches/patch-src_intel_Makefile.in  |   22 +
 ...src_intel_compiler_brw__fs__bank__conflicts.cpp |   23 +
 .../patches/patch-src_intel_tools_aubinator.c      |    6 +-
 .../patch-src_intel_vulkan_anv__allocator.c        |   62 +
 .../patches/patch-src_intel_vulkan_anv__device.c   |   46 +
 .../patches/patch-src_intel_vulkan_anv__gem.c      |   19 +
 .../patches/patch-src_intel_vulkan_anv__queue.c    |   25 +
 MesaLib-dfbsd/patches/patch-src_mapi_entry.c       | 1620 --------------------
 .../patches/patch-src_mapi_entry__x86-64__tls.h    |   10 +-
 .../patches/patch-src_mapi_entry__x86__tls.h       |   12 +-
 .../patches/patch-src_mapi_glapi_glapi__gentable.c |   15 -
 MesaLib-dfbsd/patches/patch-src_mapi_table.h       |   15 -
 MesaLib-dfbsd/patches/patch-src_mapi_u__current.c  |   10 +-
 MesaLib-dfbsd/patches/patch-src_mapi_u__current.h  |    2 +-
 .../patches/patch-src_mesa_drivers_dri_Makefile.in |   15 -
 .../patch-src_mesa_drivers_dri_common_Makefile.in  |   16 -
 .../patch-src_mesa_drivers_dri_common_xmlconfig.c  |   59 -
 ...patch-src_mesa_drivers_dri_i915_intel__screen.c |   10 +-
 ...mesa_drivers_dri_i965_brw__performance__query.c |   16 +
 .../patch-src_mesa_drivers_dri_i965_brw__sync.c    |   17 -
 ...patch-src_mesa_drivers_dri_i965_intel__screen.c |   10 +-
 ...patch-src_mesa_drivers_dri_i965_intel__screen.h |   15 +
 ...rc_mesa_drivers_dri_i965_intel__tiled__memcpy.c |    2 +
 .../patch-src_mesa_drivers_dri_swrast_swrast.c     |    4 +-
 .../patches/patch-src_mesa_main_context.c          |   40 +-
 .../patches/patch-src_mesa_main_extensions.c       |   33 +-
 MesaLib-dfbsd/patches/patch-src_mesa_main_macros.h |   22 +-
 .../patches/patch-src_mesa_tnl_t__pipeline.c       |   10 +-
 .../patches/patch-src_mesa_x86_assyntax.h          |   15 -
 MesaLib-dfbsd/patches/patch-src_util_build__id.c   |    6 +-
 MesaLib-dfbsd/patches/patch-src_util_futex.h       |   53 +
 MesaLib-dfbsd/patches/patch-src_util_os__time.c    |   27 +
 MesaLib-dfbsd/patches/patch-src_util_u__endian.h   |   15 -
 MesaLib-dfbsd/patches/patch-src_util_u__queue.c    |   44 +
 MesaLib-dfbsd/patches/patch-src_util_xmlconfig.c   |   34 +
 69 files changed, 1286 insertions(+), 2181 deletions(-)

diffs:
diff --git a/MesaLib-dfbsd/Makefile b/MesaLib-dfbsd/Makefile
index 7485b34833..df435fba1f 100644
--- a/MesaLib-dfbsd/Makefile
+++ b/MesaLib-dfbsd/Makefile
@@ -1,10 +1,13 @@
-# $NetBSD: Makefile,v 1.137 2017/03/22 20:22:31 markd Exp $
+# $NetBSD: Makefile,v 1.140 2018/01/25 10:44:51 jperkin Exp $
 
-DISTNAME=	mesa-17.1.6
+DISTNAME=	mesa-18.0.2
 PKGNAME=	${DISTNAME:S/mesa/MesaLib/}
+# DISTNAME=	mesa-18.0.0-rc5
+# PKGNAME=	MesaLib-18.0.0
+# PKGREVISION=	1
 CATEGORIES=	graphics x11
-# MASTER_SITES=	ftp://ftp.freedesktop.org/pub/mesa/${PKGVERSION_NOREV}/
 MASTER_SITES=	ftp://ftp.freedesktop.org/pub/mesa/
+# MASTER_SITES=	ftp://ftp.freedesktop.org/pub/mesa/${PKGVERSION_NOREV}/
 EXTRACT_SUFX=	.tar.xz
 
 MAINTAINER=	pkgsrc-users%NetBSD.org@localhost
@@ -52,16 +55,23 @@ SUBST_SED.wrapper-bug+=		-e 's,libglapi.la,libglapi_impl.la,g'
 SUBST_SED.wrapper-bug+=		-e 's,libglapi_tmp_rename.la,libglapi.la,g'
 
 # Replace /etc/drirc with ${PREFIX}/etc/drirc
-SUBST_CLASSES+=		drirc
-SUBST_STAGE.drirc=	pre-configure
-SUBST_MESSAGE.drirc=	Fixing hardcoded /etc/drirc references
-SUBST_FILES.drirc+=	src/mesa/drivers/dri/common/xmlconfig.c
-SUBST_SED.drirc+=	-e 's|/etc|${PREFIX}/etc|g'
+SUBST_CLASSES+=			drirc
+SUBST_STAGE.drirc=		pre-configure
+SUBST_MESSAGE.drirc=		Fixing hardcoded /etc/drirc references
+SUBST_FILES.drirc+=		src/util/xmlconfig.c
+SUBST_SED.drirc+=		 -e 's|/etc|${PREFIX}/etc|g'
+
+# Required due to clang defaulting to strict C standard by default (no strdup).
+CFLAGS.SunOS+=	-D__EXTENSIONS__
 
 .include "../../mk/bsd.prefs.mk"
 .include "../../mk/compiler.mk"
 .include "options.mk"
 
+.if ${MACHINE_ARCH} == "i386"
+CONFIGURE_ARGS+=	--enable-glx-read-only-text
+.endif
+
 .if !empty(PKGSRC_COMPILER:Mclang)
 SUBST_CLASSES+=		tr1
 SUBST_STAGE.tr1=	pre-configure
@@ -83,7 +93,7 @@ CONFIGURE_ENV+=		ac_cv_prog_PYTHON2=${PYTHONBIN}
 # which breaks the build with -Wl,--no-undefined.
 # So we piggy back on -lpthread and inject -lc after it.
 .if !empty(MACHINE_PLATFORM:MNetBSD-[1-5].*-*)
-BUILDLINK_TRANSFORM+=	l:pthread:pthread:c l:m:m:c
+BUILDLINK_TRANSFORM+=   l:pthread:pthread:c l:m:m:c
 .endif
 
 # Handle platforms without exp2
@@ -104,9 +114,10 @@ ${WRKDIR}/.manual_patch_done:
 INSTALLATION_DIRS+=	share/examples/MesaLib
 
 post-install:
-	${INSTALL_DATA} ${WRKSRC}/src/mesa/drivers/dri/common/drirc ${DESTDIR}${PREFIX}/share/examples/MesaLib
+	${INSTALL_DATA} ${WRKSRC}/src/util/drirc ${DESTDIR}${PREFIX}/share/examples/MesaLib
 
-.include "../../wip/libpthread-stubs/buildlink3.mk"
+# devel/libpthread-stubs needs to be promoted from wip to pkgsrc
+.include "../../devel/libpthread-stubs/buildlink3.mk"
 .include "../../x11/libX11/buildlink3.mk"
 .include "../../x11/libXext/buildlink3.mk"
 .include "../../x11/libxcb/buildlink3.mk"
diff --git a/MesaLib-dfbsd/PLIST b/MesaLib-dfbsd/PLIST
index 2751c7d8f5..19c7edfec7 100644
--- a/MesaLib-dfbsd/PLIST
+++ b/MesaLib-dfbsd/PLIST
@@ -1,4 +1,5 @@
-@comment $NetBSD: PLIST,v 1.33 2016/02/23 14:40:36 tnn Exp $
+@comment $NetBSD: PLIST,v 1.36 2018/01/01 22:29:36 rillig Exp $
+etc/drirc
 ${PLIST.dri}include/EGL/egl.h
 ${PLIST.dri}include/EGL/eglext.h
 ${PLIST.dri}include/EGL/eglextchromium.h
@@ -13,26 +14,28 @@ include/GL/glx_mangle.h
 include/GL/glxext.h
 ${PLIST.osmesa}include/GL/osmesa.h
 ${PLIST.dri}include/GL/internal/dri_interface.h
-${PLIST.dri}include/GLES/egl.h
-${PLIST.dri}include/GLES/gl.h
-${PLIST.dri}include/GLES/glext.h
-${PLIST.dri}include/GLES/glplatform.h
-${PLIST.dri}include/GLES2/gl2.h
-${PLIST.dri}include/GLES2/gl2ext.h
-${PLIST.dri}include/GLES2/gl2platform.h
-${PLIST.dri}include/GLES3/gl3.h
-${PLIST.dri}include/GLES3/gl31.h
-${PLIST.dri}include/GLES3/gl32.h
-${PLIST.dri}include/GLES3/gl3ext.h
-${PLIST.dri}include/GLES3/gl3platform.h
+${PLIST.glesv1}include/GLES/egl.h
+${PLIST.glesv1}include/GLES/gl.h
+${PLIST.glesv1}include/GLES/glext.h
+${PLIST.glesv1}include/GLES/glplatform.h
+${PLIST.glesv2}include/GLES2/gl2.h
+${PLIST.glesv2}include/GLES2/gl2ext.h
+${PLIST.glesv2}include/GLES2/gl2platform.h
+${PLIST.glesv2}include/GLES3/gl3.h
+${PLIST.glesv2}include/GLES3/gl31.h
+${PLIST.glesv2}include/GLES3/gl32.h
+${PLIST.glesv2}include/GLES3/gl3ext.h
+${PLIST.glesv2}include/GLES3/gl3platform.h
 ${PLIST.dri}include/KHR/khrplatform.h
 ${PLIST.gbm}include/gbm.h
 ${PLIST.xatracker}include/xa_composite.h
 ${PLIST.xatracker}include/xa_context.h
 ${PLIST.xatracker}include/xa_tracker.h
+@comment ${PLIST.vaapi}lib/dri/gallium_drv_video.la
+@comment ${PLIST.vaapi}lib/dri/gallium_drv_video.so
 ${PLIST.i915_dri}lib/dri/i915_dri.so
 ${PLIST.i965_dri}lib/dri/i965_dri.so
-${PLIST.ilo}lib/dri/ilo_dri.so
+@comment ${PLIST.ilo}lib/dri/ilo_dri.so
 ${PLIST.freedreno}lib/dri/kgsl_dri.so
 ${PLIST.swrast}lib/dri/kms_swrast_dri.so
 ${PLIST.freedreno}lib/dri/msm_dri.so
@@ -48,9 +51,17 @@ ${PLIST.vc4}lib/dri/vc4_dri.so
 ${PLIST.svga}lib/dri/vmwgfx_dri.so
 ${PLIST.dri}lib/libEGL.la
 lib/libGL.la
-${PLIST.dri}lib/libGLESv1_CM.la
-${PLIST.dri}lib/libGLESv2.la
+${PLIST.glesv1}lib/libGLESv1_CM.la
+${PLIST.glesv2}lib/libGLESv2.la
 ${PLIST.osmesa}lib/libOSMesa.la
+${PLIST.xvmc}${PLIST.nouveau}lib/libXvMCnouveau.so
+${PLIST.xvmc}${PLIST.nouveau}lib/libXvMCnouveau.so.1
+${PLIST.xvmc}${PLIST.nouveau}lib/libXvMCnouveau.so.1.0
+${PLIST.xvmc}${PLIST.nouveau}lib/libXvMCnouveau.so.1.0.0
+${PLIST.xvmc}${PLIST.r600}lib/libXvMCr600.so
+${PLIST.xvmc}${PLIST.r600}lib/libXvMCr600.so.1
+${PLIST.xvmc}${PLIST.r600}lib/libXvMCr600.so.1.0
+${PLIST.xvmc}${PLIST.r600}lib/libXvMCr600.so.1.0.0
 ${PLIST.gbm}lib/libgbm.la
 lib/libglapi.la
 ${PLIST.wayland}lib/libwayland-egl.la
@@ -60,32 +71,30 @@ ${PLIST.dri}lib/pkgconfig/egl.pc
 ${PLIST.gbm}lib/pkgconfig/gbm.pc
 ${PLIST.osmesa}lib/pkgconfig/osmesa.pc
 lib/pkgconfig/gl.pc
-${PLIST.dri}lib/pkgconfig/glesv1_cm.pc
-${PLIST.dri}lib/pkgconfig/glesv2.pc
+${PLIST.glesv1}lib/pkgconfig/glesv1_cm.pc
+${PLIST.glesv2}lib/pkgconfig/glesv2.pc
 ${PLIST.wayland}lib/pkgconfig/wayland-egl.pc
 ${PLIST.xatracker}lib/pkgconfig/xatracker.pc
-share/examples/MesaLib/drirc
 ${PLIST.nouveau}${PLIST.vdpau}lib/vdpau/libvdpau_nouveau.so
 ${PLIST.nouveau}${PLIST.vdpau}lib/vdpau/libvdpau_nouveau.so.1
 ${PLIST.nouveau}${PLIST.vdpau}lib/vdpau/libvdpau_nouveau.so.1.0
-${FREEBSDVDPAU}${PLIST.nouveau}${PLIST.vdpau}lib/vdpau/libvdpau_nouveau.so.1.0.0
+${PLIST.nouveau}${PLIST.vdpau}lib/vdpau/libvdpau_nouveau.so.1.0.0
 ${PLIST.vdpau}lib/vdpau/libvdpau_r300.so
 ${PLIST.vdpau}lib/vdpau/libvdpau_r300.so.1
 ${PLIST.vdpau}lib/vdpau/libvdpau_r300.so.1.0
-${FREEBSDVDPAU}${PLIST.vdpau}lib/vdpau/libvdpau_r300.so.1.0.0
+${PLIST.vdpau}lib/vdpau/libvdpau_r300.so.1.0.0
 ${PLIST.vdpau}lib/vdpau/libvdpau_r600.so
 ${PLIST.vdpau}lib/vdpau/libvdpau_r600.so.1
 ${PLIST.vdpau}lib/vdpau/libvdpau_r600.so.1.0
-${FREEBSDVDPAU}${PLIST.vdpau}lib/vdpau/libvdpau_r600.so.1.0.0
+${PLIST.vdpau}lib/vdpau/libvdpau_r600.so.1.0.0
 ${PLIST.vdpau}lib/vdpau/libvdpau_radeonsi.so
 ${PLIST.vdpau}lib/vdpau/libvdpau_radeonsi.so.1
 ${PLIST.vdpau}lib/vdpau/libvdpau_radeonsi.so.1.0
-${FREEBSDVDPAU}${PLIST.vdpau}lib/vdpau/libvdpau_radeonsi.so.1.0.0
+${PLIST.vdpau}lib/vdpau/libvdpau_radeonsi.so.1.0.0
 @comment ${PLIST.vdpau}lib/dri/nouveau_drv_video.la
 ${PLIST.nouveau}${PLIST.vaapi}lib/dri/nouveau_drv_video.so
 @comment ${PLIST.vdpau}lib/dri/r600_drv_video.la
 ${PLIST.vaapi}lib/dri/r600_drv_video.so
 @comment ${PLIST.vdpau}lib/dri/radeonsi_drv_video.la
 ${PLIST.vaapi}lib/dri/radeonsi_drv_video.so
-@comment ${PLIST.vaapi}lib/dri/gallium_drv_video.la
-@comment ${PLIST.vaapi}lib/dri/gallium_drv_video.so
+share/examples/MesaLib/drirc
diff --git a/MesaLib-dfbsd/TODO b/MesaLib-dfbsd/TODO
index c390cbc088..d79276b359 100644
--- a/MesaLib-dfbsd/TODO
+++ b/MesaLib-dfbsd/TODO
@@ -1,8 +1,12 @@
 Copy port to graphics/MesaLib, do not install from wip.
 
-fix bitrot that broke GLX TLS on NetBSD, replace hack
-see if libLLVM 3.9 on FreeBSD can build nouveau
-test OSX quartz, check if bug 90311 patch needs regen
-test Solaris
-test Linux
-test NetBSD 7
+* Debug crash on NetBSD amd64 for radeonsi
+     when invoking gvim or xfce Terminal settings.
+* Debug forced webgl acceleration leaving blank screen
+     for radeonsi Firefox 52 esr on DragonFly.
+* See what can be done on NetBSD build for glesv1 and glesv2
+* See if libLLVM 3.9+ on FreeBSD can build nouveau
+* Test OSX quartz, check if bug 90311 patch needs regen
+* Test Solaris
+* Test Linux
+* Fully port Vulkan support from FreeBSD ports. 
diff --git a/MesaLib-dfbsd/buildlink3.mk b/MesaLib-dfbsd/buildlink3.mk
index c02f39cd36..c868b0fe11 100644
--- a/MesaLib-dfbsd/buildlink3.mk
+++ b/MesaLib-dfbsd/buildlink3.mk
@@ -1,4 +1,4 @@
-# $NetBSD: buildlink3.mk,v 1.54 2015/09/27 21:58:03 tnn Exp $
+# $NetBSD: buildlink3.mk,v 1.56 2018/04/02 15:44:47 bsiegert Exp $
 
 BUILDLINK_TREE+=	MesaLib
 
@@ -12,10 +12,10 @@ BUILDLINK_PKGSRCDIR.MesaLib?=	../../graphics/MesaLib
 .include "../../mk/bsd.fast.prefs.mk"
 
 .if ${X11_TYPE} == "modular"
-BUILDLINK_ABI_DEPENDS.MesaLib+=	MesaLib>=13
+BUILDLINK_ABI_DEPENDS.MesaLib+=	MesaLib>=10.5.3
 # This is needed to avoid linking conflicting libstdc++ versions
 .  if defined(USE_LANGUAGES) && !empty(USE_LANGUAGES:Mc++)
-GCC_REQD+=	4.2
+GCC_REQD+=			4.2
 .  endif
 .endif
 
@@ -42,11 +42,11 @@ MESALIB_SUPPORTS_EGL=	yes
 MESALIB_SUPPORTS_EGL=	no
 .endif
 
-.include "../../x11/libXext/buildlink3.mk"
 .if ${X11_TYPE} == "modular"
 .include "../../devel/libpthread-stubs/buildlink3.mk"
 .endif
 
+.include "../../x11/libXext/buildlink3.mk"
 .endif # MESALIB_BUILDLINK3_MK
 
 BUILDLINK_TREE+=	-MesaLib
diff --git a/MesaLib-dfbsd/builtin.mk b/MesaLib-dfbsd/builtin.mk
index 124987bc4d..1981219ebf 100644
--- a/MesaLib-dfbsd/builtin.mk
+++ b/MesaLib-dfbsd/builtin.mk
@@ -1,4 +1,4 @@
-# $NetBSD: builtin.mk,v 1.20 2014/03/22 08:19:24 jperkin Exp $
+# $NetBSD: builtin.mk,v 1.21 2018/01/14 14:58:38 rillig Exp $
 
 BUILTIN_PKG:=	MesaLib
 
@@ -22,7 +22,7 @@ IS_BUILTIN.MesaLib=	yes
 IS_BUILTIN.MesaLib=	no
 .  endif
 .endif
-MAKEVARS+=		IS_BUILTIN.MesaLib
+MAKEVARS+=	IS_BUILTIN.MesaLib
 
 ###
 ### If there is a built-in implementation, then set BUILTIN_PKG.<pkg> to
@@ -67,7 +67,7 @@ USE_BUILTIN.MesaLib!=							\
 .    endif
 .  endif  # PREFER.MesaLib
 .endif
-MAKEVARS+=		USE_BUILTIN.MesaLib
+MAKEVARS+=	USE_BUILTIN.MesaLib
 
 ###
 ### The section below only applies if we are not including this file
diff --git a/MesaLib-dfbsd/distinfo b/MesaLib-dfbsd/distinfo
index c80731ef16..0831712e05 100644
--- a/MesaLib-dfbsd/distinfo
+++ b/MesaLib-dfbsd/distinfo
@@ -1,57 +1,68 @@
-$NetBSD: distinfo,v 1.117 2016/05/18 12:55:28 wiz Exp $
+$NetBSD: distinfo,v 1.121 2018/01/16 15:49:47 jperkin Exp $
 
-SHA1 (mesa-17.1.6.tar.xz) = 2acc201e24ea67c5231074d6746a42a747228ed6
-RMD160 (mesa-17.1.6.tar.xz) = 43a9b758462316ad344ccdccf72d6d0ce295620e
-SHA512 (mesa-17.1.6.tar.xz) = cf57f29a21208f0a9bc84157f806bcaf6fd0583352449fcb986b05773eeefc99c4040dc41b242782dd5aa9ff7f9c5312b17a4db82d87f600acf165b6acdfc95a
-Size (mesa-17.1.6.tar.xz) = 9868932 bytes
-SHA1 (patch-include_c11_threads__posix.h) = 0f80c61a2fcfb2ce039fec6b50f126c3e84c33f9
-SHA1 (patch-src_compiler_glsl_glsl__parser__extras.cpp) = a08fc533940472bfa7634f0a2285e85d42c7a4e2
-SHA1 (patch-src_egl_drivers_dri2_platform__drm.c) = d57bc532cda89c49ce271bf55c5de97c48a9a5fe
-SHA1 (patch-src_egl_drivers_dri2_platform__x11.c) = 942cfdb72bcb52057dea0a02a8be5629920fd4fb
-SHA1 (patch-src_egl_main_eglglobals.c) = 07a7cc6df618c2e6d74406b794a565bd728a5dd8
-SHA1 (patch-src_gallium_auxiliary_pipe-loader_pipe__loader__drm.c) = fef19b60f00e6450ca48eebd6e3625e177fef689
+SHA1 (mesa-18.0.2.tar.xz) = 2c8a500c48fdf68949328506916405936d99ee97
+RMD160 (mesa-18.0.2.tar.xz) = 90aa556b4de98fb8036b41c1a6c85f515ff52539
+SHA512 (mesa-18.0.2.tar.xz) = 77d24d01c4c22596d28421aeb74932ff232730a4f556ae1a2e8777ece2876e4e352679575385c065505df4a2a83d2c1cf30db92dcf88038417e36a2768332d7e
+Size (mesa-18.0.2.tar.xz) = 10949364 bytes
+SHA1 (patch-configure) = 0b8df3d7ac613fd75d36306580d05fd3ba34f009
+SHA1 (patch-configure.ac) = cab84b2d9149327c3534fe09964d7b299767ca9a
+SHA1 (patch-include_GL_internal_dri__interface.h) = 146d2f3f3e50fc1947e8941301d9cf9d90a035e2
+SHA1 (patch-src_amd_vulkan_winsys_amdgpu_radv__amdgpu__cs.c) = 1fe81a7b16e36dc9125400c20543271216a33a45
+SHA1 (patch-src_compiler_glsl_glsl__parser__extras.cpp) = ef114d6e288e6d212fce9d1c0606f7d454a171c4
+SHA1 (patch-src_egl_drivers_dri2_platform__drm.c) = 94ec2e969e7cf7c89c3192e60758e5ad14b02629
+SHA1 (patch-src_egl_drivers_dri2_platform__x11.c) = 49e48c31eacb79d1da357fe70eaffd2926b5280e
+SHA1 (patch-src_egl_main_eglglobals.c) = 0d52014f52e62fc5fa6650336ddb0011ecf331e6
+SHA1 (patch-src_gallium_auxiliary_pipe-loader_pipe__loader__drm.c) = b8fd5e0d1bab1fa7ae965cae382a1cd1ffbf1fc4
 SHA1 (patch-src_gallium_auxiliary_util_u__format__tests.c) = 4d5e4677c2825778c43440ab131b8807f6840975
-SHA1 (patch-src_gallium_auxiliary_util_u__network.c) = b54de38b3663fa820728a6b05f59082bcbd839df
-SHA1 (patch-src_gallium_auxiliary_util_u__network.h) = c6106d67b4fa9db0d790474182d6e0ce0c5da677
+SHA1 (patch-src_gallium_auxiliary_util_u__network.c) = 628794875a3ed60f33c125631b6f16523f2af7fc
+SHA1 (patch-src_gallium_auxiliary_util_u__network.h) = 23552d47af909d6a238d706dd8f1839e2fb52900
 SHA1 (patch-src_gallium_drivers_nouveau_nouveau__vp3__video.c) = 04f95784c3270c9bb7e95377982e217962481525
 SHA1 (patch-src_gallium_drivers_nouveau_nv50_nv84__video.c) = 1b4239fe053523835ecac006894bdb0cde0ee626
+SHA1 (patch-src_gallium_drivers_trace_tr__dump.c) = dd4c9dffd85dc5461f71d4a9cf2b689c20e30c3e
 SHA1 (patch-src_gallium_drivers_vc4_vc4__bufmgr.c) = 1d591d346486fdf58893f69ab92a272e6a31a987
-SHA1 (patch-src_gallium_state__trackers_clover_llvm_invocation.cpp) = d676e9426ff4c12242cc6db855a287f6792e3987
-SHA1 (patch-src_gallium_state__trackers_clover_llvm_metadata.hpp) = 60c137f7d37f7effe8eb4356d0a20db6945e067f
-SHA1 (patch-src_gallium_targets_dri_Makefile.in) = e559683395286a3f9cdff9a325565bb82bf89dc3
-SHA1 (patch-src_gallium_winsys_radeon_drm_radeon__drm__winsys.c) = 967e8b0d6100f4584fea8635168e3eed31b4deb9
-SHA1 (patch-src_gallium_winsys_svga_drm_vmw__screen__ioctl.c) = 22829b2d44bf47fa366148328737d0528cd273a7
-SHA1 (patch-src_glx_apple_apple__glapi.c) = df70afc24759978f954ac3a774a14e6518dde97a
+SHA1 (patch-src_gallium_include_pipe_p__config.h) = f4e38eac66167b619c30076bb0144dd716310967
+SHA1 (patch-src_gallium_state__trackers_clover_llvm_invocation.cpp) = 609c9fc0e1529cd7adc6b3c544a974ede51030a0
+SHA1 (patch-src_gallium_state__trackers_clover_llvm_metadata.hpp) = c97d38098ea03658bc193a50e445b87f1c020839
+SHA1 (patch-src_gallium_state__trackers_clover_util_range.hpp) = cdc78067986c1b92818472c4201c58ef1b42c4f4
+SHA1 (patch-src_gallium_targets_dri_Makefile.in) = fb521864b281be9e21ef48a01b6479390675a4cb
+SHA1 (patch-src_gallium_winsys_radeon_drm_radeon__drm__winsys.c) = e46d540d50e9bfa1da2dba52ba58173493a9ebf7
+SHA1 (patch-src_gbm_Makefile.am) = 5f3107afbf64b97f7d21ce427cecc4fb78974db3
+SHA1 (patch-src_gbm_Makefile.in) = 5855f4d2907a0d9c3b9a5334177a037591b51d6a
+SHA1 (patch-src_glx_apple_apple__glapi.c) = c4eea8dabf74eb03d22da4eb834b18ae3384c63b
+SHA1 (patch-src_glx_dri__glx.c) = 8fd48776e9953b18bd17ba130d90ae2935e67242
 SHA1 (patch-src_glx_glxclient.h) = f0358179ae397bc8677597b0ccb9a471f40f15de
-SHA1 (patch-src_glx_glxcurrent.c) = 713f75bcafb186c7123d19a6aae3deaed9d5fa69
-SHA1 (patch-src_glx_glxext.c) = 04896824cf9239cc740739e928476f3bda7b55b6
-SHA1 (patch-src_intel_tools_aubinator.c) = 37a0a2de6de5bc70a2be6f5aa6dd64a16c88e5c0
+SHA1 (patch-src_glx_glxcurrent.c) = 8b8e949eded13491c5865601253c6e7d4b06e228
+SHA1 (patch-src_glx_glxext.c) = 15c2c5e0c6b5095ce849fb86ad148aa05d7d907a
+SHA1 (patch-src_intel_Makefile.in) = ba2b9b8396e54ca041df9614466521001b7ca2ef
+SHA1 (patch-src_intel_compiler_brw__fs__bank__conflicts.cpp) = 6276d2c6846bb4dd08699921bec4e20202a17478
+SHA1 (patch-src_intel_tools_aubinator.c) = a15b50a700161b96e743094c059552617d0e5e35
 SHA1 (patch-src_intel_tools_aubinator__error__decode.c) = d8f636e3c3e76763a505a1dce23de0b198ad62fa
-SHA1 (patch-src_mapi_entry.c) = b0af9f644ed5be023010b44981827bfce5986d79
-SHA1 (patch-src_mapi_entry__x86-64__tls.h) = b100d1dd432a00fe4df010d488491fb1367fa6d4
-SHA1 (patch-src_mapi_entry__x86__tls.h) = a763f1f1a5e4eb458f7a654266e53e6470d3a882
+SHA1 (patch-src_intel_vulkan_anv__allocator.c) = 5dd27eea9811d739558c5b488c57a3d7ae539d87
+SHA1 (patch-src_intel_vulkan_anv__device.c) = 593e3281a34a7b1a0b541bc8e255bcecc1fe4826
+SHA1 (patch-src_intel_vulkan_anv__gem.c) = b8eb487fa704151e7c3c3b1d23973b2b0aa5922e
+SHA1 (patch-src_intel_vulkan_anv__queue.c) = 2dbf7dfd0c77f74f510032bf8d12109f58c50a30
+SHA1 (patch-src_mapi_entry__x86-64__tls.h) = 11b7ef1da435fa17fc7025a46a123d447d6a7d07
+SHA1 (patch-src_mapi_entry__x86__tls.h) = 11c0f5302d305a77f3a1780d44a2c61f48a66273
 SHA1 (patch-src_mapi_glapi_gen_gl__gentable.py) = 0b1d4ef3f78a9b3726ef7f9921608a48a5e4ac56
-SHA1 (patch-src_mapi_glapi_glapi__gentable.c) = 7341ef8b8264e5d0f4b6078e4fc7d5ed1d03740c
-SHA1 (patch-src_mapi_table.h) = 272d00c45f742303a5ff84da82c1cd585846d6e1
-SHA1 (patch-src_mapi_u__current.c) = 1731375d82119be326b35d141d7879e083d6d620
-SHA1 (patch-src_mapi_u__current.h) = 214dd29cb0c4fe127eb1157b04b12ddfc455b4b0
-SHA1 (patch-src_mesa_drivers_dri_Makefile.in) = 3fce85c54eece5d68182069a275e66740f458d64
-SHA1 (patch-src_mesa_drivers_dri_common_Makefile.in) = 88f1bb2ac2905a418dc476e1619d2420c421de63
-SHA1 (patch-src_mesa_drivers_dri_common_xmlconfig.c) = b4f3eb90e3f0e91c6e42568fed10c033196ede44
-SHA1 (patch-src_mesa_drivers_dri_i915_intel__screen.c) = 5a49fc290aa95f2e817442f02f9f71cca134a5c0
-SHA1 (patch-src_mesa_drivers_dri_i965_brw__sync.c) = df72503eedc64c11423bf30e0467fcbcf22864b7
-SHA1 (patch-src_mesa_drivers_dri_i965_intel__screen.c) = f394b41e4325dae2185f31e49931c40c1a1e375a
-SHA1 (patch-src_mesa_drivers_dri_i965_intel__tiled__memcpy.c) = c0d465fb65939ead71c9d02b6f6793824dbf441d
-SHA1 (patch-src_mesa_drivers_dri_swrast_swrast.c) = e173d4870ea54b920c4683ed15a6259babf988d1
-SHA1 (patch-src_mesa_main_context.c) = ab1d770ed9c90077d5b7b76aaacbd51fee8db537
-SHA1 (patch-src_mesa_main_extensions.c) = f2fef39e0605e28b13fcab505f930b5fcb44b4ce
-SHA1 (patch-src_mesa_main_macros.h) = a73e93653773a2c121aa8e5c14bc558cce63f94a
+SHA1 (patch-src_mapi_u__current.c) = 38d324fcd1c28d155106ccd248edb5eb1aa9ffac
+SHA1 (patch-src_mapi_u__current.h) = 465a992bd34057e9521f0a33e6f2e25cefc145ca
+SHA1 (patch-src_mesa_drivers_dri_i915_intel__screen.c) = e33f51b3502e8c52ff7283aeb807996717f79f4f
+SHA1 (patch-src_mesa_drivers_dri_i965_brw__performance__query.c) = 43ca8315a4964adf7bc99d772fd817deda3ec249
+SHA1 (patch-src_mesa_drivers_dri_i965_intel__screen.c) = 795b17970e95347222514bacc0701aa86fa1ff02
+SHA1 (patch-src_mesa_drivers_dri_i965_intel__screen.h) = 4f299a8bd451fbf168c5d43f72f32f72bae79934
+SHA1 (patch-src_mesa_drivers_dri_i965_intel__tiled__memcpy.c) = 5b940f9a56c694ffaf8a4383c3a2eae25cfd35a6
+SHA1 (patch-src_mesa_drivers_dri_swrast_swrast.c) = 3106f350e590f62c8bd29cd85f24f977639dccdb
+SHA1 (patch-src_mesa_main_context.c) = 74226013b56ad6c9678f1970458538b35967678f
+SHA1 (patch-src_mesa_main_extensions.c) = 2f48bdb1176c2878bb33bcfab7556172b50a987e
+SHA1 (patch-src_mesa_main_macros.h) = c5dceaa8dc02a58e5b2273d82e3fe1cc12e327d3
 SHA1 (patch-src_mesa_main_shader__query.cpp) = 3f9c31645d87855759def11344dee16af23c7be3
-SHA1 (patch-src_mesa_tnl_t__pipeline.c) = 5033aaf34fc8c8cf484280270dfc220c17fc366a
-SHA1 (patch-src_mesa_x86_assyntax.h) = c28c4ed2390118aae7f3bc09d459e51119fc8405
+SHA1 (patch-src_mesa_tnl_t__pipeline.c) = e6abcdb24019ca57527d25c5cd86737332db98e3
 SHA1 (patch-src_mesa_x86_common__x86.c) = f8c4b93443ef66d017f6aa114b877565b30f2598
-SHA1 (patch-src_util_build__id.c) = aa21458d638357b26799abccba891472495ec03c
+SHA1 (patch-src_util_build__id.c) = 35fa3b42d46400a1319be269c2398951a9fd4deb
+SHA1 (patch-src_util_futex.h) = 35097c3b8baf8b969c6ec5ec1feb6f4e0a48237e
+SHA1 (patch-src_util_os__time.c) = 2675009bd1d14b3bfac7fb978b797775ca3e4913
 SHA1 (patch-src_util_ralloc.c) = d311bfd9ed7e673d72e050668d351c1e6552cdc8
 SHA1 (patch-src_util_strndup.h) = 73f49694ca48ad6b9a9d8346c5b84fddec2463bd
 SHA1 (patch-src_util_u__atomic.h) = beb1df2bb28151bde0405bcae3994107be6813a5
-SHA1 (patch-src_util_u__endian.h) = 64d36c80d34039032239a6740a6a925e075ab72b
+SHA1 (patch-src_util_u__queue.c) = 1ea1c2f8e2971235aa98be96bfd6b2b68f876072
+SHA1 (patch-src_util_xmlconfig.c) = b48ad98a8c5cb6bad4ecd7595c79ffc66a5e466e
diff --git a/MesaLib-dfbsd/dri.mk b/MesaLib-dfbsd/dri.mk
index 5791123b65..4b3d75dd4d 100644
--- a/MesaLib-dfbsd/dri.mk
+++ b/MesaLib-dfbsd/dri.mk
@@ -1,35 +1,34 @@
-# $NetBSD: dri.mk,v 1.16 2016/03/10 05:29:56 tnn Exp $
+# $NetBSD: dri.mk,v 1.17 2018/03/07 11:57:30 wiz Exp $
 #
 # Currently, this is for convenience only.
 #
 .if !defined(DRI_MK)
 DRI_MK=		# defined
 
-.if !defined(USE_BUILTIN.MesaLib)
+.  if !defined(USE_BUILTIN.MesaLib)
 CHECK_BUILTIN.MesaLib:=	yes
-.  include "../../graphics/MesaLib/builtin.mk"
+.    include "../../graphics/MesaLib/builtin.mk"
 CHECK_BUILTIN.MesaLib:=	no
-.endif
+.  endif
 
-.if !empty(USE_BUILTIN.MesaLib:M[Nn][Oo])
-.  if ${OPSYS} != "Darwin"
+.  if !empty(USE_BUILTIN.MesaLib:M[Nn][Oo])
+.    if ${OPSYS} != "Darwin"
 BUILDLINK_API_DEPENDS.libdrm+=		libdrm>=2.4.60
-.  endif
-.  if ${OPSYS} == "Linux"
+.    endif
+.    if ${OPSYS} == "Linux"
 BUILDLINK_API_DEPENDS.libxcb+=	libxcb>=1.9.3
+.    endif
 .  endif
-.endif
-.include "../../textproc/expat/buildlink3.mk"
-.include "../../x11/xorgproto/buildlink3.mk"
+.  include "../../textproc/expat/buildlink3.mk"
+.  include "../../x11/xorgproto/buildlink3.mk"
 # XXX these do not have builtin.mk
-.if ${X11_TYPE} == "modular"
-# Change to option to include in options.mk
-.  include "../../x11/libxshmfence/buildlink3.mk"
-.endif
-.include "../../x11/libXdamage/buildlink3.mk"
-.include "../../x11/libXfixes/buildlink3.mk"
-.include "../../x11/libXxf86vm/buildlink3.mk"
-.if ${OPSYS} != "Darwin"
-.  include "../../x11/libdrm/buildlink3.mk"
-.endif
+.  if ${X11_TYPE} == "modular"
+.    include "../../x11/libxshmfence/buildlink3.mk"
+.  endif
+.  include "../../x11/libXdamage/buildlink3.mk"
+.  include "../../x11/libXfixes/buildlink3.mk"
+.  include "../../x11/libXxf86vm/buildlink3.mk"
+.  if ${OPSYS} != "Darwin"
+.    include "../../x11/libdrm/buildlink3.mk"
+.  endif
 .endif
diff --git a/MesaLib-dfbsd/options.mk b/MesaLib-dfbsd/options.mk
index fd22e47a91..329784ac3d 100644
--- a/MesaLib-dfbsd/options.mk
+++ b/MesaLib-dfbsd/options.mk
@@ -1,16 +1,30 @@
-# $NetBSD: options.mk,v 1.57 2017/07/01 12:48:10 maya Exp $
+# $NetBSD: options.mk,v 1.58 2018/03/24 22:11:14 sevan Exp $
 
 PKG_OPTIONS_VAR=		PKG_OPTIONS.MesaLib
 PKG_SUPPORTED_OPTIONS=		llvm dri
-PKG_SUPPORTED_OPTIONS+=		glamor xvmc dri3 debug
-PKG_SUPPORTED_OPTIONS+=		vdpau vaapi
+PKG_SUGGESTED_OPTIONS=
 
+PKG_SUPPORTED_OPTIONS+=		dri3 glx-tls xvmc debug
+PKG_SUPPORTED_OPTIONS+=		vdpau vaapi
+PKG_SUPPORTED_OPTIONS+=		texture
+PKG_SUPPORTED_OPTIONS+=		osmesa
+PKG_SUPPORTED_OPTIONS+=		glesv1 glesv2
+PKG_SUPPORTED_OPTIONS+=		xa
+PKG_SUPPORTED_OPTIONS+=		noatexit
+PKG_SUPPORTED_OPTIONS+=		libelf
+
+# PKG_SUGGESTED_OPTIONS+=		xvmc
 PKG_SUGGESTED_OPTIONS+=		vdpau vaapi
 
-.if ${OPSYS} != "Darwin"
-PKG_SUGGESTED_OPTIONS+=		dri3
+# glesv1 and glesv2 build error on NetBSD
+# due to no table_noop_array for tls patch
+.if ${OPSYS} != "NetBSD"
+PKG_SUGGESTED_OPTIONS+=		glesv1 glesv2
 .endif
 
+PKG_SUGGESTED_OPTIONS+=		xa
+PKG_SUGGESTED_OPTIONS+=		noatexit
+
 # The LLVM option enables JIT accelerated software rendering and
 # is also required to support the latest RADEON GPUs, so enable it
 # by default on platforms where such GPUs might be encountered.
@@ -26,6 +40,10 @@ PKG_SUGGESTED_OPTIONS+=		llvm
 PKG_SUGGESTED_OPTIONS+=		dri
 .endif
 
+.if ${OPSYS} == "Linux"
+PKG_SUGGESTED_OPTIONS+=		dri3
+.endif
+
 # Use Thread Local Storage in GLX where it is supported by Mesa and works.
 # XXX Fixme
 .if \
@@ -35,7 +53,13 @@ PKG_SUGGESTED_OPTIONS+=		dri
 	!empty(MACHINE_PLATFORM:MLinux-*-x86_64) ||		\
 	!empty(MACHINE_PLATFORM:MFreeBSD-1[0-9].*-x86_64) ||	\
 	!empty(MACHINE_PLATFORM:MDragonFly-*-x86_64)
-PKG_SUGGESTED_OPTIONS+=		glamor	
+PKG_SUGGESTED_OPTIONS+=		glx-tls
+.endif
+
+# segfault starting x on FreeBSD 12 (current) if not using base libelf
+# WebGL demos and mpv not working for radeonsi on NetBSD
+.if ${OPSYS} != "FreeBSD" && ${OPSYS} != "NetBSD"
+PKG_SUGGESTED_OPTIONS+=		libelf
 .endif
 
 .include "../../mk/bsd.options.mk"
@@ -46,76 +70,70 @@ PLIST_VARS+=	freedreno ilo i915 i965 nouveau r300 r600 radeonsi	\
 # classic DRI
 PLIST_VARS+=	dri swrast_dri i915_dri nouveau_dri i965_dri radeon_dri r200_dri
 # other features
-PLIST_VARS+=	gbm wayland xatracker
-PLIST_VARS+=	vaapi vdpau
+PLIST_VARS+=	gbm vaapi vdpau wayland xatracker
 PLIST_VARS+=	osmesa xvmc
+PLIST_VARS+=	glesv1 glesv2
+
+.if !empty(PKG_OPTIONS:Mtexture)
+CONFIGURE_ARGS+=	--enable-texture-float
+.endif
 
 .if !empty(PKG_OPTIONS:Mdri)
 
 CONFIGURE_ARGS+=	--enable-dri
 CONFIGURE_ARGS+=	--enable-egl
 
-.  if !empty(PKG_OPTIONS:Mdri3)
-CFLAGS+=		-DHAVE_DRI3
-CONFIGURE_ARGS+=	--enable-dri3
-.    if ${X11_TYPE} == "modular"
-.include "../../x11/xorgproto/buildlink3.mk"
-.    endif
-.  else
+.if !empty(PKG_OPTIONS:Mdri3)
+# CFLAGS+=		-DHAVE_DRI3
+# CONFIGURE_ARGS+=	--enable-dri3
+.else # !dri3
 CONFIGURE_ARGS+=	--disable-dri3
-.  endif
+.endif # dri3
 
-.  if ${OPSYS} != "Darwin"
+.if ${OPSYS} != "Darwin"
 CONFIGURE_ARGS+=	--enable-gbm
 PLIST.gbm=		yes
-.  endif
+.endif
 
-CONFIGURE_ARGS+=	--enable-texture-float
+.if !empty(PKG_OPTIONS:Mosmesa)
 CONFIGURE_ARGS+=	--enable-osmesa
 PLIST.osmesa=		yes
-CONFIGURE_ARGS+=	--enable-gles1
-CONFIGURE_ARGS+=	--enable-gles2
-
-.  if !empty(PKG_OPTIONS:Mvdpau)
-.include "../../multimedia/libvdpau/available.mk"
-.    if ${VDPAU_AVAILABLE} == "yes"
-PLIST.vdpau=   yes
-.include "../../multimedia/libvdpau/buildlink3.mk"
-.    endif
-.  endif
+.endif
 
-.  if !empty(PKG_OPTIONS:Mvaapi)
-.include "../../multimedia/libva/available.mk"
-.    if ${VAAPI_AVAILABLE} == "yes"
-PLIST.vaapi=   yes
-.include "../../multimedia/libva/buildlink3.mk"
-.    endif
-.  endif
+.if !empty(PKG_OPTIONS:Mglesv1)
+CONFIGURE_ARGS+=	--enable-gles1
+PLIST.glesv1=		yes
+.else
+CONFIGURE_ARGS+=	--disable-gles1
+.endif
 
-.  if !empty(PKG_OPTIONS:Mglamor)
+.if !empty(PKG_OPTIONS:Mglesv2)
+CONFIGURE_ARGS+=	--enable-gles2
+PLIST.glesv2=		yes
+.else
+CONFIGURE_ARGS+=	--disable-gles2
+.endif
 
+.if !empty(PKG_OPTIONS:Mglx-tls)
 # Recommended by
 # http://www.freedesktop.org/wiki/Software/Glamor/
 CONFIGURE_ARGS+=	--enable-glx-tls
-
-.  else
-
+.else
 # (EE) Failed to load /usr/pkg/lib/xorg/modules/extensions/libglx.so:
 # /usr/pkg/lib/libGL.so.1: Use of initialized Thread Local Storage with model
 # initial-exec and dlopen is not supported
 CONFIGURE_ARGS+=	--disable-glx-tls
-
-.  endif
+.endif # glx-tls
 
 # DRI on Linux needs either sysfs or udev
 CONFIGURE_ARGS.Linux+=	--enable-sysfs
 
 PLIST.dri=	yes
 
-.  if ${OPSYS} != "Darwin"
+.if ${OPSYS} != "Darwin"
 BUILDLINK_DEPMETHOD.libpciaccess=	full
 .include "../../sysutils/libpciaccess/buildlink3.mk"
-.  endif
+.endif
 .include "../../graphics/MesaLib/dri.mk"
 
 DRI_DRIVERS=		#
@@ -124,20 +142,20 @@ GALLIUM_DRIVERS=	#
 # Software rasterizer
 PLIST.swrast_dri=	yes
 DRI_DRIVERS+=		swrast
-.  if ${OPSYS} != "Darwin"
+.if ${OPSYS} != "Darwin"
 PLIST.swrast=		yes
 GALLIUM_DRIVERS+=	swrast
-.  endif
+.endif
 
 # x86 only drivers
-.  if (${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64") && ${OPSYS} != "Darwin"
+.if (${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64") && ${OPSYS} != "Darwin"
 # svga / VMWare driver
 PLIST.svga=		yes
 GALLIUM_DRIVERS+=	svga
 
 # Intel chipsets, x86 only
 PLIST.i915=		yes
-GALLIUM_DRIVERS+=	i915
+# GALLIUM_DRIVERS+=	i915
 PLIST.i915_dri=		yes
 DRI_DRIVERS+=		i915
 
@@ -148,10 +166,10 @@ DRI_DRIVERS+=		i915
 
 PLIST.i965_dri=		yes
 DRI_DRIVERS+=		i965
-.  endif
+.endif
 
 # ARM drivers
-.  if !empty(MACHINE_PLATFORM:MNetBSD-*-*arm*)
+.if !empty(MACHINE_PLATFORM:MNetBSD-*-*arm*)
 # Qualcomm SnapDragon, libdrm_freedreno.pc
 GALLIUM_DRIVERS+=	freedreno
 PLIST.freedreno=	yes
@@ -159,31 +177,32 @@ PLIST.freedreno=	yes
 # Broadcom VideoCore 4
 GALLIUM_DRIVERS+=	vc4
 PLIST.vc4=		yes
-.  endif
+.endif
 
 # qemu Linux guest driver
-.  if !empty(MACHINE_PLATFORM:MLinux-*-x86_64)
+.if !empty(MACHINE_PLATFORM:MLinux-*-x86_64)
 # XXX test this
 #GALLIUM_DRIVERS+=	virgl
 #PLIST.virgl=		yes
-.  endif
+.endif
 
-# theoretically cross platform PCI drivers, but don't build on ARM
-.  if ${OPSYS} != "Darwin" && empty(MACHINE_PLATFORM:MNetBSD-*-*arm*)
+# theoretically cross platform PCI drivers
+.if ${OPSYS} != "Darwin" && empty(MACHINE_PLATFORM:MNetBSD-*-*arm*) && \
+	empty(MACHINE_PLATFORM:MNetBSD-*-mipsel)
 
 # AMD Radeon r600
 PLIST.r600=		yes
 GALLIUM_DRIVERS+=	r600
 
-FULL_OS_VERSION_CMD=	${UNAME} -r
-FULL_OS_VERSION=	${FULL_OS_VERSION_CMD:sh}
+# FULL_OS_VERSION_CMD=	${UNAME} -r
+# FULL_OS_VERSION=	${FULL_OS_VERSION_CMD:sh}
 
-# Base llvm 3.9.x has problems building nouveau support
-.    if ${OPSYS} != "FreeBSD" || (empty(FULL_OS_VERSION:M11.0-STABLE) && empty(OS_VERSION:M12.*))
+# FreeBSD base llvm 3.9+ has problems building nouveau support
+.if ${OPSYS} != "FreeBSD" || (empty(OS_VERSION:M11.*) && empty(OS_VERSION:M12.*))
 # nVidia
 PLIST.nouveau=		yes
 GALLIUM_DRIVERS+=	nouveau
-.    endif
+.endif
 
 # classic DRI radeon
 PLIST.radeon_dri=	yes
@@ -193,51 +212,75 @@ DRI_DRIVERS+=		radeon
 PLIST.r200_dri=		yes
 DRI_DRIVERS+=		r200
 
-# Base llvm 3.9.x has problems building nouveau support
-.    if ${OPSYS} != "FreeBSD" || (empty(FULL_OS_VERSION:M11.0-STABLE) && empty(OS_VERSION:M12.*))
+# FreeBSD base llvm 3.9+ has problems building nouveau support
+.if ${OPSYS} != "FreeBSD" || (empty(OS_VERSION:M11.*) && empty(OS_VERSION:M12.*))
 # classic DRI nouveau
 PLIST.nouveau_dri=	yes
 DRI_DRIVERS+=		nouveau
-.    endif
-.  endif
+.endif
+.endif # cross platform PCI drivers
 
-.  if ${OPSYS} == "Darwin"
-CONFIGURE_ARGS+=	--with-egl-platforms=x11
+.if ${OPSYS} == "Darwin"
+CONFIGURE_ARGS+=	--with-platforms=x11
 #.elif ${OPSYS} == "Linux"
 #.include "../../wip/wayland/buildlink3.mk"
-#CONFIGURE_ARGS+=	--with-egl-platforms=x11,drm,wayland
+#CONFIGURE_ARGS+=	--with-platforms=x11,drm,wayland
 #PLIST.wayland=		yes
-.  else
-CONFIGURE_ARGS+=	--with-egl-platforms=x11,drm
-.  endif
+.else
+CONFIGURE_ARGS+=	--with-platforms=x11,drm
+.endif
 
-CONFIGURE_ARGS+=	--with-gallium-drivers=${GALLIUM_DRIVERS:ts,}
-CONFIGURE_ARGS+=	--with-dri-drivers=${DRI_DRIVERS:ts,}
+.if !empty(PKG_OPTIONS:Mllvm)
+# VA-API and VDPAU
+.if !empty(PKG_OPTIONS:Mvaapi)
+.include "../../multimedia/libva/available.mk"
+.if ${VAAPI_AVAILABLE} == "yes"
+PLIST.vaapi=	yes
+.include "../../multimedia/libva/buildlink3.mk"
+.endif
+.endif # vaapi
+.if !empty(PKG_OPTIONS:Mvdpau)
+.include "../../multimedia/libvdpau/available.mk"
+.if ${VDPAU_AVAILABLE} == "yes"
+PLIST.vdpau=	yes
+.include "../../multimedia/libvdpau/buildlink3.mk"
+.endif
+.endif # vdpau
 
-.  if !empty(PKG_OPTIONS:Mllvm)
 # XA is useful for accelerating xf86-video-vmware
+.if !empty(PKG_OPTIONS:Mxa)
 CONFIGURE_ARGS+=	--enable-xa
 PLIST.xatracker=	yes
+.endif
+
 # AMD Radeon r300
 PLIST.r300=		yes
 GALLIUM_DRIVERS+=	r300
 # AMD Canary Islands GPUs
 PLIST.radeonsi=		yes
 GALLIUM_DRIVERS+=	radeonsi
-CONFIGURE_ARGS+=	--enable-gallium-llvm
+CONFIGURE_ARGS+=	--enable-llvm
 CONFIGURE_ARGS+=	--enable-llvm-shared-libs
 # CONFIGURE_ARGS+=	--enable-r600-llvm-compiler
+
+.if !empty(PKG_OPTIONS:Mlibelf)
 .include "../../devel/libelf/buildlink3.mk"
 CPPFLAGS+=		-I${BUILDLINK_PREFIX.libelf}/include/libelf
+.endif
+
 BUILDLINK_API_DEPENDS.libLLVM+= libLLVM>=4.0
 .include "../../lang/libLLVM/buildlink3.mk"
 CONFIGURE_ENV+=		ac_cv_path_ac_pt_LLVM_CONFIG=${LLVM_CONFIG_PATH}
-.  else # !llvm
+.else # !llvm
 CONFIGURE_ARGS+=	--disable-xa
-CONFIGURE_ARGS+=	--disable-gallium-llvm
+CONFIGURE_ARGS+=	--disable-llvm
 CONFIGURE_ARGS+=	--disable-llvm-shared-libs
 # CONFIGURE_ARGS+=	--disable-r600-llvm-compiler
-.  endif # llvm
+.endif # llvm
+
+CONFIGURE_ARGS+=	--with-gallium-drivers=${GALLIUM_DRIVERS:ts,}
+CONFIGURE_ARGS+=	--with-dri-drivers=${DRI_DRIVERS:ts,}
+
 .else # !dri
 CONFIGURE_ARGS+=	--with-gallium-drivers=
 CONFIGURE_ARGS+=	--with-dri-drivers=
@@ -248,9 +291,9 @@ CONFIGURE_ARGS+=	--disable-gbm
 CONFIGURE_ARGS+=	--disable-gles1
 CONFIGURE_ARGS+=	--disable-gles2
 CONFIGURE_ARGS+=	--enable-xlib-glx
-.  if !empty(PKG_OPTIONS:Mllvm)
+.if !empty(PKG_OPTIONS:Mllvm)
 PKG_FAIL_REASON+=	"The llvm PKG_OPTION must also be disabled when dri is disabled"
-.  endif
+.endif
 .endif # dri
 
 .if !empty(PKG_OPTIONS:Mdebug)
@@ -262,10 +305,6 @@ CONFIGURE_ARGS+=	--enable-debug
 PLIST.xvmc=		yes
 .endif
 
-
-# FreeBSD does not generate library names mylib.so.x.y
-.if ${OPSYS} == "FreeBSD"
-PLIST_SUBST+=	FREEBSDVDPAU="@comment "
-.else
-PLIST_SUBST+=	FREEBSDVDPAU=""
+.if !empty(PKG_OPTIONS:Mnoatexit)
+CPPFLAGS+=	-DHAVE_NOATEXIT
 .endif
diff --git a/MesaLib-dfbsd/patches/patch-configure b/MesaLib-dfbsd/patches/patch-configure
new file mode 100644
index 0000000000..4fd715965a
--- /dev/null
+++ b/MesaLib-dfbsd/patches/patch-configure
@@ -0,0 +1,93 @@
+$NetBSD: patch-configure,v 1.5 2016/02/12 11:49:53 tnn Exp $
+
+From FreeBSD ports graphics/mesa-dri 18.0.0,
+DragonFly dports graphics/mesa-dri 17.3.1,
+files/patch-configure
+
+* Extend to FreeBSD
+osx: ld does not support --build-ld
+
+* For FreeBSD: Use monotonic clock for timeouts.
+
+* For FreeBSD: Implement futex_wake() and futex_wait() via _umtx_op() 
+
+* dri3: Mon Apr 10 19:14:48 2017 UTC
+DRI3 remains enabled at compile time, but it is now disabled at
+runtime for stock FreeBSD.  Set LIBGL_DRI3_ENABLE in the
+environment to enable DRI3.
+This change was made to work around a problem in libEGL,
+which fails to fall back to using DRI2 when run on a system
+without DRI3 support.
+
+--- configure.orig	2018-04-18 14:48:02.000000000 +0000
++++ configure
+@@ -21590,7 +21590,7 @@ fi
+ 
+ 
+ case "$host_os" in
+-darwin*)
++darwin* | freebsd*)
+     LD_BUILD_ID=""
+     ;;
+ *)
+@@ -21962,12 +21962,13 @@ case "$host_os" in
+ darwin*)
+     ;;
+ *)
+-    for ac_func in clock_gettime
++    for ac_func in clock_gettime clock_nanosleep
+ do :
+-  ac_fn_c_check_func "$LINENO" "clock_gettime" "ac_cv_func_clock_gettime"
+-if test "x$ac_cv_func_clock_gettime" = xyes; then :
++  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
++ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
++if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+   cat >>confdefs.h <<_ACEOF
+-#define HAVE_CLOCK_GETTIME 1
++#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+ _ACEOF
+  CLOCK_LIB=
+ else
+@@ -22626,11 +22627,20 @@ $as_echo "yes" >&6; }
+ fi
+ fi
+ 
+-ac_fn_c_check_header_mongrel "$LINENO" "linux/futex.h" "ac_cv_header_linux_futex_h" "$ac_includes_default"
+-if test "x$ac_cv_header_linux_futex_h" = xyes; then :
+-  DEFINES="$DEFINES -DHAVE_LINUX_FUTEX_H"
++for ac_header in linux/futex.h sys/umtx.h
++do :
++  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
++ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#include <errno.h>
++     #include <sys/types.h>
++"
++if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
++  cat >>confdefs.h <<_ACEOF
++#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
++_ACEOF
++ DEFINES="$DEFINES -DHAVE_LINUX_FUTEX_H"
+ fi
+ 
++done
+ 
+ 
+ # Check whether --enable-selinux was given.
+@@ -23528,7 +23538,7 @@ fi
+ 
+ 
+ case "$host_os" in
+-linux*)
++linux* | freebsd* | dragonfly*)
+     dri3_default=yes
+     ;;
+ *)
+@@ -27316,9 +27326,6 @@ rm -f core conftest.err conftest.$ac_obj
+         CLANG_LIBDIR=${LLVM_LIBDIR}
+     fi
+     CLANG_RESOURCE_DIR=$CLANG_LIBDIR/clang/${LLVM_VERSION}
+-    if test ! -f "$CLANG_RESOURCE_DIR/include/stddef.h"; then :
+-  as_fn_error $? "Could not find clang internal header stddef.h in $CLANG_RESOURCE_DIR Use --with-clang-libdir to specify the correct path to the clang libraries." "$LINENO" 5
+-fi
+ fi
+  if test "x$enable_opencl" = xyes; then
+   HAVE_CLOVER_TRUE=
diff --git a/MesaLib-dfbsd/patches/patch-configure.ac b/MesaLib-dfbsd/patches/patch-configure.ac
new file mode 100644
index 0000000000..a4235d78c9
--- /dev/null
+++ b/MesaLib-dfbsd/patches/patch-configure.ac
@@ -0,0 +1,71 @@
+$NetBSD$
+
+From FreeBSD ports graphics/mesa-dri 18.0.0,
+DragonFly dports graphics/mesa-dri 17.3.1,
+files/patch-configure
+
+* Extend to FreeBSD
+osx: ld does not support --build-ld
+
+* For FreeBSD: Use monotonic clock for timeouts.
+
+* For FreeBSD: Implement futex_wake() and futex_wait() via _umtx_op() 
+
+* dri3: Mon Apr 10 19:14:48 2017 UTC
+DRI3 remains enabled at compile time, but it is now disabled at
+runtime for stock FreeBSD.  Set LIBGL_DRI3_ENABLE in the
+environment to enable DRI3.
+This change was made to work around a problem in libEGL,
+which fails to fall back to using DRI2 when run on a system
+without DRI3 support.
+
+--- configure.ac.orig	2018-02-09 02:17:57.000000000 +0000
++++ configure.ac
+@@ -689,7 +689,7 @@ dnl
+ dnl OSX linker does not support build-id
+ dnl
+ case "$host_os" in
+-darwin*)
++darwin* | freebsd*)
+     LD_BUILD_ID=""
+     ;;
+ *)
+@@ -907,7 +907,7 @@ case "$host_os" in
+ darwin*)
+     ;;
+ *)
+-    AC_CHECK_FUNCS([clock_gettime], [CLOCK_LIB=],
++    AC_CHECK_FUNCS([clock_gettime clock_nanosleep], [CLOCK_LIB=],
+                    [AC_CHECK_LIB([rt], [clock_gettime], [CLOCK_LIB=-lrt],
+                                  [AC_MSG_ERROR([Could not find clock_gettime])])])
+     AC_SUBST([CLOCK_LIB])
+@@ -955,7 +955,10 @@ if test "x$pthread_stubs_possible" = xyes; then
+ fi
+ 
+ dnl Check for futex for fast inline simple_mtx_t.
+-AC_CHECK_HEADER([linux/futex.h], [DEFINES="$DEFINES -DHAVE_LINUX_FUTEX_H"])
++AC_CHECK_HEADERS([linux/futex.h sys/umtx.h],
++    [DEFINES="$DEFINES -DHAVE_LINUX_FUTEX_H"],,
++    [#include <errno.h>
++     #include <sys/types.h>])
+ 
+ dnl SELinux awareness.
+ AC_ARG_ENABLE([selinux],
+@@ -1238,7 +1241,7 @@ fi
+ AC_SUBST(LIBSENSORS_LIBS)
+ 
+ case "$host_os" in
+-linux*)
++linux* | freebsd* | dragonfly*)
+     dri3_default=yes
+     ;;
+ *)
+@@ -2378,8 +2381,6 @@ if test "x$enable_opencl" = xyes; then
+         CLANG_LIBDIR=${LLVM_LIBDIR}
+     fi
+     CLANG_RESOURCE_DIR=$CLANG_LIBDIR/clang/${LLVM_VERSION}
+-    AS_IF([test ! -f "$CLANG_RESOURCE_DIR/include/stddef.h"],
+-        [AC_MSG_ERROR([Could not find clang internal header stddef.h in $CLANG_RESOURCE_DIR Use --with-clang-libdir to specify the correct path to the clang libraries.])])
+ fi
+ AM_CONDITIONAL(HAVE_CLOVER, test "x$enable_opencl" = xyes)
+ AM_CONDITIONAL(HAVE_CLOVER_ICD, test "x$enable_opencl_icd" = xyes)
diff --git a/MesaLib-dfbsd/patches/patch-include_GL_internal_dri__interface.h b/MesaLib-dfbsd/patches/patch-include_GL_internal_dri__interface.h
new file mode 100644
index 0000000000..49e4b02679
--- /dev/null
+++ b/MesaLib-dfbsd/patches/patch-include_GL_internal_dri__interface.h
@@ -0,0 +1,27 @@
+$NetBSD$
+
+From FreeBSD ports graphics/mesa-dri 17.2.4.
+
+GCC on 9.x doesn't allow types to be overwritten, these types are defined
+in drm.h also, which causes build issues in xorg-server.
+
+--- include/GL/internal/dri_interface.h.orig	2017-11-20 14:25:47.000000000 +0000
++++ include/GL/internal/dri_interface.h
+@@ -40,6 +40,9 @@
+ #ifndef DRI_INTERFACE_H
+ #define DRI_INTERFACE_H
+ 
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++#include <drm.h>
++#else
+ #ifdef HAVE_LIBDRM
+ #include <drm.h>
+ #else
+@@ -47,6 +50,7 @@ typedef unsigned int drm_context_t;
+ typedef unsigned int drm_drawable_t;
+ typedef struct drm_clip_rect drm_clip_rect_t;
+ #endif
++#endif /* __FreeBSD__ || __DragonFly__ */
+ 
+ #include <stdint.h>
+ 
diff --git a/MesaLib-dfbsd/patches/patch-include_c11_threads__posix.h b/MesaLib-dfbsd/patches/patch-include_c11_threads__posix.h
deleted file mode 100644
index d48726fe1a..0000000000
--- a/MesaLib-dfbsd/patches/patch-include_c11_threads__posix.h
+++ /dev/null
@@ -1,16 +0,0 @@
-$NetBSD$
-
-OpenBSD, FreeBSD, and DragonFly all have pthread_mutex_timedlock
-in their manpages.
-
---- include/c11/threads_posix.h.orig	2017-02-13 11:55:49.000000000 +0000
-+++ include/c11/threads_posix.h
-@@ -43,7 +43,7 @@ Configuration macro:
-     Use pthread_mutex_timedlock() for `mtx_timedlock()'
-     Otherwise use mtx_trylock() + *busy loop* emulation.
- */
--#if !defined(__CYGWIN__) && !defined(__APPLE__) && !defined(__NetBSD__)
-+#if !defined(__CYGWIN__) && !defined(__APPLE__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__DragonFly__)
- #define EMULATED_THREADS_USE_NATIVE_TIMEDLOCK
- #endif
- 
diff --git a/MesaLib-dfbsd/patches/patch-src_amd_vulkan_winsys_amdgpu_radv__amdgpu__cs.c b/MesaLib-dfbsd/patches/patch-src_amd_vulkan_winsys_amdgpu_radv__amdgpu__cs.c
new file mode 100644
index 0000000000..614b620113
--- /dev/null
+++ b/MesaLib-dfbsd/patches/patch-src_amd_vulkan_winsys_amdgpu_radv__amdgpu__cs.c
@@ -0,0 +1,19 @@
+$NetBSD$
+
+Define ETIME if missing
+
+https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=225415
+FreeBSD Bugzilla: Bug 225415 graphics/mesa-dri: update to 18.0.0 
+
+--- src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c.orig	2018-02-09 02:17:57.000000000 +0000
++++ src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c
+@@ -33,6 +33,9 @@
+ #include "radv_amdgpu_bo.h"
+ #include "sid.h"
+ 
++#ifndef ETIME
++#define ETIME ETIMEDOUT
++#endif
+ 
+ enum {
+ 	VIRTUAL_BUFFER_HASH_TABLE_SIZE = 1024
diff --git a/MesaLib-dfbsd/patches/patch-src_compiler_glsl_glsl__parser__extras.cpp b/MesaLib-dfbsd/patches/patch-src_compiler_glsl_glsl__parser__extras.cpp
index 575e2cbcbb..6dc940c687 100644
--- a/MesaLib-dfbsd/patches/patch-src_compiler_glsl_glsl__parser__extras.cpp
+++ b/MesaLib-dfbsd/patches/patch-src_compiler_glsl_glsl__parser__extras.cpp
@@ -2,14 +2,17 @@ $NetBSD: patch-src_compiler_glsl_glsl__parser__extras.cpp,v 1.1 2016/04/17 00:03
 
 atexit() is not a good idea in a library; use destructor attribute.
 
---- src/compiler/glsl/glsl_parser_extras.cpp.orig	2017-02-13 11:55:49.000000000 +0000
+--- src/compiler/glsl/glsl_parser_extras.cpp.orig	2017-09-25 16:56:18.000000000 +0000
 +++ src/compiler/glsl/glsl_parser_extras.cpp
-@@ -2147,7 +2147,7 @@ extern "C" {
+@@ -2224,7 +2224,11 @@ extern "C" {
   * programs would be invalid.  So this should happen at approximately
   * program exit.
   */
--void
++#if defined(HAVE_NOATEXIT)
 +void __attribute__((__destructor__))
++#else
+ void
++#endif
  _mesa_destroy_shader_compiler(void)
  {
     _mesa_destroy_shader_compiler_caches();
diff --git a/MesaLib-dfbsd/patches/patch-src_egl_drivers_dri2_platform__drm.c b/MesaLib-dfbsd/patches/patch-src_egl_drivers_dri2_platform__drm.c
index 9b88f270ae..1de7c14fa3 100644
--- a/MesaLib-dfbsd/patches/patch-src_egl_drivers_dri2_platform__drm.c
+++ b/MesaLib-dfbsd/patches/patch-src_egl_drivers_dri2_platform__drm.c
@@ -1,16 +1,16 @@
-$NetBSD$
+$NetBSD: patch-src_egl_drivers_dri2_platform__drm.c,v 1.2 2016/01/05 13:02:57 tnn Exp $
 
 netbsd-5 build fix
 
---- src/egl/drivers/dri2/platform_drm.c.orig	2017-05-10 14:13:57.000000000 +0000
+--- src/egl/drivers/dri2/platform_drm.c.orig	2017-10-19 12:23:53.000000000 +0000
 +++ src/egl/drivers/dri2/platform_drm.c
-@@ -696,7 +696,9 @@ dri2_initialize_drm(_EGLDriver *drv, _EG
+@@ -688,7 +688,9 @@ dri2_initialize_drm(_EGLDriver *drv, _EG
        }
-       dri2_dpy->own_device = 1;
+       dri2_dpy->own_device = true;
     } else {
 +#ifdef F_DUPFD_CLOEXEC
-       fd = fcntl(gbm_device_get_fd(gbm), F_DUPFD_CLOEXEC, 3);
+       dri2_dpy->fd = fcntl(gbm_device_get_fd(gbm), F_DUPFD_CLOEXEC, 3);
 +#endif
-       if (fd < 0) {
+       if (dri2_dpy->fd < 0) {
           err = "DRI2: failed to fcntl() existing gbm device";
           goto cleanup;
diff --git a/MesaLib-dfbsd/patches/patch-src_egl_drivers_dri2_platform__x11.c b/MesaLib-dfbsd/patches/patch-src_egl_drivers_dri2_platform__x11.c
index 5e848b5acb..7205c82fd6 100644
--- a/MesaLib-dfbsd/patches/patch-src_egl_drivers_dri2_platform__x11.c
+++ b/MesaLib-dfbsd/patches/patch-src_egl_drivers_dri2_platform__x11.c
@@ -2,9 +2,22 @@ $NetBSD: patch-src_egl_drivers_dri2_platform__x11.c,v 1.2 2016/05/18 12:55:28 wi
 
 Provide compat strndup for older Darwin.
 
---- src/egl/drivers/dri2/platform_x11.c.orig	2017-02-13 11:55:49.000000000 +0000
+* From FreeBSD ports 18.0.0:
+work-around for https://bugs.freedesktop.org/show_bug.cgi?id=100627
+
+Mon Apr 10 19:14:48 2017 UTC
+DRI3 remains enabled at compile time, but it is now disabled at
+runtime for stock FreeBSD.  Set LIBGL_DRI3_ENABLE in the
+environment to enable DRI3.
+This change was made to work around a problem in libEGL,
+which fails to fall back to using DRI2 when run on a system
+without DRI3 support.
+
+* Added logging statement to note dri3 initialization being invoked.
+
+--- src/egl/drivers/dri2/platform_x11.c.orig	2018-02-09 02:17:57.000000000 +0000
 +++ src/egl/drivers/dri2/platform_x11.c
-@@ -603,6 +603,23 @@ dri2_x11_local_authenticate(struct dri2_
+@@ -608,6 +608,23 @@ dri2_x11_local_authenticate(struct dri2_
     return EGL_TRUE;
  }
  
@@ -28,3 +41,20 @@ Provide compat strndup for older Darwin.
  static EGLBoolean
  dri2_x11_connect(struct dri2_egl_display *dri2_dpy)
  {
+@@ -1466,8 +1483,15 @@ dri2_initialize_x11(_EGLDriver *drv, _EG
+ 
+    if (!disp->Options.ForceSoftware) {
+ #ifdef HAVE_DRI3
+-      if (!env_var_as_boolean("LIBGL_DRI3_DISABLE", false))
++#if ((defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) && !defined(__DRM_NEXT__)) || defined(__DragonFly__) || defined(__NetBSD__)
++      if (env_var_as_boolean("LIBGL_DRI3_ENABLE", false))
++#endif
++      if (!env_var_as_boolean("LIBGL_DRI3_DISABLE", false)) {
++         _eglLog(_EGL_INFO, "platform_x11.c: calling dri2_initialize_x11_dri3\n");
+          initialized = dri2_initialize_x11_dri3(drv, disp);
++         if (initialized)
++            _eglLog(_EGL_INFO, "platform_x11.c: initialized by dri2_initialize_x11_dri3\n");
++      }
+ #endif
+ 
+       if (!initialized)
diff --git a/MesaLib-dfbsd/patches/patch-src_egl_main_eglglobals.c b/MesaLib-dfbsd/patches/patch-src_egl_main_eglglobals.c
index 21537d98bd..1a93bfce0b 100644
--- a/MesaLib-dfbsd/patches/patch-src_egl_main_eglglobals.c
+++ b/MesaLib-dfbsd/patches/patch-src_egl_main_eglglobals.c
@@ -1,40 +1,53 @@
-$NetBSD$
+$NetBSD: patch-src_egl_main_eglglobals.c,v 1.1 2016/01/27 07:39:54 wiz Exp $
 
 atexit() is not a good idea in shared libraries.
 
---- src/egl/main/eglglobals.c.orig	2017-02-13 11:55:49.000000000 +0000
+FreeBSD reported atexit bug for 10.6:
+https://bugs.freedesktop.org/show_bug.cgi?id=91869
+
+--- src/egl/main/eglglobals.c.orig	2018-01-18 21:30:28.000000000 +0000
 +++ src/egl/main/eglglobals.c
-@@ -72,11 +72,16 @@ struct _egl_global _eglGlobal =
-    _EGL_DEBUG_BIT_CRITICAL | _EGL_DEBUG_BIT_ERROR, /* debugTypesEnabled */
+@@ -85,11 +85,22 @@ struct _egl_global _eglGlobal =
+    .debugTypesEnabled = _EGL_DEBUG_BIT_CRITICAL | _EGL_DEBUG_BIT_ERROR,
  };
  
++#if defined(HAVE_NOATEXIT)
 +static EGLBoolean registered = EGL_FALSE;
  
--static void
 +static void __attribute__((__destructor__))
++#else
+ static void
++#endif
  _eglAtExit(void)
  {
     EGLint i;
 +
++#if defined(HAVE_NOATEXIT)
 +   if (!registered)
-+     return;
++      return;
++#endif
 +
     for (i = _eglGlobal.NumAtExitCalls - 1; i >= 0; i--)
        _eglGlobal.AtExitCalls[i]();
  }
-@@ -86,14 +91,9 @@ void
+@@ -99,14 +110,20 @@ void
  _eglAddAtExitCall(void (*func)(void))
  {
     if (func) {
--      static EGLBoolean registered = EGL_FALSE;
--
++#if !defined(HAVE_NOATEXIT)
+       static EGLBoolean registered = EGL_FALSE;
++#endif
+ 
        mtx_lock(_eglGlobal.Mutex);
  
--      if (!registered) {
--         atexit(_eglAtExit);
--         registered = EGL_TRUE;
--      }
++#if defined(HAVE_NOATEXIT)
 +      registered = EGL_TRUE;
++#else
+       if (!registered) {
+          atexit(_eglAtExit);
+          registered = EGL_TRUE;
+       }
++#endif
  
        assert(_eglGlobal.NumAtExitCalls < ARRAY_SIZE(_eglGlobal.AtExitCalls));
        _eglGlobal.AtExitCalls[_eglGlobal.NumAtExitCalls++] = func;
diff --git a/MesaLib-dfbsd/patches/patch-src_gallium_auxiliary_pipe-loader_pipe__loader__drm.c b/MesaLib-dfbsd/patches/patch-src_gallium_auxiliary_pipe-loader_pipe__loader__drm.c
index e6e9eddb02..9574f08413 100644
--- a/MesaLib-dfbsd/patches/patch-src_gallium_auxiliary_pipe-loader_pipe__loader__drm.c
+++ b/MesaLib-dfbsd/patches/patch-src_gallium_auxiliary_pipe-loader_pipe__loader__drm.c
@@ -1,6 +1,6 @@
 $NetBSD$
 
-From FreeBSD ports / DragonFly dports, email addresses expunged:
+* From FreeBSD ports / DragonFly dports graphics/mesa-dri
 
 Revert the following commit.
 
@@ -23,13 +23,15 @@ headless system that is used for opencl.
 
 v2: Clarify the linking topic in the commit message.
 
+* Extended for NetBSD.
+
 --- src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c.orig	2017-02-06 13:49:09.000000000 +0000
 +++ src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
 @@ -224,6 +224,16 @@ pipe_loader_drm_probe_fd(struct pipe_loa
     return false;
  }
- 
-+#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__)
+
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) || defined(__NetBSD__)
 +static int
 +open_drm_minor(int minor)
 +{
@@ -46,7 +48,7 @@ v2: Clarify the linking topic in the commit message.
  int
  pipe_loader_drm_probe(struct pipe_loader_device **devs, int ndev)
  {
-+#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__)
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) || defined(__NetBSD__)
 +   int i, k, fd, num_render_node_devs;
 +   int j = 0;
 +
@@ -65,8 +67,8 @@ v2: Clarify the linking topic in the commit message.
 @@ -251,6 +273,11 @@ pipe_loader_drm_probe(struct pipe_loader
           continue;
        }
- 
-+#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__)
+
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) || defined(__NetBSD__)
 +      render_node_devs[j].vendor_id = dev->u.pci.vendor_id;
 +      render_node_devs[j].chip_id = dev->u.pci.chip_id;
 +
@@ -77,8 +79,8 @@ v2: Clarify the linking topic in the commit message.
 @@ -260,6 +287,48 @@ pipe_loader_drm_probe(struct pipe_loader
        j++;
     }
- 
-+#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__)
+
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) || defined(__NetBSD__)
 +   num_render_node_devs = j;
 +
 +   /* Next look for drm devices. */
diff --git a/MesaLib-dfbsd/patches/patch-src_gallium_auxiliary_util_u__network.c b/MesaLib-dfbsd/patches/patch-src_gallium_auxiliary_util_u__network.c
index 5fa205fc26..dd50435d70 100644
--- a/MesaLib-dfbsd/patches/patch-src_gallium_auxiliary_util_u__network.c
+++ b/MesaLib-dfbsd/patches/patch-src_gallium_auxiliary_util_u__network.c
@@ -2,18 +2,18 @@ $NetBSD: patch-src_gallium_auxiliary_util_u__network.c,v 1.1 2015/04/25 11:19:18
 
 BSD has sockets, silence warning about missing implementation.
 
---- src/gallium/auxiliary/util/u_network.c.orig	2017-02-13 11:55:49.000000000 +0000
+--- src/gallium/auxiliary/util/u_network.c.orig	2018-02-09 02:17:57.000000000 +0000
 +++ src/gallium/auxiliary/util/u_network.c
-@@ -7,7 +7,7 @@
- #  include <winsock2.h>
+@@ -10,7 +10,7 @@
  #  include <windows.h>
+ #  include <ws2tcpip.h>
  #elif defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) || \
 -   defined(PIPE_OS_APPLE) || defined(PIPE_OS_CYGWIN) || defined(PIPE_OS_SOLARIS)
 +   defined(PIPE_OS_APPLE) || defined(PIPE_OS_CYGWIN) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_BSD)
  #  include <sys/socket.h>
  #  include <netinet/in.h>
  #  include <unistd.h>
-@@ -56,7 +56,7 @@ u_socket_close(int s)
+@@ -59,7 +59,7 @@ u_socket_close(int s)
        return;
  
  #if defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) \
@@ -22,7 +22,7 @@ BSD has sockets, silence warning about missing implementation.
     shutdown(s, SHUT_RDWR);
     close(s);
  #elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
-@@ -172,7 +172,7 @@ void
+@@ -182,7 +182,7 @@ void
  u_socket_block(int s, boolean block)
  {
  #if defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) \
diff --git a/MesaLib-dfbsd/patches/patch-src_gallium_auxiliary_util_u__network.h b/MesaLib-dfbsd/patches/patch-src_gallium_auxiliary_util_u__network.h
index 095a244125..2a0e8b8682 100644
--- a/MesaLib-dfbsd/patches/patch-src_gallium_auxiliary_util_u__network.h
+++ b/MesaLib-dfbsd/patches/patch-src_gallium_auxiliary_util_u__network.h
@@ -2,7 +2,7 @@ $NetBSD: patch-src_gallium_auxiliary_util_u__network.h,v 1.1 2015/04/25 11:19:18
 
 BSD has sockets, silence warning about missing implementation.
 
---- src/gallium/auxiliary/util/u_network.h.orig	2014-09-12 21:30:32.000000000 +0000
+--- src/gallium/auxiliary/util/u_network.h.orig	2017-11-10 23:18:56.000000000 +0000
 +++ src/gallium/auxiliary/util/u_network.h
 @@ -7,7 +7,7 @@
  #if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
diff --git a/MesaLib-dfbsd/patches/patch-src_gallium_drivers_trace_tr__dump.c b/MesaLib-dfbsd/patches/patch-src_gallium_drivers_trace_tr__dump.c
new file mode 100644
index 0000000000..d085cfea2a
--- /dev/null
+++ b/MesaLib-dfbsd/patches/patch-src_gallium_drivers_trace_tr__dump.c
@@ -0,0 +1,50 @@
+$NetBSD$
+
+atexit() is not a good idea in shared libraries.
+
+FreeBSD reported atexit bug for 10.6:
+https://bugs.freedesktop.org/show_bug.cgi?id=91869
+
+--- src/gallium/drivers/trace/tr_dump.c.orig	2018-01-18 21:30:28.000000000 +0000
++++ src/gallium/drivers/trace/tr_dump.c
+@@ -63,7 +63,6 @@ static mtx_t call_mutex = _MTX_INITIALIZ
+ static long unsigned call_no = 0;
+ static boolean dumping = FALSE;
+ 
+-
+ static inline void
+ trace_dump_write(const char *buf, size_t size)
+ {
+@@ -171,9 +170,20 @@ trace_dump_trace_flush(void)
+    }
+ }
+ 
++#if defined(HAVE_NOATEXIT)
++static boolean trace_dump_has_begun = FALSE;
++
++static void __attribute__((__destructor__))
++#else
+ static void
++#endif
+ trace_dump_trace_close(void)
+ {
++#if defined(HAVE_NOATEXIT)
++   if (!trace_dump_has_begun)
++      return;
++#endif
++
+    if (stream) {
+       trace_dump_writes("</trace>\n");
+       if (close_stream) {
+@@ -233,7 +243,11 @@ trace_dump_trace_begin(void)
+        * screen multiple times, so we only write </trace> tag and close at exit
+        * time.
+        */
++#if defined(HAVE_NOATEXIT)
++      trace_dump_has_begun = TRUE;
++#else
+       atexit(trace_dump_trace_close);
++#endif
+    }
+ 
+    return TRUE;
diff --git a/MesaLib-dfbsd/patches/patch-src_gallium_include_pipe_p__config.h b/MesaLib-dfbsd/patches/patch-src_gallium_include_pipe_p__config.h
new file mode 100644
index 0000000000..f21eab9cf5
--- /dev/null
+++ b/MesaLib-dfbsd/patches/patch-src_gallium_include_pipe_p__config.h
@@ -0,0 +1,31 @@
+$NetBSD$
+
+* Patches for Sparc from FreeBSD ports for mesa-dri 17.2.3.
+
+* Definitions for DragonFly already in upstream source.
+
+--- src/gallium/include/pipe/p_config.h.orig	2017-10-19 12:23:53.000000000 +0000
++++ src/gallium/include/pipe/p_config.h
+@@ -77,6 +77,12 @@
+ #define PIPE_CC_ICL
+ #endif
+ 
++#if defined(__sparc__) || defined(__sparc64__)
++#define PIPE_ARCH_SPARC
++#if defined(__sparc64__)
++#define PIPE_ARCH_SPARC_64
++#endif
++#endif
+ 
+ /*
+  * Processor architecture
+@@ -131,7 +137,8 @@
+ 
+ #if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) || defined(PIPE_ARCH_ARM) || defined(PIPE_ARCH_AARCH64)
+ #define PIPE_ARCH_LITTLE_ENDIAN
+-#elif defined(PIPE_ARCH_PPC) || defined(PIPE_ARCH_PPC_64) || defined(PIPE_ARCH_S390)
++#elif defined(PIPE_ARCH_PPC) || defined(PIPE_ARCH_PPC_64) || defined(PIPE_ARCH_S390) || defined(PIPE_ARCH_SPARC) || defined(PIPE_ARCH_SPARC_64)
++
+ #define PIPE_ARCH_BIG_ENDIAN
+ #endif
+ 
diff --git a/MesaLib-dfbsd/patches/patch-src_gallium_state__trackers_clover_llvm_invocation.cpp b/MesaLib-dfbsd/patches/patch-src_gallium_state__trackers_clover_llvm_invocation.cpp
index 78bd95552c..134357c1cd 100644
--- a/MesaLib-dfbsd/patches/patch-src_gallium_state__trackers_clover_llvm_invocation.cpp
+++ b/MesaLib-dfbsd/patches/patch-src_gallium_state__trackers_clover_llvm_invocation.cpp
@@ -17,7 +17,7 @@ ic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5c_strEv' can not be used when
        return ctx;
     }
  
-+#if defined(__FreeBSD__)
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
 +   const char* cstr(const std::string& str) { return str.c_str(); }
 +#endif
 +
@@ -29,7 +29,7 @@ ic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5c_strEv' can not be used when
        // and must have the .cl extension in order for the CompilerInvocation
        // class to recognize it as an OpenCL source file.
 +
-+#if defined(__FreeBSD__)
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
 +      std::vector<const char *> copts(opts.size());
 +      std::transform(opts.begin(), opts.end(), copts.begin(), cstr);
 +#else
diff --git a/MesaLib-dfbsd/patches/patch-src_gallium_state__trackers_clover_llvm_metadata.hpp b/MesaLib-dfbsd/patches/patch-src_gallium_state__trackers_clover_llvm_metadata.hpp
index 8c649afb8d..320f520a78 100644
--- a/MesaLib-dfbsd/patches/patch-src_gallium_state__trackers_clover_llvm_metadata.hpp
+++ b/MesaLib-dfbsd/patches/patch-src_gallium_state__trackers_clover_llvm_metadata.hpp
@@ -11,7 +11,7 @@ From FreeBSD ports graphics/libGL mesa 13.0.5
           get_kernel_nodes(const ::llvm::Module &mod) {
              if (const ::llvm::NamedMDNode *n =
                     mod.getNamedMetadata("opencl.kernels"))
-+#if defined(__FreeBSD__)
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
 +               return { n->getOperand(0), n->getOperand(n->getNumOperands()) };
 +#else
                 return { n->op_begin(), n->op_end() };
diff --git a/MesaLib-dfbsd/patches/patch-src_gallium_state__trackers_clover_util_range.hpp b/MesaLib-dfbsd/patches/patch-src_gallium_state__trackers_clover_util_range.hpp
new file mode 100644
index 0000000000..4382079330
--- /dev/null
+++ b/MesaLib-dfbsd/patches/patch-src_gallium_state__trackers_clover_util_range.hpp
@@ -0,0 +1,40 @@
+$NetBSD$
+
+From FreeBSD ports for mesa 17.1.10:
+
+From b95533b981af9a6687b41418e7cc2a5652fc2bdb Mon Sep 17 00:00:00 2001
+Date: Fri, 7 Mar 2014 15:16:08 +0100
+Subject: [PATCH 3/3] Work around for clang 3.4 which fails to build Clover
+
+See:
+  https://bugs.freedesktop.org/show_bug.cgi?id=74098#c3
+
+--- src/gallium/state_trackers/clover/util/range.hpp.orig	2017-09-25 16:56:19.000000000 +0000
++++ src/gallium/state_trackers/clover/util/range.hpp
+@@ -362,6 +362,14 @@ namespace clover {
+       return { i, i + n };
+    }
+ 
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++   namespace detail {
++      template<typename T>
++      using fixup_function_type =
++         typename std::conditional<std::is_function<T>::value, T &, T>::type;
++   }
++#endif
++
+    ///
+    /// Create a range by transforming the contents of a number of
+    /// source ranges \a rs element-wise using a provided functor \a f.
+@@ -369,7 +377,11 @@ namespace clover {
+    /// \sa adaptor_range.
+    ///
+    template<typename F, typename... Rs>
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++   adaptor_range<detail::fixup_function_type<F>, Rs...>
++#else
+    adaptor_range<F, Rs...>
++#endif
+    map(F &&f, Rs &&... rs) {
+       return { std::forward<F>(f), std::forward<Rs>(rs)... };
+    }
diff --git a/MesaLib-dfbsd/patches/patch-src_gallium_targets_dri_Makefile.in b/MesaLib-dfbsd/patches/patch-src_gallium_targets_dri_Makefile.in
index 83534c76ec..5265fba72d 100644
--- a/MesaLib-dfbsd/patches/patch-src_gallium_targets_dri_Makefile.in
+++ b/MesaLib-dfbsd/patches/patch-src_gallium_targets_dri_Makefile.in
@@ -3,18 +3,16 @@ $NetBSD: patch-src_gallium_targets_dri_Makefile.in,v 1.1 2015/04/25 11:19:18 tnn
 DRI drivers need explicit linkage to glapi. FDO bug 57702. We only need to do
 this for the "mega" drivers since that's where final linking takes place.
 
---- src/gallium/targets/dri/Makefile.in.orig	2017-05-10 14:14:10.000000000 +0000
+--- src/gallium/targets/dri/Makefile.in.orig	2018-01-18 21:30:40.000000000 +0000
 +++ src/gallium/targets/dri/Makefile.in
-@@ -783,8 +783,10 @@ GALLIUM_TARGET_CFLAGS = \
+@@ -813,7 +813,9 @@ GALLIUM_TARGET_CFLAGS = \
  	$(LIBDRM_CFLAGS) \
  	$(VISIBILITY_CFLAGS)
  
 -GALLIUM_COMMON_LIB_DEPS = -lm $(LIBUNWIND_LIBS) $(LIBSENSORS_LIBS) \
--	$(CLOCK_LIB) $(PTHREAD_LIBS) $(DLOPEN_LIBS) $(am__append_1)
 +GALLIUM_COMMON_LIB_DEPS = \
 +	$(top_srcdir)/src/mapi/shared-glapi/libglapi.la \
-+	-lm \
-+	$(LIBUNWIND_LIBS) $(LIBSENSORS_LIBS) $(CLOCK_LIB) $(PTHREAD_LIBS) $(DLOPEN_LIBS) $(am__append_1)
++	-lm $(LIBUNWIND_LIBS) $(LIBSENSORS_LIBS) \
+ 	$(CLOCK_LIB) $(PTHREAD_LIBS) $(DLOPEN_LIBS) $(am__append_1)
  GALLIUM_WINSYS_CFLAGS = \
  	-I$(top_srcdir)/src \
- 	-I$(top_srcdir)/include \
diff --git a/MesaLib-dfbsd/patches/patch-src_gallium_winsys_radeon_drm_radeon__drm__winsys.c b/MesaLib-dfbsd/patches/patch-src_gallium_winsys_radeon_drm_radeon__drm__winsys.c
index 5843681912..7e42d9be7f 100644
--- a/MesaLib-dfbsd/patches/patch-src_gallium_winsys_radeon_drm_radeon__drm__winsys.c
+++ b/MesaLib-dfbsd/patches/patch-src_gallium_winsys_radeon_drm_radeon__drm__winsys.c
@@ -1,17 +1,17 @@
-$NetBSD$
+$NetBSD: patch-src_gallium_winsys_radeon_drm_radeon__drm__winsys.c,v 1.1 2015/04/25 11:19:18 tnn Exp $
 
 Don't create pipe thread on NetBSD. It triggers some kernel bug.
 kern/49838.
 
---- src/gallium/winsys/radeon/drm/radeon_drm_winsys.c.orig	2017-02-13 11:55:49.000000000 +0000
+--- src/gallium/winsys/radeon/drm/radeon_drm_winsys.c.orig	2017-10-19 12:23:53.000000000 +0000
 +++ src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
-@@ -821,8 +821,10 @@ radeon_drm_winsys_create(int fd, radeon_
+@@ -824,8 +824,10 @@ radeon_drm_winsys_create(int fd, unsigne
      /* TTM aligns the BO size to the CPU page size */
      ws->info.gart_page_size = sysconf(_SC_PAGESIZE);
  
 +#if !defined(__NetBSD__)
      if (ws->num_cpus > 1 && debug_get_option_thread())
-         util_queue_init(&ws->cs_queue, "radeon_cs", 8, 1);
+         util_queue_init(&ws->cs_queue, "radeon_cs", 8, 1, 0);
 +#endif
  
      /* Create the screen at the end. The winsys must be initialized
diff --git a/MesaLib-dfbsd/patches/patch-src_gallium_winsys_svga_drm_vmw__screen__ioctl.c b/MesaLib-dfbsd/patches/patch-src_gallium_winsys_svga_drm_vmw__screen__ioctl.c
deleted file mode 100644
index c1e0382461..0000000000
--- a/MesaLib-dfbsd/patches/patch-src_gallium_winsys_svga_drm_vmw__screen__ioctl.c
+++ /dev/null
@@ -1,32 +0,0 @@
-$NetBSD: patch-src_gallium_winsys_svga_drm_vmw__screen__ioctl.c,v 1.3 2015/05/15 14:27:42 nros Exp $
-
-Make sure ERESTART gets defined.
-
---- src/gallium/winsys/svga/drm/vmw_screen_ioctl.c.orig	2017-05-25 07:13:13.000000000 +0000
-+++ src/gallium/winsys/svga/drm/vmw_screen_ioctl.c
-@@ -48,9 +48,25 @@
- 
- #include "os/os_mman.h"
- 
-+#if defined(__NetBSD__)
-+#define _KMEMUSER
-+#endif
-+
- #include <errno.h>
- #include <unistd.h>
- 
-+#if defined(__NetBSD__)
-+#if !defined(ERESTART)
-+#define ERESTART (-3)
-+#endif
-+#endif
-+
-+#if defined(__FreeBSD__) || defined(__DragonFly__)
-+#if !defined(ERESTART)
-+#define ERESTART (-1)
-+#endif
-+#endif
-+
- #define VMW_MAX_DEFAULT_TEXTURE_SIZE   (128 * 1024 * 1024)
- #define VMW_FENCE_TIMEOUT_SECONDS 60
- 
diff --git a/MesaLib-dfbsd/patches/patch-src_gbm_Makefile.am b/MesaLib-dfbsd/patches/patch-src_gbm_Makefile.am
new file mode 100644
index 0000000000..12d1e83088
--- /dev/null
+++ b/MesaLib-dfbsd/patches/patch-src_gbm_Makefile.am
@@ -0,0 +1,12 @@
+$NetBSD$
+
+--- src/gbm/Makefile.am.orig	2017-11-20 14:25:47.000000000 +0000
++++ src/gbm/Makefile.am
+@@ -28,6 +28,7 @@ libgbm_la_LIBADD = \
+ 	$(top_builddir)/src/loader/libloader.la \
+ 	$(top_builddir)/src/util/libmesautil.la \
+ 	$(top_builddir)/src/util/libxmlconfig.la \
++	$(PTHREAD_LIBS) \
+ 	$(DLOPEN_LIBS)
+ 
+ if HAVE_PLATFORM_WAYLAND
diff --git a/MesaLib-dfbsd/patches/patch-src_gbm_Makefile.in b/MesaLib-dfbsd/patches/patch-src_gbm_Makefile.in
new file mode 100644
index 0000000000..e161ce1aee
--- /dev/null
+++ b/MesaLib-dfbsd/patches/patch-src_gbm_Makefile.in
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/gbm/Makefile.in.orig	2018-02-09 02:18:14.000000000 +0000
++++ src/gbm/Makefile.in
+@@ -756,7 +756,7 @@ libgbm_la_LDFLAGS = \
+ 
+ libgbm_la_LIBADD = $(top_builddir)/src/loader/libloader.la \
+ 	$(top_builddir)/src/util/libmesautil.la \
+-	$(top_builddir)/src/util/libxmlconfig.la $(DLOPEN_LIBS) \
++	$(top_builddir)/src/util/libxmlconfig.la $(DLOPEN_LIBS) $(PTHREAD_LIBS) \
+ 	$(am__append_2) $(am__append_5)
+ TESTS = gbm-symbols-check
+ EXTRA_DIST = gbm-symbols-check meson.build
diff --git a/MesaLib-dfbsd/patches/patch-src_glx_apple_apple__glapi.c b/MesaLib-dfbsd/patches/patch-src_glx_apple_apple__glapi.c
index 6e538e67aa..b71d4f9b51 100644
--- a/MesaLib-dfbsd/patches/patch-src_glx_apple_apple__glapi.c
+++ b/MesaLib-dfbsd/patches/patch-src_glx_apple_apple__glapi.c
@@ -3,7 +3,7 @@ $NetBSD: patch-src_glx_apple_apple__glapi.c,v 1.1 2015/09/27 21:58:03 tnn Exp $
 https://bugs.freedesktop.org/show_bug.cgi?id=90311
 See also hacks.mk.
 
---- src/glx/apple/apple_glapi.c.orig	2015-08-07 17:36:03.000000000 +0000
+--- src/glx/apple/apple_glapi.c.orig	2018-02-09 02:17:59.000000000 +0000
 +++ src/glx/apple/apple_glapi.c
 @@ -39,6 +39,7 @@
  #include <GL/gl.h>
@@ -12,8 +12,8 @@ See also hacks.mk.
 +#include "main/remap.h"
  #include "glapi.h"
  #include "glapitable.h"
- #include "main/dispatch.h"
-@@ -54,6 +55,8 @@ static void _apple_glapi_create_table(vo
+ 
+@@ -53,6 +54,8 @@ static void _apple_glapi_create_table(vo
      if (__applegl_api)
          return;
  
diff --git a/MesaLib-dfbsd/patches/patch-src_glx_dri__glx.c b/MesaLib-dfbsd/patches/patch-src_glx_dri__glx.c
new file mode 100644
index 0000000000..3cc568348f
--- /dev/null
+++ b/MesaLib-dfbsd/patches/patch-src_glx_dri__glx.c
@@ -0,0 +1,43 @@
+$NetBSD$
+
+atexit() is not a good idea in shared libraries.
+
+FreeBSD reported atexit bug for 10.6:
+https://bugs.freedesktop.org/show_bug.cgi?id=91869
+
+--- src/glx/dri_glx.c.orig	2018-01-18 21:30:28.000000000 +0000
++++ src/glx/dri_glx.c
+@@ -183,9 +183,21 @@ static struct driver_config_entry *drive
+ /* Called as an atexit function. Otherwise, this would have to be called with
+  * driver_config_mutex locked.
+  */
++#if defined(HAVE_NOATEXIT)
++static Bool e_next_ever_null = False;
++
++static void __attribute__((__destructor__))
++#else
+ static void
++#endif
+ clear_driver_config_cache()
+ {
++
++#if defined(HAVE_NOATEXIT)
++   if (!e_next_ever_null)
++      return;
++#endif
++
+    while (driver_config_cache) {
+       struct driver_config_entry *e = driver_config_cache;
+       driver_config_cache = e->next;
+@@ -276,7 +288,11 @@ glXGetDriverConfig(const char *driverNam
+    driver_config_cache = e;
+ 
+    if (!e->next)
++#if defined(HAVE_NOATEXIT)
++      e_next_ever_null = True;
++#else
+       atexit(clear_driver_config_cache);
++#endif
+ 
+ out:
+    pthread_mutex_unlock(&driver_config_mutex);
diff --git a/MesaLib-dfbsd/patches/patch-src_glx_glxcurrent.c b/MesaLib-dfbsd/patches/patch-src_glx_glxcurrent.c
index 86406e4b4e..3e1b8ee451 100644
--- a/MesaLib-dfbsd/patches/patch-src_glx_glxcurrent.c
+++ b/MesaLib-dfbsd/patches/patch-src_glx_glxcurrent.c
@@ -5,10 +5,10 @@ Interim fix for toolchain/50277.
 NetBSD only supports zero-initialized initial-exec tls variables in conjuction
 with dlopen(3) at the moment.
 
---- src/glx/glxcurrent.c.orig	2015-09-02 17:06:23.000000000 +0000
+--- src/glx/glxcurrent.c.orig	2018-02-09 02:17:59.000000000 +0000
 +++ src/glx/glxcurrent.c
 @@ -40,6 +40,18 @@
- #include "glapi.h"
+ #include "glx_error.h"
  
  /*
 + * MASSIVE KLUDGE!
diff --git a/MesaLib-dfbsd/patches/patch-src_glx_glxext.c b/MesaLib-dfbsd/patches/patch-src_glx_glxext.c
index dd813cf19b..df6c6feedc 100644
--- a/MesaLib-dfbsd/patches/patch-src_glx_glxext.c
+++ b/MesaLib-dfbsd/patches/patch-src_glx_glxext.c
@@ -1,20 +1,47 @@
 $NetBSD$
 
-Patch from FreeBSD ports graphics/mesa-dri 17.1.0
+* Patch from FreeBSD ports graphics/mesa-dri 18.0.0
 
 # work-around for https://bugs.freedesktop.org/show_bug.cgi?id=100627
 
---- src/glx/glxext.c.orig	2017-05-25 07:13:13.000000000 +0000
+* Extended to DragonFly and NetBSD.  Other OSes might need this as well.
+
+* Added logging statements to note dri3 initialization being invoked.
+
+--- src/glx/glxext.c.orig	2017-12-08 13:49:11.000000000 +0000
 +++ src/glx/glxext.c
-@@ -906,7 +906,11 @@ __glXInitialize(Display * dpy)
+@@ -55,6 +55,7 @@
+ #include <xcb/xcb.h>
+ #include <xcb/glx.h>
+ 
++#include "dri_common.h"
+ 
+ #ifdef DEBUG
+ void __glXDumpDrawBuffer(struct glx_context * ctx);
+@@ -817,7 +818,11 @@ AllocAndFetchScreenConfigs(Display * dpy
+ #if defined(GLX_USE_DRM)
+ #if defined(HAVE_DRI3)
+       if (priv->dri3Display)
++         InfoMessageF("glxext.c: AllocAndFetchScreenConfigs: priv->dri3Display\n");
++      if (priv->dri3Display)
+          psc = (*priv->dri3Display->createScreen) (i, priv);
++      if (psc != NULL && priv->dri3Display)
++         InfoMessageF("glxext.c: AllocAndFetchScreenConfigs: psc set by priv->dri3Display\n");
+ #endif /* HAVE_DRI3 */
+       if (psc == NULL && priv->dri2Display)
+ 	 psc = (*priv->dri2Display->createScreen) (i, priv);
+@@ -920,8 +925,13 @@ __glXInitialize(Display * dpy)
  #if defined(GLX_USE_DRM)
     if (glx_direct && glx_accel) {
  #if defined(HAVE_DRI3)
-+#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) || defined(__NetBSD__)) && !defined (__DRM_NEXT__)
-+      if (getenv("LIBGL_DRI3_ENABLE") && !getenv("LIBGL_DRI3_DISABLE"))
-+#else
-       if (!getenv("LIBGL_DRI3_DISABLE"))
+-      if (!env_var_as_boolean("LIBGL_DRI3_DISABLE", false))
++#if ((defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) && !defined(__DRM_NEXT__)) || defined(__DragonFly__) || defined(__NetBSD__)
++      if (env_var_as_boolean("LIBGL_DRI3_ENABLE", false))
 +#endif
++      if (!env_var_as_boolean("LIBGL_DRI3_DISABLE", false)) {
++         InfoMessageF("glxext.c: __glxInitialize: dpyPriv->dri3Display = dri3_create_display\n");
           dpyPriv->dri3Display = dri3_create_display(dpy);
++      }
  #endif /* HAVE_DRI3 */
        dpyPriv->dri2Display = dri2CreateDisplay(dpy);
+       dpyPriv->driDisplay = driCreateDisplay(dpy);
diff --git a/MesaLib-dfbsd/patches/patch-src_intel_Makefile.in b/MesaLib-dfbsd/patches/patch-src_intel_Makefile.in
new file mode 100644
index 0000000000..90af9a8997
--- /dev/null
+++ b/MesaLib-dfbsd/patches/patch-src_intel_Makefile.in
@@ -0,0 +1,22 @@
+$NetBSD$
+
+From FreeBSD ports / DragonFly dports graphics/mesa-dri 17.3.1.
+
+../../src/util/.libs/libmesautil.a(libmesautil_la-half_float.o): In function `_mesa_float_to_half':
+half_float.c:(.text+0x94): undefined reference to `lrintf'
+half_float.c:(.text+0xbf): undefined reference to `lrintf'
+cc: error: linker command failed with exit code 1 (use -v to see invocation)
+gmake[5]: *** [Makefile:2706: tools/aubinator_error_decode] Error 1
+
+--- src/intel/Makefile.in.orig	2018-01-18 21:30:42.000000000 +0000
++++ src/intel/Makefile.in
+@@ -1978,7 +1978,8 @@ tools_aubinator_error_decode_LDADD = \
+ 	compiler/libintel_compiler.la \
+ 	$(top_builddir)/src/util/libmesautil.la \
+ 	$(PTHREAD_LIBS) \
+-	$(ZLIB_LIBS)
++	$(ZLIB_LIBS) \
++	-lm
+ 
+ tools_aubinator_error_decode_CFLAGS = \
+ 	$(AM_CFLAGS) \
diff --git a/MesaLib-dfbsd/patches/patch-src_intel_compiler_brw__fs__bank__conflicts.cpp b/MesaLib-dfbsd/patches/patch-src_intel_compiler_brw__fs__bank__conflicts.cpp
new file mode 100644
index 0000000000..4e9ad6e596
--- /dev/null
+++ b/MesaLib-dfbsd/patches/patch-src_intel_compiler_brw__fs__bank__conflicts.cpp
@@ -0,0 +1,23 @@
+$NetBSD$
+
+https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=225415
+FreeBSD Bugzilla: Bug 225415 graphics/mesa-dri: update to 18.0.0
+
+compiler/brw_fs_bank_conflicts.cpp:719:25: error: scalar initializer cannot be empty
+      vector_type s_p = {}, s_n = {};
+                        ^~
+compiler/brw_fs_bank_conflicts.cpp:719:35: error: scalar initializer cannot be empty
+      vector_type s_p = {}, s_n = {};
+                                  ^~
+
+--- src/intel/compiler/brw_fs_bank_conflicts.cpp.orig	2018-02-09 02:17:59.000000000 +0000
++++ src/intel/compiler/brw_fs_bank_conflicts.cpp
+@@ -716,7 +716,7 @@ namespace {
+                    const weight_vector_type &conflicts)
+    {
+       const unsigned m = DIV_ROUND_UP(conflicts.size, vector_width);
+-      vector_type s_p = {}, s_n = {};
++      vector_type s_p = {0}, s_n = {0};
+ 
+       for (unsigned r = 0; r < m; r++) {
+          s_p = adds(s_p, mask(bank_mask_p.v[r], conflicts.v[r]));
diff --git a/MesaLib-dfbsd/patches/patch-src_intel_tools_aubinator.c b/MesaLib-dfbsd/patches/patch-src_intel_tools_aubinator.c
index d7a2480d6b..2dfb71cb3e 100644
--- a/MesaLib-dfbsd/patches/patch-src_intel_tools_aubinator.c
+++ b/MesaLib-dfbsd/patches/patch-src_intel_tools_aubinator.c
@@ -5,14 +5,14 @@ From FreeBSD ports graphics/libGL mesa 13.0.5
 # We don't have MAP_NORESERVE so use MAP_NOSYNC | MAP_NOCORE and
 # hope for the best (this alloc is too big but it's only a test)
 
---- src/intel/tools/aubinator.c.orig	2017-02-13 11:55:49.000000000 +0000
+--- src/intel/tools/aubinator.c.orig	2018-01-09 16:03:43.000000000 +0000
 +++ src/intel/tools/aubinator.c
-@@ -1298,8 +1298,14 @@ int main(int argc, char *argv[])
+@@ -1236,8 +1236,14 @@ int main(int argc, char *argv[])
  
     /* mmap a terabyte for our gtt space. */
     gtt_size = 1ull << 40;
 +/* MAP_NORESERVE removed in FreeBSD 11 and never was implemented before */
-+#if defined(__FreeBSD__) || defined(__DragonFly__)
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
 +   gtt = mmap(NULL, gtt_size, PROT_READ | PROT_WRITE,
 +              MAP_PRIVATE | MAP_ANONYMOUS |  MAP_NOSYNC | MAP_NOCORE, -1, 0);
 +#else
diff --git a/MesaLib-dfbsd/patches/patch-src_intel_vulkan_anv__allocator.c b/MesaLib-dfbsd/patches/patch-src_intel_vulkan_anv__allocator.c
new file mode 100644
index 0000000000..23f834d22e
--- /dev/null
+++ b/MesaLib-dfbsd/patches/patch-src_intel_vulkan_anv__allocator.c
@@ -0,0 +1,62 @@
+$NetBSD$
+
+* Partially implement memfd_create() via mkostemp()
+* Ignore MAP_POPULATE if unsupported
+
+FreeBSD Bugzilla - Bug 225415: graphics/mesa-dri: update to 18.0.0
+https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=225415
+
+--- src/intel/vulkan/anv_allocator.c.orig	2018-02-09 02:17:59.000000000 +0000
++++ src/intel/vulkan/anv_allocator.c
+@@ -25,9 +25,21 @@
+ #include <unistd.h>
+ #include <limits.h>
+ #include <assert.h>
++#ifdef __linux__
+ #include <linux/memfd.h>
++#else
++#include <fcntl.h>
++#endif
+ #include <sys/mman.h>
+ 
++#ifndef MAP_POPULATE
++#define MAP_POPULATE 0
++#endif
++
++#ifndef MFD_CLOEXEC
++#define MFD_CLOEXEC O_CLOEXEC
++#endif
++
+ #include "anv_private.h"
+ 
+ #include "util/hash_table.h"
+@@ -113,7 +125,29 @@ struct anv_mmap_cleanup {
+ static inline int
+ memfd_create(const char *name, unsigned int flags)
+ {
++#if defined(__linux__)
+    return syscall(SYS_memfd_create, name, flags);
++#elif defined(__FreeBSD__)
++   return shm_open(SHM_ANON, flags | O_RDWR | O_CREAT, 0600);
++#else /* DragonFly, NetBSD, OpenBSD, Solaris */
++   char template[] = "/tmp/shmfd-XXXXXX";
++#ifdef HAVE_MKOSTEMP
++   int fd = mkostemp(template, flags);
++#else
++   int fd = mkstemp(template);
++   if (flags & O_CLOEXEC) {
++      int flags = fcntl(fd, F_GETFD);
++      if (flags != -1) {
++         flags |= FD_CLOEXEC;
++         (void) fcntl(fd, F_SETFD, &flags);
++      }
++   }
++#endif /* HAVE_MKOSTEMP */
++   if (fd >= 0)
++      unlink(template);
++
++   return fd;
++#endif /* __linux__ */
+ }
+ #endif
+ 
diff --git a/MesaLib-dfbsd/patches/patch-src_intel_vulkan_anv__device.c b/MesaLib-dfbsd/patches/patch-src_intel_vulkan_anv__device.c
new file mode 100644
index 0000000000..93ce5d4a30
--- /dev/null
+++ b/MesaLib-dfbsd/patches/patch-src_intel_vulkan_anv__device.c
@@ -0,0 +1,46 @@
+$NetBSD$
+
+* Without sysinfo() fall back to sysconf()
+* Define ETIME if missing
+
+FreeBSD Bugzilla - Bug 225415: graphics/mesa-dri: update to 18.0.0
+https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=225415
+
+--- src/intel/vulkan/anv_device.c.orig	2018-02-09 02:17:59.000000000 +0000
++++ src/intel/vulkan/anv_device.c
+@@ -25,7 +25,9 @@
+ #include <stdbool.h>
+ #include <string.h>
+ #include <sys/mman.h>
++#ifdef __GLIBC__
+ #include <sys/sysinfo.h>
++#endif
+ #include <unistd.h>
+ #include <fcntl.h>
+ #include <xf86drm.h>
+@@ -40,6 +42,10 @@
+ 
+ #include "genxml/gen7_pack.h"
+ 
++#ifndef ETIME
++#define ETIME ETIMEDOUT
++#endif
++
+ static void
+ compiler_debug_log(void *data, const char *fmt, ...)
+ { }
+@@ -75,10 +81,14 @@ anv_compute_heap_size(int fd, uint64_t *
+    }
+ 
+    /* Query the total ram from the system */
++#ifdef __GLIBC__
+    struct sysinfo info;
+    sysinfo(&info);
+ 
+    uint64_t total_ram = (uint64_t)info.totalram * (uint64_t)info.mem_unit;
++#else
++   uint64_t total_ram = sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGE_SIZE);
++#endif
+ 
+    /* We don't want to burn too much ram with the GPU.  If the user has 4GiB
+     * or less, we use at most half.  If they have more than 4GiB, we use 3/4.
diff --git a/MesaLib-dfbsd/patches/patch-src_intel_vulkan_anv__gem.c b/MesaLib-dfbsd/patches/patch-src_intel_vulkan_anv__gem.c
new file mode 100644
index 0000000000..be78e8d6ca
--- /dev/null
+++ b/MesaLib-dfbsd/patches/patch-src_intel_vulkan_anv__gem.c
@@ -0,0 +1,19 @@
+$NetBSD$
+
+* Define ETIME if missing
+
+FreeBSD Bugzilla - Bug 225415: graphics/mesa-dri: update to 18.0.0
+https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=225415
+
+--- src/intel/vulkan/anv_gem.c.orig	2018-02-09 02:17:59.000000000 +0000
++++ src/intel/vulkan/anv_gem.c
+@@ -26,6 +26,9 @@
+ #include <sys/mman.h>
+ #include <string.h>
+ #include <errno.h>
++#ifndef ETIME
++#define ETIME ETIMEDOUT
++#endif
+ #include <unistd.h>
+ #include <fcntl.h>
+ 
diff --git a/MesaLib-dfbsd/patches/patch-src_intel_vulkan_anv__queue.c b/MesaLib-dfbsd/patches/patch-src_intel_vulkan_anv__queue.c
new file mode 100644
index 0000000000..e529c7854a
--- /dev/null
+++ b/MesaLib-dfbsd/patches/patch-src_intel_vulkan_anv__queue.c
@@ -0,0 +1,25 @@
+$NetBSD$
+
+* Define ETIME if missing
+* Drop header that was never used (modified for Linux inclusion)
+
+FreeBSD Bugzilla - Bug 225415: graphics/mesa-dri: update to 18.0.0
+https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=225415
+
+--- src/intel/vulkan/anv_queue.c.orig	2018-02-09 02:17:59.000000000 +0000
++++ src/intel/vulkan/anv_queue.c
+@@ -26,8 +26,14 @@
+  */
+ 
+ #include <fcntl.h>
++#include <errno.h>
++#ifndef ETIME
++#define ETIME ETIMEDOUT
++#endif
+ #include <unistd.h>
++#if defined(__linux__)
+ #include <sys/eventfd.h>
++#endif
+ 
+ #include "anv_private.h"
+ #include "vk_util.h"
diff --git a/MesaLib-dfbsd/patches/patch-src_mapi_entry.c b/MesaLib-dfbsd/patches/patch-src_mapi_entry.c
deleted file mode 100644
index bbbd0dd15b..0000000000
--- a/MesaLib-dfbsd/patches/patch-src_mapi_entry.c
+++ /dev/null
@@ -1,1620 +0,0 @@
-$NetBSD$
-
-For some reason the previously used table_noop_array has a link error.
-
-HACK: Create new array of noop functions.
-BUG: Using environment variable LIBGL_DEBUG=verbose causes
-massive failure in keyboard input for a Radeon 6450 (CAICOS) card.
-
---- src/mapi/entry.c.orig	2016-11-10 22:05:17.000000000 +0000
-+++ src/mapi/entry.c
-@@ -41,6 +41,1609 @@
- #define ENTRY_CURRENT_TABLE_GET U_STRINGIFY(u_current_get_table_internal)
- #endif
- 
-+#if defined(__NetBSD__) && defined(GLX_USE_TLS)
-+static int netbsd_noop_generic(void) {
-+    return 0;
-+}
-+
-+/*
-+ * src/mapi/table.h defines
-+ *    MAPI_TABLE_NUM_SLOTS to be 
-+ *      MAPI_TABLE_NUM_STATIC + MAPI_TABLE_NUM_DYNAMIC
-+ *       = 1330 + 256 = 1586 entries
-+ * according to values from mapi/shared-glapi/glapi_mapi_tmp.h
-+ */
-+
-+const mapi_func netbsd_table_noop_array[] = {
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic,
-+    (mapi_func)netbsd_noop_generic
-+};
-+#endif /* defined(__NetBSD__) && defined(GLX_USE_TLS) */
-+
- #if defined(USE_X86_ASM) && defined(__GNUC__)
- #   ifdef GLX_USE_TLS
- #      include "entry_x86_tls.h"
diff --git a/MesaLib-dfbsd/patches/patch-src_mapi_entry__x86-64__tls.h b/MesaLib-dfbsd/patches/patch-src_mapi_entry__x86-64__tls.h
index 0a4d04a87a..35d6ce0c0d 100644
--- a/MesaLib-dfbsd/patches/patch-src_mapi_entry__x86-64__tls.h
+++ b/MesaLib-dfbsd/patches/patch-src_mapi_entry__x86-64__tls.h
@@ -5,21 +5,21 @@ with dlopen(3) at the moment.
 
 Fix --enable-glx-tls with clang. From FreeBSD.
 
-HACK: Renamed non-linking table_noop_array to locally created
-netbsd_table_noop_array.
+table_noop_array is only defined for shared-glapi.
+es1api and es2api are not going to be patched for NetBSD.
 
---- src/mapi/entry_x86-64_tls.h.orig	2017-01-25 13:26:34.000000000 +0000
+--- src/mapi/entry_x86-64_tls.h.orig	2017-11-20 14:25:47.000000000 +0000
 +++ src/mapi/entry_x86-64_tls.h
 @@ -43,10 +43,19 @@ __asm__(".text\n"
  
  #ifndef __ILP32__
  
-+#if defined(__NetBSD__) && defined(GLX_USE_TLS)
++#if defined(__NetBSD__) && defined(MAPI_MODE_GLAPI)
  #define STUB_ASM_CODE(slot)                              \
     "movq " ENTRY_CURRENT_TABLE "@GOTTPOFF(%rip), %rax\n\t"  \
     "movq %fs:(%rax), %r11\n\t"                           \
 +   "testq %r11, %r11\n\t"                                \
-+   "cmoveq netbsd_table_noop_array @GOTPCREL(%rip), %r11\n\t"    \
++   "cmoveq table_noop_array@GOTPCREL(%rip), %r11\n\t"    \
     "jmp *(8 * " slot ")(%r11)"
 +#else
 +#define STUB_ASM_CODE(slot)                              \
diff --git a/MesaLib-dfbsd/patches/patch-src_mapi_entry__x86__tls.h b/MesaLib-dfbsd/patches/patch-src_mapi_entry__x86__tls.h
index 2013d314d6..720af26bc7 100644
--- a/MesaLib-dfbsd/patches/patch-src_mapi_entry__x86__tls.h
+++ b/MesaLib-dfbsd/patches/patch-src_mapi_entry__x86__tls.h
@@ -5,17 +5,17 @@ with dlopen(3) at the moment.
 
 Fix --enable-glx-tls with clang. From FreeBSD.
 
-HACK: Renamed non-linking table_noop_array to locally created
-netbsd_table_noop_array.
+table_noop_array is only defined for shared-glapi.
+es1api and es2api are not going to be patched for NetBSD.
 
---- src/mapi/entry_x86_tls.h.orig	2016-11-10 22:05:17.000000000 +0000
+--- src/mapi/entry_x86_tls.h.orig	2018-01-18 21:30:29.000000000 +0000
 +++ src/mapi/entry_x86_tls.h
 @@ -56,10 +56,27 @@ __asm__(".balign 16\n"
     ".balign 16\n"                \
     func ":"
  
-+#if defined(__NetBSD__) && defined(GLX_USE_TLS)
-+extern const mapi_func netbsd_table_noop_array[];
++#if defined(__NetBSD__) && defined(MAPI_MODE_GLAPI)
++extern const mapi_func table_noop_array[];
  #define STUB_ASM_CODE(slot)      \
     "call x86_current_tls\n\t"    \
     "movl %gs:(%eax), %eax\n\t"   \
@@ -27,7 +27,7 @@ netbsd_table_noop_array.
 +   "2:\n\t"                      \
 +   "popl %eax\n\t"               \
 +   "addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %eax\n\t" \
-+   "movl netbsd_table_noop_array@GOT(%eax), %eax\n\t" \
++   "movl table_noop_array@GOT(%eax), %eax\n\t" \
     "jmp *(4 * " slot ")(%eax)"
 +#else
 +#define STUB_ASM_CODE(slot)      \
diff --git a/MesaLib-dfbsd/patches/patch-src_mapi_glapi_glapi__gentable.c b/MesaLib-dfbsd/patches/patch-src_mapi_glapi_glapi__gentable.c
deleted file mode 100644
index 0838124e27..0000000000
--- a/MesaLib-dfbsd/patches/patch-src_mapi_glapi_glapi__gentable.c
+++ /dev/null
@@ -1,15 +0,0 @@
-$NetBSD$
-
-Why shouldn't FreeBSD define USE_BACKTRACE as well.
-
---- src/mapi/glapi/glapi_gentable.c.orig	2017-02-13 11:56:32.000000000 +0000
-+++ src/mapi/glapi/glapi_gentable.c
-@@ -36,7 +36,7 @@
- #endif
- 
- #if (defined(GLXEXT) && defined(HAVE_BACKTRACE)) \
--	|| (!defined(GLXEXT) && defined(DEBUG) && !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__))
-+	|| (!defined(GLXEXT) && defined(DEBUG) && !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined(__DragonFly__))
- #define USE_BACKTRACE
- #endif
- 
diff --git a/MesaLib-dfbsd/patches/patch-src_mapi_table.h b/MesaLib-dfbsd/patches/patch-src_mapi_table.h
deleted file mode 100644
index 28f2042e94..0000000000
--- a/MesaLib-dfbsd/patches/patch-src_mapi_table.h
+++ /dev/null
@@ -1,15 +0,0 @@
-$NetBSD$
-
---- src/mapi/table.h.orig	2016-11-10 22:05:17.000000000 +0000
-+++ src/mapi/table.h
-@@ -40,7 +40,9 @@
- struct mapi_table;
- 
- extern const mapi_func table_noop_array[];
--
-+#if defined(__NetBSD__) && defined(GLX_USE_TLS)
-+extern const mapi_func netbsd_table_noop_array[];
-+#endif
- 
- typedef void (*nop_handler_proc)(const char *name);
- 
diff --git a/MesaLib-dfbsd/patches/patch-src_mapi_u__current.c b/MesaLib-dfbsd/patches/patch-src_mapi_u__current.c
index 1091eb49e8..d03a829fb3 100644
--- a/MesaLib-dfbsd/patches/patch-src_mapi_u__current.c
+++ b/MesaLib-dfbsd/patches/patch-src_mapi_u__current.c
@@ -7,25 +7,25 @@ with dlopen(3) at the moment.
 +++ src/mapi/u_current.c
 @@ -101,7 +101,11 @@ extern void (*__glapi_noop_table[])(void
  
- __thread struct mapi_table *u_current_table
+ __thread struct _glapi_table *u_current_table
      __attribute__((tls_model("initial-exec")))
 +#if defined(__NetBSD__)
 +    = NULL; /* non-zero initializers not supported with dlopen */
 +#else
-     = (struct mapi_table *) table_noop_array;
+     = (struct _glapi_table *) table_noop_array;
 +#endif
  
  __thread void *u_current_context
      __attribute__((tls_model("initial-exec")));
-@@ -283,7 +287,11 @@ struct mapi_table *
+@@ -283,7 +287,11 @@ struct _glapi_table *
  u_current_get_table_internal(void)
  {
  #if defined(GLX_USE_TLS)
 +#  if defined(__NetBSD__)
-+   return (likely(u_current_table) ? u_current_table : (struct mapi_table *) table_noop_array);
++   return (likely(u_current_table) ? u_current_table : (struct _glapi_table *) table_noop_array);
 +#  else
     return u_current_table;
 +#  endif
  #else
     if (ThreadSafe)
-       return (struct mapi_table *) tss_get(u_current_table_tsd);
+       return (struct _glapi_table *) tss_get(u_current_table_tsd);
diff --git a/MesaLib-dfbsd/patches/patch-src_mapi_u__current.h b/MesaLib-dfbsd/patches/patch-src_mapi_u__current.h
index c137f9122b..dc1ac14d7b 100644
--- a/MesaLib-dfbsd/patches/patch-src_mapi_u__current.h
+++ b/MesaLib-dfbsd/patches/patch-src_mapi_u__current.h
@@ -6,7 +6,7 @@ with dlopen(3) at the moment.
 --- src/mapi/u_current.h.orig	2015-09-02 17:06:23.000000000 +0000
 +++ src/mapi/u_current.h
 @@ -68,7 +68,7 @@ u_current_get_context_internal(void);
- static inline const struct mapi_table *
+ static inline const struct _glapi_table *
  u_current_get_table(void)
  {
 -#ifdef GLX_USE_TLS
diff --git a/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_Makefile.in b/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_Makefile.in
deleted file mode 100644
index 2e50bf1d46..0000000000
--- a/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_Makefile.in
+++ /dev/null
@@ -1,15 +0,0 @@
-$NetBSD$
-
-DRI drivers need explicit linkage to glapi. FDO bug 57702. We only need to do
-this for the "mega" drivers since that's where final linking takes place.
-
---- src/mesa/drivers/dri/Makefile.in.orig	2017-02-13 11:56:03.000000000 +0000
-+++ src/mesa/drivers/dri/Makefile.in
-@@ -609,6 +609,7 @@ mesa_dri_drivers_la_LIBADD = \
-         $(SHARED_GLAPI_LIB) \
-         $(MEGADRIVERS_DEPS) \
-         $(DRI_LIB_DEPS) \
-+        $(top_srcdir)/src/mapi/shared-glapi/libglapi.la \
-         $()
- 
- @NEED_MEGADRIVER_TRUE@dri_LTLIBRARIES = mesa_dri_drivers.la
diff --git a/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_common_Makefile.in b/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_common_Makefile.in
deleted file mode 100644
index 20343a6f75..0000000000
--- a/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_common_Makefile.in
+++ /dev/null
@@ -1,16 +0,0 @@
-$NetBSD: patch-src_mesa_drivers_dri_common_Makefile.in,v 1.1 2015/04/25 11:19:18 tnn Exp $
-
-Don't install the sysconf directory for now.
-
---- src/mesa/drivers/dri/common/Makefile.in.orig	2017-02-13 11:56:03.000000000 +0000
-+++ src/mesa/drivers/dri/common/Makefile.in
-@@ -733,6 +733,9 @@ mostlyclean-libtool:
- clean-libtool:
- 	-rm -rf .libs _libs
- install-sysconfDATA: $(sysconf_DATA)
-+	true
-+
-+disabled-install-sysconfDATA:
- 	@$(NORMAL_INSTALL)
- 	@list='$(sysconf_DATA)'; test -n "$(sysconfdir)" || list=; \
- 	if test -n "$$list"; then \
diff --git a/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_common_xmlconfig.c b/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_common_xmlconfig.c
deleted file mode 100644
index 8df9b313db..0000000000
--- a/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_common_xmlconfig.c
+++ /dev/null
@@ -1,59 +0,0 @@
-$NetBSD: patch-src_mesa_drivers_dri_common_xmlconfig.c,v 1.3 2016/02/23 11:16:55 jperkin Exp $
-
-PR pkg/50202.
-Provide compat strndup for older Darwin.
-
---- src/mesa/drivers/dri/common/xmlconfig.c.orig	2017-05-10 14:13:57.000000000 +0000
-+++ src/mesa/drivers/dri/common/xmlconfig.c
-@@ -50,12 +50,17 @@ extern char *program_invocation_name, *p
- #    define GET_PROGRAM_NAME() program_invocation_short_name
- #elif defined(__CYGWIN__)
- #    define GET_PROGRAM_NAME() program_invocation_short_name
-+/*
- #elif defined(__FreeBSD__) && (__FreeBSD__ >= 2)
- #    include <osreldate.h>
- #    if (__FreeBSD_version >= 440000)
- #        include <stdlib.h>
- #        define GET_PROGRAM_NAME() getprogname()
- #    endif
-+*/
-+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
-+#    include <stdlib.h>
-+#    define GET_PROGRAM_NAME() getprogname()
- #elif defined(__NetBSD__) && defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 106000100)
- #    include <stdlib.h>
- #    define GET_PROGRAM_NAME() getprogname()
-@@ -115,6 +120,24 @@ __getProgramName()
- #    endif
- #endif
- 
-+#if (defined(__APPLE__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0 < 1070)
-+static char *
-+strndup(const char *str, size_t n)
-+{
-+  size_t len;
-+  char *copy;
-+
-+  for (len = 0; len < n && str[len]; len++)
-+    continue;
-+
-+  if ((copy = (char *)malloc(len + 1)) == NULL)
-+    return (NULL);
-+  memcpy(copy, str, len);
-+  copy[len] = '\0';
-+  return (copy);
-+}
-+#endif
-+
- /** \brief Find an option in an option cache with the name as key */
- static uint32_t
- findOption(const driOptionCache *cache, const char *name)
-@@ -980,7 +1003,7 @@ parseOneConfigFile(XML_Parser p)
- }
- 
- #ifndef SYSCONFDIR
--#define SYSCONFDIR "/etc"
-+#define SYSCONFDIR "/usr/pkg/etc"
- #endif
- 
- void
diff --git a/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_i915_intel__screen.c b/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_i915_intel__screen.c
index a1e1a226a7..1007daccb5 100644
--- a/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_i915_intel__screen.c
+++ b/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_i915_intel__screen.c
@@ -6,25 +6,25 @@ to a two argument ALIGN.
 
 Fix build on older NetBSD w/o _SC_PHYS_PAGES.
 
---- src/mesa/drivers/dri/i915/intel_screen.c.orig	2017-02-13 11:55:49.000000000 +0000
+--- src/mesa/drivers/dri/i915/intel_screen.c.orig	2017-11-10 23:18:56.000000000 +0000
 +++ src/mesa/drivers/dri/i915/intel_screen.c
 @@ -28,6 +28,11 @@
  #include <errno.h>
  #include <time.h>
  #include <unistd.h>
 +
-+#ifdef HAVE_SYS_SYSCTL_H
++#if defined(HAVE_SYS_SYSCTL_H) && defined(__NetBSD__)
 +# include <sys/sysctl.h>
 +#endif
 +
  #include "main/glheader.h"
  #include "main/context.h"
  #include "main/framebuffer.h"
-@@ -730,6 +735,13 @@ i915_query_renderer_integer(__DRIscreen
+@@ -739,6 +744,13 @@ i915_query_renderer_integer(__DRIscreen
        const unsigned gpu_mappable_megabytes =
           (aper_size / (1024 * 1024)) * 3 / 4;
  
-+#if defined(HW_PHYSMEM64)
++#if defined(HW_PHYSMEM64) && defined(__NetBSD__)
 +      int mib[2] = { CTL_HW, HW_PHYSMEM64 };
 +      uint64_t system_memory_bytes;
 +      size_t len = sizeof(system_memory_bytes);
@@ -34,7 +34,7 @@ Fix build on older NetBSD w/o _SC_PHYS_PAGES.
        const long system_memory_pages = sysconf(_SC_PHYS_PAGES);
        const long system_page_size = sysconf(_SC_PAGE_SIZE);
  
-@@ -738,6 +750,7 @@ i915_query_renderer_integer(__DRIscreen
+@@ -747,6 +759,7 @@ i915_query_renderer_integer(__DRIscreen
  
        const uint64_t system_memory_bytes = (uint64_t) system_memory_pages
           * (uint64_t) system_page_size;
diff --git a/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_i965_brw__performance__query.c b/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_i965_brw__performance__query.c
new file mode 100644
index 0000000000..99588dbe89
--- /dev/null
+++ b/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_i965_brw__performance__query.c
@@ -0,0 +1,16 @@
+$NetBSD$
+
+Prevents libdrm i915_drm.h header from being used.
+libdrm 2.4.88 does not have certain symbols defined in its i915_drm.h.
+
+--- src/mesa/drivers/dri/i965/brw_performance_query.c.orig	2017-10-19 12:23:53.000000000 +0000
++++ src/mesa/drivers/dri/i965/brw_performance_query.c
+@@ -56,7 +56,7 @@
+ #include <sys/ioctl.h>
+ 
+ #include <xf86drm.h>
+-#include <i915_drm.h>
++#include "drm-uapi/i915_drm.h"
+ 
+ #include "main/hash.h"
+ #include "main/macros.h"
diff --git a/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_i965_brw__sync.c b/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_i965_brw__sync.c
deleted file mode 100644
index b7f139b9c9..0000000000
--- a/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_i965_brw__sync.c
+++ /dev/null
@@ -1,17 +0,0 @@
-$NetBSD$
-
-libdrm libsync.h should probably be patched instead for ETIME.
-
---- src/mesa/drivers/dri/i965/brw_sync.c.orig	2017-05-25 07:13:13.000000000 +0000
-+++ src/mesa/drivers/dri/i965/brw_sync.c
-@@ -38,6 +38,10 @@
-  * performance bottleneck, though.
-  */
- 
-+#ifndef ETIME
-+#define ETIME ETIMEDOUT
-+#endif
-+
- #include <libsync.h> /* Requires Android or libdrm-2.4.72 */
- 
- #include "main/imports.h"
diff --git a/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_i965_intel__screen.c b/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_i965_intel__screen.c
index 6f26118442..5fbfbc3f98 100644
--- a/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_i965_intel__screen.c
+++ b/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_i965_intel__screen.c
@@ -6,25 +6,25 @@ to a two argument ALIGN.
 
 Fix build on older NetBSD w/o _SC_PHYS_PAGES.
 
---- src/mesa/drivers/dri/i965/intel_screen.c.orig	2017-05-10 14:13:57.000000000 +0000
+--- src/mesa/drivers/dri/i965/intel_screen.c.orig	2017-11-10 23:18:56.000000000 +0000
 +++ src/mesa/drivers/dri/i965/intel_screen.c
 @@ -27,6 +27,11 @@
  #include <errno.h>
  #include <time.h>
  #include <unistd.h>
 +
-+#ifdef HAVE_SYS_SYSCTL_H
++#if defined(HAVE_SYS_SYSCTL_H) && defined(__NetBSD__)
 +# include <sys/sysctl.h>
 +#endif
 +
  #include "main/context.h"
  #include "main/framebuffer.h"
  #include "main/renderbuffer.h"
-@@ -1019,6 +1024,13 @@ brw_query_renderer_integer(__DRIscreen *
+@@ -1220,6 +1225,13 @@ brw_query_renderer_integer(__DRIscreen *
        const unsigned gpu_mappable_megabytes =
           screen->aperture_threshold / (1024 * 1024);
  
-+#if defined(HW_PHYSMEM64)
++#if defined(HW_PHYSMEM64) && defined(__NetBSD__)
 +      int mib[2] = { CTL_HW, HW_PHYSMEM64 };
 +      const uint64_t system_memory_bytes;
 +      size_t len = sizeof(system_memory_bytes);
@@ -34,7 +34,7 @@ Fix build on older NetBSD w/o _SC_PHYS_PAGES.
        const long system_memory_pages = sysconf(_SC_PHYS_PAGES);
        const long system_page_size = sysconf(_SC_PAGE_SIZE);
  
-@@ -1027,6 +1039,7 @@ brw_query_renderer_integer(__DRIscreen *
+@@ -1228,6 +1240,7 @@ brw_query_renderer_integer(__DRIscreen *
  
        const uint64_t system_memory_bytes = (uint64_t) system_memory_pages
           * (uint64_t) system_page_size;
diff --git a/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_i965_intel__screen.h b/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_i965_intel__screen.h
new file mode 100644
index 0000000000..e473d4b0f0
--- /dev/null
+++ b/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_i965_intel__screen.h
@@ -0,0 +1,15 @@
+$NetBSD$
+
+libdrm 2.4.88 does not have certain symbols defined in i915_drm.h.
+
+--- src/mesa/drivers/dri/i965/intel_screen.h.orig	2017-11-20 14:25:47.000000000 +0000
++++ src/mesa/drivers/dri/i965/intel_screen.h
+@@ -35,7 +35,7 @@
+ #include "dri_util.h"
+ #include "brw_bufmgr.h"
+ #include "common/gen_device_info.h"
+-#include "i915_drm.h"
++#include "drm-uapi/i915_drm.h"
+ #include "util/xmlconfig.h"
+ 
+ #include "isl/isl.h"
diff --git a/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_i965_intel__tiled__memcpy.c b/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_i965_intel__tiled__memcpy.c
index 8c2201edd8..d0d724be03 100644
--- a/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_i965_intel__tiled__memcpy.c
+++ b/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_i965_intel__tiled__memcpy.c
@@ -1,5 +1,7 @@
 $NetBSD$
 
+From wip/MesaLib 13.0.1.
+
 --- src/mesa/drivers/dri/i965/intel_tiled_memcpy.c.orig	2016-11-10 22:05:17.000000000 +0000
 +++ src/mesa/drivers/dri/i965/intel_tiled_memcpy.c
 @@ -64,6 +64,7 @@ ror(uint32_t n, uint32_t d)
diff --git a/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_swrast_swrast.c b/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_swrast_swrast.c
index 84eda7e33c..75b4fa05dc 100644
--- a/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_swrast_swrast.c
+++ b/MesaLib-dfbsd/patches/patch-src_mesa_drivers_dri_swrast_swrast.c
@@ -2,13 +2,13 @@ $NetBSD: patch-src_mesa_drivers_dri_swrast_swrast.c,v 1.2 2015/06/07 15:48:12 tn
 
 Fix build on older NetBSD w/o _SC_PHYS_PAGES.
 
---- src/mesa/drivers/dri/swrast/swrast.c.orig	2017-02-13 11:55:49.000000000 +0000
+--- src/mesa/drivers/dri/swrast/swrast.c.orig	2017-10-19 12:23:53.000000000 +0000
 +++ src/mesa/drivers/dri/swrast/swrast.c
 @@ -151,6 +151,12 @@ swrast_query_renderer_integer(__DRIscree
          size_t len = sizeof(system_memory_bytes);
          if (sysctl(mib, 2, &system_memory_bytes, &len, NULL, 0) != 0)
              return -1;
-+#elif defined(HW_PHYSMEM64)
++#elif defined(HW_PHYSMEM64) && defined(__NetBSD__)
 +        int mib[2] = { CTL_HW, HW_PHYSMEM64 };
 +        uint64_t system_memory_bytes;
 +        size_t len = sizeof(system_memory_bytes);
diff --git a/MesaLib-dfbsd/patches/patch-src_mesa_main_context.c b/MesaLib-dfbsd/patches/patch-src_mesa_main_context.c
index 7381717f36..5f2bd3704e 100644
--- a/MesaLib-dfbsd/patches/patch-src_mesa_main_context.c
+++ b/MesaLib-dfbsd/patches/patch-src_mesa_main_context.c
@@ -2,40 +2,56 @@ $NetBSD: patch-src_mesa_main_context.c,v 1.3 2015/09/26 08:45:02 tnn Exp $
 
 * Fix exit time segfault of qt5 application with modular xorg
 
---- src/mesa/main/context.c.orig	2017-05-10 14:13:57.000000000 +0000
+Bug 82246 (atexit) - Libraries should not call atexit()
+
+https://bugs.freedesktop.org/show_bug.cgi?id=82246
+
+FreeBSD reported atexit bug for 10.6:
+https://bugs.freedesktop.org/show_bug.cgi?id=91869
+
+--- src/mesa/main/context.c.orig	2017-11-20 14:25:47.000000000 +0000
 +++ src/mesa/main/context.c
-@@ -351,11 +351,14 @@ mtx_t OneTimeLock = _MTX_INITIALIZER_NP;
+@@ -354,11 +354,23 @@ mtx_t OneTimeLock = _MTX_INITIALIZER_NP;
   * Calls all the various one-time-fini functions in Mesa
   */
  
--static void
++#if defined(HAVE_NOATEXIT)
 +static GLbitfield api_init_mask = 0x0;
 +static void __attribute__((__destructor__))
++#else
+ static void
++#endif
  one_time_fini(void)
  {
--   _mesa_destroy_shader_compiler();
--   _mesa_locale_fini();
++#if defined(HAVE_NOATEXIT)
 +   if (api_init_mask) {
 +      _mesa_destroy_shader_compiler();
 +      _mesa_locale_fini();
 +   }
++#else
+    _mesa_destroy_shader_compiler();
+    _mesa_locale_fini();
++#endif
  }
  
  /**
-@@ -370,7 +373,6 @@ one_time_fini(void)
+@@ -373,7 +385,9 @@ one_time_fini(void)
  static void
  one_time_init( struct gl_context *ctx )
  {
--   static GLbitfield api_init_mask = 0x0;
++#if !defined(HAVE_NOATEXIT)
+    static GLbitfield api_init_mask = 0x0;
++#endif
  
     mtx_lock(&OneTimeLock);
  
-@@ -395,8 +397,6 @@ one_time_init( struct gl_context *ctx )
+@@ -398,7 +412,9 @@ one_time_init( struct gl_context *ctx )
           _mesa_ubyte_to_float_color_tab[i] = (float) i / 255.0F;
        }
  
--      atexit(one_time_fini);
--
- #if defined(DEBUG) && defined(__DATE__) && defined(__TIME__)
++#if !defined(HAVE_NOATEXIT)
+       atexit(one_time_fini);
++#endif
+ 
+ #if defined(DEBUG)
        if (MESA_VERBOSE != 0) {
-          _mesa_debug(ctx, "Mesa %s DEBUG build %s %s\n",
diff --git a/MesaLib-dfbsd/patches/patch-src_mesa_main_extensions.c b/MesaLib-dfbsd/patches/patch-src_mesa_main_extensions.c
index 00e5cd0ed7..4088e763c2 100644
--- a/MesaLib-dfbsd/patches/patch-src_mesa_main_extensions.c
+++ b/MesaLib-dfbsd/patches/patch-src_mesa_main_extensions.c
@@ -2,23 +2,30 @@ $NetBSD: patch-src_mesa_main_extensions.c,v 1.1 2016/01/27 07:39:54 wiz Exp $
 
 atexit() is not a good idea in shared libraries.
 
---- src/mesa/main/extensions.c.orig	2017-02-13 11:55:49.000000000 +0000
+FreeBSD reported atexit bug for 10.6:
+https://bugs.freedesktop.org/show_bug.cgi?id=91869
+
+--- src/mesa/main/extensions.c.orig	2018-02-09 02:17:59.000000000 +0000
 +++ src/mesa/main/extensions.c
-@@ -237,7 +237,7 @@ get_extension_override( struct gl_contex
-  * These strings are allocated early during the first context creation by
+@@ -203,7 +203,11 @@ set_extension(struct gl_extensions *ext,
+  * This string is allocated early during the first context creation by
   * _mesa_one_time_init_extension_overrides.
   */
--static void
++#if defined(HAVE_NOATEXIT)
 +static void __attribute__((__destructor__))
++#else
+ static void
++#endif
  free_unknown_extensions_strings(void)
  {
-    free(extra_extensions);
-@@ -258,7 +258,7 @@ _mesa_one_time_init_extension_overrides(
-    int len;
-    size_t offset;
- 
--   atexit(free_unknown_extensions_strings);
-+   /* atexit(free_unknown_extensions_strings); */
+    free(unrecognized_extensions);
+@@ -293,7 +297,9 @@ _mesa_one_time_init_extension_overrides(
+       free(env);
+    } else {
+       unrecognized_extensions = env;
++#if !defined(HAVE_NOATEXIT)
+       atexit(free_unknown_extensions_strings);
++#endif
+    }
+ }
  
-    memset(&_mesa_extension_override_enables, 0, sizeof(struct gl_extensions));
-    memset(&_mesa_extension_override_disables, 0, sizeof(struct gl_extensions));
diff --git a/MesaLib-dfbsd/patches/patch-src_mesa_main_macros.h b/MesaLib-dfbsd/patches/patch-src_mesa_main_macros.h
index 8df0228288..362d661f79 100644
--- a/MesaLib-dfbsd/patches/patch-src_mesa_main_macros.h
+++ b/MesaLib-dfbsd/patches/patch-src_mesa_main_macros.h
@@ -2,12 +2,11 @@ $NetBSD: patch-src_mesa_main_macros.h,v 1.1 2016/01/05 13:02:57 tnn Exp $
 
 ALIGN is also defined in sys/param.h on NetBSD.
 
-Add MESA_ALIGN for if there are still conflicts between an
-OS-defined one-argument ALIGN and mesa defined two-argument ALIGN.
+Extend undefining ALIGN to all other OSes.
 
---- src/mesa/main/macros.h.orig	2017-02-13 11:55:49.000000000 +0000
+--- src/mesa/main/macros.h.orig	2017-11-10 23:18:56.000000000 +0000
 +++ src/mesa/main/macros.h
-@@ -677,11 +677,24 @@ minify(unsigned value, unsigned levels)
+@@ -677,6 +677,9 @@ minify(unsigned value, unsigned levels)
   *
   * \sa ROUND_DOWN_TO()
   */
@@ -17,18 +16,3 @@ OS-defined one-argument ALIGN and mesa defined two-argument ALIGN.
  static inline uintptr_t
  ALIGN(uintptr_t value, int32_t alignment)
  {
-    assert((alignment > 0) && _mesa_is_pow_two(alignment));
-    return (((value) + (alignment) - 1) & ~((alignment) - 1));
-+}
-+
-+/**
-+ * Like ALIGN(), but won't clash with other OSes ALIGN.
-+ */
-+static inline uintptr_t
-+MESA_ALIGN(uintptr_t value, int32_t alignment)
-+{
-+   assert((alignment > 0) && _mesa_is_pow_two(alignment));
-+   return (((value) + (alignment) - 1) & ~((alignment) - 1));
- }
- 
- /**
diff --git a/MesaLib-dfbsd/patches/patch-src_mesa_tnl_t__pipeline.c b/MesaLib-dfbsd/patches/patch-src_mesa_tnl_t__pipeline.c
index 86cb8730d1..46d4749763 100644
--- a/MesaLib-dfbsd/patches/patch-src_mesa_tnl_t__pipeline.c
+++ b/MesaLib-dfbsd/patches/patch-src_mesa_tnl_t__pipeline.c
@@ -2,19 +2,17 @@ $NetBSD: patch-src_mesa_tnl_t__pipeline.c,v 1.1 2015/09/11 00:03:36 tnn Exp $
 
 i386 FPU control word defaults.
 
-0x127f is the value of FreeBSD fpu.h __INITIAL_FPUCW_I386__
+Neither FreeBSD ports nor DragonFly dports graphics/mesa-dri
+mentions any concern with DEFAULT_X86_FPUs value.
 
---- src/mesa/tnl/t_pipeline.c.orig	2017-02-13 11:55:50.000000000 +0000
+--- src/mesa/tnl/t_pipeline.c.orig	2018-01-09 16:03:44.000000000 +0000
 +++ src/mesa/tnl/t_pipeline.c
-@@ -132,7 +132,14 @@ static GLuint check_output_changes( stru
+@@ -132,7 +132,11 @@ static GLuint check_output_changes( stru
  /* Hardware default: All exceptions masked, extended double precision,
   * round to nearest (IEEE compliant):
   */
 +#if defined(__NetBSD__)
 +#define DEFAULT_X86_FPU	0x127f  /* __NetBSD_NPXCW__ */
-+#elif defined(__FreeBSD__) || defined(__DragonFly__)
-+/* __INITIAL_FPUCW_I386__ from FreeBSD fpu.h */
-+#define DEFAULT_X86_FPU	0x127f
 +#else
  #define DEFAULT_X86_FPU		0x037f
 +#endif
diff --git a/MesaLib-dfbsd/patches/patch-src_mesa_x86_assyntax.h b/MesaLib-dfbsd/patches/patch-src_mesa_x86_assyntax.h
deleted file mode 100644
index 14d1866884..0000000000
--- a/MesaLib-dfbsd/patches/patch-src_mesa_x86_assyntax.h
+++ /dev/null
@@ -1,15 +0,0 @@
-$NetBSD$
-
-Why not add DragonFly to OSes here.
-
---- src/mesa/x86/assyntax.h.orig	2017-02-13 11:55:50.000000000 +0000
-+++ src/mesa/x86/assyntax.h
-@@ -977,7 +977,7 @@
- 
- #if defined(Lynx) || (defined(SYSV) || defined(SVR4)) \
-  || (defined(__linux__) || defined(__OS2ELF__)) && defined(__ELF__) \
-- || (defined(__FreeBSD__) && __FreeBSD__ >= 3) \
-+ || (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(__DragonFly__) \
-  || (defined(__NetBSD__) && defined(__ELF__))
- #define GLNAME(a)	a
- #else
diff --git a/MesaLib-dfbsd/patches/patch-src_util_build__id.c b/MesaLib-dfbsd/patches/patch-src_util_build__id.c
index 28756fd9ca..5d6485388e 100644
--- a/MesaLib-dfbsd/patches/patch-src_util_build__id.c
+++ b/MesaLib-dfbsd/patches/patch-src_util_build__id.c
@@ -1,6 +1,8 @@
 $NetBSD$
 
-Patch taken from FreeBSD ports graphics/mesa-dri mesa 17.1.0
+Patch taken from FreeBSD ports graphics/mesa-dri mesa 17.1.0.
+
+# Elf_ doesn't exist, use Elf32_ or Elf64_.
 
 --- src/util/build_id.c.orig	2017-05-25 07:13:13.000000000 +0000
 +++ src/util/build_id.c
@@ -8,7 +10,7 @@ Patch taken from FreeBSD ports graphics/mesa-dri mesa 17.1.0
  #endif
  
  #ifndef ElfW
-+#if defined(__FreeBSD__) || defined(__DragonFly__)
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
 +#ifdef __LP64__
 +#define ElfW(type) Elf64_##type
 +#else
diff --git a/MesaLib-dfbsd/patches/patch-src_util_futex.h b/MesaLib-dfbsd/patches/patch-src_util_futex.h
new file mode 100644
index 0000000000..c0f1b0da7e
--- /dev/null
+++ b/MesaLib-dfbsd/patches/patch-src_util_futex.h
@@ -0,0 +1,53 @@
+$NetBSD$
+
+Implement futex_wake() and futex_wait() via _umtx_op()
+
+FreeBSD Bugzilla - Bug 225415: graphics/mesa-dri: update to 18.0.0
+https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=225415
+
+--- src/util/futex.h.orig	2018-02-09 02:18:00.000000000 +0000
++++ src/util/futex.h
+@@ -29,10 +29,35 @@
+ #include <limits.h>
+ #include <stdint.h>
+ #include <unistd.h>
++#if defined(__FreeBSD__)
++#include <errno.h>
++# if __FreeBSD__ < 11
++#  include <machine/atomic.h>
++# endif
++#include <sys/umtx.h>
++#else
+ #include <linux/futex.h>
+ #include <sys/syscall.h>
++#endif
+ #include <sys/time.h>
+ 
++#if defined(__FreeBSD__)
++static inline int futex_wake(uint32_t *addr, int count)
++{
++   return _umtx_op(addr, UMTX_OP_WAKE, (uint32_t)count, NULL, NULL) == -1 ? errno : 0;
++}
++
++static inline int futex_wait(uint32_t *addr, int32_t value, struct timespec *timeout)
++{
++   void *uaddr = NULL, *uaddr2 = NULL;
++   if (timeout != NULL) {
++      const struct _umtx_time tmo = { ._timeout = *timeout, ._flags = UMTX_ABSTIME, ._clockid = CLOCK_MONOTONIC };
++      uaddr = (void *)(uintptr_t)sizeof(tmo);
++      uaddr2 = (void *)&tmo;
++   }
++   return _umtx_op(addr, UMTX_OP_WAIT_UINT, (uint32_t)value, uaddr, uaddr2) == -1 ? errno : 0;
++}
++#else
+ static inline long sys_futex(void *addr1, int op, int val1, const struct timespec *timeout, void *addr2, int val3)
+ {
+    return syscall(SYS_futex, addr1, op, val1, timeout, addr2, val3);
+@@ -50,6 +75,7 @@ static inline int futex_wait(uint32_t *a
+    return sys_futex(addr, FUTEX_WAIT_BITSET, value, timeout, NULL,
+                     FUTEX_BITSET_MATCH_ANY);
+ }
++#endif
+ 
+ #endif
+ 
diff --git a/MesaLib-dfbsd/patches/patch-src_util_os__time.c b/MesaLib-dfbsd/patches/patch-src_util_os__time.c
new file mode 100644
index 0000000000..8c686072a1
--- /dev/null
+++ b/MesaLib-dfbsd/patches/patch-src_util_os__time.c
@@ -0,0 +1,27 @@
+$NetBSD$
+
+Use monotonic clock for timeouts
+
+FreeBSD Bugzilla - Bug 225415  graphics/mesa-dri: update to 18.0.0
+https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=225415
+
+--- src/util/os_time.c.orig	2018-02-09 02:18:00.000000000 +0000
++++ src/util/os_time.c
+@@ -55,7 +55,7 @@
+ int64_t
+ os_time_get_nano(void)
+ {
+-#if defined(PIPE_OS_LINUX)
++#if defined(PIPE_OS_BSD) || defined(PIPE_OS_LINUX)
+ 
+    struct timespec tv;
+    clock_gettime(CLOCK_MONOTONIC, &tv);
+@@ -95,7 +95,7 @@ os_time_get_nano(void)
+ void
+ os_time_sleep(int64_t usecs)
+ {
+-#if defined(PIPE_OS_LINUX)
++#if defined(HAVE_CLOCK_NANOSLEEP) || defined(PIPE_OS_LINUX)
+    struct timespec time;
+    time.tv_sec = usecs / 1000000;
+    time.tv_nsec = (usecs % 1000000) * 1000;
diff --git a/MesaLib-dfbsd/patches/patch-src_util_u__endian.h b/MesaLib-dfbsd/patches/patch-src_util_u__endian.h
deleted file mode 100644
index 8710ccade1..0000000000
--- a/MesaLib-dfbsd/patches/patch-src_util_u__endian.h
+++ /dev/null
@@ -1,15 +0,0 @@
-$NetBSD$
-
-From FreeBSD ports graphics/libGL mesa 13.0.5.
-
---- src/util/u_endian.h.orig	2017-02-13 11:55:50.000000000 +0000
-+++ src/util/u_endian.h
-@@ -54,7 +54,7 @@
- # define PIPE_ARCH_BIG_ENDIAN
- #endif
- 
--#elif defined(__OpenBSD__) || defined(__NetBSD__)
-+#elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
- #include <sys/types.h>
- #include <machine/endian.h>
- 
diff --git a/MesaLib-dfbsd/patches/patch-src_util_u__queue.c b/MesaLib-dfbsd/patches/patch-src_util_u__queue.c
new file mode 100644
index 0000000000..d2283c47e3
--- /dev/null
+++ b/MesaLib-dfbsd/patches/patch-src_util_u__queue.c
@@ -0,0 +1,44 @@
+$NetBSD$
+
+atexit() is not a good idea in shared libraries.
+
+FreeBSD reported atexit bug for 10.6:
+https://bugs.freedesktop.org/show_bug.cgi?id=91869
+
+--- src/util/u_queue.c.orig	2018-01-09 16:03:44.000000000 +0000
++++ src/util/u_queue.c
+@@ -40,11 +40,22 @@ static once_flag atexit_once_flag = ONCE
+ static struct list_head queue_list;
+ static mtx_t exit_mutex = _MTX_INITIALIZER_NP;
+ 
++#if defined(HAVE_NOATEXIT)
++static int global_init_called = 0;
++
++static void __attribute__((__destructor__))
++#else
+ static void
++#endif
+ atexit_handler(void)
+ {
+    struct util_queue *iter;
+ 
++#if defined(HAVE_NOATEXIT)
++   if (!global_init_called)
++      return;
++#endif
++
+    mtx_lock(&exit_mutex);
+    /* Wait for all queues to assert idle. */
+    LIST_FOR_EACH_ENTRY(iter, &queue_list, head) {
+@@ -57,7 +68,11 @@ static void
+ global_init(void)
+ {
+    LIST_INITHEAD(&queue_list);
++#if defined(HAVE_NOATEXIT)
++   global_init_called = 1;
++#else
+    atexit(atexit_handler);
++#endif
+ }
+ 
+ static void
diff --git a/MesaLib-dfbsd/patches/patch-src_util_xmlconfig.c b/MesaLib-dfbsd/patches/patch-src_util_xmlconfig.c
new file mode 100644
index 0000000000..7718ce1163
--- /dev/null
+++ b/MesaLib-dfbsd/patches/patch-src_util_xmlconfig.c
@@ -0,0 +1,34 @@
+$NetBSD: patch-src_mesa_drivers_dri_common_xmlconfig.c,v 1.3 2016/02/23 11:16:55 jperkin Exp $
+
+PR pkg/50202.
+Provide compat strndup for older Darwin.
+
+Remove patches for FreeBSD and DragonFly since code covers those cases.
+
+--- src/util/xmlconfig.c.orig	2017-12-21 17:31:22.000000000 +0000
++++ src/util/xmlconfig.c
+@@ -113,6 +113,24 @@ __getProgramName()
+ #    endif
+ #endif
+ 
++#if (defined(__APPLE__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0 < 1070)
++static char *
++strndup(const char *str, size_t n)
++{
++  size_t len;
++  char *copy;
++
++  for (len = 0; len < n && str[len]; len++)
++    continue;
++
++  if ((copy = (char *)malloc(len + 1)) == NULL)
++    return (NULL);
++  memcpy(copy, str, len);
++  copy[len] = '\0';
++  return (copy);
++}
++#endif
++
+ /** \brief Find an option in an option cache with the name as key */
+ static uint32_t
+ findOption(const driOptionCache *cache, const char *name)


Home | Main Index | Thread Index | Old Index