Ravenports generated: 17 May 2018 21:47
[ravenports.git] / bucket_F0 / mesa
1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
2
3 NAMEBASE=               mesa
4 VERSION=                18.0.4
5 KEYWORDS=               graphics
6 VARIANTS=               standard
7 SDESC[standard]=        Mesa 3D Graphics Library
8 HOMEPAGE=               https://www.mesa3d.org/
9 CONTACT=                nobody
10
11 DOWNLOAD_GROUPS=        main
12 SITES[main]=            https://mesa.freedesktop.org/archive/
13                         ftp://ftp.freedesktop.org/pub/mesa/
14 DISTFILE[1]=            mesa-18.0.4.tar.xz:main
15 DF_INDEX=               1
16 SPKGS[standard]=        complete
17                         libs
18                         clover
19                         drivers
20                         osmesa
21
22 OPTIONS_AVAILABLE=      X86_DRIVERS ARM_DRIVERS
23 OPTIONS_STANDARD=       X86_DRIVERS ARM_DRIVERS
24 OPT_ON[aarch64]=        ARM_DRIVERS
25 OPT_ON[x86_64]=         X86_DRIVERS
26 OPT_ON[i386]=           X86_DRIVERS
27
28 BUILD_DEPENDS=          libpthread-stubs:single:standard
29                         libclc:single:standard
30                         llvm40:llvm:standard
31                         llvm40:clang:standard
32                         zlib:complete:standard
33                         libelf:single:standard
34                         libvdpau:single:standard
35                         libva:single:standard
36                         expat:static:standard
37 BUILDRUN_DEPENDS=       expat:shared:standard
38                         libdrm:single:standard
39                         ocl-icd:primary:standard
40                         opencl:single:standard
41 B_DEPS[sunos]=          libbsd4sol:single:standard
42 EXRUN[clover]=          llvm40:llvm:standard
43                         zlib:shared:standard
44                         libelf:single:standard
45                         expat:shared:standard
46                         libdrm:single:standard
47 EXRUN[drivers]=         llvm40:llvm:standard
48                         mesa:libs:standard
49                         zlib:shared:standard
50                         libelf:single:standard
51 EXRUN[osmesa]=          llvm40:llvm:standard
52                         mesa:libs:standard
53                         zlib:shared:standard
54
55 USES=                   bison gettext-tools gmake libtool pkgconfig
56                         python:py27,build shebangfix
57                         c++:clover,drivers,osmesa
58 XORG_COMPONENTS=        x11 xcb xdamage xext xfixes xshmfence xxf86vm xv
59                         xvmc
60
61 LICENSE=                MIT:libs CUSTOM1:libs CUSTOM2:libs
62 LICENSE_NAME=           CUSTOM1:"Kronos License (MIT with modifications)"
63                         CUSTOM2:"SGI Free Software License B"
64 LICENSE_FILE=           MIT:{{WRKDIR}}/LICENSE_MIT
65                         CUSTOM1:{{WRKDIR}}/LICENSE_KHRONOS
66                         CUSTOM2:{{WRKDIR}}/LICENSE_SGI
67 LICENSE_AWK=            MIT:"^$$"
68                         CUSTOM2:"^$$"
69 LICENSE_SOURCE=         MIT:{{WRKSRC}}/include/GL/gl.h
70                         CUSTOM2:{{WRKSRC}}/src/glx/eval.c
71 LICENSE_SCHEME=         multi
72
73 FPC_EQUIVALENT=         graphics/mesa-libs
74 SHEBANG_FILES=          src/gallium/*/*/*.py
75                         src/gallium/tools/trace/*.py
76                         src/gallium/drivers/svga/svgadump/svga_dump.py
77                         src/mapi/glapi/gen/*.py
78                         src/mapi/mapi_abi.py
79                         src/util/xmlpool/gen_xmlpool.py
80                         src/mesa/main/get_*.py
81                         src/util/format_srgb.py
82                         src/amd/*/*.py
83                         src/intel/genxml/gen_pack_header.py
84 SHEBANG_OLD_PYTHON=     /usr/bin/env[[:space:]]python2
85                         /usr/bin/python2
86                         /bin/env[[:space:]]python
87
88 MUST_CONFIGURE=         gnu
89 CONFIGURE_ARGS=         --enable-llvm
90                         --enable-texture-float
91                         --enable-vdpau
92                         --enable-va
93                         --enable-xvmc
94                         --disable-glx-tls
95                         --disable-gles1
96                         --disable-libunwind
97                         --with-platforms=x11,drm
98                         --enable-gallium-osmesa
99                         --with-llvm-prefix={{LOCALBASE}}/llvm40
100                         --with-dri-drivers="{{DRI_DRIVERS:tl}}"
101                         --with-gallium_drivers="{{GALLIUM_DRIVERS:tl}}"
102 CONFIGURE_ENV=          ax_cv_check_cflags___Wno_initializer_overrides=no
103
104 INSTALL_TARGET=         install-strip
105 INSTALL_REQ_TOOLCHAIN=  yes
106
107 LDFLAGS=                -Wl,-rpath,{{LOCALBASE}}/llvm40/lib
108 VAR_OPSYS[sunos]=       CPPFLAGS=-D__EXTENSIONS__=1
109                         CPPFLAGS=-D_POSIX_PTHREAD_SEMANTICS
110                         CFLAGS=-DF_DUPFD_CLOEXEC=F_DUPFD
111
112 [ARM_DRIVERS].DESCRIPTION=              Build drivers for aarch64 architecture
113 [ARM_DRIVERS].MAKEFILE_ON=              GALLIUM_DRIVERS+=FREEDRENO
114                                         GALLIUM_DRIVERS+=VC4
115
116 [X86_DRIVERS].DESCRIPTION=              Build drivers for i386 and x86_64 architectures
117 [X86_DRIVERS].CONFIGURE_ENABLE_BOTH=    opencl
118                                         opencl-icd
119 [X86_DRIVERS].MAKEFILE_ON=              DRI_DRIVERS+=RADEON
120                                         DRI_DRIVERS+=R200
121                                         DRI_DRIVERS+=I915
122                                         DRI_DRIVERS+=I965
123                                         GALLIUM_DRIVERS+=R300
124                                         GALLIUM_DRIVERS+=R600
125                                         GALLIUM_DRIVERS+=RADEONSI
126                                         GALLIUM_DRIVERS+=SVGA
127
128 post-patch:
129         ${REINPLACE_CMD} -e 's|/etc/|${PREFIX}/etc/|g' \
130                 ${WRKSRC}/src/util/xmlconfig.c
131         # Use --link-static until ports/223191 is fixed
132         ${REINPLACE_CMD} -e '/$$LLVM_VERSION_MAJOR -ge 4/s|test |false |' \
133                 ${WRKSRC}/configure
134
135 post-extract:
136         ${AWK} '/Copyright/,/DEALINGS/' ${WRKSRC}/include/GL/glext.h \
137                 > ${WRKDIR}/LICENSE_KHRONOS
138
139 post-patch-freebsd:
140         ${REINPLACE_CMD} -e 's|x86_64|amd64|' ${WRKSRC}/configure
141
142 post-patch-sunos:
143         ${REINPLACE_CMD}\
144                 -e '/^CFLAGS =/ s|$$| -I$$(prefix)/include/bsd|' \
145                 -e '/^LDFLAGS =/ s|$$| -lbsd|' \
146                 ${WRKSRC}/src/egl/Makefile.in \
147                 ${WRKSRC}/src/gallium/drivers/r600/Makefile.in \
148                 ${WRKSRC}/src/gallium/drivers/radeon/Makefile.in \
149                 ${WRKSRC}/src/gallium/drivers/radeonsi/Makefile.in \
150                 ${WRKSRC}/src/gallium/auxiliary/Makefile.in \
151                 ${WRKSRC}/src/loader/Makefile.in
152
153 [FILE:808:descriptions/desc.libs]
154 The Mesa project began as an open-source implementation of the OpenGL
155 specification - a system for rendering interactive 3D graphics.
156
157 Over the years the project has grown to implement more graphics APIs,
158 including OpenGL ES (versions 1, 2, 3), OpenCL, OpenMAX, VDPAU, VA API,
159 XvMC and Vulkan.
160
161 A variety of device drivers allows the Mesa libraries to be used in many
162 different environments ranging from software emulation to complete
163 hardware acceleration for modern GPUs.
164
165 Mesa ties into several other open-source projects: the Direct Rendering
166 Infrastructure and X.org to provide OpenGL support on Linux, FreeBSD
167 and other operating systems.
168
169 This package contains the Mesa OpenGL libraries for GLX and EGL clients.
170 These include libEGL, libGL, and libglesv2 as well as utlity libraries
171 libglapi and gbm.
172
173
174 [FILE:130:descriptions/desc.clover]
175 This package contains Mesa's libOpenCL implementation "Clover".
176 It is built upon GALLIUM and currently only supports Radeon GPUs.
177
178
179 [FILE:162:descriptions/desc.drivers]
180 This package contains the Mesa OpenGL libraries for GLX and EGL clients.
181 These include libEGL, libGL, and libglesv2 as well as utlity libraries
182 libglapi and gbm.
183
184
185 [FILE:591:descriptions/desc.osmesa]
186 Mesa is a 3-D graphics library with an API which is very similar to that
187 of OpenGL*.  To the extent that Mesa utilizes the OpenGL command syntax or
188 state machine, it is being used with authorization from Silicon Graphics,
189 Inc.  However, the author makes no claim that Mesa is in any way a
190 compatible replacement for OpenGL or associated with Silicon Graphics, Inc.
191
192 This is a Off-Screen version of Mesa in order to do off-screen rendering in
193 other packages like VTK. Offscreen rendering is useful for a
194 number of things, such as batch processing, parallel processing, and
195 remote processing.
196
197
198 [FILE:97:distinfo]
199 1f3bcfe7cef0a5c20dae2b41df5d7e0a985e06be0183fa4d43b6068fcba2920f     10939356 mesa-18.0.4.tar.xz
200
201
202 [FILE:721:manifests/plist.libs]
203 @comment lib/libwayland-egl.so
204 @comment lib/libwayland-egl.so.1
205 @comment lib/libwayland-egl.so.1.0.0
206 @comment lib/pkgconfig/wayland-egl.pc
207 include/gbm.h
208 include/EGL/
209  egl.h
210  eglext.h
211  eglextchromium.h
212  eglmesaext.h
213  eglplatform.h
214 include/GL/
215  gl.h
216  gl_mangle.h
217  glcorearb.h
218  glext.h
219  glx.h
220  glx_mangle.h
221  glxext.h
222 include/GLES2/
223  gl2.h
224  gl2ext.h
225  gl2platform.h
226 include/GLES3/
227  gl3.h
228  gl31.h
229  gl32.h
230  gl3ext.h
231  gl3platform.h
232 include/KHR/khrplatform.h
233 lib/
234  libEGL.so
235  libEGL.so.1
236  libEGL.so.1.0.0
237  libGL.so
238  libGL.so.1
239  libGL.so.1.2.0
240  libGLESv2.so
241  libGLESv2.so.2
242  libGLESv2.so.2.0.0
243  libgbm.so
244  libgbm.so.1
245  libgbm.so.1.0.0
246  libglapi.so
247  libglapi.so.0
248  libglapi.so.0.0.0
249 lib/pkgconfig/
250  egl.pc
251  gbm.pc
252  gl.pc
253  glesv2.pc
254
255
256 [FILE:245:manifests/plist.clover]
257 %%X86_DRIVERS-ON%%etc/OpenCL/vendors/mesa.icd
258 %%X86_DRIVERS-ON%%lib/
259  libMesaOpenCL.so
260  libMesaOpenCL.so.1
261  libMesaOpenCL.so.1.0.0
262 %%X86_DRIVERS-ON%%lib/gallium-pipe/
263  pipe_r300.so
264  pipe_r600.so
265  pipe_radeonsi.so
266  pipe_swrast.so
267  pipe_vmwgfx.so
268
269
270 [FILE:751:manifests/plist.drivers]
271 %%ARM_DRIVERS-ON%%lib/dri/
272  kgsl_dri.so
273  msm_dri.so
274  vc4_dri.so
275 %%X86_DRIVERS-ON%%lib/
276  libXvMCr600.so
277  libXvMCr600.so.1
278  libXvMCr600.so.1.0
279  libXvMCr600.so.1.0.0
280 %%X86_DRIVERS-ON%%lib/dri/
281  i915_dri.so
282  i965_dri.so
283  r200_dri.so
284  r300_dri.so
285  r600_dri.so
286  r600_drv_video.so
287  radeon_dri.so
288  radeonsi_dri.so
289  radeonsi_drv_video.so
290  vmwgfx_dri.so
291 %%X86_DRIVERS-ON%%lib/vdpau/
292  libvdpau_r300.so
293  libvdpau_r300.so.1
294  libvdpau_r300.so.1.0
295  libvdpau_r300.so.1.0.0
296  libvdpau_r600.so
297  libvdpau_r600.so.1
298  libvdpau_r600.so.1.0
299  libvdpau_r600.so.1.0.0
300  libvdpau_radeonsi.so
301  libvdpau_radeonsi.so.1
302  libvdpau_radeonsi.so.1.0
303  libvdpau_radeonsi.so.1.0.0
304 etc/drirc
305 include/GL/internal/dri_interface.h
306 lib/dri/
307  kms_swrast_dri.so
308  swrast_dri.so
309 lib/pkgconfig/dri.pc
310
311
312 [FILE:99:manifests/plist.osmesa]
313 include/GL/osmesa.h
314 lib/
315  libOSMesa.so
316  libOSMesa.so.8
317  libOSMesa.so.8.0.0
318 lib/pkgconfig/osmesa.pc
319
320
321 [FILE:2052:patches/patch-configure]
322 --- configure.orig      2018-04-18 14:48:02 UTC
323 +++ configure
324 @@ -21522,7 +21522,7 @@ LDFLAGS=$save_LDFLAGS
325  
326  
327  case "$host_os" in
328 -openbsd* | darwin* )
329 +openbsd* | darwin* | solaris* )
330      LD_NO_UNDEFINED="" ;;
331  *)
332      if test "x$enable_sanitize" = xno; then
333 @@ -23528,7 +23528,7 @@ fi
334  
335  
336  case "$host_os" in
337 -linux*)
338 +linux* | freebsd* | dragonfly*)
339      dri3_default=yes
340      ;;
341  *)
342 @@ -27316,9 +27316,6 @@ rm -f core conftest.err conftest.$ac_obj
343          CLANG_LIBDIR=${LLVM_LIBDIR}
344      fi
345      CLANG_RESOURCE_DIR=$CLANG_LIBDIR/clang/${LLVM_VERSION}
346 -    if test ! -f "$CLANG_RESOURCE_DIR/include/stddef.h"; then :
347 -  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
348 -fi
349  fi
350   if test "x$enable_opencl" = xyes; then
351    HAVE_CLOVER_TRUE=
352 @@ -28643,7 +28640,7 @@ if test "x$enable_llvm" = xyes; then
353      LLVM_CXXFLAGS=`strip_unwanted_llvm_flags "$LLVM_CONFIG --cxxflags"`
354  
355  
356 -    if test $LLVM_VERSION_MAJOR -ge 4 -o $LLVM_VERSION_MAJOR -eq 3 -a $LLVM_VERSION_MINOR -ge 9; then
357 +    if false $LLVM_VERSION_MAJOR -ge 4 -o $LLVM_VERSION_MAJOR -eq 3 -a $LLVM_VERSION_MINOR -ge 9; then
358          if test "x$enable_llvm_shared_libs" = xyes; then
359              LLVM_LIBS="`$LLVM_CONFIG --link-shared --libs ${LLVM_COMPONENTS}`"
360          else
361 @@ -28657,7 +28654,7 @@ if test "x$enable_llvm" = xyes; then
362          else
363              { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Building mesa with statically linked LLVM may cause compilation issues" >&5
364  $as_echo "$as_me: WARNING: Building mesa with statically linked LLVM may cause compilation issues" >&2;}
365 -                                    if test $LLVM_VERSION_MAJOR -ge 4 -o $LLVM_VERSION_MAJOR -eq 3 -a $LLVM_VERSION_MINOR -ge 5; then
366 +                                    if false $LLVM_VERSION_MAJOR -ge 4 -o $LLVM_VERSION_MAJOR -eq 3 -a $LLVM_VERSION_MINOR -ge 5; then
367                  LLVM_LIBS="$LLVM_LIBS `$LLVM_CONFIG --system-libs`"
368              fi
369          fi
370
371
372 [FILE:512:patches/patch-include_GL_internal_dri__interface.h]
373 GCC on 9.x doesn't allow types to be overwritten, these types are defined
374 in drm.h also, which causes build issues in xorg-server.
375
376 --- include/GL/internal/dri_interface.h.orig    2018-04-18 14:47:53 UTC
377 +++ include/GL/internal/dri_interface.h
378 @@ -40,13 +40,7 @@
379  #ifndef DRI_INTERFACE_H
380  #define DRI_INTERFACE_H
381  
382 -#ifdef HAVE_LIBDRM
383  #include <drm.h>
384 -#else
385 -typedef unsigned int drm_context_t;
386 -typedef unsigned int drm_drawable_t;
387 -typedef struct drm_clip_rect drm_clip_rect_t;
388 -#endif
389  
390  #include <stdint.h>
391  
392
393
394 [FILE:629:patches/patch-src_amd_common_ac__debug.c]
395 --- src/amd/common/ac_debug.c.orig      2018-04-18 14:47:53 UTC
396 +++ src/amd/common/ac_debug.c
397 @@ -560,6 +560,10 @@ void ac_parse_ib_chunk(FILE *f, uint32_t
398                        unsigned trace_id_count, enum chip_class chip_class,
399                         ac_debug_addr_callback addr_callback, void *addr_callback_data)
400  {
401 +#ifdef __sun__
402 +       printf("\nac_parse_ib_chunk: open_memstream unsupported on solaris");
403 +       exit (1);
404 +#else
405         struct ac_ib_parser ib = {};
406         ib.ib = ib_ptr;
407         ib.num_dw = num_dw;
408 @@ -585,6 +589,7 @@ void ac_parse_ib_chunk(FILE *f, uint32_t
409                 printf("\nPacket ends after the end of IB.\n");
410                 exit(1);
411         }
412 +#endif
413  }
414  
415  /**
416
417
418 [FILE:321:patches/patch-src_amd_vulkan_winsys_amdgpu_radv__amdgpu__cs.c]
419 - Define ETIME if missing
420
421 --- src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c.orig  2018-01-23 18:08:49 UTC
422 +++ src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c
423 @@ -33,6 +33,9 @@
424  #include "radv_amdgpu_bo.h"
425  #include "sid.h"
426  
427 +#ifndef ETIME
428 +#define ETIME ETIMEDOUT
429 +#endif
430  
431  enum {
432         VIRTUAL_BUFFER_HASH_TABLE_SIZE = 1024
433
434
435 [FILE:787:patches/patch-src_compiler_glsl_linker.cpp]
436 --- src/compiler/glsl/linker.cpp.orig   2018-04-18 14:47:54 UTC
437 +++ src/compiler/glsl/linker.cpp
438 @@ -87,6 +87,38 @@
439  #include "main/shaderobj.h"
440  #include "main/enums.h"
441  
442 +#ifdef __sun__
443 +/* uses libbsd4sol prototypes, so can't be static */
444 +#include <stdlib.h>
445 +#include <stdint.h>
446 +#include <string.h>
447 +
448 +size_t
449 +strnlen(const char *s, size_t maxlen)
450 +{
451 +       size_t len;
452 +       for (len = 0; len < maxlen; len++, s++) {
453 +               if (!*s) break;
454 +       }
455 +       return (len);
456 +}
457 +
458 +char *
459 +strndup(const char *str, size_t n)
460 +{
461 +    size_t len;
462 +    char *copy;
463 +
464 +    len = strlen(str);
465 +    if (len <= n)
466 +        return strdup(str);
467 +    if ((copy = (char *)malloc(len + 1)) == NULL)
468 +        return (NULL);
469 +    memcpy(copy, str, len);
470 +    copy[len] = '\0';
471 +    return (copy);
472 +}
473 +#endif
474  
475  namespace {
476  
477
478
479 [FILE:586:patches/patch-src_egl_drivers_dri2_platform__x11.c]
480 # work-around for https://bugs.freedesktop.org/show_bug.cgi?id=100627
481 #
482 --- src/egl/drivers/dri2/platform_x11.c.orig    2018-04-18 14:47:54 UTC
483 +++ src/egl/drivers/dri2/platform_x11.c
484 @@ -1466,6 +1466,9 @@ dri2_initialize_x11(_EGLDriver *drv, _EG
485  
486     if (!disp->Options.ForceSoftware) {
487  #ifdef HAVE_DRI3
488 +#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) && !defined(__DRM_NEXT__)
489 +      if (env_var_as_boolean("LIBGL_DRI3_ENABLE", false))
490 +#endif
491        if (!env_var_as_boolean("LIBGL_DRI3_DISABLE", false))
492           initialized = dri2_initialize_x11_dri3(drv, disp);
493  #endif
494
495
496 [FILE:3256:patches/patch-src_gallium_auxiliary_pipe-loader_pipe__loader__drm.c]
497 Revert the following commit.
498
499 FreeBSD and DragonFly don't have the required render nodes.
500
501 -------
502
503 From 69a1b9959e59653da262185c4e2cf57d24939b19 Mon Sep 17 00:00:00 2001
504 From: Emil Velikov <emil.l.velikov@gmail.com>
505 Date: Mon, 29 Jun 2015 12:36:45 +0100
506 Subject: pipe-loader: drop support for non-render node devices
507
508 Render nodes have been around for quite some time. Removing support via
509 the master/primary node allows us to clean up the conditional
510 compilation and simplify the build greatly.
511
512 For example currently we the pipe-loader, which explicitly links against
513 xcb and friends (for X auth) if found at compile-time. That
514 would cause problems as one will be forced to use X/xcb, even if it's a
515 headless system that is used for opencl.
516
517 v2: Clarify the linking topic in the commit message.
518
519 Cc: Tom Stellard <thomas.stellard@amd.com>
520 Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
521 Reviewed-by: Francisco Jerez <currojerez@riseup.net>
522
523
524 --- src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c.orig    2018-04-18 14:47:54 UTC
525 +++ src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
526 @@ -207,6 +207,14 @@ pipe_loader_drm_probe_fd(struct pipe_loa
527  }
528  
529  static int
530 +open_drm_minor(int minor)
531 +{
532 +   char path[PATH_MAX];
533 +   snprintf(path, sizeof(path), DRM_DEV_NAME, DRM_DIR_NAME, minor);
534 +   return open(path, O_RDWR, 0);
535 +}
536 +
537 +static int
538  open_drm_render_node_minor(int minor)
539  {
540     char path[PATH_MAX];
541 @@ -218,8 +226,15 @@ open_drm_render_node_minor(int minor)
542  int
543  pipe_loader_drm_probe(struct pipe_loader_device **devs, int ndev)
544  {
545 -   int i, j, fd;
546 +   int i, k, fd, num_render_node_devs;
547 +   int j = 0;
548 +
549 +   struct {
550 +      unsigned vendor_id;
551 +      unsigned chip_id;
552 +   } render_node_devs[DRM_RENDER_NODE_MAX_NODES];
553  
554 +   /* Look for render nodes first */
555     for (i = DRM_RENDER_NODE_MIN_MINOR, j = 0;
556          i <= DRM_RENDER_NODE_MAX_MINOR; i++) {
557        struct pipe_loader_device *dev;
558 @@ -233,6 +248,9 @@ pipe_loader_drm_probe(struct pipe_loader
559           continue;
560        }
561  
562 +      render_node_devs[j].vendor_id = dev->u.pci.vendor_id;
563 +      render_node_devs[j].chip_id = dev->u.pci.chip_id;
564 +
565        if (j < ndev) {
566           devs[j] = dev;
567        } else {
568 @@ -242,6 +260,46 @@ pipe_loader_drm_probe(struct pipe_loader
569        j++;
570     }
571  
572 +   num_render_node_devs = j;
573 +
574 +   /* Next look for drm devices. */
575 +   for (i = 0; i < DRM_MAX_MINOR; i++) {
576 +      struct pipe_loader_device *dev;
577 +      boolean duplicate = FALSE;
578 +      fd = open_drm_minor(i);
579 +      if (fd < 0)
580 +         continue;
581 +
582 +      if (!pipe_loader_drm_probe_fd(&dev, fd)) {
583 +         close(fd);
584 +         continue;
585 +      }
586 +
587 +      /* Check to make sure we aren't already accessing this device via
588 +       * render nodes.
589 +       */
590 +      for (k = 0; k < num_render_node_devs; k++) {
591 +         if (dev->u.pci.vendor_id == render_node_devs[k].vendor_id &&
592 +             dev->u.pci.chip_id == render_node_devs[k].chip_id) {
593 +            close(fd);
594 +            dev->ops->release(&dev);
595 +            duplicate = TRUE;
596 +            break;
597 +         }
598 +      }
599 +
600 +      if (duplicate)
601 +         continue;
602 +
603 +      if (j < ndev) {
604 +         devs[j] = dev;
605 +      } else {
606 +         dev->ops->release(&dev);
607 +      }
608 +
609 +      j++;
610 +   }
611 +
612     return j;
613  }
614  
615
616
617 [FILE:257:patches/patch-src_gallium_auxiliary_util_u__math.h]
618 --- src/gallium/auxiliary/util/u_math.h.orig    2018-04-18 14:47:54 UTC
619 +++ src/gallium/auxiliary/util/u_math.h
620 @@ -49,6 +49,9 @@
621  #include "util/bitscan.h"
622  
623  #ifdef __cplusplus
624 +# ifdef __sun__
625 +#define restrict       __restrict__
626 +# endif
627  extern "C" {
628  #endif
629  
630
631
632 [FILE:487:patches/patch-src_gallium_auxiliary_util_u__network.c]
633 --- src/gallium/auxiliary/util/u_network.c.orig 2018-04-18 14:47:54 UTC
634 +++ src/gallium/auxiliary/util/u_network.c
635 @@ -9,7 +9,7 @@
636  #  include <winsock2.h>
637  #  include <windows.h>
638  #  include <ws2tcpip.h>
639 -#elif defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) || \
640 +#elif defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_HAIKU) || \
641     defined(PIPE_OS_APPLE) || defined(PIPE_OS_CYGWIN) || defined(PIPE_OS_SOLARIS)
642  #  include <sys/socket.h>
643  #  include <netinet/in.h>
644
645
646 [FILE:357:patches/patch-src_gallium_drivers_radeonsi_si__shader.c]
647 --- src/gallium/drivers/radeonsi/si_shader.c.orig       2018-04-18 14:47:54 UTC
648 +++ src/gallium/drivers/radeonsi/si_shader.c
649 @@ -21,6 +21,10 @@
650   * USE OR OTHER DEALINGS IN THE SOFTWARE.
651   */
652  
653 +#ifdef __sun__
654 +#include <alloca.h> /* for alloca */
655 +#endif
656 +
657  #include "gallivm/lp_bld_const.h"
658  #include "gallivm/lp_bld_gather.h"
659  #include "gallivm/lp_bld_intr.h"
660
661
662 [FILE:511:patches/patch-src_gallium_drivers_radeonsi_si__state__shaders.c]
663 --- src/gallium/drivers/radeonsi/si_state_shaders.c.orig        2018-04-18 14:47:54 UTC
664 +++ src/gallium/drivers/radeonsi/si_state_shaders.c
665 @@ -1463,6 +1463,7 @@ static void si_build_shader_variant(stru
666                 return;
667         }
668  
669 +#ifndef __sun__
670         if (shader->compiler_ctx_state.is_debug_context) {
671                 FILE *f = open_memstream(&shader->shader_log,
672                                          &shader->shader_log_size);
673 @@ -1471,6 +1472,7 @@ static void si_build_shader_variant(stru
674                         fclose(f);
675                 }
676         }
677 +#endif
678  
679         si_shader_init_pm4_state(sscreen, shader);
680  }
681
682
683 [FILE:360:patches/patch-src_gallium_drivers_vc4_vc4__bufmgr.c]
684 # define ETIME as ETIMEOUT same as in intel driver
685 #
686 --- src/gallium/drivers/vc4/vc4_bufmgr.c.orig   2018-04-18 14:47:54 UTC
687 +++ src/gallium/drivers/vc4/vc4_bufmgr.c
688 @@ -27,6 +27,9 @@
689  #include <fcntl.h>
690  #include <xf86drm.h>
691  #include <xf86drmMode.h>
692 +#ifndef ETIME
693 +#define ETIME ETIMEDOUT
694 +#endif
695  
696  #include "util/u_hash_table.h"
697  #include "util/u_memory.h"
698
699
700 [FILE:1043:patches/patch-src_gallium_include_pipe_p__config.h]
701 --- src/gallium/include/pipe/p_config.h.orig    2018-04-18 14:47:54 UTC
702 +++ src/gallium/include/pipe/p_config.h
703 @@ -77,6 +77,13 @@
704  #define PIPE_CC_ICL
705  #endif
706  
707 +#if defined(__sparc__) || defined(__sparc64__)
708 +#define PIPE_ARCH_SPARC
709 +#if defined(__sparc64__)
710 +#define PIPE_ARCH_SPARC_64
711 +#endif
712 +#endif
713 +
714  
715  /*
716   * Processor architecture
717 @@ -131,7 +138,7 @@
718  
719  #if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) || defined(PIPE_ARCH_ARM) || defined(PIPE_ARCH_AARCH64)
720  #define PIPE_ARCH_LITTLE_ENDIAN
721 -#elif defined(PIPE_ARCH_PPC) || defined(PIPE_ARCH_PPC_64) || defined(PIPE_ARCH_S390)
722 +#elif defined(PIPE_ARCH_PPC) || defined(PIPE_ARCH_PPC_64) || defined(PIPE_ARCH_S390) || defined(PIPE_ARCH_SPARC) || defined(PIPE_ARCH_SPARC_64)
723  #define PIPE_ARCH_BIG_ENDIAN
724  #endif
725  
726 @@ -160,6 +167,12 @@
727  #define PIPE_OS_ANDROID
728  #endif
729  
730 +#if defined(__DragonFly__)
731 +#define PIPE_OS_DRAGONFLY
732 +#define PIPE_OS_BSD
733 +#define PIPE_OS_UNIX
734 +#endif
735 +
736  #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
737  #define PIPE_OS_FREEBSD
738  #define PIPE_OS_BSD
739
740
741 [FILE:1577:patches/patch-src_gallium_state__trackers_clover_llvm_invocation.cpp]
742 # fix errors like the following
743 #
744 # llvm/invocation.cpp:(.text+0x1275): undefined reference to `std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::c_str()
745  const'
746 # /usr/bin/ld: ../../../../src/gallium/state_trackers/clover/.libs/libclover.a(libclllvm_la-invocation.o): relocation R_X86_64_PC32 against `_ZNKSt3__112bas
747 ic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5c_strEv' can not be used when making a shared object; recompile with -fPIC
748 # /usr/bin/ld: final link failed: Bad value
749 #
750 --- src/gallium/state_trackers/clover/llvm/invocation.cpp.orig  2018-04-18 14:47:54 UTC
751 +++ src/gallium/state_trackers/clover/llvm/invocation.cpp
752 @@ -93,6 +93,8 @@ namespace {
753        return ctx;
754     }
755  
756 +   const char* cstr(const std::string& str) { return str.c_str(); }
757 +
758     std::unique_ptr<clang::CompilerInstance>
759     create_compiler_instance(const target &target,
760                              const std::vector<std::string> &opts,
761 @@ -105,8 +107,8 @@ namespace {
762        // Parse the compiler options.  A file name should be present at the end
763        // and must have the .cl extension in order for the CompilerInvocation
764        // class to recognize it as an OpenCL source file.
765 -      const std::vector<const char *> copts =
766 -         map(std::mem_fn(&std::string::c_str), opts);
767 +      std::vector<const char *> copts(opts.size());
768 +      std::transform(opts.begin(), opts.end(), copts.begin(), cstr);
769  
770        if (!clang::CompilerInvocation::CreateFromArgs(
771               c->getInvocation(), copts.data(), copts.data() + copts.size(), diag))
772
773
774 [FILE:635:patches/patch-src_gallium_state__trackers_clover_llvm_metadata.hpp]
775 # Fix error: no matching constructor for initialization of 'std::vector<const ::llvm::MDNode *>' 
776 #
777 --- src/gallium/state_trackers/clover/llvm/metadata.hpp.orig    2018-04-18 14:47:54 UTC
778 +++ src/gallium/state_trackers/clover/llvm/metadata.hpp
779 @@ -42,7 +42,7 @@ namespace clover {
780           get_kernel_nodes(const ::llvm::Module &mod) {
781              if (const ::llvm::NamedMDNode *n =
782                     mod.getNamedMetadata("opencl.kernels"))
783 -               return { n->op_begin(), n->op_end() };
784 +               return { n->getOperand(0), n->getOperand(n->getNumOperands()) };
785              else
786                 return {};
787           }
788
789
790 [FILE:1150:patches/patch-src_gallium_state__trackers_clover_util_range.hpp]
791 From b95533b981af9a6687b41418e7cc2a5652fc2bdb Mon Sep 17 00:00:00 2001
792 From: =?UTF-8?q?Jean-S=C3=A9bastien=20P=C3=A9dron?= <dumbbell@FreeBSD.org>
793 Date: Fri, 7 Mar 2014 15:16:08 +0100
794 Subject: [PATCH 3/3] Work around for clang 3.4 which fails to build Clover
795
796 See:
797   https://bugs.freedesktop.org/show_bug.cgi?id=74098#c3
798 --- src/gallium/state_trackers/clover/util/range.hpp.orig       2018-04-18 14:47:54 UTC
799 +++ src/gallium/state_trackers/clover/util/range.hpp
800 @@ -362,6 +362,12 @@ namespace clover {
801        return { i, i + n };
802     }
803  
804 +   namespace detail {
805 +      template<typename T>
806 +      using fixup_function_type =
807 +         typename std::conditional<std::is_function<T>::value, T &, T>::type;
808 +   }
809 +
810     ///
811     /// Create a range by transforming the contents of a number of
812     /// source ranges \a rs element-wise using a provided functor \a f.
813 @@ -369,7 +375,7 @@ namespace clover {
814     /// \sa adaptor_range.
815     ///
816     template<typename F, typename... Rs>
817 -   adaptor_range<F, Rs...>
818 +   adaptor_range<detail::fixup_function_type<F>, Rs...>
819     map(F &&f, Rs &&... rs) {
820        return { std::forward<F>(f), std::forward<Rs>(rs)... };
821     }
822
823
824 [FILE:292:patches/patch-src_gallium_winsys_amdgpu_drm_amdgpu__cs.c]
825 --- src/gallium/winsys/amdgpu/drm/amdgpu_cs.c.orig      2018-04-18 14:47:54 UTC
826 +++ src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
827 @@ -33,6 +33,10 @@
828  
829  #include "amd/common/sid.h"
830  
831 +#ifdef __sun__
832 +#include <alloca.h>
833 +#endif
834 +
835  DEBUG_GET_ONCE_BOOL_OPTION(noop, "RADEON_NOOP", false)
836  
837  /* FENCES */
838
839
840 [FILE:575:patches/patch-src_glx_glxext.c]
841 # work-around for https://bugs.freedesktop.org/show_bug.cgi?id=100627
842 #
843 --- src/glx/glxext.c.orig       2018-04-18 14:47:54 UTC
844 +++ src/glx/glxext.c
845 @@ -920,6 +920,9 @@ __glXInitialize(Display * dpy)
846  #if defined(GLX_USE_DRM)
847     if (glx_direct && glx_accel) {
848  #if defined(HAVE_DRI3)
849 +#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) && !defined(__DRM_NEXT__)
850 +      if (env_var_as_boolean("LIBGL_DRI3_ENABLE", false))
851 +#endif
852        if (!env_var_as_boolean("LIBGL_DRI3_DISABLE", false))
853           dpyPriv->dri3Display = dri3_create_display(dpy);
854  #endif /* HAVE_DRI3 */
855
856
857 [FILE:702:patches/patch-src_intel_Makefile.in]
858 ../../src/util/.libs/libmesautil.a(libmesautil_la-half_float.o): In function `_mesa_float_to_half':
859 half_float.c:(.text+0x94): undefined reference to `lrintf'
860 half_float.c:(.text+0xbf): undefined reference to `lrintf'
861 cc: error: linker command failed with exit code 1 (use -v to see invocation)
862 gmake[5]: *** [Makefile:2706: tools/aubinator_error_decode] Error 1
863
864 --- src/intel/Makefile.in.orig  2018-04-18 14:48:09 UTC
865 +++ src/intel/Makefile.in
866 @@ -1987,7 +1987,8 @@ tools_aubinator_error_decode_LDADD = \
867         compiler/libintel_compiler.la \
868         $(top_builddir)/src/util/libmesautil.la \
869         $(PTHREAD_LIBS) \
870 -       $(ZLIB_LIBS)
871 +       $(ZLIB_LIBS) \
872 +       -lm
873  
874  tools_aubinator_error_decode_CFLAGS = \
875         $(AM_CFLAGS) \
876
877
878 [FILE:995:patches/patch-src_intel_compiler_brw__eu__validate.c]
879 --- src/intel/compiler/brw_eu_validate.c.orig   2018-04-18 14:47:54 UTC
880 +++ src/intel/compiler/brw_eu_validate.c
881 @@ -28,6 +28,39 @@
882  
883  #include "brw_eu.h"
884  
885 +#ifdef __sun__
886 +#include <string.h>
887 +
888 +static void *
889 +memmem(const void *l, size_t l_len, const void *s, size_t s_len)
890 +{
891 +       char *cur, *last;
892 +       const char *cl = (const char *)l;
893 +       const char *cs = (const char *)s;
894 +
895 +       /* we need something to compare */
896 +       if (l_len == 0 || s_len == 0)
897 +               return NULL;
898 +
899 +       /* "s" must be smaller or equal to "l" */
900 +       if (l_len < s_len)
901 +               return NULL;
902 +
903 +       /* special case where s_len == 1 */
904 +       if (s_len == 1)
905 +               return memchr(l, (int)*cs, l_len);
906 +
907 +       /* the last position where its possible to find "s" in "l" */
908 +       last = (char *)cl + l_len - s_len;
909 +
910 +       for (cur = (char *)cl; cur <= last; cur++)
911 +               if (cur[0] == cs[0] && memcmp(cur, cs, s_len) == 0)
912 +                       return cur;
913 +
914 +       return NULL;
915 +}
916 +#endif
917 +
918  /* We're going to do lots of string concatenation, so this should help. */
919  struct string {
920     char *str;
921
922
923 [FILE:794:patches/patch-src_intel_compiler_brw__fs__bank__conflicts.cpp]
924 compiler/brw_fs_bank_conflicts.cpp:719:25: error: scalar initializer cannot be empty
925       vector_type s_p = {}, s_n = {};
926                         ^~
927 compiler/brw_fs_bank_conflicts.cpp:719:35: error: scalar initializer cannot be empty
928       vector_type s_p = {}, s_n = {};
929                                   ^~
930
931 --- src/intel/compiler/brw_fs_bank_conflicts.cpp.orig   2018-01-23 18:08:50 UTC
932 +++ src/intel/compiler/brw_fs_bank_conflicts.cpp
933 @@ -716,7 +716,7 @@ namespace {
934                     const weight_vector_type &conflicts)
935     {
936        const unsigned m = DIV_ROUND_UP(conflicts.size, vector_width);
937 -      vector_type s_p = {}, s_n = {};
938 +      vector_type s_p = {0}, s_n = {0};
939  
940        for (unsigned r = 0; r < m; r++) {
941           s_p = adds(s_p, mask(bank_mask_p.v[r], conflicts.v[r]));
942
943
944 [FILE:225:patches/patch-src_intel_isl_isl.h]
945 --- src/intel/isl/isl.h.orig    2018-04-18 14:47:54 UTC
946 +++ src/intel/isl/isl.h
947 @@ -46,6 +46,9 @@
948  #include "util/macros.h"
949  
950  #ifdef __cplusplus
951 +# ifdef __sun__
952 +# define restrict      __restrict__
953 +# endif
954  extern "C" {
955  #endif
956  
957
958
959 [FILE:302:patches/patch-src_intel_tools_aubinator__error__decode.c]
960 # expose getline in FreeBSD's stdio.h
961 #
962 --- src/intel/tools/aubinator_error_decode.c.orig       2018-04-18 14:47:54 UTC
963 +++ src/intel/tools/aubinator_error_decode.c
964 @@ -22,6 +22,9 @@
965   *
966   */
967  
968 +#ifdef __FreeBSD__
969 +#define _WITH_GETLINE
970 +#endif
971  #include <stdbool.h>
972  #include <stdio.h>
973  #include <stdlib.h>
974
975
976 [FILE:619:patches/patch-src_mapi_glapi_gen_gl__gentable.py]
977 --- src/mapi/glapi/gen/gl_gentable.py.orig      2018-04-18 14:47:54 UTC
978 +++ src/mapi/glapi/gen/gl_gentable.py
979 @@ -43,7 +43,7 @@ header = """/* GLXEXT is the define used
980  #endif
981  
982  #if (defined(GLXEXT) && defined(HAVE_BACKTRACE)) \\
983 -       || (!defined(GLXEXT) && defined(DEBUG) && !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__))
984 +       || (!defined(GLXEXT) && defined(DEBUG) && !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined(__DragonFly__))
985  #define USE_BACKTRACE
986  #endif
987  
988
989
990 [FILE:425:patches/patch-src_mesa_drivers_dri_i965_brw__bufmgr.c]
991 --- src/mesa/drivers/dri/i965/brw_bufmgr.c.orig 2018-04-18 14:47:54 UTC
992 +++ src/mesa/drivers/dri/i965/brw_bufmgr.c
993 @@ -74,6 +74,10 @@
994  #define VG(x)
995  #endif
996  
997 +#ifndef O_CLOEXEC
998 +#define O_CLOEXEC      0
999 +#endif
1000 +
1001  /* VALGRIND_FREELIKE_BLOCK unfortunately does not actually undo the earlier
1002   * VALGRIND_MALLOCLIKE_BLOCK but instead leaves vg convinced the memory is
1003   * leaked. All because it does not call VG(cli_free) from its
1004
1005
1006 [FILE:1343:patches/patch-src_mesa_drivers_dri_i965_brw__performance__query.c]
1007 --- src/mesa/drivers/dri/i965/brw_performance_query.c.orig      2018-04-18 14:47:54 UTC
1008 +++ src/mesa/drivers/dri/i965/brw_performance_query.c
1009 @@ -1767,9 +1767,17 @@ enumerate_sysfs_metrics(struct brw_conte
1010     while ((metric_entry = readdir(metricsdir))) {
1011        struct hash_entry *entry;
1012  
1013 +#ifdef __sun__
1014 +      struct stat entry_stat;
1015 +
1016 +      lstat(metric_entry->d_name, &entry_stat);
1017 +      if ((!S_ISDIR(entry_stat.st_mode) && !S_ISLNK(entry_stat.st_mode)) ||
1018 +          metric_entry->d_name[0] == '.') 
1019 +#else
1020        if ((metric_entry->d_type != DT_DIR &&
1021             metric_entry->d_type != DT_LNK) ||
1022            metric_entry->d_name[0] == '.')
1023 +#endif
1024           continue;
1025  
1026        DBG("metric set: %s\n", metric_entry->d_name);
1027 @@ -2041,9 +2049,17 @@ get_sysfs_dev_dir(struct brw_context *br
1028     }
1029  
1030     while ((drm_entry = readdir(drmdir))) {
1031 +#ifdef __sun__
1032 +      struct stat drm_stat;
1033 +
1034 +      lstat(drm_entry->d_name, &drm_stat);
1035 +      if ((S_ISDIR(drm_stat.st_mode) || S_ISLNK(drm_stat.st_mode)) &&
1036 +          strncmp(drm_entry->d_name, "card", 4) == 0)
1037 +#else
1038        if ((drm_entry->d_type == DT_DIR ||
1039             drm_entry->d_type == DT_LNK) &&
1040            strncmp(drm_entry->d_name, "card", 4) == 0)
1041 +#endif
1042        {
1043           len = snprintf(path_buf, path_buf_len,
1044                          "/sys/dev/char/%d:%d/device/drm/%s",
1045
1046
1047 [FILE:406:patches/patch-src_mesa_main_compiler.h]
1048 --- src/mesa/main/compiler.h.orig       2018-04-18 14:47:54 UTC
1049 +++ src/mesa/main/compiler.h
1050 @@ -51,6 +51,9 @@
1051  #if defined(__linux__)
1052  #include <byteswap.h>
1053  #define CPU_TO_LE32( x )       bswap_32( x )
1054 +#elif defined(__FreeBSD__)
1055 +#include <sys/endian.h>
1056 +#define CPU_TO_LE32( x )       bswap32( x )
1057  #elif defined(__APPLE__)
1058  #include <CoreFoundation/CFByteOrder.h>
1059  #define CPU_TO_LE32( x )       CFSwapInt32HostToLittle( x )
1060
1061
1062 [FILE:377:patches/patch-src_util_build__id.c]
1063 # Elf_ doesn't exist, use Elf32_ or Elf64_
1064 #
1065 --- src/util/build_id.c.orig    2018-04-18 14:47:54 UTC
1066 +++ src/util/build_id.c
1067 @@ -34,7 +34,11 @@
1068  #endif
1069  
1070  #ifndef ElfW
1071 -#define ElfW(type) Elf_##type
1072 +#ifdef __LP64__
1073 +#define ElfW(type) Elf64_##type
1074 +#else
1075 +#define ElfW(type) Elf32_##type
1076 +#endif
1077  #endif
1078  
1079  #define ALIGN(val, align)      (((val) + (align) - 1) & ~((align) - 1))
1080
1081
1082 [FILE:649:patches/patch-src_util_disk__cache.c]
1083 --- src/util/disk_cache.c.orig  2018-04-18 14:47:54 UTC
1084 +++ src/util/disk_cache.c
1085 @@ -51,6 +51,10 @@
1086  
1087  #include "disk_cache.h"
1088  
1089 +#ifndef O_CLOEXEC
1090 +#define O_CLOEXEC      0
1091 +#endif
1092 +
1093  /* Number of bits to mask off from a cache key to get an index. */
1094  #define CACHE_INDEX_KEY_BITS 16
1095  
1096 @@ -498,7 +502,11 @@ choose_lru_file_matching(const char *dir
1097           break;
1098  
1099        struct stat sb;
1100 +#ifdef __sun__
1101 +      if (fstatat(dir->dd_fd, entry->d_name, &sb, 0) == 0) {
1102 +#else
1103        if (fstatat(dirfd(dir), entry->d_name, &sb, 0) == 0) {
1104 +#endif
1105           if (!lru_atime || (sb.st_atime < lru_atime)) {
1106              size_t len = strlen(entry->d_name);
1107  
1108
1109
1110 [FILE:1476:patches/patch-src_util_futex.h]
1111 - Implement futex_wake() and futex_wait() via _umtx_op()
1112
1113 --- src/util/futex.h.orig       2018-01-23 18:08:50 UTC
1114 +++ src/util/futex.h
1115 @@ -29,10 +29,35 @@
1116  #include <limits.h>
1117  #include <stdint.h>
1118  #include <unistd.h>
1119 +#if defined(__FreeBSD__)
1120 +#include <errno.h>
1121 +# if __FreeBSD__ < 11
1122 +#  include <machine/atomic.h>
1123 +# endif
1124 +#include <sys/umtx.h>
1125 +#else
1126  #include <linux/futex.h>
1127  #include <sys/syscall.h>
1128 +#endif
1129  #include <sys/time.h>
1130  
1131 +#if defined(__FreeBSD__)
1132 +static inline int futex_wake(uint32_t *addr, int count)
1133 +{
1134 +   return _umtx_op(addr, UMTX_OP_WAKE, (uint32_t)count, NULL, NULL) == -1 ? errno : 0;
1135 +}
1136 +
1137 +static inline int futex_wait(uint32_t *addr, int32_t value, struct timespec *timeout)
1138 +{
1139 +   void *uaddr = NULL, *uaddr2 = NULL;
1140 +   if (timeout != NULL) {
1141 +      const struct _umtx_time tmo = { ._timeout = *timeout, ._flags = UMTX_ABSTIME, ._clockid = CLOCK_MONOTONIC };
1142 +      uaddr = (void *)(uintptr_t)sizeof(tmo);
1143 +      uaddr2 = (void *)&tmo;
1144 +   }
1145 +   return _umtx_op(addr, UMTX_OP_WAIT_UINT, (uint32_t)value, uaddr, uaddr2) == -1 ? errno : 0;
1146 +}
1147 +#else
1148  static inline long sys_futex(void *addr1, int op, int val1, const struct timespec *timeout, void *addr2, int val3)
1149  {
1150     return syscall(SYS_futex, addr1, op, val1, timeout, addr2, val3);
1151 @@ -50,6 +75,7 @@ static inline int futex_wait(uint32_t *addr, int32_t v
1152     return sys_futex(addr, FUTEX_WAIT_BITSET, value, timeout, NULL,
1153                      FUTEX_BITSET_MATCH_ANY);
1154  }
1155 +#endif
1156  
1157  #endif
1158  
1159
1160
1161 [FILE:561:patches/patch-src_util_os__time.c]
1162 - Use monotonic clock for timeouts
1163
1164 --- src/util/os_time.c.orig     2018-01-23 18:08:50 UTC
1165 +++ src/util/os_time.c
1166 @@ -55,7 +55,7 @@
1167  int64_t
1168  os_time_get_nano(void)
1169  {
1170 -#if defined(PIPE_OS_LINUX)
1171 +#if defined(PIPE_OS_BSD) || defined(PIPE_OS_LINUX)
1172  
1173     struct timespec tv;
1174     clock_gettime(CLOCK_MONOTONIC, &tv);
1175 @@ -95,7 +95,7 @@ os_time_get_nano(void)
1176  void
1177  os_time_sleep(int64_t usecs)
1178  {
1179 -#if defined(PIPE_OS_LINUX)
1180 +#if defined(HAVE_CLOCK_NANOSLEEP)
1181     struct timespec time;
1182     time.tv_sec = usecs / 1000000;
1183     time.tv_nsec = (usecs % 1000000) * 1000;
1184
1185
1186 [FILE:430:patches/patch-src_util_u__atomic.h]
1187 --- src/util/u_atomic.h.orig    2018-04-18 14:47:54 UTC
1188 +++ src/util/u_atomic.h
1189 @@ -20,11 +20,7 @@
1190   * locally coded assembly, compiler intrinsic or ultimately a
1191   * mutex-based implementation.
1192   */
1193 -#if defined(__sun)
1194 -#define PIPE_ATOMIC_OS_SOLARIS
1195 -#elif defined(_MSC_VER)
1196 -#define PIPE_ATOMIC_MSVC_INTRINSIC
1197 -#elif defined(__GNUC__)
1198 +#if defined(__GNUC__)
1199  #define PIPE_ATOMIC_GCC_INTRINSIC
1200  #else
1201  #error "Unsupported platform"
1202
1203
1204 [FILE:1265:patches/patch-src_util_u__thread.h]
1205 - Implement setting thread name
1206 - Use monotonic clock for timeouts
1207
1208 --- src/util/u_thread.h.orig    2018-02-09 02:18:00 UTC
1209 +++ src/util/u_thread.h
1210 @@ -34,7 +34,11 @@
1211  
1212  #ifdef HAVE_PTHREAD
1213  #include <signal.h>
1214 +#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
1215 +#include <pthread_np.h>
1216 +#undef ALIGN /* Avoid conflict on FreeBSD in main/macros.h */
1217  #endif
1218 +#endif
1219  
1220  
1221  static inline thrd_t u_thread_create(int (*routine)(void *), void *param)
1222 @@ -65,6 +69,12 @@ static inline void u_thread_setname( const char *name 
1223        (__GLIBC__ >= 3 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 12)) && \
1224        defined(__linux__)
1225     pthread_setname_np(pthread_self(), name);
1226 +#  elif defined(__sun)
1227 +   pthread_setname_np(pthread_self(), name);
1228 +#  elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
1229 +   pthread_set_name_np(pthread_self(), name);
1230 +#  elif defined(__NetBSD__)
1231 +   pthread_setname_np(pthread_self(), "%s", (void*)name);
1232  #  endif
1233  #endif
1234     (void)name;
1235 @@ -78,7 +88,7 @@ static inline void u_thread_setname( const char *name 
1236  static inline int64_t
1237  u_thread_get_time_nano(thrd_t thread)
1238  {
1239 -#if defined(__linux__) && defined(HAVE_PTHREAD)
1240 +#if defined(HAVE_PTHREAD)
1241     struct timespec ts;
1242     clockid_t cid;
1243  
1244
1245
1246 [FILE:47:files/special.mk]
1247 DRI_DRIVERS+=           SWRAST
1248 GALLIUM_DRIVERS+=       SWRAST
1249
1250
1251 [FILE:684:dragonfly/patch-src_intel_tools_aubinator.c]
1252 # We don't have MAP_NORESERVE so use MAP_NOSYNC | MAP_NOCORE and
1253 # hope for the best (this alloc is too big but it's only a test)
1254 #
1255 --- src/intel/tools/aubinator.c.orig    2018-04-18 14:47:54 UTC
1256 +++ src/intel/tools/aubinator.c
1257 @@ -637,7 +637,7 @@ int main(int argc, char *argv[])
1258     /* mmap a terabyte for our gtt space. */
1259     gtt_size = 1ull << 40;
1260     gtt = mmap(NULL, gtt_size, PROT_READ | PROT_WRITE,
1261 -              MAP_PRIVATE | MAP_ANONYMOUS |  MAP_NORESERVE, -1, 0);
1262 +              MAP_PRIVATE | MAP_ANONYMOUS | MAP_NOSYNC | MAP_NOCORE, -1, 0);
1263     if (gtt == MAP_FAILED) {
1264        fprintf(stderr, "failed to alloc gtt space: %s\n", strerror(errno));
1265        exit(EXIT_FAILURE);
1266
1267
1268 [FILE:684:freebsd/patch-src_intel_tools_aubinator.c]
1269 # We don't have MAP_NORESERVE so use MAP_NOSYNC | MAP_NOCORE and
1270 # hope for the best (this alloc is too big but it's only a test)
1271 #
1272 --- src/intel/tools/aubinator.c.orig    2018-04-18 14:47:54 UTC
1273 +++ src/intel/tools/aubinator.c
1274 @@ -637,7 +637,7 @@ int main(int argc, char *argv[])
1275     /* mmap a terabyte for our gtt space. */
1276     gtt_size = 1ull << 40;
1277     gtt = mmap(NULL, gtt_size, PROT_READ | PROT_WRITE,
1278 -              MAP_PRIVATE | MAP_ANONYMOUS |  MAP_NORESERVE, -1, 0);
1279 +              MAP_PRIVATE | MAP_ANONYMOUS | MAP_NOSYNC | MAP_NOCORE, -1, 0);
1280     if (gtt == MAP_FAILED) {
1281        fprintf(stderr, "failed to alloc gtt space: %s\n", strerror(errno));
1282        exit(EXIT_FAILURE);
1283
1284
1285 [FILE:722:sunos/patch-src_amd_Makefile.in]
1286 --- src/amd/Makefile.in.orig    2018-01-18 21:30:38 UTC
1287 +++ src/amd/Makefile.in
1288 @@ -332,7 +332,7 @@ CCAS = @CCAS@
1289  CCASDEPMODE = @CCASDEPMODE@
1290  CCASFLAGS = @CCASFLAGS@
1291  CCDEPMODE = @CCDEPMODE@
1292 -CFLAGS = @CFLAGS@
1293 +CFLAGS = @CFLAGS@ -I$(prefix)/include/bsd
1294  CLANG_RESOURCE_DIR = @CLANG_RESOURCE_DIR@
1295  CLOCK_LIB = @CLOCK_LIB@
1296  CLOVER_STD_OVERRIDE = @CLOVER_STD_OVERRIDE@
1297 @@ -739,7 +739,7 @@ addrlib_libamdgpu_addrlib_la_SOURCES = $
1298  @HAVE_GALLIUM_LLVM_TRUE@       $(AMD_GENERATED_FILES) \
1299  @HAVE_GALLIUM_LLVM_TRUE@       $(AMD_NIR_FILES)
1300  
1301 -common_libamd_common_la_LIBADD = $(LIBELF_LIBS)
1302 +common_libamd_common_la_LIBADD = $(LIBELF_LIBS) -lbsd
1303  BUILT_SOURCES = $(AMD_GENERATED_FILES)
1304  all: $(BUILT_SOURCES)
1305         $(MAKE) $(AM_MAKEFLAGS) all-am
1306
1307
1308 [FILE:360:sunos/patch-src_compiler_Makefile.in]
1309 --- src/compiler/Makefile.in.orig       2018-01-18 21:30:39 UTC
1310 +++ src/compiler/Makefile.in
1311 @@ -731,7 +731,7 @@ CLANG_RESOURCE_DIR = @CLANG_RESOURCE_DIR
1312  CLOCK_LIB = @CLOCK_LIB@
1313  CLOVER_STD_OVERRIDE = @CLOVER_STD_OVERRIDE@
1314  CPP = @CPP@
1315 -CPPFLAGS = @CPPFLAGS@
1316 +CPPFLAGS = @CPPFLAGS@ -I$(prefix)/include/bsd
1317  CXX = @CXX@
1318  CXXCPP = @CXXCPP@
1319  CXXDEPMODE = @CXXDEPMODE@
1320
1321
1322 [FILE:343:sunos/patch-src_intel_Makefile.in]
1323 --- src/intel/Makefile.in.orig  2018-02-07 05:00:00 UTC
1324 +++ src/intel/Makefile.in
1325 @@ -1983,7 +1983,7 @@ tools_aubinator_error_decode_LDADD = \
1326  
1327  tools_aubinator_error_decode_CFLAGS = \
1328         $(AM_CFLAGS) \
1329 -       $(ZLIB_CFLAGS)
1330 +       $(ZLIB_CFLAGS) -I$(prefix)/include/bsd
1331  
1332  
1333  # Due to a what seems like a autoconf bug, we must ensure that the genaration
1334
1335
1336 [FILE:760:sunos/patch-src_mesa_drivers_dri_common_Makefile.in]
1337 --- src/mesa/drivers/dri/common/Makefile.in.orig        2018-01-18 21:30:42 UTC
1338 +++ src/mesa/drivers/dri/common/Makefile.in
1339 @@ -138,7 +138,7 @@ AM_V_lt = $(am__v_lt_@AM_V@)
1340  am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
1341  am__v_lt_0 = --silent
1342  am__v_lt_1 = 
1343 -libmegadriver_stub_la_LIBADD =
1344 +libmegadriver_stub_la_LIBADD = -lbsd
1345  am__objects_2 = megadriver_stub.lo
1346  am_libmegadriver_stub_la_OBJECTS = $(am__objects_2)
1347  libmegadriver_stub_la_OBJECTS = $(am_libmegadriver_stub_la_OBJECTS)
1348 @@ -224,7 +224,7 @@ CCAS = @CCAS@
1349  CCASDEPMODE = @CCASDEPMODE@
1350  CCASFLAGS = @CCASFLAGS@
1351  CCDEPMODE = @CCDEPMODE@
1352 -CFLAGS = @CFLAGS@
1353 +CFLAGS = @CFLAGS@ -I$(prefix)/include/bsd
1354  CLANG_RESOURCE_DIR = @CLANG_RESOURCE_DIR@
1355  CLOCK_LIB = @CLOCK_LIB@
1356  CLOVER_STD_OVERRIDE = @CLOVER_STD_OVERRIDE@
1357
1358
1359 [FILE:927:sunos/patch-src_util_Makefile.in]
1360 --- src/util/Makefile.in.orig   2018-01-18 21:30:42 UTC
1361 +++ src/util/Makefile.in
1362 @@ -865,6 +865,7 @@ libmesautil_la_CPPFLAGS = \
1363         -I$(top_srcdir)/src/mesa \
1364         -I$(top_srcdir)/src/gallium/include \
1365         -I$(top_srcdir)/src/gallium/auxiliary \
1366 +       -I$(prefix)/include/bsd \
1367         $(VISIBILITY_CFLAGS) \
1368         $(MSVC2013_COMPAT_CFLAGS) \
1369         $(ZLIB_CFLAGS)
1370 @@ -876,18 +877,19 @@ libmesautil_la_SOURCES = \
1371  libmesautil_la_LIBADD = \
1372         $(CLOCK_LIB) \
1373         $(ZLIB_LIBS) \
1374 -       $(LIBATOMIC_LIBS)
1375 +       $(LIBATOMIC_LIBS) -lbsd
1376  
1377  libxmlconfig_la_SOURCES = $(XMLCONFIG_FILES)
1378  libxmlconfig_la_CFLAGS = \
1379         $(DEFINES) \
1380         -I$(top_srcdir)/include \
1381         -I$(top_srcdir)/src \
1382 +       -I$(prefix)/include/bsd \
1383         -DSYSCONFDIR=\"$(sysconfdir)\" \
1384         $(VISIBILITY_CFLAGS) \
1385         $(EXPAT_CFLAGS)
1386  
1387 -libxmlconfig_la_LIBADD = $(EXPAT_LIBS) -lm
1388 +libxmlconfig_la_LIBADD = $(EXPAT_LIBS) -lm -lbsd
1389  sysconf_DATA = drirc
1390  u_atomic_test_LDADD = libmesautil.la
1391  roundeven_test_LDADD = -lm
1392