Ravenports generated: 30 Aug 2021 00:07
[ravenports.git] / bucket_F0 / mesa
1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
2
3 NAMEBASE=               mesa
4 VERSION=                21.1.7
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-21.1.7.tar.xz:main
15 DF_INDEX=               1
16 SPKGS[standard]=        complete
17                         libs
18                         drivers
19
20 OPTIONS_AVAILABLE=      X86_DRIVERS ARM_DRIVERS LLVMPIPE WAYLAND
21 OPTIONS_STANDARD=       X86_DRIVERS ARM_DRIVERS LLVMPIPE
22 OPT_ON[freebsd]=        LLVMPIPE//i386|x86_64
23 OPT_ON[aarch64]=        ARM_DRIVERS
24 OPT_ON[linux]=          LLVMPIPE//i386|x86_64
25 OPT_ON[x86_64]=         X86_DRIVERS
26 OPT_ON[dragonfly]=      LLVMPIPE//i386|x86_64
27 OPT_ON[i386]=           X86_DRIVERS
28
29 BUILD_DEPENDS=          python-Mako:single:python_used
30                         libpthread-stubs:single:standard
31                         libelf:single:standard
32                         libvdpau:single:standard
33                         libva:single:standard
34 BUILDRUN_DEPENDS=       libdrm:single:standard
35 EXRUN[drivers]=         mesa:libs:standard
36                         libelf:single:standard
37
38 USES=                   cpe bison gettext-tools gmake meson pkgconfig zstd
39                         zlib expat shebangfix solaris-funcs python:build
40                         c++:libs,drivers
41 XORG_COMPONENTS=        x11 xdamage xext xfixes xshmfence xxf86vm xv xrandr
42                         xcb
43
44 LICENSE=                MIT:libs CUSTOM1:libs CUSTOM2:libs
45 LICENSE_NAME=           CUSTOM1:"Kronos License (MIT with modifications)"
46                         CUSTOM2:"SGI Free Software License B"
47 LICENSE_FILE=           MIT:{{WRKDIR}}/LICENSE_MIT
48                         CUSTOM1:{{WRKDIR}}/LICENSE_KHRONOS
49                         CUSTOM2:{{WRKDIR}}/LICENSE_SGI
50 LICENSE_AWK=            MIT:"^$$"
51                         CUSTOM2:"^$$"
52 LICENSE_SOURCE=         MIT:{{WRKSRC}}/include/GL/gl.h
53                         CUSTOM2:{{WRKSRC}}/src/glx/eval.c
54 LICENSE_SCHEME=         multi
55
56 CPE_VENDOR=             mesa3d
57 FPC_EQUIVALENT=         graphics/mesa-libs
58 MESON_ARGS=             -Dplatforms=x11{{WAYPLAT}}
59                         -Dzstd=enabled
60                         -Ddri3=true
61                         -Ddri-drivers={{DRI_DRIVERS:tW:tl:C/[[:space:]]/,/g}}
62                         -Dgallium-drivers={{GALLIUM_DRIVERS:tW:tl:C/[[:space:]]/,/g}}
63                         -Dgallium-vdpau=enabled
64                         -Dosmesa=true
65                         -Dlibunwind=false
66                         -Dgles1=disabled
67                         -Dvulkan-drivers={{VULKAN_DRIVERS:tW:tl:C/[[:space:]]/,/g}}
68 SHEBANG_FILES=          src/gallium/*/*/*.py
69                         src/gallium/tools/trace/*.py
70                         src/gallium/drivers/svga/svgadump/svga_dump.py
71                         src/mapi/glapi/gen/*.py
72                         src/mapi/mapi_abi.py
73                         src/mesa/main/get_*.py
74                         src/util/format_srgb.py
75                         src/amd/*/*.py
76                         src/intel/genxml/gen_pack_header.py
77 SHEBANG_OLD_PYTHON=     /usr/bin/env[[:space:]]python2
78                         /usr/bin/python2
79                         /bin/env[[:space:]]python
80 SOL_FUNCTIONS=          dirfd:src/util/disk_cache.c
81                         asprintf:src/util/anon_file.c
82                         asprintf:src/mesa/drivers/dri/common/megadriver_stub.c
83                         asprintf:src/loader/loader.c
84                         asprintf:src/egl/main/eglcurrent.c
85                         asprintf:src/util/u_string.h
86                         asprintf:src/amd/common/ac_rtld.c
87                         strnlen:src/util/ralloc.c
88                         strnlen:src/mesa/main/errors.c
89                         strndup:src/loader/loader.c
90                         strndup:src/egl/drivers/dri2/platform_x11.c
91                         strndup:src/gallium/drivers/r600/evergreen_compute.c
92                         strndup:src/gallium/drivers/radeonsi/si_debug.c
93
94 CONFIGURE_ENV=          ax_cv_check_cflags___Wno_initializer_overrides=no
95
96 INSTALL_TARGET=         install-strip
97 INSTALL_REQ_TOOLCHAIN=  yes
98
99 CFLAGS=                 -Wno-pointer-sign
100 VAR_OPSYS[sunos]=       CPPFLAGS=-D__EXTENSIONS__=1
101                         CPPFLAGS=-Wno-unused-function
102                         CXXFLAGS=-Drestrict=__restrict__
103                         CFLAGS=-D_POSIX_PTHREAD_SEMANTICS
104                         CFLAGS=-DF_DUPFD_CLOEXEC=F_DUPFD
105                         CFLAGS=-Wno-incompatible-pointer-types
106                         LDFLAGS=-lsocket
107                         LDFLAGS=-lnsl
108                         MAKEFILE_LINE=MESON_ARGS+=-Dshader-cache=false
109
110 [ARM_DRIVERS].DESCRIPTION=              Build drivers for aarch64 architecture
111 [ARM_DRIVERS].MAKEFILE_ON=              GALLIUM_DRIVERS+=FREEDRENO
112                                         GALLIUM_DRIVERS+=VC4
113
114 [X86_DRIVERS].DESCRIPTION=              Build drivers for i386 and x86_64 architectures
115 [X86_DRIVERS].MAKEFILE_ON=              DRI_DRIVERS+=R100
116                                         DRI_DRIVERS+=R200
117                                         DRI_DRIVERS+=I915
118                                         DRI_DRIVERS+=I965
119                                         GALLIUM_DRIVERS+=R300
120                                         GALLIUM_DRIVERS+=SVGA
121                                         VULKAN_DRIVERS+={{VULKAN_DRIVERS_X86}}
122
123 [WAYLAND].DESCRIPTION=                  Build Vulkan drivers for Wayland platform
124 [WAYLAND].BUILDRUN_DEPENDS_ON=          wayland:primary:standard
125 [WAYLAND].BUILD_DEPENDS_ON=             wayland-protocols:single:standard
126                                         python-Mako:single:python_default
127 [WAYLAND].MAKEFILE_ON=                  WAYPLAT=,wayland
128                                         VULKAN_DRIVERS+=INTEL
129                                         VULKAN_DRIVERS_X86+=RADEON
130
131 [LLVMPIPE].DESCRIPTION=                 Build LLVM-based drivers and libraries
132 [LLVMPIPE].BUILDRUN_DEPENDS_ON=         llvm:single:standard
133                                         ocl-icd:primary:standard
134 [LLVMPIPE].BUILD_DEPENDS_ON=            libclc:single:standard
135                                         opencl-headers:single:standard
136 [LLVMPIPE].MAKEFILE_OFF=                MESON_ARGS+=-Dgallium-opencl=disabled
137 [LLVMPIPE].MAKEFILE_ON=                 GALLIUM_LLVM_DRIVERS+=R600
138                                         GALLIUM_LLVM_DRIVERS+=RADEONSI
139                                         GALLIUM_DRIVERS+={{GALLIUM_LLVM_DRIVERS}}
140                                         MESON_ARGS+=-Dllvm=true
141                                         MESON_ARGS+=-Dgallium-xvmc=enabled
142                                         MESON_ARGS+=-Dgallium-va=enabled
143                                         MESON_ARGS+=-Dgallium-opencl=icd
144 [LLVMPIPE].RUN_DEPENDS_ON=              clang:dynlibs:standard
145 [LLVMPIPE].USES_ON=                     clang:keepcc
146 [LLVMPIPE].XORG_COMPONENTS_ON=          xvmc
147
148 post-patch:
149         ${REINPLACE_CMD} -e 's|/etc/|${PREFIX}/etc/|g' \
150                 ${WRKSRC}/src/util/xmlconfig.c
151
152 post-extract:
153         ${AWK} '/Copyright/,/DEALINGS/' ${WRKSRC}/include/GL/glext.h \
154                 > ${WRKDIR}/LICENSE_KHRONOS
155
156 [FILE:1198:descriptions/desc.libs]
157 The Mesa project began as an open-source implementation of the OpenGL
158 specification - a system for rendering interactive 3D graphics.
159
160 Over the years the project has grown to implement more graphics APIs,
161 including OpenGL ES (versions 1, 2, 3), OpenCL, OpenMAX, VDPAU, VA API,
162 XvMC and Vulkan.
163
164 A variety of device drivers allows the Mesa libraries to be used in many
165 different environments ranging from software emulation to complete
166 hardware acceleration for modern GPUs.
167
168 Mesa ties into several other open-source projects: the Direct Rendering
169 Infrastructure and X.org to provide OpenGL support on Linux, FreeBSD
170 and other operating systems.
171
172 This package contains the Mesa OpenGL libraries for GLX and EGL clients.
173 These include libOSMesa, libEGL, libGL, and libglesv2 as well as utility
174 libraries libglapi and gbm.  The OSMesa library is an Off-Screen version
175 of Mesa in order to do off-screen rendering in other packages like VTK.
176 Offscreen rendering is useful for a number of things, such as batch
177 processing, parallel processing, and remote processing.
178
179 This package also contains Mesa's libOpenCL implementation "Clover".  It is
180 built upon GALLIUM and currently only supports Radeon GPUs.
181
182
183 [FILE:162:descriptions/desc.drivers]
184 This package contains the Mesa OpenGL libraries for GLX and EGL clients.
185 These include libEGL, libGL, and libglesv2 as well as utlity libraries
186 libglapi and gbm.
187
188
189 [FILE:97:distinfo]
190 e9e67c10654f2e4bf15b944bb048007a614292aa4792b1b7512eb700b7b3a7bb     15391776 mesa-21.1.7.tar.xz
191
192
193 [FILE:981:manifests/plist.libs]
194 %%LLVMPIPE-ON%%etc/OpenCL/vendors/mesa.icd
195 %%LLVMPIPE-ON%%lib/
196  libMesaOpenCL.so
197  libMesaOpenCL.so.1
198  libMesaOpenCL.so.1.0.0
199 %%LLVMPIPE-ON%%lib/gallium-pipe/
200  pipe_r300.so
201  pipe_r600.so
202  pipe_radeonsi.so
203  pipe_swrast.so
204  pipe_vmwgfx.so
205 include/
206  gbm.h
207  xa_composite.h
208  xa_context.h
209  xa_tracker.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  glcorearb.h
219  glext.h
220  glx.h
221  glxext.h
222  osmesa.h
223 include/GLES2/
224  gl2.h
225  gl2ext.h
226  gl2platform.h
227 include/GLES3/
228  gl3.h
229  gl31.h
230  gl32.h
231  gl3ext.h
232  gl3platform.h
233 include/KHR/khrplatform.h
234 lib/
235  libEGL.so
236  libEGL.so.1
237  libEGL.so.1.0.0
238  libGL.so
239  libGL.so.1
240  libGL.so.1.2.0
241  libGLESv2.so
242  libGLESv2.so.2
243  libGLESv2.so.2.0.0
244  libOSMesa.so
245  libOSMesa.so.8
246  libOSMesa.so.8.0.0
247  libgbm.so
248  libgbm.so.1
249  libgbm.so.1.0.0
250  libglapi.so
251  libglapi.so.0
252  libglapi.so.0.0.0
253  libxatracker.so
254  libxatracker.so.2
255  libxatracker.so.2.5.0
256 lib/pkgconfig/
257  egl.pc
258  gbm.pc
259  gl.pc
260  glesv2.pc
261  osmesa.pc
262  xatracker.pc
263
264
265 [FILE:824:manifests/plist.drivers]
266 %%ARM_DRIVERS-ON%%lib/dri/
267  kgsl_dri.so
268  msm_dri.so
269  vc4_dri.so
270 %%LLVMPIPE-ON%%lib/
271  libXvMCr600.so
272  libXvMCr600.so.1
273  libXvMCr600.so.1.0
274  libXvMCr600.so.1.0.0
275 %%LLVMPIPE-ON%%lib/dri/
276  r600_dri.so
277  r600_drv_video.so
278  radeonsi_dri.so
279  radeonsi_drv_video.so
280 %%LLVMPIPE-ON%%lib/vdpau/
281  libvdpau_r600.so
282  libvdpau_r600.so.1
283  libvdpau_r600.so.1.0
284  libvdpau_r600.so.1.0.0
285  libvdpau_radeonsi.so
286  libvdpau_radeonsi.so.1
287  libvdpau_radeonsi.so.1.0
288  libvdpau_radeonsi.so.1.0.0
289 %%X86_DRIVERS-ON%%lib/dri/
290  i915_dri.so
291  i965_dri.so
292  r200_dri.so
293  r300_dri.so
294  radeon_dri.so
295  vmwgfx_dri.so
296 %%X86_DRIVERS-ON%%lib/vdpau/
297  libvdpau_r300.so
298  libvdpau_r300.so.1
299  libvdpau_r300.so.1.0
300  libvdpau_r300.so.1.0.0
301 include/GL/internal/dri_interface.h
302 lib/dri/
303  kms_swrast_dri.so
304  swrast_dri.so
305 lib/pkgconfig/dri.pc
306 share/drirc.d/00-mesa-defaults.conf
307
308
309 [FILE:511:patches/patch-include_GL_internal_dri__interface.h]
310 GCC on 9.x doesn't allow types to be overwritten, these types are defined
311 in drm.h also, which causes build issues in xorg-server.
312
313 --- include/GL/internal/dri_interface.h.orig    2021-08-11 20:27:37 UTC
314 +++ include/GL/internal/dri_interface.h
315 @@ -40,13 +40,7 @@
316  #ifndef DRI_INTERFACE_H
317  #define DRI_INTERFACE_H
318  
319 -#ifdef HAVE_LIBDRM
320  #include <drm.h>
321 -#else
322 -typedef unsigned int drm_context_t;
323 -typedef unsigned int drm_drawable_t;
324 -typedef struct drm_clip_rect drm_clip_rect_t;
325 -#endif
326  
327  #include <GL/gl.h>
328  
329
330
331 [FILE:227:patches/patch-src_amd_llvm_ac__llvm__build.h]
332 --- src/amd/llvm/ac_llvm_build.h.orig   2021-08-11 20:27:37 UTC
333 +++ src/amd/llvm/ac_llvm_build.h
334 @@ -35,6 +35,10 @@
335  
336  #include <stdbool.h>
337  
338 +#ifdef __sun
339 +#include <alloca.h>
340 +#endif
341 +
342  #ifdef __cplusplus
343  extern "C" {
344  #endif
345
346
347 [FILE:503:patches/patch-src_amd_vulkan_radv__device.c]
348 - Define CLOCK_MONOTONIC_RAW if missing
349
350 --- src/amd/vulkan/radv_device.c.orig   2021-08-11 20:27:37 UTC
351 +++ src/amd/vulkan/radv_device.c
352 @@ -97,6 +97,14 @@ radv_get_absolute_timeout(uint64_t timeo
353     return current_time + timeout;
354  }
355  
356 +#ifndef CLOCK_MONOTONIC_RAW
357 +# ifdef CLOCK_MONOTONIC_FAST
358 +#  define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC_FAST
359 +# else
360 +#  define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC
361 +# endif
362 +#endif
363 +
364  static int
365  radv_device_get_cache_uuid(enum radeon_family family, void *uuid)
366  {
367
368
369 [FILE:354:patches/patch-src_amd_vulkan_winsys_amdgpu_radv__amdgpu__cs.c]
370 - Define ETIME if missing
371
372 --- src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c.orig  2021-08-11 20:27:37 UTC
373 +++ src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c
374 @@ -40,6 +40,10 @@
375  
376  enum { VIRTUAL_BUFFER_HASH_TABLE_SIZE = 1024 };
377  
378 +#ifndef ETIME
379 +#define ETIME ETIMEDOUT
380 +#endif
381 +
382  struct radv_amdgpu_ib {
383     struct radeon_winsys_bo *bo;
384     unsigned cdw;
385
386
387 [FILE:557:patches/patch-src_egl_drivers_dri2_egl__dri2.c]
388 --- src/egl/drivers/dri2/egl_dri2.c.orig        2021-08-11 20:27:37 UTC
389 +++ src/egl/drivers/dri2/egl_dri2.c
390 @@ -1002,11 +1002,13 @@ dri2_setup_screen(_EGLDisplay *disp)
391               disp->Extensions.KHR_gl_texture_3D_image = EGL_TRUE;
392        }
393  #ifdef HAVE_LIBDRM
394 +# ifndef __DragonFly__
395        if (dri2_dpy->image->base.version >= 8 &&
396            dri2_dpy->image->createImageFromDmaBufs) {
397           disp->Extensions.EXT_image_dma_buf_import = EGL_TRUE;
398           disp->Extensions.EXT_image_dma_buf_import_modifiers = EGL_TRUE;
399        }
400 +# endif
401  #endif
402     }
403  
404
405
406 [FILE:790:patches/patch-src_egl_drivers_dri2_platform__wayland.c]
407 --- src/egl/drivers/dri2/platform_wayland.c.orig        2021-08-11 20:27:37 UTC
408 +++ src/egl/drivers/dri2/platform_wayland.c
409 @@ -1354,6 +1354,7 @@ registry_handle_global_drm(void *data, s
410        dri2_dpy->wl_drm =
411           wl_registry_bind(registry, name, &wl_drm_interface, MIN2(version, 2));
412        wl_drm_add_listener(dri2_dpy->wl_drm, &drm_listener, dri2_dpy);
413 +#ifndef __DragonFly__
414     } else if (strcmp(interface, "zwp_linux_dmabuf_v1") == 0 && version >= 3) {
415        dri2_dpy->wl_dmabuf =
416           wl_registry_bind(registry, name, &zwp_linux_dmabuf_v1_interface,
417 @@ -1361,6 +1362,7 @@ registry_handle_global_drm(void *data, s
418        zwp_linux_dmabuf_v1_add_listener(dri2_dpy->wl_dmabuf, &dmabuf_listener,
419                                         dri2_dpy);
420     }
421 +#endif
422  }
423  
424  static void
425
426
427 [FILE:352:patches/patch-src_egl_main_eglglobals.c]
428 --- src/egl/main/eglglobals.c.orig      2021-08-11 20:27:37 UTC
429 +++ src/egl/main/eglglobals.c
430 @@ -138,7 +138,7 @@ _eglPointerIsDereferencable(void *p)
431  {
432     uintptr_t addr = (uintptr_t) p;
433     const long page_size = getpagesize();
434 -#ifdef HAVE_MINCORE
435 +#if defined(HAVE_MINCORE) && !defined(__DragonFly__)
436     unsigned char valid = 0;
437  
438     if (p == NULL)
439
440
441 [FILE:3256:patches/patch-src_gallium_auxiliary_pipe-loader_pipe__loader__drm.c]
442 Revert the following commit.
443
444 FreeBSD and DragonFly don't have the required render nodes.
445
446 -------
447
448 From 69a1b9959e59653da262185c4e2cf57d24939b19 Mon Sep 17 00:00:00 2001
449 From: Emil Velikov <emil.l.velikov@gmail.com>
450 Date: Mon, 29 Jun 2015 12:36:45 +0100
451 Subject: pipe-loader: drop support for non-render node devices
452
453 Render nodes have been around for quite some time. Removing support via
454 the master/primary node allows us to clean up the conditional
455 compilation and simplify the build greatly.
456
457 For example currently we the pipe-loader, which explicitly links against
458 xcb and friends (for X auth) if found at compile-time. That
459 would cause problems as one will be forced to use X/xcb, even if it's a
460 headless system that is used for opencl.
461
462 v2: Clarify the linking topic in the commit message.
463
464 Cc: Tom Stellard <thomas.stellard@amd.com>
465 Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
466 Reviewed-by: Francisco Jerez <currojerez@riseup.net>
467
468
469 --- src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c.orig    2021-08-11 20:27:37 UTC
470 +++ src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
471 @@ -197,6 +197,14 @@ pipe_loader_drm_probe_fd(struct pipe_loa
472  }
473  
474  static int
475 +open_drm_minor(int minor)
476 +{
477 +   char path[PATH_MAX];
478 +   snprintf(path, sizeof(path), DRM_DEV_NAME, DRM_DIR_NAME, minor);
479 +   return open(path, O_RDWR, 0);
480 +}
481 +
482 +static int
483  open_drm_render_node_minor(int minor)
484  {
485     char path[PATH_MAX];
486 @@ -208,8 +216,15 @@ open_drm_render_node_minor(int minor)
487  int
488  pipe_loader_drm_probe(struct pipe_loader_device **devs, int ndev)
489  {
490 -   int i, j, fd;
491 +   int i, k, fd, num_render_node_devs;
492 +   int j = 0;
493 +
494 +   struct {
495 +      unsigned vendor_id;
496 +      unsigned chip_id;
497 +   } render_node_devs[DRM_RENDER_NODE_MAX_NODES];
498  
499 +   /* Look for render nodes first */
500     for (i = DRM_RENDER_NODE_MIN_MINOR, j = 0;
501          i <= DRM_RENDER_NODE_MAX_MINOR; i++) {
502        struct pipe_loader_device *dev;
503 @@ -223,6 +238,9 @@ pipe_loader_drm_probe(struct pipe_loader
504           continue;
505        }
506  
507 +      render_node_devs[j].vendor_id = dev->u.pci.vendor_id;
508 +      render_node_devs[j].chip_id = dev->u.pci.chip_id;
509 +
510        if (j < ndev) {
511           devs[j] = dev;
512        } else {
513 @@ -232,6 +250,46 @@ pipe_loader_drm_probe(struct pipe_loader
514        j++;
515     }
516  
517 +   num_render_node_devs = j;
518 +
519 +   /* Next look for drm devices. */
520 +   for (i = 0; i < DRM_MAX_MINOR; i++) {
521 +      struct pipe_loader_device *dev;
522 +      boolean duplicate = FALSE;
523 +      fd = open_drm_minor(i);
524 +      if (fd < 0)
525 +         continue;
526 +
527 +      if (!pipe_loader_drm_probe_fd(&dev, fd)) {
528 +         close(fd);
529 +         continue;
530 +      }
531 +
532 +      /* Check to make sure we aren't already accessing this device via
533 +       * render nodes.
534 +       */
535 +      for (k = 0; k < num_render_node_devs; k++) {
536 +         if (dev->u.pci.vendor_id == render_node_devs[k].vendor_id &&
537 +             dev->u.pci.chip_id == render_node_devs[k].chip_id) {
538 +            close(fd);
539 +            dev->ops->release(&dev);
540 +            duplicate = TRUE;
541 +            break;
542 +         }
543 +      }
544 +
545 +      if (duplicate)
546 +         continue;
547 +
548 +      if (j < ndev) {
549 +         devs[j] = dev;
550 +      } else {
551 +         dev->ops->release(&dev);
552 +      }
553 +
554 +      j++;
555 +   }
556 +
557     return j;
558  }
559  
560
561
562 [FILE:271:patches/patch-src_gallium_auxiliary_rbug_rbug__texture.c]
563 --- src/gallium/auxiliary/rbug/rbug_texture.c.orig      2021-08-11 20:27:37 UTC
564 +++ src/gallium/auxiliary/rbug/rbug_texture.c
565 @@ -36,6 +36,10 @@
566  
567  #include "c99_alloca.h"
568  
569 +#ifdef __sun
570 +#include <alloca.h>
571 +#endif
572 +
573  #include "rbug_internal.h"
574  #include "rbug_texture.h"
575  
576
577
578 [FILE:357:patches/patch-src_gallium_auxiliary_renderonly_renderonly.c]
579 --- src/gallium/auxiliary/renderonly/renderonly.c.orig  2021-08-11 20:27:37 UTC
580 +++ src/gallium/auxiliary/renderonly/renderonly.c
581 @@ -37,6 +37,10 @@
582  #include "util/u_inlines.h"
583  #include "util/u_memory.h"
584  
585 +#ifndef O_CLOEXEC
586 +#define O_CLOEXEC 0
587 +#endif
588 +
589  void
590  renderonly_scanout_destroy(struct renderonly_scanout *scanout,
591                            struct renderonly *ro)
592
593
594 [FILE:544:patches/patch-src_gallium_drivers_radeonsi_si__state__shaders.c]
595 --- src/gallium/drivers/radeonsi/si_state_shaders.c.orig        2021-08-11 20:27:37 UTC
596 +++ src/gallium/drivers/radeonsi/si_state_shaders.c
597 @@ -2127,6 +2127,7 @@ static void si_build_shader_variant(stru
598        return;
599     }
600  
601 +#ifndef __sun
602     if (shader->compiler_ctx_state.is_debug_context) {
603        FILE *f = open_memstream(&shader->shader_log, &shader->shader_log_size);
604        if (f) {
605 @@ -2134,6 +2135,7 @@ static void si_build_shader_variant(stru
606           fclose(f);
607        }
608     }
609 +#endif
610  
611     si_shader_init_pm4_state(sscreen, shader);
612  }
613
614
615 [FILE:360:patches/patch-src_gallium_drivers_vc4_vc4__bufmgr.c]
616 # define ETIME as ETIMEOUT same as in intel driver
617 #
618 --- src/gallium/drivers/vc4/vc4_bufmgr.c.orig   2021-08-11 20:27:37 UTC
619 +++ src/gallium/drivers/vc4/vc4_bufmgr.c
620 @@ -27,6 +27,9 @@
621  #include <fcntl.h>
622  #include <xf86drm.h>
623  #include <xf86drmMode.h>
624 +#ifndef ETIME
625 +#define ETIME ETIMEDOUT
626 +#endif
627  
628  #include "util/u_hash_table.h"
629  #include "util/u_memory.h"
630
631
632 [FILE:271:patches/patch-src_gallium_winsys_amdgpu_drm_amdgpu__cs.c]
633 --- src/gallium/winsys/amdgpu/drm/amdgpu_cs.c.orig      2021-08-11 20:27:37 UTC
634 +++ src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
635 @@ -33,6 +33,10 @@
636  
637  #include "amd/common/sid.h"
638  
639 +#ifdef __sun__
640 +#include <alloca.h>
641 +#endif
642 +
643  /* FENCES */
644  
645  static struct pipe_fence_handle *
646
647
648 [FILE:575:patches/patch-src_glx_glxext.c]
649 # work-around for https://bugs.freedesktop.org/show_bug.cgi?id=100627
650 #
651 --- src/glx/glxext.c.orig       2021-08-11 20:27:37 UTC
652 +++ src/glx/glxext.c
653 @@ -925,6 +925,9 @@ __glXInitialize(Display * dpy)
654  #if defined(GLX_USE_DRM)
655     if (glx_direct && glx_accel) {
656  #if defined(HAVE_DRI3)
657 +#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) && !defined(__DRM_NEXT__)
658 +      if (env_var_as_boolean("LIBGL_DRI3_ENABLE", false))
659 +#endif
660        if (!env_var_as_boolean("LIBGL_DRI3_DISABLE", false))
661           dpyPriv->dri3Display = dri3_create_display(dpy);
662  #endif /* HAVE_DRI3 */
663
664
665 [FILE:318:patches/patch-src_glx_meson.build]
666 --- src/glx/meson.build.orig    2021-08-11 20:27:37 UTC
667 +++ src/glx/meson.build
668 @@ -135,7 +135,7 @@ libglx = static_library(
669      extra_libs_libglx,
670    ],
671    dependencies : [
672 -    idep_mesautil, idep_xmlconfig,
673 +    idep_xmlconfig, idep_mesautil,
674      dep_libdrm, dep_dri2proto, dep_glproto, dep_x11, dep_glvnd,
675    ],
676  )
677
678
679 [FILE:1012:patches/patch-src_intel_common_intel__measure.c]
680 --- src/intel/common/intel_measure.c.orig       2021-08-11 20:27:37 UTC
681 +++ src/intel/common/intel_measure.c
682 @@ -42,6 +42,46 @@
683  #include "util/macros.h"
684  #include "util/u_debug.h"
685  
686 +#ifdef __sun
687 +static int
688 +mkfifoat(int fd, const char *path, mode_t mode)
689 +{
690 +       int     er, curfd = -1, newfd = -1;
691 +
692 +       /* Get our current directory then switch to the given one. */
693 +
694 +       if (fd != AT_FDCWD) {
695 +               if ((curfd = open(".", O_RDONLY, 0)) == -1)
696 +                       return -1;
697 +               if (fchdir(fd) == -1)
698 +                       goto out;
699 +       }
700 +
701 +       if ((newfd = mkfifo(path, mode)) == -1)
702 +               goto out;
703 +
704 +       /* This leaves the fifo if it fails. */
705 +
706 +       if (curfd != -1 && fchdir(curfd) == -1)
707 +               goto out;
708 +       if (curfd != -1)
709 +               close(curfd);
710 +
711 +       return newfd;
712 +out:
713 +       /* Ignore errors in close(2). */
714 +
715 +       er = errno;
716 +       if (curfd != -1)
717 +               fchdir(curfd);
718 +       if (curfd != -1)
719 +               close(curfd);
720 +       if (newfd != -1)
721 +               close(newfd);
722 +       errno = er;
723 +       return -1;
724 +}
725 +#endif
726  
727  static const struct debug_control debug_control[] = {
728     { "draw",            INTEL_MEASURE_DRAW       },
729
730
731 [FILE:1014:patches/patch-src_intel_compiler_brw__eu__validate.c]
732 --- src/intel/compiler/brw_eu_validate.c.orig   2021-08-11 20:27:37 UTC
733 +++ src/intel/compiler/brw_eu_validate.c
734 @@ -41,6 +41,39 @@
735  #include <stdlib.h>
736  #include "brw_eu.h"
737  
738 +#ifdef __sun__
739 +#include <string.h>
740 +
741 +static void *
742 +memmem(const void *l, size_t l_len, const void *s, size_t s_len)
743 +{
744 +       char *cur, *last;
745 +       const char *cl = (const char *)l;
746 +       const char *cs = (const char *)s;
747 +
748 +       /* we need something to compare */
749 +       if (l_len == 0 || s_len == 0)
750 +               return NULL;
751 +
752 +       /* "s" must be smaller or equal to "l" */
753 +       if (l_len < s_len)
754 +               return NULL;
755 +
756 +       /* special case where s_len == 1 */
757 +       if (s_len == 1)
758 +               return memchr(l, (int)*cs, l_len);
759 +
760 +       /* the last position where its possible to find "s" in "l" */
761 +       last = (char *)cl + l_len - s_len;
762 +
763 +       for (cur = (char *)cl; cur <= last; cur++)
764 +               if (cur[0] == cs[0] && memcmp(cur, cs, s_len) == 0)
765 +                       return cur;
766 +
767 +       return NULL;
768 +}
769 +#endif
770 +
771  /* We're going to do lots of string concatenation, so this should help. */
772  struct string {
773     char *str;
774
775
776 [FILE:954:patches/patch-src_intel_compiler_brw__fs__bank__conflicts.cpp]
777 --- src/intel/compiler/brw_fs_bank_conflicts.cpp.orig   2021-08-11 20:27:37 UTC
778 +++ src/intel/compiler/brw_fs_bank_conflicts.cpp
779 @@ -309,8 +309,13 @@ namespace {
780           const unsigned align = MAX2(sizeof(void *), __alignof__(vector_type));
781           const unsigned size = DIV_ROUND_UP(n, vector_width) * sizeof(vector_type);
782           void *p;
783 +#ifdef __sun
784 +       p = memalign(align, size);
785 +       if (p == NULL) return NULL;
786 +#else
787           if (posix_memalign(&p, align, size))
788              return NULL;
789 +#endif
790           memset(p, 0, size);
791           return reinterpret_cast<vector_type *>(p);
792        }
793 @@ -736,7 +741,7 @@ namespace {
794                     const weight_vector_type &conflicts)
795     {
796        const unsigned m = DIV_ROUND_UP(conflicts.size, vector_width);
797 -      vector_type s_p = {}, s_n = {};
798 +      vector_type s_p = {0}, s_n = {0};
799  
800        for (unsigned r = 0; r < m; r++) {
801           s_p = adds(s_p, mask(bank_mask_p.v[r], conflicts.v[r]));
802
803
804 [FILE:3524:patches/patch-src_intel_compiler_brw__nir__lower__shader__calls.c]
805 --- src/intel/compiler/brw_nir_lower_shader_calls.c.orig        2021-08-11 20:27:37 UTC
806 +++ src/intel/compiler/brw_nir_lower_shader_calls.c
807 @@ -151,15 +151,15 @@ instr_is_shader_call(nir_instr *instr)
808            intrin->intrinsic == nir_intrinsic_execute_callable;
809  }
810  
811 -struct bitset {
812 +struct mesa_bitset {
813     BITSET_WORD *set;
814     unsigned size;
815  };
816  
817 -static struct bitset
818 +static struct mesa_bitset
819  bitset_create(void *mem_ctx, unsigned size)
820  {
821 -   return (struct bitset) {
822 +   return (struct mesa_bitset) {
823        .set = rzalloc_array(mem_ctx, BITSET_WORD, BITSET_WORDS(size)),
824        .size = size,
825     };
826 @@ -168,7 +168,7 @@ bitset_create(void *mem_ctx, unsigned si
827  static bool
828  src_is_in_bitset(nir_src *src, void *_set)
829  {
830 -   struct bitset *set = _set;
831 +   struct mesa_bitset *set = _set;
832     assert(src->is_ssa);
833  
834     /* Any SSA values which were added after we generated liveness information
835 @@ -183,7 +183,7 @@ src_is_in_bitset(nir_src *src, void *_se
836  }
837  
838  static void
839 -add_ssa_def_to_bitset(nir_ssa_def *def, struct bitset *set)
840 +add_ssa_def_to_bitset(nir_ssa_def *def, struct mesa_bitset *set)
841  {
842     if (def->index >= set->size)
843        return;
844 @@ -192,7 +192,7 @@ add_ssa_def_to_bitset(nir_ssa_def *def,
845  }
846  
847  static bool
848 -can_remat_instr(nir_instr *instr, struct bitset *remat)
849 +can_remat_instr(nir_instr *instr, struct mesa_bitset *remat)
850  {
851     /* Set of all values which are trivially re-materializable and we shouldn't
852      * ever spill them.  This includes:
853 @@ -270,7 +270,7 @@ can_remat_instr(nir_instr *instr, struct
854  }
855  
856  static bool
857 -can_remat_ssa_def(nir_ssa_def *def, struct bitset *remat)
858 +can_remat_ssa_def(nir_ssa_def *def, struct mesa_bitset *remat)
859  {
860     return can_remat_instr(def->parent_instr, remat);
861  }
862 @@ -362,7 +362,7 @@ spill_ssa_defs_and_lower_shader_calls(ni
863  
864     const unsigned num_ssa_defs = impl->ssa_alloc;
865     const unsigned live_words = BITSET_WORDS(num_ssa_defs);
866 -   struct bitset trivial_remat = bitset_create(mem_ctx, num_ssa_defs);
867 +   struct mesa_bitset trivial_remat = bitset_create(mem_ctx, num_ssa_defs);
868  
869     /* Array of all live SSA defs which are spill candidates */
870     nir_ssa_def **spill_defs =
871 @@ -434,7 +434,7 @@ spill_ssa_defs_and_lower_shader_calls(ni
872           /* Make a copy of trivial_remat that we'll update as we crawl through
873            * the live SSA defs and unspill them.
874            */
875 -         struct bitset remat = bitset_create(mem_ctx, num_ssa_defs);
876 +         struct mesa_bitset remat = bitset_create(mem_ctx, num_ssa_defs);
877           memcpy(remat.set, trivial_remat.set, live_words * sizeof(BITSET_WORD));
878  
879           /* Before the two builders are always separated by the call
880 @@ -926,7 +926,7 @@ flatten_resume_if_ladder(nir_function_im
881                           struct exec_list *child_list,
882                           bool child_list_contains_cursor,
883                           nir_instr *resume_instr,
884 -                         struct bitset *remat)
885 +                         struct mesa_bitset *remat)
886  {
887     nir_shader *shader = impl->function->shader;
888     nir_cf_list cf_list;
889 @@ -1113,7 +1113,7 @@ lower_resume(nir_shader *shader, int cal
890     /* Used to track which things may have been assumed to be re-materialized
891      * by the spilling pass and which we shouldn't delete.
892      */
893 -   struct bitset remat = bitset_create(mem_ctx, impl->ssa_alloc);
894 +   struct mesa_bitset remat = bitset_create(mem_ctx, impl->ssa_alloc);
895  
896     /* Create a nop instruction to use as a cursor as we extract and re-insert
897      * stuff into the CFG.
898
899
900 [FILE:234:patches/patch-src_intel_isl_isl.h]
901 --- src/intel/isl/isl.h.orig    2021-08-11 20:27:37 UTC
902 +++ src/intel/isl/isl.h
903 @@ -48,6 +48,9 @@
904  #include "util/format/u_format.h"
905  
906  #ifdef __cplusplus
907 +# ifdef __sun__
908 +# define restrict      __restrict__
909 +# endif
910  extern "C" {
911  #endif
912  
913
914
915 [FILE:302:patches/patch-src_intel_tools_aubinator__error__decode.c]
916 # expose getline in FreeBSD's stdio.h
917 #
918 --- src/intel/tools/aubinator_error_decode.c.orig       2021-08-11 20:27:37 UTC
919 +++ src/intel/tools/aubinator_error_decode.c
920 @@ -22,6 +22,9 @@
921   *
922   */
923  
924 +#ifdef __FreeBSD__
925 +#define _WITH_GETLINE
926 +#endif
927  #include <stdbool.h>
928  #include <stdio.h>
929  #include <stdlib.h>
930
931
932 [FILE:238:patches/patch-src_intel_tools_error2aub.c]
933 --- src/intel/tools/error2aub.c.orig    2021-08-11 20:27:37 UTC
934 +++ src/intel/tools/error2aub.c
935 @@ -22,6 +22,9 @@
936   *
937   */
938  
939 +#ifdef __FreeBSD__
940 +#define _WITH_GETLINE
941 +#endif
942  #include <assert.h>
943  #include <getopt.h>
944  #include <inttypes.h>
945
946
947 [FILE:936:patches/patch-src_mesa_drivers_dri_i965_brw__bufmgr.c]
948 --- src/mesa/drivers/dri/i965/brw_bufmgr.c.orig 2021-08-11 20:27:37 UTC
949 +++ src/mesa/drivers/dri/i965/brw_bufmgr.c
950 @@ -85,6 +85,10 @@
951  } while (0)
952  
953  
954 +#ifndef O_CLOEXEC
955 +#define O_CLOEXEC      0
956 +#endif
957 +
958  /* VALGRIND_FREELIKE_BLOCK unfortunately does not actually undo the earlier
959   * VALGRIND_MALLOCLIKE_BLOCK but instead leaves vg convinced the memory is
960   * leaked. All because it does not call VG(cli_free) from its
961 @@ -1885,8 +1889,12 @@ brw_bufmgr_create(struct gen_device_info
962        bufmgr->initial_kflags |= EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
963  
964        /* Allocate VMA in userspace if we have softpin and full PPGTT. */
965 +#ifdef __DragonFly__
966 +      if (false) {
967 +#else
968        if (gem_param(fd, I915_PARAM_HAS_EXEC_SOFTPIN) > 0 &&
969            gem_param(fd, I915_PARAM_HAS_ALIASING_PPGTT) > 1) {
970 +#endif
971           bufmgr->initial_kflags |= EXEC_OBJECT_PINNED;
972  
973           util_vma_heap_init(&bufmgr->vma_allocator[BRW_MEMZONE_LOW_4G],
974
975
976 [FILE:712:patches/patch-src_mesa_drivers_dri_i965_brw__disk__cache.c]
977 --- src/mesa/drivers/dri/i965/brw_disk_cache.c.orig     2021-08-11 20:27:37 UTC
978 +++ src/mesa/drivers/dri/i965/brw_disk_cache.c
979 @@ -394,6 +394,7 @@ brw_disk_cache_init(struct brw_screen *s
980     if (INTEL_DEBUG & DEBUG_DISK_CACHE_DISABLE_MASK)
981        return;
982  
983 +# ifdef HAVE_DL_ITERATE_PHDR
984     /* array length: print length + null char + 1 extra to verify it is unused */
985     char renderer[11];
986     ASSERTED int len = snprintf(renderer, sizeof(renderer), "i965_%04x",
987 @@ -413,5 +414,6 @@ brw_disk_cache_init(struct brw_screen *s
988     const uint64_t driver_flags =
989        brw_get_compiler_config_value(screen->compiler);
990     screen->disk_cache = disk_cache_create(renderer, timestamp, driver_flags);
991 +# endif
992  #endif
993  }
994
995
996 [FILE:851:patches/patch-src_mesa_drivers_dri_i965_brw__program__binary.c]
997 --- src/mesa/drivers/dri/i965/brw_program_binary.c.orig 2021-08-11 20:27:37 UTC
998 +++ src/mesa/drivers/dri/i965/brw_program_binary.c
999 @@ -36,9 +36,11 @@ static uint8_t driver_sha1[20];
1000  void
1001  brw_program_binary_init(unsigned device_id)
1002  {
1003 +#ifdef HAVE_DL_ITERATE_PHDR
1004     const struct build_id_note *note =
1005        build_id_find_nhdr_for_addr(brw_program_binary_init);
1006     assert(note);
1007 +#endif
1008  
1009     /**
1010      * With Mesa's megadrivers, taking the sha1 of i965_dri.so may not be
1011 @@ -52,7 +54,9 @@ brw_program_binary_init(unsigned device_
1012     int len = snprintf(renderer, sizeof(renderer), "i965_%04x", device_id);
1013     assert(len == sizeof(renderer) - 1);
1014     _mesa_sha1_update(&ctx, renderer, len);
1015 +#ifdef HAVE_DL_ITERATE_PHDR
1016     _mesa_sha1_update(&ctx, build_id_data(note), build_id_length(note));
1017 +#endif
1018     _mesa_sha1_final(&ctx, driver_sha1);
1019  }
1020  
1021
1022
1023 [FILE:328:patches/patch-src_util_build__id.c]
1024 # Elf_ doesn't exist, use Elf32_ or Elf64_
1025 #
1026 --- src/util/build_id.c.orig    2021-08-11 20:27:38 UTC
1027 +++ src/util/build_id.c
1028 @@ -35,7 +35,11 @@
1029  #endif
1030  
1031  #ifndef ElfW
1032 -#define ElfW(type) Elf_##type
1033 +#ifdef __LP64__
1034 +#define ElfW(type) Elf64_##type
1035 +#else
1036 +#define ElfW(type) Elf32_##type
1037 +#endif
1038  #endif
1039  
1040  struct build_id_note {
1041
1042
1043 [FILE:422:patches/patch-src_util_compiler.h]
1044 --- src/util/compiler.h.orig    2021-08-11 20:27:38 UTC
1045 +++ src/util/compiler.h
1046 @@ -51,6 +51,9 @@
1047  #if defined(__linux__)
1048  #include <byteswap.h>
1049  #define CPU_TO_LE32( x )       bswap_32( x )
1050 +#elif defined(__FreeBSD__) || defined(__DragonFly__)
1051 +#include <sys/endian.h>
1052 +#define CPU_TO_LE32( x )       bswap32( x )
1053  #elif defined(__APPLE__)
1054  #include <CoreFoundation/CFByteOrder.h>
1055  #define CPU_TO_LE32( x )       CFSwapInt32HostToLittle( x )
1056
1057
1058 [FILE:1512:patches/patch-src_util_futex.h]
1059 - Implement futex_wake() and futex_wait() via _umtx_op()
1060
1061 --- src/util/futex.h.orig       2021-08-11 20:27:38 UTC
1062 +++ src/util/futex.h
1063 @@ -30,10 +30,35 @@
1064  #include <limits.h>
1065  #include <stdint.h>
1066  #include <unistd.h>
1067 +#if defined(__FreeBSD__)
1068 +#include <errno.h>
1069 +# if __FreeBSD__ < 11
1070 +#  include <machine/atomic.h>
1071 +# endif
1072 +#include <sys/umtx.h>
1073 +#else
1074  #include <linux/futex.h>
1075  #include <sys/syscall.h>
1076 +#endif
1077  #include <sys/time.h>
1078  
1079 +#if defined(__FreeBSD__)
1080 +static inline int futex_wake(uint32_t *addr, int count)
1081 +{
1082 +   return _umtx_op(addr, UMTX_OP_WAKE, (uint32_t)count, NULL, NULL) == -1 ? errno : 0;
1083 +}
1084 +
1085 +static inline int futex_wait(uint32_t *addr, int32_t value, struct timespec *timeout)
1086 +{
1087 +   void *uaddr = NULL, *uaddr2 = NULL;
1088 +   if (timeout != NULL) {
1089 +      const struct _umtx_time tmo = { ._timeout = *timeout, ._flags = UMTX_ABSTIME, ._clockid = CLOCK_MONOTONIC };
1090 +      uaddr = (void *)(uintptr_t)sizeof(tmo);
1091 +      uaddr2 = (void *)&tmo;
1092 +   }
1093 +   return _umtx_op(addr, UMTX_OP_WAIT_UINT, (uint32_t)value, uaddr, uaddr2) == -1 ? errno : 0;
1094 +}
1095 +#else
1096  static inline long sys_futex(void *addr1, int op, int val1, const struct timespec *timeout, void *addr2, int val3)
1097  {
1098     return syscall(SYS_futex, addr1, op, val1, timeout, addr2, val3);
1099 @@ -51,6 +76,7 @@ static inline int futex_wait(uint32_t *a
1100     return sys_futex(addr, FUTEX_WAIT_BITSET, value, timeout, NULL,
1101                      FUTEX_BITSET_MATCH_ANY);
1102  }
1103 +#endif
1104  
1105  #elif defined(__FreeBSD__)
1106  #define UTIL_FUTEX_SUPPORTED 1
1107
1108
1109 [FILE:239:patches/patch-src_util_libsync.h]
1110 --- src/util/libsync.h.orig     2021-08-11 20:27:38 UTC
1111 +++ src/util/libsync.h
1112 @@ -36,6 +36,10 @@
1113  #include <sys/poll.h>
1114  #include <unistd.h>
1115  
1116 +#ifdef __sun__
1117 +#include <sys/ioccom.h>
1118 +#endif
1119 +
1120  #if defined(__cplusplus)
1121  extern "C" {
1122  #endif
1123
1124
1125 [FILE:310:patches/patch-src_util_memstream.c]
1126 --- src/util/memstream.c.orig   2021-08-11 20:27:38 UTC
1127 +++ src/util/memstream.c
1128 @@ -51,7 +51,7 @@ u_memstream_open(struct u_memstream *mem
1129     }
1130  
1131     return success;
1132 -#elif defined(__APPLE__)
1133 +#elif defined(__APPLE__) || defined(__sun)
1134     return false;
1135  #else
1136     FILE *const f = open_memstream(bufp, sizep);
1137
1138
1139 [FILE:230:patches/patch-src_util_os__file.c]
1140 --- src/util/os_file.c.orig     2021-08-11 20:27:38 UTC
1141 +++ src/util/os_file.c
1142 @@ -25,6 +25,9 @@
1143  #endif
1144  #endif
1145  
1146 +#ifndef ENODATA
1147 +#define ENODATA ENOATTR
1148 +#endif
1149  
1150  FILE *
1151  os_file_create_unique(const char *filename, int filemode)
1152
1153
1154 [FILE:592:patches/patch-src_util_os__memory__aligned.h]
1155 --- src/util/os_memory_aligned.h.orig   2021-08-11 20:27:38 UTC
1156 +++ src/util/os_memory_aligned.h
1157 @@ -53,11 +53,16 @@ add_overflow_size_t(size_t a, size_t b,
1158  static inline void *
1159  os_malloc_aligned(size_t size, size_t alignment)
1160  {
1161 +#ifdef __sun__
1162 +   alignment = (alignment + sizeof(void*) - 1) & ~(sizeof(void*) - 1);
1163 +   return memalign(alignment, size);
1164 +#else
1165     void *ptr;
1166     alignment = (alignment + sizeof(void*) - 1) & ~(sizeof(void*) - 1);
1167     if(posix_memalign(&ptr, alignment, size) != 0)
1168        return NULL;
1169     return ptr;
1170 +#endif
1171  }
1172  
1173  #define os_free_aligned(_ptr) free(_ptr)
1174
1175
1176 [FILE:853:patches/patch-src_util_strndup.h]
1177 --- src/util/strndup.h.orig     2021-08-11 20:27:38 UTC
1178 +++ src/util/strndup.h
1179 @@ -24,7 +24,7 @@
1180  #ifndef STRNDUP_H
1181  #define STRNDUP_H
1182  
1183 -#if defined(_WIN32)
1184 +#if defined(_WIN32) || defined(__sun)
1185  
1186  #include <stdlib.h> // size_t
1187  #include <string.h>
1188 @@ -34,6 +34,7 @@ extern "C" {
1189  #endif
1190  
1191  static inline char *
1192 +#if defined(_WIN32)
1193  strndup(const char *str, size_t max)
1194  {
1195     size_t n;
1196 @@ -50,6 +51,22 @@ strndup(const char *str, size_t max)
1197     memcpy(ptr, str, n);
1198     return ptr;
1199  }
1200 +#else  // version without strnlen
1201 +strndup(const char *str, size_t n)
1202 +{
1203 +    size_t len;
1204 +    char *copy;
1205 +
1206 +    len = strlen(str);
1207 +    if (len <= n)
1208 +        return (strdup(str));
1209 +    if ((copy = (char *)malloc(len + 1)) == NULL)
1210 +        return (NULL);
1211 +    memcpy(copy, str, len);
1212 +    copy[len] = '\0';
1213 +    return (copy);
1214 +}
1215 +#endif
1216  
1217  #ifdef __cplusplus
1218  }
1219
1220
1221 [FILE:430:patches/patch-src_util_u__atomic.h]
1222 --- src/util/u_atomic.h.orig    2021-08-11 20:27:38 UTC
1223 +++ src/util/u_atomic.h
1224 @@ -20,11 +20,7 @@
1225   * locally coded assembly, compiler intrinsic or ultimately a
1226   * mutex-based implementation.
1227   */
1228 -#if defined(__sun)
1229 -#define PIPE_ATOMIC_OS_SOLARIS
1230 -#elif defined(_MSC_VER)
1231 -#define PIPE_ATOMIC_MSVC_INTRINSIC
1232 -#elif defined(__GNUC__)
1233 +#if defined(__GNUC__)
1234  #define PIPE_ATOMIC_GCC_INTRINSIC
1235  #else
1236  #error "Unsupported platform"
1237
1238
1239 [FILE:188:patches/patch-src_util_u__math.h]
1240 --- src/util/u_math.h.orig      2021-08-11 20:27:38 UTC
1241 +++ src/util/u_math.h
1242 @@ -51,6 +51,7 @@
1243  extern "C" {
1244  #endif
1245  
1246 +#undef ALIGN
1247  
1248  #ifndef M_SQRT2
1249  #define M_SQRT2 1.41421356237309504880
1250
1251
1252 [FILE:1328:patches/patch-src_util_u__thread.h]
1253 --- src/util/u_thread.h.orig    2021-08-11 20:27:38 UTC
1254 +++ src/util/u_thread.h
1255 @@ -39,6 +39,7 @@
1256  #include <signal.h>
1257  #ifdef HAVE_PTHREAD_NP_H
1258  #include <pthread_np.h>
1259 +#undef ALIGN
1260  #endif
1261  #endif
1262  
1263 @@ -103,9 +104,9 @@ static inline thrd_t u_thread_create(int
1264  static inline void u_thread_setname( const char *name )
1265  {
1266  #if defined(HAVE_PTHREAD)
1267 -#if DETECT_OS_LINUX || DETECT_OS_CYGWIN || DETECT_OS_SOLARIS
1268 +#if DETECT_OS_LINUX || DETECT_OS_CYGWIN
1269     pthread_setname_np(pthread_self(), name);
1270 -#elif DETECT_OS_FREEBSD || DETECT_OS_OPENBSD
1271 +#elif DETECT_OS_FREEBSD || DETECT_OS_OPENBSD || DETECT_OS_DRAGONFLY
1272     pthread_set_name_np(pthread_self(), name);
1273  #elif DETECT_OS_NETBSD
1274     pthread_setname_np(pthread_self(), "%s", (void *)name);
1275 @@ -113,8 +114,6 @@ static inline void u_thread_setname( con
1276     pthread_setname_np(name);
1277  #elif DETECT_OS_HAIKU
1278     rename_thread(find_thread(NULL), name);
1279 -#else
1280 -#warning Not sure how to call pthread_setname_np
1281  #endif
1282  #endif
1283     (void)name;
1284 @@ -209,7 +208,7 @@ util_set_current_thread_affinity(const u
1285  static inline int64_t
1286  util_thread_get_time_nano(thrd_t thread)
1287  {
1288 -#if defined(HAVE_PTHREAD) && !defined(__APPLE__) && !defined(__HAIKU__)
1289 +#if defined(HAVE_PTHREAD) && !defined(__APPLE__) && !defined(__HAIKU__) && !defined(__sun)
1290     struct timespec ts;
1291     clockid_t cid;
1292  
1293
1294
1295 [FILE:25:files/special.mk]
1296 GALLIUM_DRIVERS+=       SWRAST
1297
1298
1299 [FILE:911:sunos/patch-src_gallium_targets_dri_meson.build]
1300 --- src/gallium/targets/dri/meson.build.orig    2020-12-31 03:59:58 UTC
1301 +++ src/gallium/targets/dri/meson.build
1302 @@ -45,11 +45,12 @@ libgallium_dri = shared_library(
1303      inc_gallium_winsys, include_directories('../../frontends/dri'),
1304    ],
1305    gnu_symbol_visibility : 'hidden',
1306 -  link_args : [ld_args_build_id, ld_args_gc_sections, gallium_dri_ld_args],
1307 +  link_args : [ld_args_gc_sections, gallium_dri_ld_args],
1308    link_depends : gallium_dri_link_depends,
1309 +  link_whole : [libdri, libdricommon, libgallium, libr300, _libnir, libglsl, libglcpp], # libr600, libamd_common
1310    link_with : [
1311 -    libdri, libmesa_gallium, libdricommon, libmegadriver_stub, libgalliumvl,
1312 -    libgallium, libglapi, libpipe_loader_static, libws_null, libwsw, libswdri,
1313 +    libmesa_gallium, libmegadriver_stub, libgalliumvl,
1314 +    libglapi, libpipe_loader_static, libws_null, libwsw, libswdri,
1315      libswkmsdri,
1316    ],
1317    dependencies : [
1318
1319
1320 [FILE:424:sunos/patch-src_gallium_targets_opencl_meson.build]
1321 --- src/gallium/targets/opencl/meson.build.orig 2021-01-29 18:33:19 UTC
1322 +++ src/gallium/targets/opencl/meson.build
1323 @@ -90,7 +90,7 @@ libopencl = shared_library(
1324    [],
1325    link_args : [ld_args_gc_sections, opencl_link_args],
1326    link_depends : opencl_link_deps,
1327 -  link_whole : libclover,
1328 +  link_whole : [libclover,libmesa_format],
1329    link_with : [libpipe_loader_dynamic, libgallium],
1330    dependencies : [
1331      idep_mesautil,
1332
1333
1334 [FILE:604:sunos/patch-src_gallium_targets_osmesa_meson.build]
1335 --- src/gallium/targets/osmesa/meson.build.orig 2020-12-31 03:59:58 UTC
1336 +++ src/gallium/targets/osmesa/meson.build
1337 @@ -49,9 +49,9 @@ libosmesa = shared_library(
1338      inc_gallium_drivers,
1339    ],
1340    link_depends : osmesa_link_deps,
1341 -  link_whole : [libosmesa_st, libglapi_static],
1342 +  link_whole : [libosmesa_st, libglapi_static, libsoftpipe, libgallium, _libnir, libglsl, libglcpp],
1343    link_with : [
1344 -    libmesa_gallium, libgallium, libws_null, osmesa_link_with,
1345 +    libmesa_gallium, libws_null, osmesa_link_with,
1346    ],
1347    dependencies : [
1348      dep_ws2_32, dep_selinux, dep_thread, dep_clock, dep_unwind,
1349
1350
1351 [FILE:2062:sunos/patch-src_gallium_targets_pipe-loader_meson.build]
1352 --- src/gallium/targets/pipe-loader/meson.build.orig    2021-01-29 18:33:19 UTC
1353 +++ src/gallium/targets/pipe-loader/meson.build
1354 @@ -57,16 +57,16 @@ if with_gallium_v3d
1355  endif
1356  
1357  pipe_loaders = [
1358 -  [with_gallium_i915, 'i915', driver_i915, []],
1359 -  [with_gallium_iris, 'iris', [driver_iris, idep_xmlconfig], []],
1360 -  [with_gallium_nouveau, 'nouveau', driver_nouveau, []],
1361 -  [with_gallium_r300, 'r300', driver_r300, []],
1362 -  [with_gallium_r600, 'r600', driver_r600, []],
1363 -  [with_gallium_radeonsi, 'radeonsi', [driver_radeonsi, idep_xmlconfig], []],
1364 -  [with_gallium_freedreno, 'msm', driver_freedreno, []],
1365 -  [with_gallium_kmsro, 'kmsro', _kmsro_targets, []],
1366 -  [with_gallium_svga, 'vmwgfx', driver_svga, []],
1367 -  [with_gallium_softpipe, 'swrast', [driver_swrast, driver_swr], [libwsw, libws_null]],
1368 +  [with_gallium_i915, 'i915', driver_i915, [], []],
1369 +  [with_gallium_iris, 'iris', [driver_iris, idep_xmlconfig], [], []],
1370 +  [with_gallium_nouveau, 'nouveau', driver_nouveau, [], []],
1371 +  [with_gallium_r300, 'r300', driver_r300, [], [libr300,libradeonwinsys,libmesa_format]],
1372 +  [with_gallium_r600, 'r600', driver_r600, [], [libr600,libradeonwinsys,libmesa_format,libgalliumvl]],
1373 +  [with_gallium_radeonsi, 'radeonsi', [driver_radeonsi], [], [libradeonsi,libradeonwinsys,libamd_common,libamd_common_llvm,libmesa_format,_libxmlconfig,libgalliumvl]],
1374 +  [with_gallium_freedreno, 'msm', driver_freedreno, [], []],
1375 +  [with_gallium_kmsro, 'kmsro', _kmsro_targets, [], []],
1376 +  [with_gallium_svga, 'vmwgfx', driver_svga, [], [libsvga,libsvgadrm,libmesa_format]],
1377 +  [with_gallium_softpipe, 'swrast', [driver_swrast, driver_swr], [libwsw, libws_null], [libllvmpipe,libmesa_format,libsoftpipe]],
1378  ]
1379  
1380  foreach x : pipe_loaders
1381 @@ -80,6 +80,7 @@ foreach x : pipe_loaders
1382        link_args : pipe_loader_link_args,
1383        link_depends : pipe_loader_link_deps,
1384        include_directories : pipe_loader_incs,
1385 +      link_whole : [x[4]],
1386        link_with : [pipe_loader_link_with, x[3]],
1387        dependencies : [idep_mesautil, idep_nir, dep_thread, x[2]],
1388        name_prefix : '',
1389
1390
1391 [FILE:838:sunos/patch-src_gallium_targets_va_meson.build]
1392 --- src/gallium/targets/va/meson.build.orig     2021-01-29 18:33:19 UTC
1393 +++ src/gallium/targets/va/meson.build
1394 @@ -39,13 +39,14 @@ libva_gallium = shared_library(
1395    include_directories : [
1396      inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_util, inc_gallium_winsys, inc_gallium_drivers,
1397    ],
1398 -  link_whole : [libva_st],
1399 +  link_whole : [libva_st, _libxmlconfig, libmesa_format, libloader, libpipe_loader_static],
1400    link_with : [
1401      libgalliumvlwinsys, libgalliumvl, libgallium,
1402 -    libpipe_loader_static, libws_null, libwsw, libswdri, libswkmsdri,
1403 +    libws_null, libwsw, libswdri, libswkmsdri,
1404 +    libr600, libradeonsi,
1405    ],
1406    dependencies : [
1407 -    dep_libdrm, driver_r600, driver_radeonsi, driver_nouveau,
1408 +    dep_libdrm, driver_nouveau,
1409      idep_mesautil,
1410    ],
1411    link_depends : va_link_depends,
1412
1413
1414 [FILE:784:sunos/patch-src_gallium_targets_vdpau_meson.build]
1415 --- src/gallium/targets/vdpau/meson.build.orig  2020-12-31 03:59:58 UTC
1416 +++ src/gallium/targets/vdpau/meson.build
1417 @@ -44,10 +44,10 @@ libvdpau_gallium = shared_library(
1418    include_directories : [
1419      inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_util, inc_gallium_winsys, inc_gallium_drivers,
1420    ],
1421 -  link_whole : [libvdpau_st],
1422 +  link_whole : [libvdpau_st, libr300, libradeonwinsys, libmesa_format, _libxmlconfig, libpipe_loader_static, libgallium, _libnir], # libr600, libradeonsi, libamd_common, libamd_common_llvm,
1423    link_with : [
1424      libgalliumvlwinsys, libgalliumvl, libgallium,
1425 -    libpipe_loader_static, libws_null, libwsw, libswdri, libswkmsdri,
1426 +    libws_null, libwsw, libswdri, libswkmsdri,
1427    ],
1428    dependencies : [
1429      idep_mesautil,
1430
1431
1432 [FILE:670:sunos/patch-src_gallium_targets_xa_meson.build]
1433 --- src/gallium/targets/xa/meson.build.orig     2020-12-31 03:59:58 UTC
1434 +++ src/gallium/targets/xa/meson.build
1435 @@ -40,9 +40,9 @@ libxatracker = shared_library(
1436    include_directories : [
1437      inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_util, inc_gallium_winsys, inc_gallium_drivers,
1438    ],
1439 -  link_whole : [libxa_st],
1440 +  link_whole : [libxa_st, libsvga, libsvgadrm, libpipe_loader_static, libmesa_format, _libxmlconfig, libgallium, _libnir],
1441    link_with : [
1442 -    libgalliumvl_stub, libgallium, libpipe_loader_static,
1443 +    libgalliumvl_stub, libgallium,
1444      libws_null, libwsw, libswdri, libswkmsdri,
1445    ],
1446    link_depends : xa_link_depends,
1447
1448
1449 [FILE:846:sunos/patch-src_gallium_targets_xvmc_meson.build]
1450 --- src/gallium/targets/xvmc/meson.build.orig   2021-01-29 18:33:19 UTC
1451 +++ src/gallium/targets/xvmc/meson.build
1452 @@ -39,12 +39,12 @@ libxvmc_gallium = shared_library(
1453    include_directories : [
1454      inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_util, inc_gallium_winsys, inc_gallium_drivers,
1455    ],
1456 -  link_whole : [libxvmc_st],
1457 +  link_whole : [libxvmc_st,libradeonwinsys,libr600,_libxmlconfig,libmesa_format,libpipe_loader_static],
1458    link_with : [
1459      libgalliumvlwinsys, libgalliumvl, libgallium,
1460      libpipe_loader_static, libws_null, libwsw, libswdri, libswkmsdri,
1461    ],
1462 -  dependencies : [idep_mesautil, driver_r600, driver_nouveau],
1463 +  dependencies : [idep_mesautil, driver_nouveau],
1464    link_depends : xvmc_link_depends,
1465    # Will be deleted during installation, see install_megadrivers.py
1466    install : true,
1467
1468
1469 [FILE:510:sunos/patch-src_gbm_meson.build]
1470 --- src/gbm/meson.build.orig    2021-01-29 18:33:19 UTC
1471 +++ src/gbm/meson.build
1472 @@ -49,8 +49,8 @@ libgbm = shared_library(
1473    include_directories : incs_gbm,
1474    c_args : [args_gbm],
1475    link_args : [ld_args_gc_sections],
1476 -  link_with : libloader,
1477 -  dependencies : [deps_gbm, dep_dl, dep_thread, idep_mesautil, idep_xmlconfig],
1478 +  link_with : [libloader, _libxmlconfig],
1479 +  dependencies : [deps_gbm, dep_dl, dep_thread, idep_mesautil],
1480    gnu_symbol_visibility : 'hidden',
1481    version : '1.0.0',
1482    install : true,
1483
1484
1485 [FILE:997:sunos/patch-src_mesa_drivers_dri_meson.build]
1486 --- src/mesa/drivers/dri/meson.build.orig       2020-12-31 03:59:58 UTC
1487 +++ src/mesa/drivers/dri/meson.build
1488 @@ -20,7 +20,7 @@
1489  
1490  subdir('common')
1491  
1492 -_dri_drivers = []
1493 +_dri_drivers = [ _libnir, libmesa_classic, libmesa_common, libintel_compiler, libglcpp, libdricommon ]
1494  _dri_link = []
1495  if with_dri_swrast
1496    subdir('swrast')
1497 @@ -59,14 +59,13 @@ if _dri_drivers != []
1498      [],
1499      link_whole : _dri_drivers,
1500      link_with : [
1501 -      libmegadriver_stub, libdricommon, libglapi,
1502 -      libmesa_classic,
1503 +      libmegadriver_stub, libglapi, libintel_dev,
1504      ],
1505      dependencies : [
1506        dep_selinux, dep_libdrm, dep_m, dep_thread, dep_dl,
1507 -      idep_nir, idep_xmlconfig, idep_mesautil,
1508 +      idep_xmlconfig, idep_mesautil,
1509      ],
1510 -    link_args : [ld_args_build_id, ld_args_bsymbolic, ld_args_gc_sections],
1511 +    link_args : [ld_args_build_id, ld_args_gc_sections],
1512      # Will be deleted during installation, see install_megadrivers.py
1513      install : true,
1514      install_dir : dri_drivers_path,
1515