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