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