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