diff --git a/desktop/font/gnu-gs-fonts-std/pspec.xml b/desktop/font/gnu-gs-fonts-std/pspec.xml index 3b4ee55268..73467f8a94 100644 --- a/desktop/font/gnu-gs-fonts-std/pspec.xml +++ b/desktop/font/gnu-gs-fonts-std/pspec.xml @@ -27,6 +27,13 @@ + + 2017-02-05 + 8.11 + Rebuild + Pisi Linux Community + admin@pisilinux.org + 2016-06-09 8.11 diff --git a/desktop/toolkit/qt5/qt5-base/pspec.xml b/desktop/toolkit/qt5/qt5-base/pspec.xml index 09d4ae40bb..efc40a71d5 100644 --- a/desktop/toolkit/qt5/qt5-base/pspec.xml +++ b/desktop/toolkit/qt5/qt5-base/pspec.xml @@ -11,7 +11,7 @@ Cross platform application and UI framework Cross platform application and UI development framework 'GPL3' 'LGPL3' 'FDL' 'custom' - http://download.qt.io/official_releases/qt/5.6/5.6.2/submodules/qtbase-opensource-src-5.6.2.tar.xz + http://download.qt.io/official_releases/qt/5.7/5.7.1/submodules/qtbase-opensource-src-5.7.1.tar.xz at-spi2-core-devel cups-devel @@ -248,6 +248,13 @@ + + 2017-02-04 + 5.7.1 + Release bump. + Stefan Gronewold(groni) + groni@pisilinux.org + 2016-10-21 5.6.2 @@ -284,4 +291,4 @@ ertugrulerata@gmail.com - \ No newline at end of file + diff --git a/hardware/misc/gpm/pspec.xml b/hardware/misc/gpm/pspec.xml index 3552bc1282..7de26e54ea 100644 --- a/hardware/misc/gpm/pspec.xml +++ b/hardware/misc/gpm/pspec.xml @@ -44,6 +44,13 @@ + + 2017-02-05 + 1.20.7 + Rebuild + Pisi Linux Community + admin@pisilinux.org + 2016-06-09 1.20.7 diff --git a/hardware/optical/libcdio/pspec.xml b/hardware/optical/libcdio/pspec.xml index 4a9184e95a..0ca10af0d2 100644 --- a/hardware/optical/libcdio/pspec.xml +++ b/hardware/optical/libcdio/pspec.xml @@ -12,7 +12,7 @@ library A library to encapsulate CD-ROM reading and control This library provides an interface for CD-ROM access. It can be used by applications that need OS- and device-independent access to CD-ROM devices. - mirrors://gnu/libcdio/libcdio-0.92.tar.gz + mirrors://gnu/libcdio/libcdio-0.94.tar.gz libgcc @@ -49,6 +49,13 @@ + + 2017-02-05 + 0.94 + Version Bump + Pisi Linux Community + admin@pisilinux.org + 2016-06-09 0.92 diff --git a/hardware/printer/libpaper/pspec.xml b/hardware/printer/libpaper/pspec.xml index 9db68f73b7..a58384fe4b 100644 --- a/hardware/printer/libpaper/pspec.xml +++ b/hardware/printer/libpaper/pspec.xml @@ -48,6 +48,13 @@ + + 2017-02-05 + 1.1.24 + Rebuild + Pisi Linux Community + admin@pisilinux.org + 2016-06-09 1.1.24 diff --git a/multimedia/converter/ccd2iso/pspec.xml b/multimedia/converter/ccd2iso/pspec.xml index 7f43c226b8..76a3ad6ba7 100644 --- a/multimedia/converter/ccd2iso/pspec.xml +++ b/multimedia/converter/ccd2iso/pspec.xml @@ -25,6 +25,13 @@ + + 2017-02-05 + 0.3 + Rebuild + Pisi Linux Community + admin@pisilinux.org + 2016-06-09 0.3 diff --git a/multimedia/converter/libnut/pspec.xml b/multimedia/converter/libnut/pspec.xml index 28130e676e..715b040575 100644 --- a/multimedia/converter/libnut/pspec.xml +++ b/multimedia/converter/libnut/pspec.xml @@ -40,6 +40,13 @@ + + 2017-02-05 + 0.0_661 + Rebuild + Pisi Linux Community + admin@pisilinux.org + 2016-06-09 0.0_661 diff --git a/multimedia/converter/unoconv/pspec.xml b/multimedia/converter/unoconv/pspec.xml index 6e8e555cea..dd02263748 100644 --- a/multimedia/converter/unoconv/pspec.xml +++ b/multimedia/converter/unoconv/pspec.xml @@ -34,6 +34,13 @@ + + 2017-02-05 + 0.7 + Rebuild + Pisi Linux Community + admin@pisilinux.org + 2016-06-09 0.7 diff --git a/multimedia/converter/vcdimager/pspec.xml b/multimedia/converter/vcdimager/pspec.xml index 6db17a9d9a..e19f08eba0 100644 --- a/multimedia/converter/vcdimager/pspec.xml +++ b/multimedia/converter/vcdimager/pspec.xml @@ -15,7 +15,7 @@ VCDImager is a full-featured mastering suite for authoring, disassembling and analyzing Video CD's and Super Video CD's. The core functionality consists of directly making Video CD BIN/CUE-style CD images from mpeg files. http://ftp.gnu.org/gnu/vcdimager/vcdimager-0.7.24.tar.gz - libcdio-devel + libcdio-devel popt @@ -23,7 +23,7 @@ vcdimager - libcdio + libcdio popt libxml2 @@ -50,6 +50,13 @@ + + 2017-02-05 + 0.7.24 + Rebuild + Pisi Linux Community + admin@pisilinux.org + 2016-06-09 0.7.24 diff --git a/multimedia/editor/blender/actions.py b/multimedia/editor/blender/actions.py index 2d5c1bc798..29485d297e 100644 --- a/multimedia/editor/blender/actions.py +++ b/multimedia/editor/blender/actions.py @@ -33,10 +33,10 @@ def setup(): -DWITH_GAMEENGINE=ON \ -DWITH_PYTHON_INSTALL=OFF \ -DWITH_MOD_OCEANSIM=ON \ - -DPYTHON_VERSION=3.4 \ + -DPYTHON_VERSION=3.6 \ -DPYTHON_LIBPATH=/usr/lib \ - -DPYTHON_LIBRARY=python3.4m \ - -DPYTHON_INCLUDE_DIRS=/usr/include/python3.4m \ + -DPYTHON_LIBRARY=python3.6m \ + -DPYTHON_INCLUDE_DIRS=/usr/include/python3.6m \ -DWITH_CODEC_SNDFILE=ON ") def build(): diff --git a/multimedia/editor/blender/pspec.xml b/multimedia/editor/blender/pspec.xml index e65de6ce2c..face18b855 100644 --- a/multimedia/editor/blender/pspec.xml +++ b/multimedia/editor/blender/pspec.xml @@ -39,7 +39,7 @@ openal-devel openexr-devel openjpeg-devel - python3-devel + python3-devel tiff-devel openimageio-devel webp-devel diff --git a/multimedia/editor/dvdauthor/files/dvdauthor-fix-build.patch b/multimedia/editor/dvdauthor/files/dvdauthor-fix-build.patch new file mode 100644 index 0000000000..0a3f4422ed --- /dev/null +++ b/multimedia/editor/dvdauthor/files/dvdauthor-fix-build.patch @@ -0,0 +1,25 @@ +Description: Fix for #807657 -- missing include "config.h" +Author: Tobias Frost +Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=807657 +Last-Update: 2016-01-07 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +--- a/src/compat.h ++++ b/src/compat.h +@@ -1,6 +1,8 @@ + // basic headers + #define _GNU_SOURCE /* really just for strndup */ + ++#include "config.h" ++ + #ifdef HAVE_STDBOOL_H + # include + #else +@@ -17,6 +19,7 @@ + # define __bool_true_false_are_defined 1 + #endif + ++ + #include + + #ifdef HAVE_STDLIB_H diff --git a/multimedia/editor/dvdauthor/pspec.xml b/multimedia/editor/dvdauthor/pspec.xml index e4788fe321..cb2a4e1694 100644 --- a/multimedia/editor/dvdauthor/pspec.xml +++ b/multimedia/editor/dvdauthor/pspec.xml @@ -12,7 +12,7 @@ app:console A simple DVD tool dvdauthor is a set of simple tools to help you author a DVD. - https://sourceforge.net/projects/dvdauthor/files/dvdauthor-0.7.2.tar.gz + https://sourceforge.net/projects/dvdauthor/files/dvdauthor/0.7.1/dvdauthor-0.7.1.tar.gz fribidi-devel libdvdread-devel @@ -24,7 +24,7 @@ libxml2-devel - + dvdauthor-fix-build.patch @@ -51,8 +51,8 @@ 2017-02-03 - 0.7.2 - Version bump. + 0.7.1 + Rebuild for new Toolchains. Stefan Gronewold(groni) groni@pisilinux.org diff --git a/multimedia/graphics/aalib/pspec.xml b/multimedia/graphics/aalib/pspec.xml index a4bd170863..885c6b256a 100644 --- a/multimedia/graphics/aalib/pspec.xml +++ b/multimedia/graphics/aalib/pspec.xml @@ -51,6 +51,13 @@ + + 2017-02-05 + 1.4_rc5 + Rebuild + Pisi Linux Community + admin@pisilinux.org + 2016-06-09 1.4_rc5 diff --git a/multimedia/graphics/babl/actions.py b/multimedia/graphics/babl/actions.py index 1453027ac4..c0062de730 100644 --- a/multimedia/graphics/babl/actions.py +++ b/multimedia/graphics/babl/actions.py @@ -18,4 +18,4 @@ def build(): def install(): autotools.install() - pisitools.dodoc("AUTHORS", "ChangeLog", "COPYING", "NEWS", "README", "TODO") + pisitools.dodoc("AUTHORS", "COPYING", "NEWS", "README", "TODO") diff --git a/multimedia/graphics/babl/pspec.xml b/multimedia/graphics/babl/pspec.xml index af223e28cb..58e9a1e549 100644 --- a/multimedia/graphics/babl/pspec.xml +++ b/multimedia/graphics/babl/pspec.xml @@ -13,7 +13,7 @@ library A dynamic, any to any, pixel format translation library babl is a library that allows converting between different methods of storing pixels known as pixel formats that have with different bitdepths and other data representations, color models and component permutations. - http://download.gimp.org/pub/babl/0.1/babl-0.1.12.tar.bz2 + https://download.gimp.org/pub/babl/0.1/babl-0.1.24.tar.bz2 @@ -43,6 +43,13 @@ + + 2017-02-05 + 0.1.24 + Version Bump + Pisi Linux Community + admin@pisilinux.org + 2016-06-09 0.1.12 diff --git a/multimedia/graphics/giflib/pspec.xml b/multimedia/graphics/giflib/pspec.xml index 79cb8a8ac6..7388036768 100644 --- a/multimedia/graphics/giflib/pspec.xml +++ b/multimedia/graphics/giflib/pspec.xml @@ -12,7 +12,7 @@ library Library to handle, display and manipulate GIF images The giflib package contains a shared library of functions for loading and saving GIF format image files. It is API and ABI compatible with libungif, the library which supported uncompressed GIFs while the Unisys LZW patent was in effect. - mirrors://sourceforge/giflib/giflib-5.0.6.tar.bz2 + mirrors://sourceforge/giflib/giflib-5.1.4.tar.bz2 + @@ -63,6 +63,13 @@ + + 2017-02-05 + 1.4.9 + Version Bump + Pisi Linux Community + admin@pisilinux.org + 2016-06-09 1.4.6 diff --git a/multimedia/graphics/jasper/pspec.xml b/multimedia/graphics/jasper/pspec.xml index 3479d0f066..fe80e7e731 100644 --- a/multimedia/graphics/jasper/pspec.xml +++ b/multimedia/graphics/jasper/pspec.xml @@ -13,14 +13,14 @@ library Software implementation of JPEG-2000 Part 1 JasPer is a software-based implementation of the codec specified in the JPEG-2000 Part-1 standard (ISO/IEC 15444-1:2000). - http://www.ece.uvic.ca/~mdadams/jasper/software/jasper-1.900.1.zip + http://www.ece.uvic.ca/~frodo/jasper/software/jasper-2.0.10.tar.gz libjpeg-turbo-devel - jasper-1.900.1-fixes-20081208.patch.bz2 + @@ -81,6 +81,13 @@ + + 2017-02-06 + 2.0.10 + Version Bump + Pisi Linux Community + admin@pisilinux.org + 2016-06-09 1.900.1 diff --git a/multimedia/graphics/lcms/pspec.xml b/multimedia/graphics/lcms/pspec.xml index 1e05476a47..ad41beb365 100644 --- a/multimedia/graphics/lcms/pspec.xml +++ b/multimedia/graphics/lcms/pspec.xml @@ -73,6 +73,13 @@ + + 2017-02-05 + 1.19 + Rebuild + Pisi Linux Community + admin@pisilinux.org + 2016-06-09 1.19 diff --git a/multimedia/graphics/lcms2/pspec.xml b/multimedia/graphics/lcms2/pspec.xml index 8f6426ae0e..07a289ffa4 100644 --- a/multimedia/graphics/lcms2/pspec.xml +++ b/multimedia/graphics/lcms2/pspec.xml @@ -13,7 +13,7 @@ library A color management library. Little cms is a color management library. Implements fast transforms between ICC profiles. It is focused on speed, and is portable across several platforms. - http://sourceforge.net/projects/lcms/files/lcms/2.6/lcms2-2.6.tar.gz + http://sourceforge.net/projects/lcms/files/lcms/2.8/lcms2-2.8.tar.gz libjpeg-turbo-devel tiff-devel @@ -65,6 +65,13 @@ + + 2017-02-05 + 2.8 + Version Bump + Pisi Linux Community + admin@pisilinux.org + 2016-06-09 2.6 diff --git a/multimedia/graphics/lensfun/pspec.xml b/multimedia/graphics/lensfun/pspec.xml index 9ab7f28df0..ff6cb82fd4 100644 --- a/multimedia/graphics/lensfun/pspec.xml +++ b/multimedia/graphics/lensfun/pspec.xml @@ -53,7 +53,14 @@ - + + 2017-02-05 + 0.3.2 + Rebuild. + Stefan Gronewold(groni) + groni@pisilinux.org + + 2016-11-13 0.3.2 First Release. diff --git a/multimedia/graphics/libart_lgpl/pspec.xml b/multimedia/graphics/libart_lgpl/pspec.xml index 5945d8ccb9..701285ee0a 100644 --- a/multimedia/graphics/libart_lgpl/pspec.xml +++ b/multimedia/graphics/libart_lgpl/pspec.xml @@ -42,6 +42,13 @@ + + 2017-02-05 + 2.3.21 + Rebuild + Pisi Linux Community + admin@pisilinux.org + 2016-06-09 2.3.21 diff --git a/multimedia/graphics/libmng/pspec.xml b/multimedia/graphics/libmng/pspec.xml index 2d8265caad..def1820276 100644 --- a/multimedia/graphics/libmng/pspec.xml +++ b/multimedia/graphics/libmng/pspec.xml @@ -12,7 +12,7 @@ library Multiple Image Networkgraphics lib (animated png's) Libmng -The reference library for reading, displaying, writing and examining Multiple-Image Network Graphics. MNG is the animation extension to the popular PNG image-format. - http://sourceforge.net/projects/libmng/files/libmng-devel/2.0.2/libmng-2.0.2.tar.gz + http://sourceforge.net/projects/libmng/files/libmng-devel/2.0.3/libmng-2.0.3.tar.xz zlib-devel lcms2-devel @@ -66,6 +66,13 @@ + + 2017-02-05 + 2.0.3 + Version Bump + Pisi Linux Community + admin@pisilinux.org + 2016-06-09 2.0.2 diff --git a/multimedia/graphics/netpbm/pspec.xml b/multimedia/graphics/netpbm/pspec.xml index 5fe5c1ca49..9c1b04737f 100644 --- a/multimedia/graphics/netpbm/pspec.xml +++ b/multimedia/graphics/netpbm/pspec.xml @@ -66,6 +66,13 @@ + + 2017-02-05 + 10.61.02 + Rebuild + Pisi Linux Community + admin@pisilinux.org + 2016-06-09 10.61.02 diff --git a/multimedia/graphics/openjpeg/pspec.xml b/multimedia/graphics/openjpeg/pspec.xml index 82f1306a93..f0188c2191 100644 --- a/multimedia/graphics/openjpeg/pspec.xml +++ b/multimedia/graphics/openjpeg/pspec.xml @@ -72,6 +72,13 @@ + + 2017-02-05 + 1.5.2 + Rebuild + Pisi Linux Community + admin@pisilinux.org + 2016-06-09 1.5.2 diff --git a/multimedia/sound/pulseaudio/pspec.xml b/multimedia/sound/pulseaudio/pspec.xml index c3f364643e..74ca995aac 100644 --- a/multimedia/sound/pulseaudio/pspec.xml +++ b/multimedia/sound/pulseaudio/pspec.xml @@ -15,7 +15,7 @@ library A networked sound server with an advanced plugin system pulseaudio is a sound server for POSIX and Win32 systems. It allows you to do advanced operations on your sound data as it passes between your application and your hardware. - https://freedesktop.org/software/pulseaudio/releases/pulseaudio-9.0.tar.xz + https://freedesktop.org/software/pulseaudio/releases/pulseaudio-10.0.tar.xz orc-devel sbc-devel @@ -220,6 +220,13 @@ + + 2017-02-05 + 10.0 + Release bump. + Stefan Gronewold(groni) + groni@pisilinux.org + 2016-09-13 9.0 diff --git a/multimedia/video/ffmpeg/actions.py b/multimedia/video/ffmpeg/actions.py index e156567e3f..70ac57b930 100644 --- a/multimedia/video/ffmpeg/actions.py +++ b/multimedia/video/ffmpeg/actions.py @@ -9,7 +9,7 @@ from pisi.actionsapi import autotools from pisi.actionsapi import pisitools def setup(): - autotools.rawConfigure("--prefix=/usr \ + autotools.configure("--prefix=/usr \ --mandir=/usr/share/man \ --disable-debug \ --disable-static \ diff --git a/multimedia/video/ffmpeg/pspec.xml b/multimedia/video/ffmpeg/pspec.xml index 182feda788..48e3ca56cf 100644 --- a/multimedia/video/ffmpeg/pspec.xml +++ b/multimedia/video/ffmpeg/pspec.xml @@ -15,7 +15,7 @@ app:console A command-line tool to record, convert and stream audio and video FFmpeg is a complete solution to record, convert and stream audio and video. - http://ffmpeg.org/releases/ffmpeg-3.0.2.tar.xz + http://ffmpeg.org/releases/ffmpeg-3.2.2.tar.xz freetype-devel faac-devel @@ -45,6 +45,7 @@ speex-devel yasm-devel libv4l-devel + pkgconfig libvo-amrwbenc-devel libvo-aacenc-devel xvid-devel @@ -125,6 +126,13 @@ + + 2017-02-05 + 3.2.2 + Release bump. + Stefan Gronewold(groni) + groni@pisilinux.org + 2016-06-13 3.0.2 diff --git a/multimedia/video/libvpx/pspec.xml b/multimedia/video/libvpx/pspec.xml index 1cf84b4306..270e56ddee 100644 --- a/multimedia/video/libvpx/pspec.xml +++ b/multimedia/video/libvpx/pspec.xml @@ -13,13 +13,13 @@ library WebM VP8 Codec SDK libvpx is the VP8 development library usually used in WebM and similiar formats. - https://github.com/webmproject/libvpx/archive/v1.5.0.tar.gz + https://github.com/webmproject/libvpx/archive/v1.6.1.tar.gz libgcc yasm-devel - 0001-Fix-for-issue-1114-compile-error.patch + @@ -48,6 +48,13 @@ + + 2017-02-05 + 1.6.1 + Version Bump + Pisi Linux Community + admin@pisilinux.org + 2016-06-12 1.5.0 diff --git a/multimedia/video/opencore-amr/actions.py b/multimedia/video/opencore-amr/actions.py index 3656bfb829..658e0c58e2 100644 --- a/multimedia/video/opencore-amr/actions.py +++ b/multimedia/video/opencore-amr/actions.py @@ -20,4 +20,4 @@ def build(): def install(): autotools.rawInstall('DESTDIR="%s"' % get.installDIR()) - pisitools.dodoc("AUTHORS", "ChangeLog", "README") + pisitools.dodoc("LICENSE", "ChangeLog", "README") diff --git a/multimedia/video/opencore-amr/pspec.xml b/multimedia/video/opencore-amr/pspec.xml index 9180c00194..95891305b2 100644 --- a/multimedia/video/opencore-amr/pspec.xml +++ b/multimedia/video/opencore-amr/pspec.xml @@ -12,7 +12,7 @@ library AMR speech codec implementation Opencore AMR is an implementation of Adaptive Multi Rate Narrowband and Wideband speech codec. - https://sourceforge.net/projects/opencore-amr/files/opencore-amr/opencore-amr-0.1.4.tar.gz + mirrors://sourceforge/opencore-amr/opencore-amr/opencore-amr-0.1.4.tar.gz @@ -37,7 +37,7 @@ - 2017-02-03 + 2017-02-05 0.1.4 Version bump. Stefan Gronewold(groni) @@ -58,4 +58,4 @@ kaptan@pisilinux.org - + \ No newline at end of file diff --git a/office/docbook/asciidoc/pspec.xml b/office/docbook/asciidoc/pspec.xml index 2d7de1f65b..1879484943 100644 --- a/office/docbook/asciidoc/pspec.xml +++ b/office/docbook/asciidoc/pspec.xml @@ -36,6 +36,13 @@ + + 2017-02-05 + 8.6.9 + Rebuild + Pisi Linux Community + admin@pisilinux.org + 2016-06-09 8.6.9 diff --git a/office/postscript/ghostscript/files/fedora/ghostscript-9.20-cve-2016-7976.patch b/office/postscript/ghostscript/files/fedora/ghostscript-9.20-cve-2016-7976.patch new file mode 100644 index 0000000000..618278c06f --- /dev/null +++ b/office/postscript/ghostscript/files/fedora/ghostscript-9.20-cve-2016-7976.patch @@ -0,0 +1,179 @@ +From fee19fa8d4f6f351e5a76f5801884880249d6a45 Mon Sep 17 00:00:00 2001 +From: Chris Liddell +Date: Wed, 5 Oct 2016 09:55:55 +0100 +Subject: [PATCH] Bug 697178: Add a file permissions callback + +For the rare occasions when the graphics library directly opens a file +(currently for reading), this allows us to apply any restrictions on +file access normally applied in the interpteter. +--- + base/gsicc_manage.c | 10 ++++++---- + base/gslibctx.c | 12 +++++++++++- + base/gslibctx.h | 7 +++++++ + psi/imain.c | 2 ++ + psi/int.mak | 2 +- + psi/zfile.c | 19 +++++++++++++++++++ + psi/zfile.h | 7 +++++++ + 7 files changed, 53 insertions(+), 6 deletions(-) + +diff --git a/base/gsicc_manage.c b/base/gsicc_manage.c +index 931c2a6..e9c09c3 100644 +--- a/base/gsicc_manage.c ++++ b/base/gsicc_manage.c +@@ -1124,10 +1124,12 @@ gsicc_open_search(const char* pname, int namelen, gs_memory_t *mem_gc, + } + + /* First just try it like it is */ +- str = sfopen(pname, "r", mem_gc); +- if (str != NULL) { +- *strp = str; +- return 0; ++ if (gs_check_file_permission(mem_gc, pname, namelen, "r") >= 0) { ++ str = sfopen(pname, "r", mem_gc); ++ if (str != NULL) { ++ *strp = str; ++ return 0; ++ } + } + + /* If that fails, try %rom% */ /* FIXME: Not sure this is needed or correct */ +diff --git a/base/gslibctx.c b/base/gslibctx.c +index fa4432a..f2c13e3 100644 +--- a/base/gslibctx.c ++++ b/base/gslibctx.c +@@ -183,7 +183,7 @@ int gs_lib_ctx_init( gs_memory_t *mem ) + mem->gs_lib_ctx = NULL; + return -1; + } +- ++ pio->client_check_file_permission = NULL; + gp_get_realtime(pio->real_time_0); + + /* Set scanconverter to 1 (default) */ +@@ -336,3 +336,13 @@ void errflush(const gs_memory_t *mem) + fflush(mem->gs_lib_ctx->fstderr); + /* else nothing to flush */ + } ++ ++int ++gs_check_file_permission (gs_memory_t *mem, const char *fname, const int len, const char *permission) ++{ ++ int code = 0; ++ if (mem->gs_lib_ctx->client_check_file_permission != NULL) { ++ code = mem->gs_lib_ctx->client_check_file_permission(mem, fname, len, permission); ++ } ++ return code; ++} +diff --git a/base/gslibctx.h b/base/gslibctx.h +index 84ec205..55eb4a6 100644 +--- a/base/gslibctx.h ++++ b/base/gslibctx.h +@@ -32,6 +32,9 @@ typedef struct gs_fapi_server_s gs_fapi_server; + # define gs_font_dir_DEFINED + typedef struct gs_font_dir_s gs_font_dir; + #endif ++ ++typedef int (*client_check_file_permission_t) (gs_memory_t *mem, const char *fname, const int len, const char *permission); ++ + typedef struct gs_lib_ctx_s + { + gs_memory_t *memory; /* mem->gs_lib_ctx->memory == mem */ +@@ -61,6 +64,7 @@ typedef struct gs_lib_ctx_s + struct gx_io_device_s **io_device_table; + int io_device_table_count; + int io_device_table_size; ++ client_check_file_permission_t client_check_file_permission; + /* Define the default value of AccurateScreens that affects setscreen + and setcolorscreen. */ + bool screen_accurate_screens; +@@ -132,6 +136,9 @@ int + gs_lib_ctx_get_default_device_list(const gs_memory_t *mem, char** dev_list_str, + int *list_str_len); + ++int ++gs_check_file_permission (gs_memory_t *mem, const char *fname, const int len, const char *permission); ++ + #define IS_LIBCTX_STDOUT(mem, f) (f == mem->gs_lib_ctx->fstdout) + #define IS_LIBCTX_STDERR(mem, f) (f == mem->gs_lib_ctx->fstderr) + +diff --git a/psi/imain.c b/psi/imain.c +index 9a9bb5d..6874128 100644 +--- a/psi/imain.c ++++ b/psi/imain.c +@@ -57,6 +57,7 @@ + #include "ivmspace.h" + #include "idisp.h" /* for setting display device callback */ + #include "iplugin.h" ++#include "zfile.h" + + #ifdef PACIFY_VALGRIND + #include "valgrind.h" +@@ -212,6 +213,7 @@ gs_main_init1(gs_main_instance * minst) + "the_gs_name_table"); + if (code < 0) + return code; ++ mem->gs_lib_ctx->client_check_file_permission = z_check_file_permissions; + } + code = obj_init(&minst->i_ctx_p, &idmem); /* requires name_init */ + if (code < 0) +diff --git a/psi/int.mak b/psi/int.mak +index 4654afc..bb30d51 100644 +--- a/psi/int.mak ++++ b/psi/int.mak +@@ -2024,7 +2024,7 @@ $(PSOBJ)imain.$(OBJ) : $(PSSRC)imain.c $(GH) $(memory__h) $(string__h)\ + $(ialloc_h) $(iconf_h) $(idebug_h) $(idict_h) $(idisp_h) $(iinit_h)\ + $(iname_h) $(interp_h) $(iplugin_h) $(isave_h) $(iscan_h) $(ivmspace_h)\ + $(iinit_h) $(main_h) $(oper_h) $(ostack_h)\ +- $(sfilter_h) $(store_h) $(stream_h) $(strimpl_h)\ ++ $(sfilter_h) $(store_h) $(stream_h) $(strimpl_h) $(zfile_h)\ + $(INT_MAK) $(MAKEDIRS) + $(PSCC) $(PSO_)imain.$(OBJ) $(C_) $(PSSRC)imain.c + +diff --git a/psi/zfile.c b/psi/zfile.c +index b6caea2..fd94f67 100644 +--- a/psi/zfile.c ++++ b/psi/zfile.c +@@ -197,6 +197,25 @@ check_file_permissions(i_ctx_t *i_ctx_p, const char *fname, int len, + return check_file_permissions_reduced(i_ctx_p, fname_reduced, rlen, permitgroup); + } + ++/* z_check_file_permissions: see zfile.h for explanation ++ */ ++int ++z_check_file_permissions(gs_memory_t *mem, const char *fname, const int len, const char *permission) ++{ ++ i_ctx_t *i_ctx_p = get_minst_from_memory(mem)->i_ctx_p; ++ gs_parsed_file_name_t pname; ++ const char *permitgroup = permission[0] == 'r' ? "PermitFileReading" : "PermitFileWriting"; ++ int code = gs_parse_file_name(&pname, fname, len, imemory); ++ if (code < 0) ++ return code; ++ ++ if (pname.iodev && i_ctx_p->LockFilePermissions && strcmp(pname.iodev->dname, "%pipe%") == 0) ++ return gs_error_invalidfileaccess; ++ ++ code = check_file_permissions(i_ctx_p, fname, len, permitgroup); ++ return code; ++} ++ + /* file */ + int /* exported for zsysvm.c */ + zfile(i_ctx_t *i_ctx_p) +diff --git a/psi/zfile.h b/psi/zfile.h +index fdf1373..a9399c7 100644 +--- a/psi/zfile.h ++++ b/psi/zfile.h +@@ -22,4 +22,11 @@ + int zopen_file(i_ctx_t *i_ctx_p, const gs_parsed_file_name_t *pfn, + const char *file_access, stream **ps, gs_memory_t *mem); + ++/* z_check_file_permissions: a callback (via mem->gs_lib_ctx->client_check_file_permission) ++ * to allow applying the above permissions checks when opening file(s) from ++ * the graphics library ++ */ ++int ++z_check_file_permissions(gs_memory_t *mem, const char *fname, ++ const int len, const char *permission); + #endif +-- +2.7.4 \ No newline at end of file diff --git a/office/postscript/ghostscript/files/fedora/ghostscript-9.20-cve-2016-7977.patch b/office/postscript/ghostscript/files/fedora/ghostscript-9.20-cve-2016-7977.patch new file mode 100644 index 0000000000..176ba9e72d --- /dev/null +++ b/office/postscript/ghostscript/files/fedora/ghostscript-9.20-cve-2016-7977.patch @@ -0,0 +1,28 @@ +From 8abd22010eb4db0fb1b10e430d5f5d83e015ef70 Mon Sep 17 00:00:00 2001 +From: Chris Liddell +Date: Mon, 3 Oct 2016 01:46:28 +0100 +Subject: [PATCH] Bug 697169: Be rigorous with SAFER permissions + +Once we've opened our input file from the command line, enforce the SAFER +rules. +--- + psi/zfile.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/psi/zfile.c b/psi/zfile.c +index b6caea2..2c6c958 100644 +--- a/psi/zfile.c ++++ b/psi/zfile.c +@@ -1081,6 +1081,9 @@ lib_file_open(gs_file_path_ptr lib_path, const gs_memory_t *mem, i_ctx_t *i_ctx + gs_main_instance *minst = get_minst_from_memory(mem); + int code; + ++ if (i_ctx_p && starting_arg_file) ++ i_ctx_p->starting_arg_file = false; ++ + /* when starting arg files (@ files) iodev_default is not yet set */ + if (iodev == 0) + iodev = (gx_io_device *)gx_io_device_table[0]; +-- +2.7.4 + diff --git a/office/postscript/ghostscript/files/fedora/ghostscript-9.20-cve-2016-7978.patch b/office/postscript/ghostscript/files/fedora/ghostscript-9.20-cve-2016-7978.patch new file mode 100644 index 0000000000..477f85052e --- /dev/null +++ b/office/postscript/ghostscript/files/fedora/ghostscript-9.20-cve-2016-7978.patch @@ -0,0 +1,24 @@ +From 6f749c0c44e7b9e09737b9f29edf29925a34f0cf Mon Sep 17 00:00:00 2001 +From: Chris Liddell +Date: Wed, 5 Oct 2016 09:59:25 +0100 +Subject: [PATCH] Bug 697179: Reference count device icc profile + +when copying a device +--- + base/gsdevice.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/base/gsdevice.c b/base/gsdevice.c +index 778106f..aea986a 100644 +--- a/base/gsdevice.c ++++ b/base/gsdevice.c +@@ -614,6 +614,7 @@ gx_device_init(gx_device * dev, const gx_device * proto, gs_memory_t * mem, + dev->memory = mem; + dev->retained = !internal; + rc_init(dev, mem, (internal ? 0 : 1)); ++ rc_increment(dev->icc_struct); + } + + void +-- +2.7.4 \ No newline at end of file diff --git a/office/postscript/ghostscript/files/fedora/ghostscript-9.20-cve-2016-7979.patch b/office/postscript/ghostscript/files/fedora/ghostscript-9.20-cve-2016-7979.patch new file mode 100644 index 0000000000..95c6b11e17 --- /dev/null +++ b/office/postscript/ghostscript/files/fedora/ghostscript-9.20-cve-2016-7979.patch @@ -0,0 +1,42 @@ +From 875a0095f37626a721c7ff57d606a0f95af03913 Mon Sep 17 00:00:00 2001 +From: Ken Sharp +Date: Wed, 5 Oct 2016 10:10:58 +0100 +Subject: [PATCH] DSC parser - validate parameters + +Bug #697190 ".initialize_dsc_parser doesn't validate the parameter is a dict type before using it." + +Regardless of any security implications, its simply wrong for a PostScript +operator not to validate its parameter(s). + +No differences expected. +--- + psi/zdscpars.c | 13 +++++++++---- + 1 file changed, 9 insertions(+), 4 deletions(-) + +diff --git a/psi/zdscpars.c b/psi/zdscpars.c +index c05e154..9b4b605 100644 +--- a/psi/zdscpars.c ++++ b/psi/zdscpars.c +@@ -150,11 +150,16 @@ zinitialize_dsc_parser(i_ctx_t *i_ctx_p) + ref local_ref; + int code; + os_ptr const op = osp; +- dict * const pdict = op->value.pdict; +- gs_memory_t * const mem = (gs_memory_t *)dict_memory(pdict); +- dsc_data_t * const data = +- gs_alloc_struct(mem, dsc_data_t, &st_dsc_data_t, "DSC parser init"); ++ dict *pdict; ++ gs_memory_t *mem; ++ dsc_data_t *data; + ++ check_read_type(*op, t_dictionary); ++ ++ pdict = op->value.pdict; ++ mem = (gs_memory_t *)dict_memory(pdict); ++ ++ data = gs_alloc_struct(mem, dsc_data_t, &st_dsc_data_t, "DSC parser init"); + if (!data) + return_error(gs_error_VMerror); + data->document_level = 0; +-- +2.7.4 \ No newline at end of file diff --git a/office/postscript/ghostscript/files/fedora/ghostscript-9.20-cve-2016-8602.patch b/office/postscript/ghostscript/files/fedora/ghostscript-9.20-cve-2016-8602.patch new file mode 100644 index 0000000000..280a5ab261 --- /dev/null +++ b/office/postscript/ghostscript/files/fedora/ghostscript-9.20-cve-2016-8602.patch @@ -0,0 +1,41 @@ +From f5c7555c30393e64ec1f5ab0dfae5b55b3b3fc78 Mon Sep 17 00:00:00 2001 +From: Chris Liddell +Date: Sat, 8 Oct 2016 16:10:27 +0100 +Subject: [PATCH] Bug 697203: check for sufficient params in .sethalftone5 + +and param types +--- + psi/zht2.c | 12 ++++++++++-- + 1 file changed, 10 insertions(+), 2 deletions(-) + +diff --git a/psi/zht2.c b/psi/zht2.c +index fb4a264..dfa27a4 100644 +--- a/psi/zht2.c ++++ b/psi/zht2.c +@@ -82,14 +82,22 @@ zsethalftone5(i_ctx_t *i_ctx_p) + gs_memory_t *mem; + uint edepth = ref_stack_count(&e_stack); + int npop = 2; +- int dict_enum = dict_first(op); ++ int dict_enum; + ref rvalue[2]; + int cname, colorant_number; + byte * pname; + uint name_size; + int halftonetype, type = 0; + gs_gstate *pgs = igs; +- int space_index = r_space_index(op - 1); ++ int space_index; ++ ++ if (ref_stack_count(&o_stack) < 2) ++ return_error(gs_error_stackunderflow); ++ check_type(*op, t_dictionary); ++ check_type(*(op - 1), t_dictionary); ++ ++ dict_enum = dict_first(op); ++ space_index = r_space_index(op - 1); + + mem = (gs_memory_t *) idmemory->spaces_indexed[space_index]; + +-- +2.7.4 diff --git a/office/postscript/ghostscript/files/fedora/ghostscript-9.20-cve-2016-9601.patch b/office/postscript/ghostscript/files/fedora/ghostscript-9.20-cve-2016-9601.patch new file mode 100644 index 0000000000..0f756ded54 --- /dev/null +++ b/office/postscript/ghostscript/files/fedora/ghostscript-9.20-cve-2016-9601.patch @@ -0,0 +1,896 @@ +From cecf6b592945d247bf932f6a4f50065db4acfba8 Mon Sep 17 00:00:00 2001 +From: Robin Watts +Date: Mon, 12 Dec 2016 17:47:17 +0000 +Subject: [PATCH] Squash signed/unsigned warnings in MSVC jbig2 build. + +Also rename "new" to "new_dict", because "new" is a bad +variable name. +--- + jbig2dec/jbig2.c | 4 +-- + jbig2dec/jbig2.h | 8 +++-- + jbig2dec/jbig2_generic.c | 2 +- + jbig2dec/jbig2_halftone.c | 24 +++++++-------- + jbig2dec/jbig2_huffman.c | 10 +++--- + jbig2dec/jbig2_huffman.h | 2 +- + jbig2dec/jbig2_image.c | 32 +++++++++---------- + jbig2dec/jbig2_mmr.c | 66 ++++++++++++++++++++------------------- + jbig2dec/jbig2_page.c | 6 ++-- + jbig2dec/jbig2_priv.h | 4 +-- + jbig2dec/jbig2_segment.c | 10 +++--- + jbig2dec/jbig2_symbol_dict.c | 73 ++++++++++++++++++++++---------------------- + jbig2dec/jbig2_symbol_dict.h | 6 ++-- + jbig2dec/jbig2_text.c | 16 +++++----- + jbig2dec/jbig2_text.h | 2 +- + 15 files changed, 134 insertions(+), 131 deletions(-) + +diff --git a/jbig2dec/jbig2.c b/jbig2dec/jbig2.c +index f729e29..e51380f 100644 +--- a/jbig2dec/jbig2.c ++++ b/jbig2dec/jbig2.c +@@ -379,7 +379,7 @@ typedef struct { + } Jbig2WordStreamBuf; + + static int +-jbig2_word_stream_buf_get_next_word(Jbig2WordStream *self, int offset, uint32_t *word) ++jbig2_word_stream_buf_get_next_word(Jbig2WordStream *self, size_t offset, uint32_t *word) + { + Jbig2WordStreamBuf *z = (Jbig2WordStreamBuf *) self; + const byte *data = z->data; +@@ -390,7 +390,7 @@ jbig2_word_stream_buf_get_next_word(Jbig2WordStream *self, int offset, uint32_t + else if (offset > z->size) + return -1; + else { +- int i; ++ size_t i; + + result = 0; + for (i = 0; i < z->size - offset; i++) +diff --git a/jbig2dec/jbig2.h b/jbig2dec/jbig2.h +index d5aa52f..624e0ed 100644 +--- a/jbig2dec/jbig2.h ++++ b/jbig2dec/jbig2.h +@@ -56,17 +56,19 @@ typedef struct _Jbig2SymbolDictionary Jbig2SymbolDictionary; + */ + + struct _Jbig2Image { +- int width, height, stride; ++ uint32_t width; ++ uint32_t height; ++ uint32_t stride; + uint8_t *data; + int refcount; + }; + +-Jbig2Image *jbig2_image_new(Jbig2Ctx *ctx, int width, int height); ++Jbig2Image *jbig2_image_new(Jbig2Ctx *ctx, uint32_t width, uint32_t height); + Jbig2Image *jbig2_image_clone(Jbig2Ctx *ctx, Jbig2Image *image); + void jbig2_image_release(Jbig2Ctx *ctx, Jbig2Image *image); + void jbig2_image_free(Jbig2Ctx *ctx, Jbig2Image *image); + void jbig2_image_clear(Jbig2Ctx *ctx, Jbig2Image *image, int value); +-Jbig2Image *jbig2_image_resize(Jbig2Ctx *ctx, Jbig2Image *image, int width, int height); ++Jbig2Image *jbig2_image_resize(Jbig2Ctx *ctx, Jbig2Image *image, uint32_t width, uint32_t height); + + /* errors are returned from the library via a callback. If no callback + is provided (a NULL argument is passed ot jbig2_ctx_new) a default +diff --git a/jbig2dec/jbig2_generic.c b/jbig2dec/jbig2_generic.c +index 02fdbfb..9656198 100644 +--- a/jbig2dec/jbig2_generic.c ++++ b/jbig2dec/jbig2_generic.c +@@ -718,7 +718,7 @@ jbig2_immediate_generic_region(Jbig2Ctx *ctx, Jbig2Segment *segment, const byte + byte seg_flags; + int8_t gbat[8]; + int offset; +- int gbat_bytes = 0; ++ uint32_t gbat_bytes = 0; + Jbig2GenericRegionParams params; + int code = 0; + Jbig2Image *image = NULL; +diff --git a/jbig2dec/jbig2_halftone.c b/jbig2dec/jbig2_halftone.c +index aeab576..acfbc56 100644 +--- a/jbig2dec/jbig2_halftone.c ++++ b/jbig2dec/jbig2_halftone.c +@@ -257,8 +257,8 @@ jbig2_decode_gray_scale_image(Jbig2Ctx *ctx, Jbig2Segment *segment, + { + uint8_t **GSVALS = NULL; + size_t consumed_bytes = 0; +- int i, j, code, stride; +- int x, y; ++ uint32_t i, j, stride, x, y; ++ int code; + Jbig2Image **GSPLANES; + Jbig2GenericRegionParams rparams; + Jbig2WordStream *ws = NULL; +@@ -276,9 +276,8 @@ jbig2_decode_gray_scale_image(Jbig2Ctx *ctx, Jbig2Segment *segment, + if (GSPLANES[i] == NULL) { + jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "failed to allocate %dx%d image for GSPLANES", GSW, GSH); + /* free already allocated */ +- for (j = i - 1; j >= 0; --j) { +- jbig2_image_release(ctx, GSPLANES[j]); +- } ++ for (j = i; j > 0;) ++ jbig2_image_release(ctx, GSPLANES[--j]); + jbig2_free(ctx->allocator, GSPLANES); + return NULL; + } +@@ -323,9 +322,10 @@ jbig2_decode_gray_scale_image(Jbig2Ctx *ctx, Jbig2Segment *segment, + } + + /* C.5 step 2. Set j = GSBPP-2 */ +- j = GSBPP - 2; ++ j = GSBPP - 1; + /* C.5 step 3. decode loop */ +- while (j >= 0) { ++ while (j > 0) { ++ j--; + /* C.5 step 3. (a) */ + if (GSMMR) { + code = jbig2_decode_halftone_mmr(ctx, &rparams, data + consumed_bytes, size - consumed_bytes, GSPLANES[j], &consumed_bytes); +@@ -345,7 +345,6 @@ jbig2_decode_gray_scale_image(Jbig2Ctx *ctx, Jbig2Segment *segment, + GSPLANES[j]->data[i] ^= GSPLANES[j + 1]->data[i]; + + /* C.5 step 3. (c) */ +- --j; + } + + /* allocate GSVALS */ +@@ -359,9 +358,8 @@ jbig2_decode_gray_scale_image(Jbig2Ctx *ctx, Jbig2Segment *segment, + if (GSVALS[i] == NULL) { + jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "failed to allocate GSVALS: %d bytes", GSH * GSW); + /* free already allocated */ +- for (j = i - 1; j >= 0; --j) { +- jbig2_free(ctx->allocator, GSVALS[j]); +- } ++ for (j = i; j > 0;) ++ jbig2_free(ctx->allocator, GSVALS[--j]); + jbig2_free(ctx->allocator, GSVALS); + GSVALS = NULL; + goto cleanup; +@@ -450,7 +448,7 @@ jbig2_decode_halftone_region(Jbig2Ctx *ctx, Jbig2Segment *segment, + uint8_t **GI; + Jbig2Image *HSKIP = NULL; + Jbig2PatternDict *HPATS; +- int i; ++ uint32_t i; + uint32_t mg, ng; + int32_t x, y; + uint8_t gray_val; +@@ -476,7 +474,7 @@ jbig2_decode_halftone_region(Jbig2Ctx *ctx, Jbig2Segment *segment, + + /* calculate ceil(log2(HNUMPATS)) */ + HBPP = 0; +- while (HNUMPATS > (1 << ++HBPP)); ++ while (HNUMPATS > (1U << ++HBPP)); + + /* 6.6.5 point 4. decode gray-scale image as mentioned in annex C */ + GI = jbig2_decode_gray_scale_image(ctx, segment, data, size, +diff --git a/jbig2dec/jbig2_huffman.c b/jbig2dec/jbig2_huffman.c +index 4521b48..f77981b 100644 +--- a/jbig2dec/jbig2_huffman.c ++++ b/jbig2dec/jbig2_huffman.c +@@ -47,16 +47,16 @@ struct _Jbig2HuffmanState { + is (offset + 4) * 8. */ + uint32_t this_word; + uint32_t next_word; +- int offset_bits; +- int offset; +- int offset_limit; ++ uint32_t offset_bits; ++ uint32_t offset; ++ uint32_t offset_limit; + + Jbig2WordStream *ws; + Jbig2Ctx *ctx; + }; + + static uint32_t +-huff_get_next_word(Jbig2HuffmanState *hs, int offset) ++huff_get_next_word(Jbig2HuffmanState *hs, uint32_t offset) + { + uint32_t word = 0; + Jbig2WordStream *ws = hs->ws; +@@ -213,7 +213,7 @@ jbig2_huffman_advance(Jbig2HuffmanState *hs, int offset) + /* return the offset of the huffman decode pointer (in bytes) + * from the beginning of the WordStream + */ +-int ++uint32_t + jbig2_huffman_offset(Jbig2HuffmanState *hs) + { + return hs->offset + (hs->offset_bits >> 3); +diff --git a/jbig2dec/jbig2_huffman.h b/jbig2dec/jbig2_huffman.h +index 5d1e6e0..cfda9e0 100644 +--- a/jbig2dec/jbig2_huffman.h ++++ b/jbig2dec/jbig2_huffman.h +@@ -64,7 +64,7 @@ void jbig2_huffman_skip(Jbig2HuffmanState *hs); + + void jbig2_huffman_advance(Jbig2HuffmanState *hs, int offset); + +-int jbig2_huffman_offset(Jbig2HuffmanState *hs); ++uint32_t jbig2_huffman_offset(Jbig2HuffmanState *hs); + + int32_t jbig2_huffman_get(Jbig2HuffmanState *hs, const Jbig2HuffmanTable *table, bool *oob); + +diff --git a/jbig2dec/jbig2_image.c b/jbig2dec/jbig2_image.c +index 1ae614e..94e5a4c 100644 +--- a/jbig2dec/jbig2_image.c ++++ b/jbig2dec/jbig2_image.c +@@ -32,10 +32,10 @@ + + /* allocate a Jbig2Image structure and its associated bitmap */ + Jbig2Image * +-jbig2_image_new(Jbig2Ctx *ctx, int width, int height) ++jbig2_image_new(Jbig2Ctx *ctx, uint32_t width, uint32_t height) + { + Jbig2Image *image; +- int stride; ++ uint32_t stride; + int64_t check; + + image = jbig2_new(ctx, Jbig2Image, 1); +@@ -99,7 +99,7 @@ jbig2_image_free(Jbig2Ctx *ctx, Jbig2Image *image) + + /* resize a Jbig2Image */ + Jbig2Image * +-jbig2_image_resize(Jbig2Ctx *ctx, Jbig2Image *image, int width, int height) ++jbig2_image_resize(Jbig2Ctx *ctx, Jbig2Image *image, uint32_t width, uint32_t height) + { + if (width == image->width) { + /* check for integer multiplication overflow */ +@@ -133,11 +133,11 @@ jbig2_image_resize(Jbig2Ctx *ctx, Jbig2Image *image, int width, int height) + static int + jbig2_image_compose_unopt(Jbig2Ctx *ctx, Jbig2Image *dst, Jbig2Image *src, int x, int y, Jbig2ComposeOp op) + { +- int i, j; +- int sw = src->width; +- int sh = src->height; +- int sx = 0; +- int sy = 0; ++ uint32_t i, j; ++ uint32_t sw = src->width; ++ uint32_t sh = src->height; ++ uint32_t sx = 0; ++ uint32_t sy = 0; + + /* clip to the dst image boundaries */ + if (x < 0) { +@@ -200,10 +200,10 @@ jbig2_image_compose_unopt(Jbig2Ctx *ctx, Jbig2Image *dst, Jbig2Image *src, int x + int + jbig2_image_compose(Jbig2Ctx *ctx, Jbig2Image *dst, Jbig2Image *src, int x, int y, Jbig2ComposeOp op) + { +- int i, j; +- int w, h; +- int leftbyte, rightbyte; +- int shift; ++ uint32_t i, j; ++ uint32_t w, h; ++ uint32_t leftbyte, rightbyte; ++ uint32_t shift; + uint8_t *s, *ss; + uint8_t *d, *dd; + uint8_t mask, rightmask; +@@ -226,8 +226,8 @@ jbig2_image_compose(Jbig2Ctx *ctx, Jbig2Image *dst, Jbig2Image *src, int x, int + h += y; + y = 0; + } +- w = (x + w < dst->width) ? w : dst->width - x; +- h = (y + h < dst->height) ? h : dst->height - y; ++ w = ((uint32_t)x + w < dst->width) ? w : ((dst->width >= (uint32_t)x) ? dst->width - (uint32_t)x : 0); ++ h = ((uint32_t)y + h < dst->height) ? h : ((dst->height >= (uint32_t)y) ? dst->height - (uint32_t)y : 0); + #ifdef JBIG2_DEBUG + jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, -1, "compositing %dx%d at (%d, %d) after clipping\n", w, h, x, y); + #endif +@@ -249,8 +249,8 @@ jbig2_image_compose(Jbig2Ctx *ctx, Jbig2Image *dst, Jbig2Image *src, int x, int + } + #endif + +- leftbyte = x >> 3; +- rightbyte = (x + w - 1) >> 3; ++ leftbyte = (uint32_t)x >> 3; ++ rightbyte = ((uint32_t)x + w - 1) >> 3; + shift = x & 7; + + /* general OR case */ +diff --git a/jbig2dec/jbig2_mmr.c b/jbig2dec/jbig2_mmr.c +index d4cd3a2..390e27c 100644 +--- a/jbig2dec/jbig2_mmr.c ++++ b/jbig2dec/jbig2_mmr.c +@@ -38,19 +38,21 @@ + #include "jbig2_mmr.h" + + typedef struct { +- int width; +- int height; ++ uint32_t width; ++ uint32_t height; + const byte *data; + size_t size; +- int data_index; +- int bit_index; ++ uint32_t data_index; ++ uint32_t bit_index; + uint32_t word; + } Jbig2MmrCtx; + ++#define MINUS1 ((uint32_t)-1) ++ + static void + jbig2_decode_mmr_init(Jbig2MmrCtx *mmr, int width, int height, const byte *data, size_t size) + { +- int i; ++ size_t i; + uint32_t word = 0; + + mmr->width = width; +@@ -732,14 +734,14 @@ const mmr_table_node jbig2_mmr_black_decode[] = { + #define getbit(buf, x) ( ( buf[x >> 3] >> ( 7 - (x & 7) ) ) & 1 ) + + static int +-jbig2_find_changing_element(const byte *line, int x, int w) ++jbig2_find_changing_element(const byte *line, uint32_t x, uint32_t w) + { + int a, b; + + if (line == 0) +- return w; ++ return (int)w; + +- if (x == -1) { ++ if (x == MINUS1) { + a = 0; + x = 0; + } else { +@@ -758,7 +760,7 @@ jbig2_find_changing_element(const byte *line, int x, int w) + } + + static int +-jbig2_find_changing_element_of_color(const byte *line, int x, int w, int color) ++jbig2_find_changing_element_of_color(const byte *line, uint32_t x, uint32_t w, int color) + { + if (line == 0) + return w; +@@ -772,9 +774,9 @@ static const byte lm[8] = { 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01 }; + static const byte rm[8] = { 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE }; + + static void +-jbig2_set_bits(byte *line, int x0, int x1) ++jbig2_set_bits(byte *line, uint32_t x0, uint32_t x1) + { +- int a0, a1, b0, b1, a; ++ uint32_t a0, a1, b0, b1, a; + + a0 = x0 >> 3; + a1 = x1 >> 3; +@@ -831,8 +833,8 @@ jbig2_decode_get_run(Jbig2MmrCtx *mmr, const mmr_table_node *table, int initial_ + static int + jbig2_decode_mmr_line(Jbig2MmrCtx *mmr, const byte *ref, byte *dst) + { +- int a0 = -1; +- int a1, a2, b1, b2; ++ uint32_t a0 = MINUS1; ++ uint32_t a1, a2, b1, b2; + int c = 0; /* 0 is white, black is 1 */ + + while (1) { +@@ -840,7 +842,7 @@ jbig2_decode_mmr_line(Jbig2MmrCtx *mmr, const byte *ref, byte *dst) + + /* printf ("%08x\n", word); */ + +- if (a0 >= mmr->width) ++ if (a0 != MINUS1 && a0 >= mmr->width) + break; + + if ((word >> (32 - 3)) == 1) { +@@ -848,7 +850,7 @@ jbig2_decode_mmr_line(Jbig2MmrCtx *mmr, const byte *ref, byte *dst) + + jbig2_decode_mmr_consume(mmr, 3); + +- if (a0 == -1) ++ if (a0 == MINUS1) + a0 = 0; + + if (c == 0) { +@@ -860,7 +862,7 @@ jbig2_decode_mmr_line(Jbig2MmrCtx *mmr, const byte *ref, byte *dst) + a1 = mmr->width; + if (a2 > mmr->width) + a2 = mmr->width; +- if (a2 < a1 || a1 < 0) ++ if (a1 == MINUS1 || a2 < a1) + return -1; + jbig2_set_bits(dst, a1, a2); + a0 = a2; +@@ -874,7 +876,7 @@ jbig2_decode_mmr_line(Jbig2MmrCtx *mmr, const byte *ref, byte *dst) + a1 = mmr->width; + if (a2 > mmr->width) + a2 = mmr->width; +- if (a1 < a0 || a0 < 0) ++ if (a0 == MINUS1 || a1 < a0) + return -1; + jbig2_set_bits(dst, a0, a1); + a0 = a2; +@@ -888,7 +890,7 @@ jbig2_decode_mmr_line(Jbig2MmrCtx *mmr, const byte *ref, byte *dst) + b1 = jbig2_find_changing_element_of_color(ref, a0, mmr->width, !c); + b2 = jbig2_find_changing_element(ref, b1, mmr->width); + if (c) { +- if (b2 < a0 || a0 < 0) ++ if (a0 == MINUS1 || b2 < a0) + return -1; + jbig2_set_bits(dst, a0, b2); + } +@@ -900,7 +902,7 @@ jbig2_decode_mmr_line(Jbig2MmrCtx *mmr, const byte *ref, byte *dst) + jbig2_decode_mmr_consume(mmr, 1); + b1 = jbig2_find_changing_element_of_color(ref, a0, mmr->width, !c); + if (c) { +- if (b1 < a0 || a0 < 0) ++ if (a0 == MINUS1 || b1 < a0) + return -1; + jbig2_set_bits(dst, a0, b1); + } +@@ -915,7 +917,7 @@ jbig2_decode_mmr_line(Jbig2MmrCtx *mmr, const byte *ref, byte *dst) + if (b1 + 1 > mmr->width) + break; + if (c) { +- if (b1 + 1 < a0 || a0 < 0) ++ if (a0 == MINUS1 || b1 + 1 < a0) + return -1; + jbig2_set_bits(dst, a0, b1 + 1); + } +@@ -930,7 +932,7 @@ jbig2_decode_mmr_line(Jbig2MmrCtx *mmr, const byte *ref, byte *dst) + if (b1 + 2 > mmr->width) + break; + if (c) { +- if (b1 + 2 < a0 || a0 < 0) ++ if (a0 == MINUS1 || b1 + 2 < a0) + return -1; + jbig2_set_bits(dst, a0, b1 + 2); + } +@@ -942,10 +944,10 @@ jbig2_decode_mmr_line(Jbig2MmrCtx *mmr, const byte *ref, byte *dst) + /* printf ("VR(3)\n"); */ + jbig2_decode_mmr_consume(mmr, 7); + b1 = jbig2_find_changing_element_of_color(ref, a0, mmr->width, !c); +- if (b1 + 3 > mmr->width) ++ if (b1 + 3 > (int)mmr->width) + break; + if (c) { +- if (b1 + 3 < a0 || a0 < 0) ++ if (a0 == MINUS1 || b1 + 3 < a0) + return -1; + jbig2_set_bits(dst, a0, b1 + 3); + } +@@ -957,10 +959,10 @@ jbig2_decode_mmr_line(Jbig2MmrCtx *mmr, const byte *ref, byte *dst) + /* printf ("VL(1)\n"); */ + jbig2_decode_mmr_consume(mmr, 3); + b1 = jbig2_find_changing_element_of_color(ref, a0, mmr->width, !c); +- if (b1 - 1 < 0) ++ if (b1 < 1) + break; + if (c) { +- if (b1 - 1 < a0 || a0 < 0) ++ if (a0 == MINUS1 || b1 - 1 < a0) + return -1; + jbig2_set_bits(dst, a0, b1 - 1); + } +@@ -972,7 +974,7 @@ jbig2_decode_mmr_line(Jbig2MmrCtx *mmr, const byte *ref, byte *dst) + /* printf ("VL(2)\n"); */ + jbig2_decode_mmr_consume(mmr, 6); + b1 = jbig2_find_changing_element_of_color(ref, a0, mmr->width, !c); +- if (b1 - 2 < 0) ++ if (b1 < 2) + break; + if (c) { + if (b1 - 2 < a0 || a0 < 0) +@@ -987,10 +989,10 @@ jbig2_decode_mmr_line(Jbig2MmrCtx *mmr, const byte *ref, byte *dst) + /* printf ("VL(3)\n"); */ + jbig2_decode_mmr_consume(mmr, 7); + b1 = jbig2_find_changing_element_of_color(ref, a0, mmr->width, !c); +- if (b1 - 3 < 0) ++ if (b1 < 3) + break; + if (c) { +- if (b1 - 3 < a0 || a0 < 0) ++ if (a0 == MINUS1 || b1 - 3 < a0) + return -1; + jbig2_set_bits(dst, a0, b1 - 3); + } +@@ -1009,10 +1011,10 @@ int + jbig2_decode_generic_mmr(Jbig2Ctx *ctx, Jbig2Segment *segment, const Jbig2GenericRegionParams *params, const byte *data, size_t size, Jbig2Image *image) + { + Jbig2MmrCtx mmr; +- const int rowstride = image->stride; ++ const uint32_t rowstride = image->stride; + byte *dst = image->data; + byte *ref = NULL; +- int y; ++ uint32_t y; + int code = 0; + + jbig2_decode_mmr_init(&mmr, image->width, image->height, data, size); +@@ -1047,10 +1049,10 @@ int + jbig2_decode_halftone_mmr(Jbig2Ctx *ctx, const Jbig2GenericRegionParams *params, const byte *data, size_t size, Jbig2Image *image, size_t *consumed_bytes) + { + Jbig2MmrCtx mmr; +- const int rowstride = image->stride; ++ const uint32_t rowstride = image->stride; + byte *dst = image->data; + byte *ref = NULL; +- int y; ++ uint32_t y; + int code = 0; + const uint32_t EOFB = 0x001001; + +diff --git a/jbig2dec/jbig2_page.c b/jbig2dec/jbig2_page.c +index 110ff7c..1ed1c8a 100644 +--- a/jbig2dec/jbig2_page.c ++++ b/jbig2dec/jbig2_page.c +@@ -155,9 +155,9 @@ int + jbig2_end_of_stripe(Jbig2Ctx *ctx, Jbig2Segment *segment, const uint8_t *segment_data) + { + Jbig2Page page = ctx->pages[ctx->current_page]; +- int end_row; ++ uint32_t end_row; + +- end_row = jbig2_get_int32(segment_data); ++ end_row = jbig2_get_uint32(segment_data); + if (end_row < page.end_row) { + jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, + "end of stripe segment with non-positive end row advance" " (new end row %d vs current end row %d)", end_row, page.end_row); +@@ -248,7 +248,7 @@ jbig2_page_add_result(Jbig2Ctx *ctx, Jbig2Page *page, Jbig2Image *image, int x, + + /* grow the page to accomodate a new stripe if necessary */ + if (page->striped) { +- int new_height = y + image->height + page->end_row; ++ uint32_t new_height = y + image->height + page->end_row; + + if (page->image->height < new_height) { + jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, -1, "growing page buffer to %d rows " "to accomodate new stripe", new_height); +diff --git a/jbig2dec/jbig2_priv.h b/jbig2dec/jbig2_priv.h +index 42ba496..3d44b42 100644 +--- a/jbig2dec/jbig2_priv.h ++++ b/jbig2dec/jbig2_priv.h +@@ -132,7 +132,7 @@ struct _Jbig2Page { + uint32_t x_resolution, y_resolution; /* in pixels per meter */ + uint16_t stripe_size; + bool striped; +- int end_row; ++ uint32_t end_row; + uint8_t flags; + Jbig2Image *image; + }; +@@ -182,7 +182,7 @@ int jbig2_halftone_region(Jbig2Ctx *ctx, Jbig2Segment *segment, const byte *segm + typedef struct _Jbig2WordStream Jbig2WordStream; + + struct _Jbig2WordStream { +- int (*get_next_word)(Jbig2WordStream *self, int offset, uint32_t *word); ++ int (*get_next_word)(Jbig2WordStream *self, size_t offset, uint32_t *word); + }; + + Jbig2WordStream *jbig2_word_stream_buf_new(Jbig2Ctx *ctx, const byte *data, size_t size); +diff --git a/jbig2dec/jbig2_segment.c b/jbig2dec/jbig2_segment.c +index 2e0db67..5b63706 100644 +--- a/jbig2dec/jbig2_segment.c ++++ b/jbig2dec/jbig2_segment.c +@@ -39,10 +39,10 @@ jbig2_parse_segment_header(Jbig2Ctx *ctx, uint8_t *buf, size_t buf_size, size_t + uint8_t rtscarf; + uint32_t rtscarf_long; + uint32_t *referred_to_segments; +- int referred_to_segment_count; +- int referred_to_segment_size; +- int pa_size; +- int offset; ++ uint32_t referred_to_segment_count; ++ uint32_t referred_to_segment_size; ++ uint32_t pa_size; ++ uint32_t offset; + + /* minimum possible size of a jbig2 segment header */ + if (buf_size < 11) +@@ -83,7 +83,7 @@ jbig2_parse_segment_header(Jbig2Ctx *ctx, uint8_t *buf, size_t buf_size, size_t + + /* 7.2.5 */ + if (referred_to_segment_count) { +- int i; ++ uint32_t i; + + referred_to_segments = jbig2_new(ctx, uint32_t, referred_to_segment_count * referred_to_segment_size); + if (referred_to_segments == NULL) { +diff --git a/jbig2dec/jbig2_symbol_dict.c b/jbig2dec/jbig2_symbol_dict.c +index 2c71a4c..11a2252 100644 +--- a/jbig2dec/jbig2_symbol_dict.c ++++ b/jbig2dec/jbig2_symbol_dict.c +@@ -88,40 +88,40 @@ jbig2_dump_symbol_dict(Jbig2Ctx *ctx, Jbig2Segment *segment) + + /* return a new empty symbol dict */ + Jbig2SymbolDict * +-jbig2_sd_new(Jbig2Ctx *ctx, int n_symbols) ++jbig2_sd_new(Jbig2Ctx *ctx, uint32_t n_symbols) + { +- Jbig2SymbolDict *new = NULL; ++ Jbig2SymbolDict *new_dict = NULL; + + if (n_symbols < 0) { + jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, "Negative number of symbols in symbol dict: %d", n_symbols); + return NULL; + } + +- new = jbig2_new(ctx, Jbig2SymbolDict, 1); +- if (new != NULL) { +- new->glyphs = jbig2_new(ctx, Jbig2Image *, n_symbols); +- new->n_symbols = n_symbols; ++ new_dict = jbig2_new(ctx, Jbig2SymbolDict, 1); ++ if (new_dict != NULL) { ++ new_dict->glyphs = jbig2_new(ctx, Jbig2Image *, n_symbols); ++ new_dict->n_symbols = n_symbols; + } else { + jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, "unable to allocate new empty symbol dict"); + return NULL; + } + +- if (new->glyphs != NULL) { +- memset(new->glyphs, 0, n_symbols * sizeof(Jbig2Image *)); ++ if (new_dict->glyphs != NULL) { ++ memset(new_dict->glyphs, 0, n_symbols * sizeof(Jbig2Image *)); + } else { + jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, "unable to allocate glyphs for new empty symbol dict"); +- jbig2_free(ctx->allocator, new); ++ jbig2_free(ctx->allocator, new_dict); + return NULL; + } + +- return new; ++ return new_dict; + } + + /* release the memory associated with a symbol dict */ + void + jbig2_sd_release(Jbig2Ctx *ctx, Jbig2SymbolDict *dict) + { +- int i; ++ uint32_t i; + + if (dict == NULL) + return; +@@ -142,12 +142,12 @@ jbig2_sd_glyph(Jbig2SymbolDict *dict, unsigned int id) + } + + /* count the number of dictionary segments referred to by the given segment */ +-int ++uint32_t + jbig2_sd_count_referred(Jbig2Ctx *ctx, Jbig2Segment *segment) + { + int index; + Jbig2Segment *rsegment; +- int n_dicts = 0; ++ uint32_t n_dicts = 0; + + for (index = 0; index < segment->referred_to_segment_count; index++) { + rsegment = jbig2_find_segment(ctx, segment->referred_to_segments[index]); +@@ -166,8 +166,8 @@ jbig2_sd_list_referred(Jbig2Ctx *ctx, Jbig2Segment *segment) + int index; + Jbig2Segment *rsegment; + Jbig2SymbolDict **dicts; +- int n_dicts = jbig2_sd_count_referred(ctx, segment); +- int dindex = 0; ++ uint32_t n_dicts = jbig2_sd_count_referred(ctx, segment); ++ uint32_t dindex = 0; + + dicts = jbig2_new(ctx, Jbig2SymbolDict *, n_dicts); + if (dicts == NULL) { +@@ -195,10 +195,10 @@ jbig2_sd_list_referred(Jbig2Ctx *ctx, Jbig2Segment *segment) + /* generate a new symbol dictionary by concatenating a list of + existing dictionaries */ + Jbig2SymbolDict * +-jbig2_sd_cat(Jbig2Ctx *ctx, int n_dicts, Jbig2SymbolDict **dicts) ++jbig2_sd_cat(Jbig2Ctx *ctx, uint32_t n_dicts, Jbig2SymbolDict **dicts) + { +- int i, j, k, symbols; +- Jbig2SymbolDict *new = NULL; ++ uint32_t i, j, k, symbols; ++ Jbig2SymbolDict *new_dict = NULL; + + /* count the imported symbols and allocate a new array */ + symbols = 0; +@@ -206,17 +206,17 @@ jbig2_sd_cat(Jbig2Ctx *ctx, int n_dicts, Jbig2SymbolDict **dicts) + symbols += dicts[i]->n_symbols; + + /* fill a new array with cloned glyph pointers */ +- new = jbig2_sd_new(ctx, symbols); +- if (new != NULL) { ++ new_dict = jbig2_sd_new(ctx, symbols); ++ if (new_dict != NULL) { + k = 0; + for (i = 0; i < n_dicts; i++) + for (j = 0; j < dicts[i]->n_symbols; j++) +- new->glyphs[k++] = jbig2_image_clone(ctx, dicts[i]->glyphs[j]); ++ new_dict->glyphs[k++] = jbig2_image_clone(ctx, dicts[i]->glyphs[j]); + } else { + jbig2_error(ctx, JBIG2_SEVERITY_WARNING, -1, "failed to allocate new symbol dictionary"); + } + +- return new; ++ return new_dict; + } + + /* Decoding routines */ +@@ -431,7 +431,7 @@ jbig2_decode_symbol_dict(Jbig2Ctx *ctx, + + if (REFAGGNINST > 1) { + Jbig2Image *image; +- int i; ++ uint32_t i; + + if (tparams == NULL) { + /* First time through, we need to initialise the */ +@@ -512,7 +512,7 @@ jbig2_decode_symbol_dict(Jbig2Ctx *ctx, + uint32_t ID; + int32_t RDX, RDY; + int BMSIZE = 0; +- int ninsyms = params->SDNUMINSYMS; ++ uint32_t ninsyms = params->SDNUMINSYMS; + int code1 = 0; + int code2 = 0; + int code3 = 0; +@@ -609,8 +609,9 @@ jbig2_decode_symbol_dict(Jbig2Ctx *ctx, + if (params->SDHUFF && !params->SDREFAGG) { + /* 6.5.9 */ + Jbig2Image *image; +- int BMSIZE = jbig2_huffman_get(hs, params->SDHUFFBMSIZE, &code); +- int j, x; ++ uint32_t BMSIZE = jbig2_huffman_get(hs, params->SDHUFFBMSIZE, &code); ++ uint32_t j; ++ int x; + + if (code || (BMSIZE < 0)) { + jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "error decoding size of collective bitmap!"); +@@ -700,22 +701,22 @@ jbig2_decode_symbol_dict(Jbig2Ctx *ctx, + jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "failed to allocate symbols exported from symbols dictionary"); + goto cleanup4; + } else { +- int i = 0; +- int j = 0; +- int k; ++ uint32_t i = 0; ++ uint32_t j = 0; ++ uint32_t k; + int exflag = 0; +- int64_t limit = params->SDNUMINSYMS + params->SDNUMNEWSYMS; +- int32_t exrunlength; ++ uint32_t limit = params->SDNUMINSYMS + params->SDNUMNEWSYMS; ++ uint32_t exrunlength; + int zerolength = 0; + + while (i < limit) { + if (params->SDHUFF) + exrunlength = jbig2_huffman_get(hs, SBHUFFRSIZE, &code); + else +- code = jbig2_arith_int_decode(IAEX, as, &exrunlength); ++ code = jbig2_arith_int_decode(IAEX, as, (int32_t *)&exrunlength); + /* prevent infinite loop */ + zerolength = exrunlength > 0 ? 0 : zerolength + 1; +- if (code || (exrunlength > limit - i) || (exrunlength < 0) || (zerolength > 4) || (exflag && (exrunlength > params->SDNUMEXSYMS - j))) { ++ if (code || (exrunlength > limit - i) || (exrunlength < 0) || (zerolength > 4) || (exflag && (exrunlength + j > params->SDNUMEXSYMS))) { + if (code) + jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "failed to decode exrunlength for exported symbols"); + else if (exrunlength <= 0) +@@ -797,8 +798,8 @@ jbig2_symbol_dictionary(Jbig2Ctx *ctx, Jbig2Segment *segment, const byte *segmen + { + Jbig2SymbolDictParams params; + uint16_t flags; +- int sdat_bytes; +- int offset; ++ uint32_t sdat_bytes; ++ uint32_t offset; + Jbig2ArithCx *GB_stats = NULL; + Jbig2ArithCx *GR_stats = NULL; + int table_index = 0; +@@ -951,7 +952,7 @@ jbig2_symbol_dictionary(Jbig2Ctx *ctx, Jbig2Segment *segment, const byte *segmen + + /* 7.4.2.2 (2) */ + { +- int n_dicts = jbig2_sd_count_referred(ctx, segment); ++ uint32_t n_dicts = jbig2_sd_count_referred(ctx, segment); + Jbig2SymbolDict **dicts = NULL; + + if (n_dicts > 0) { +diff --git a/jbig2dec/jbig2_symbol_dict.h b/jbig2dec/jbig2_symbol_dict.h +index d56d62d..30211d4 100644 +--- a/jbig2dec/jbig2_symbol_dict.h ++++ b/jbig2dec/jbig2_symbol_dict.h +@@ -32,18 +32,18 @@ int jbig2_symbol_dictionary(Jbig2Ctx *ctx, Jbig2Segment *segment, const byte *se + Jbig2Image *jbig2_sd_glyph(Jbig2SymbolDict *dict, unsigned int id); + + /* return a new empty symbol dict */ +-Jbig2SymbolDict *jbig2_sd_new(Jbig2Ctx *ctx, int n_symbols); ++Jbig2SymbolDict *jbig2_sd_new(Jbig2Ctx *ctx, uint32_t n_symbols); + + /* release the memory associated with a symbol dict */ + void jbig2_sd_release(Jbig2Ctx *ctx, Jbig2SymbolDict *dict); + + /* generate a new symbol dictionary by concatenating a list of + existing dictionaries */ +-Jbig2SymbolDict *jbig2_sd_cat(Jbig2Ctx *ctx, int n_dicts, Jbig2SymbolDict **dicts); ++Jbig2SymbolDict *jbig2_sd_cat(Jbig2Ctx *ctx, uint32_t n_dicts, Jbig2SymbolDict **dicts); + + /* count the number of dictionary segments referred + to by the given segment */ +-int jbig2_sd_count_referred(Jbig2Ctx *ctx, Jbig2Segment *segment); ++uint32_t jbig2_sd_count_referred(Jbig2Ctx *ctx, Jbig2Segment *segment); + + /* return an array of pointers to symbol dictionaries referred + to by a segment */ +diff --git a/jbig2dec/jbig2_text.c b/jbig2dec/jbig2_text.c +index 5c99640..e77460f 100644 +--- a/jbig2dec/jbig2_text.c ++++ b/jbig2dec/jbig2_text.c +@@ -55,7 +55,7 @@ + int + jbig2_decode_text_region(Jbig2Ctx *ctx, Jbig2Segment *segment, + const Jbig2TextRegionParams *params, +- const Jbig2SymbolDict *const *dicts, const int n_dicts, ++ const Jbig2SymbolDict *const *dicts, const uint32_t n_dicts, + Jbig2Image *image, const byte *data, const size_t size, Jbig2ArithCx *GR_stats, Jbig2ArithState *as, Jbig2WordStream *ws) + { + /* relevent bits of 6.4.4 */ +@@ -476,19 +476,19 @@ cleanup2: + int + jbig2_text_region(Jbig2Ctx *ctx, Jbig2Segment *segment, const byte *segment_data) + { +- int offset = 0; ++ uint32_t offset = 0; + Jbig2RegionSegmentInfo region_info; + Jbig2TextRegionParams params; + Jbig2Image *image = NULL; + Jbig2SymbolDict **dicts = NULL; +- int n_dicts = 0; ++ uint32_t n_dicts = 0; + uint16_t flags = 0; + uint16_t huffman_flags = 0; + Jbig2ArithCx *GR_stats = NULL; + int code = 0; + Jbig2WordStream *ws = NULL; + Jbig2ArithState *as = NULL; +- int table_index = 0; ++ uint32_t table_index = 0; + const Jbig2HuffmanParams *huffman_params = NULL; + + /* 7.4.1 */ +@@ -779,7 +779,7 @@ jbig2_text_region(Jbig2Ctx *ctx, Jbig2Segment *segment, const byte *segment_data + code = jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "unable to retrive symbol dictionaries! previous parsing error?"); + goto cleanup1; + } else { +- int index; ++ uint32_t index; + + if (dicts[0] == NULL) { + code = jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "unable to find first referenced symbol dictionary!"); +@@ -823,8 +823,8 @@ jbig2_text_region(Jbig2Ctx *ctx, Jbig2Segment *segment, const byte *segment_data + } + + if (!params.SBHUFF) { +- int SBSYMCODELEN, index; +- int SBNUMSYMS = 0; ++ uint32_t SBSYMCODELEN, index; ++ uint32_t SBNUMSYMS = 0; + + for (index = 0; index < n_dicts; index++) { + SBNUMSYMS += dicts[index]->n_symbols; +@@ -840,7 +840,7 @@ jbig2_text_region(Jbig2Ctx *ctx, Jbig2Segment *segment, const byte *segment_data + } + + /* Table 31 */ +- for (SBSYMCODELEN = 0; (1 << SBSYMCODELEN) < SBNUMSYMS; SBSYMCODELEN++) { ++ for (SBSYMCODELEN = 0; (1U << SBSYMCODELEN) < SBNUMSYMS; SBSYMCODELEN++) { + } + params.IAID = jbig2_arith_iaid_ctx_new(ctx, SBSYMCODELEN); + params.IARI = jbig2_arith_int_ctx_new(ctx); +diff --git a/jbig2dec/jbig2_text.h b/jbig2dec/jbig2_text.h +index aec2732..51d242e 100644 +--- a/jbig2dec/jbig2_text.h ++++ b/jbig2dec/jbig2_text.h +@@ -70,5 +70,5 @@ typedef struct { + int + jbig2_decode_text_region(Jbig2Ctx *ctx, Jbig2Segment *segment, + const Jbig2TextRegionParams *params, +- const Jbig2SymbolDict *const *dicts, const int n_dicts, ++ const Jbig2SymbolDict *const *dicts, const uint32_t n_dicts, + Jbig2Image *image, const byte *data, const size_t size, Jbig2ArithCx *GR_stats, Jbig2ArithState *as, Jbig2WordStream *ws); +-- +2.9.3 \ No newline at end of file diff --git a/office/postscript/ghostscript/files/fedora/ghostscript-9.20-fix-openjpeg-system-build.patch b/office/postscript/ghostscript/files/fedora/ghostscript-9.20-fix-openjpeg-system-build.patch new file mode 100644 index 0000000000..3c990e67ef --- /dev/null +++ b/office/postscript/ghostscript/files/fedora/ghostscript-9.20-fix-openjpeg-system-build.patch @@ -0,0 +1,55 @@ +From 99cf218dbd5f6fbdbda2ce6872eb9ab7f475c353 Mon Sep 17 00:00:00 2001 +From: Chris Liddell +Date: Tue, 27 Sep 2016 11:22:18 +0100 +Subject: [PATCH 1/2] Add pre-processor define for shared OpenJPEG + +--- + Makefile.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile.in b/Makefile.in +index 25875ad..2ca2a80 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -290,7 +290,7 @@ JBIG2_CFLAGS=@JBIG2_AUTOCONF_CFLAGS@ + JPX_LIB=@JPX_DECODER@ + SHARE_JPX=@SHARE_JPX@ + JPXSRCDIR=@JPXDIR@ +-JPX_CFLAGS=@JPX_AUTOCONF_CFLAGS@ @JPX_SSE_CFLAGS@ ++JPX_CFLAGS=-DSHARE_JPX=$(SHARE_JPX) @JPX_AUTOCONF_CFLAGS@ @JPX_SSE_CFLAGS@ + + # uncomment the following three lines and one of the last two to + # compile in the Luratech lwf_jp2 codec +-- +2.7.4 + + +From 4f19ab99cac2d8a7d21aea34d8aea0727fad52d3 Mon Sep 17 00:00:00 2001 +From: Didier Raboud +Date: Thu, 6 Oct 2016 17:08:41 +0200 +Subject: [PATCH 2/2] Don't pass -DOPJ_STATIC when compiling the OpenJPEG code. + + It makes the symbols hidden when including + /usr/include/openjpeg-2.1/openjpeg.h. + Fixes a FTBFS against libopenjp2-7 (>= 2.1.1). + + Debian bug: https://bugs.debian.org/832873 +--- + base/lib.mak | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/base/lib.mak b/base/lib.mak +index 173e2c6..cffdc9d 100644 +--- a/base/lib.mak ++++ b/base/lib.mak +@@ -1849,7 +1849,7 @@ $(GLOBJ)sjpx_openjpeg.$(OBJ) : $(GLSRC)sjpx_openjpeg.c $(AK) \ + $(memory__h) $(gserror_h) $(gserrors_h) \ + $(gdebug_h) $(strimpl_h) $(sjpx_openjpeg_h) $(LIB_MAK) $(MAKEDIRS) + $(GLJPXOPJCC) $(GLO_)sjpx_openjpeg.$(OBJ) \ +- $(C_) -DOPJ_STATIC $(GLSRC)sjpx_openjpeg.c ++ $(C_) $(GLSRC)sjpx_openjpeg.c + + # ---------------- Pixel-difference filters ---------------- # + # The Predictor facility of the LZW and Flate filters uses these. +-- +2.7.4 \ No newline at end of file diff --git a/office/postscript/ghostscript/files/fedora/ghostscript-9.20-handle-glyphdirectory-correctly.patch b/office/postscript/ghostscript/files/fedora/ghostscript-9.20-handle-glyphdirectory-correctly.patch new file mode 100644 index 0000000000..c181ac2553 --- /dev/null +++ b/office/postscript/ghostscript/files/fedora/ghostscript-9.20-handle-glyphdirectory-correctly.patch @@ -0,0 +1,51 @@ +From 329e0a6d187cc5b5698689d76636ed3214d7efa7 Mon Sep 17 00:00:00 2001 +From: Chris Liddell +Date: Thu, 3 Nov 2016 13:09:27 +0000 +Subject: [PATCH] Bug 697286: handle GlyphDirectory as an array + +For high level devices that need to copy CIDFonts, we need to establish the +highest CID in a given CIDFont. If the font has a GlyphDirectory dictionary +the only way to do so is to iterate through the keys to find the highest. + +The code handling this ignored that the GlyphDirectory could be an array, +which confused the dictionary content iterator, and caused a segfault. + +In the case of an array, set the high CID to the highest index available in the +array. +--- + psi/zfcid.c | 18 +++++++++++------- + 1 file changed, 11 insertions(+), 7 deletions(-) + +diff --git a/psi/zfcid.c b/psi/zfcid.c +index ce583af..3098a22 100644 +--- a/psi/zfcid.c ++++ b/psi/zfcid.c +@@ -76,15 +76,19 @@ cid_font_data_param(os_ptr op, gs_font_cid_data *pdata, ref *pGlyphDirectory) + * the number of CIDs in the font. We need to know the maximum CID + * when copying fonts, so calculate and store it now. + */ +- index = dict_first(pgdir); +- while (index >= 0) { +- index = dict_next(pgdir, index, (ref *)&element); +- if (index >= 0) { +- if (element[0].value.intval > pdata->MaxCID) +- pdata->MaxCID = element[0].value.intval; ++ if (r_has_type(pgdir, t_dictionary)) { ++ index = dict_first(pgdir); ++ while (index >= 0) { ++ index = dict_next(pgdir, index, (ref *)&element); ++ if (index >= 0) { ++ if (element[0].value.intval > pdata->MaxCID) ++ pdata->MaxCID = element[0].value.intval; ++ } + } + } +- ++ else { ++ pdata->MaxCID = r_size(pgdir) - 1; ++ } + return code; + } else { + return_error(gs_error_typecheck); +-- +2.7.4 diff --git a/office/postscript/ghostscript/files/fedora/ghostscript-9.20-remove-and-reimplement-ConvertUTF.patch b/office/postscript/ghostscript/files/fedora/ghostscript-9.20-remove-and-reimplement-ConvertUTF.patch new file mode 100644 index 0000000000..d64bd0f48c --- /dev/null +++ b/office/postscript/ghostscript/files/fedora/ghostscript-9.20-remove-and-reimplement-ConvertUTF.patch @@ -0,0 +1,1227 @@ +From 273a133110838ee5702e7eb6409a853c598211b2 Mon Sep 17 00:00:00 2001 +From: Ken Sharp +Date: Thu, 29 Sep 2016 17:35:05 +0100 +Subject: [PATCH] Remove (and re-implement) ConvertUTF.c + +Bug #697122 " embedded ConvertUTF.c is buggy and licensed incompatibly with GPL/APGL" + +Its not clear that this code is incompatible with GPL, nor do we think +any 'bugginess' in the code affects us, since we are using a comparatively +small part of the included code. + +Nevertheless its possible to remove the code, and re-implement the small +part we actually need, and that is done here. + +Also removed the DSCEncodingToUnicode option which was insanely difficult +to use, and incorrectly documented. + +Yhis shows one difference, 692486_-_heap_overflow_in_pdf_to_ucs2.pdf +now correctly throws an error, because the PDF file contains document +information (Application) which has an invalid UTF16-BE sequence. +--- + base/ConvertUTF.c | 539 ----------------------------------------- + base/ConvertUTF.h | 155 ------------ + base/lib.mak | 4 - + devices/devs.mak | 5 +- + devices/vector/gdevpdf.c | 16 +- + devices/vector/gdevpdfb.h | 1 - + devices/vector/gdevpdfe.c | 270 +++++++++++---------- + devices/vector/gdevpdfp.c | 1 - + devices/vector/gdevpdfx.h | 17 +- + windows/ghostscript.vcproj | 8 - + windows/ghostscript_rt.vcxproj | 2 - + 11 files changed, 155 insertions(+), 863 deletions(-) + delete mode 100644 base/ConvertUTF.c + delete mode 100644 base/ConvertUTF.h + +diff --git a/base/ConvertUTF.c b/base/ConvertUTF.c +deleted file mode 100644 +index cb2e2de..0000000 +--- a/base/ConvertUTF.c ++++ /dev/null +@@ -1,539 +0,0 @@ +-/* +- * Copyright 2001-2004 Unicode, Inc. +- * +- * Disclaimer +- * +- * This source code is provided as is by Unicode, Inc. No claims are +- * made as to fitness for any particular purpose. No warranties of any +- * kind are expressed or implied. The recipient agrees to determine +- * applicability of information provided. If this file has been +- * purchased on magnetic or optical media from Unicode, Inc., the +- * sole remedy for any claim will be exchange of defective media +- * within 90 days of receipt. +- * +- * Limitations on Rights to Redistribute This Code +- * +- * Unicode, Inc. hereby grants the right to freely use the information +- * supplied in this file in the creation of products supporting the +- * Unicode Standard, and to make copies of this file in any form +- * for internal or external distribution as long as this notice +- * remains attached. +- */ +- +- +-/* --------------------------------------------------------------------- +- +- Conversions between UTF32, UTF-16, and UTF-8. Source code file. +- Author: Mark E. Davis, 1994. +- Rev History: Rick McGowan, fixes & updates May 2001. +- Sept 2001: fixed const & error conditions per +- mods suggested by S. Parent & A. Lillich. +- June 2002: Tim Dodd added detection and handling of incomplete +- source sequences, enhanced error detection, added casts +- to eliminate compiler warnings. +- July 2003: slight mods to back out aggressive FFFE detection. +- Jan 2004: updated switches in from-UTF8 conversions. +- Oct 2004: updated to use UNI_MAX_LEGAL_UTF32 in UTF-32 conversions. +- +- See the header file "ConvertUTF.h" for complete documentation. +- +------------------------------------------------------------------------- */ +- +-#include "ConvertUTF.h" +-#ifdef CVTUTF_DEBUG +-#include +-#endif +- +-static const int halfShift = 10; /* used for shifting by 10 bits */ +- +-static const UTF32 halfBase = 0x0010000UL; +-static const UTF32 halfMask = 0x3FFUL; +- +-#define UNI_SUR_HIGH_START (UTF32)0xD800 +-#define UNI_SUR_HIGH_END (UTF32)0xDBFF +-#define UNI_SUR_LOW_START (UTF32)0xDC00 +-#define UNI_SUR_LOW_END (UTF32)0xDFFF +-#define false 0 +-#define true 1 +- +-/* --------------------------------------------------------------------- */ +- +-ConversionResult ConvertUTF32toUTF16 ( +- const UTF32** sourceStart, const UTF32* sourceEnd, +- UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags) { +- ConversionResult result = conversionOK; +- const UTF32* source = *sourceStart; +- UTF16* target = *targetStart; +- while (source < sourceEnd) { +- UTF32 ch; +- if (target >= targetEnd) { +- result = targetExhausted; break; +- } +- ch = *source++; +- if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */ +- /* UTF-16 surrogate values are illegal in UTF-32; 0xffff or 0xfffe are both reserved values */ +- if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { +- if (flags == strictConversion) { +- --source; /* return to the illegal value itself */ +- result = sourceIllegal; +- break; +- } else { +- *target++ = UNI_REPLACEMENT_CHAR; +- } +- } else { +- *target++ = (UTF16)ch; /* normal case */ +- } +- } else if (ch > UNI_MAX_LEGAL_UTF32) { +- if (flags == strictConversion) { +- result = sourceIllegal; +- } else { +- *target++ = UNI_REPLACEMENT_CHAR; +- } +- } else { +- /* target is a character in range 0xFFFF - 0x10FFFF. */ +- if (target + 1 >= targetEnd) { +- --source; /* Back up source pointer! */ +- result = targetExhausted; break; +- } +- ch -= halfBase; +- *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START); +- *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START); +- } +- } +- *sourceStart = source; +- *targetStart = target; +- return result; +-} +- +-/* --------------------------------------------------------------------- */ +- +-ConversionResult ConvertUTF16toUTF32 ( +- const UTF16** sourceStart, const UTF16* sourceEnd, +- UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags) { +- ConversionResult result = conversionOK; +- const UTF16* source = *sourceStart; +- UTF32* target = *targetStart; +- UTF32 ch, ch2; +- while (source < sourceEnd) { +- const UTF16* oldSource = source; /* In case we have to back up because of target overflow. */ +- ch = *source++; +- /* If we have a surrogate pair, convert to UTF32 first. */ +- if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) { +- /* If the 16 bits following the high surrogate are in the source buffer... */ +- if (source < sourceEnd) { +- ch2 = *source; +- /* If it's a low surrogate, convert to UTF32. */ +- if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) { +- ch = ((ch - UNI_SUR_HIGH_START) << halfShift) +- + (ch2 - UNI_SUR_LOW_START) + halfBase; +- ++source; +- } else if (flags == strictConversion) { /* it's an unpaired high surrogate */ +- --source; /* return to the illegal value itself */ +- result = sourceIllegal; +- break; +- } +- } else { /* We don't have the 16 bits following the high surrogate. */ +- --source; /* return to the high surrogate */ +- result = sourceExhausted; +- break; +- } +- } else if (flags == strictConversion) { +- /* UTF-16 surrogate values are illegal in UTF-32 */ +- if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) { +- --source; /* return to the illegal value itself */ +- result = sourceIllegal; +- break; +- } +- } +- if (target >= targetEnd) { +- source = oldSource; /* Back up source pointer! */ +- result = targetExhausted; break; +- } +- *target++ = ch; +- } +- *sourceStart = source; +- *targetStart = target; +-#ifdef CVTUTF_DEBUG +-if (result == sourceIllegal) { +- fprintf(stderr, "ConvertUTF16toUTF32 illegal seq 0x%04x,%04x\n", ch, ch2); +- fflush(stderr); +-} +-#endif +- return result; +-} +- +-/* --------------------------------------------------------------------- */ +- +-/* +- * Index into the table below with the first byte of a UTF-8 sequence to +- * get the number of trailing bytes that are supposed to follow it. +- * Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is +- * left as-is for anyone who may want to do such conversion, which was +- * allowed in earlier algorithms. +- */ +-static const char trailingBytesForUTF8[256] = { +- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, +- 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 +-}; +- +-/* +- * Magic values subtracted from a buffer value during UTF8 conversion. +- * This table contains as many values as there might be trailing bytes +- * in a UTF-8 sequence. +- */ +-static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, +- 0x03C82080UL, 0xFA082080UL, 0x82082080UL }; +- +-/* +- * Once the bits are split out into bytes of UTF-8, this is a mask OR-ed +- * into the first byte, depending on how many bytes follow. There are +- * as many entries in this table as there are UTF-8 sequence types. +- * (I.e., one byte sequence, two byte... etc.). Remember that sequencs +- * for *legal* UTF-8 will be 4 or fewer bytes total. +- */ +-static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; +- +-/* --------------------------------------------------------------------- */ +- +-/* The interface converts a whole buffer to avoid function-call overhead. +- * Constants have been gathered. Loops & conditionals have been removed as +- * much as possible for efficiency, in favor of drop-through switches. +- * (See "Note A" at the bottom of the file for equivalent code.) +- * If your compiler supports it, the "isLegalUTF8" call can be turned +- * into an inline function. +- */ +- +-/* --------------------------------------------------------------------- */ +- +-ConversionResult ConvertUTF16toUTF8 ( +- const UTF16** sourceStart, const UTF16* sourceEnd, +- UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags) { +- ConversionResult result = conversionOK; +- const UTF16* source = *sourceStart; +- UTF8* target = *targetStart; +- while (source < sourceEnd) { +- UTF32 ch; +- unsigned short bytesToWrite = 0; +- const UTF32 byteMask = 0xBF; +- const UTF32 byteMark = 0x80; +- const UTF16* oldSource = source; /* In case we have to back up because of target overflow. */ +- ch = *source++; +- /* If we have a surrogate pair, convert to UTF32 first. */ +- if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) { +- /* If the 16 bits following the high surrogate are in the source buffer... */ +- if (source < sourceEnd) { +- UTF32 ch2 = *source; +- /* If it's a low surrogate, convert to UTF32. */ +- if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) { +- ch = ((ch - UNI_SUR_HIGH_START) << halfShift) +- + (ch2 - UNI_SUR_LOW_START) + halfBase; +- ++source; +- } else if (flags == strictConversion) { /* it's an unpaired high surrogate */ +- --source; /* return to the illegal value itself */ +- result = sourceIllegal; +- break; +- } +- } else { /* We don't have the 16 bits following the high surrogate. */ +- --source; /* return to the high surrogate */ +- result = sourceExhausted; +- break; +- } +- } else if (flags == strictConversion) { +- /* UTF-16 surrogate values are illegal in UTF-32 */ +- if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) { +- --source; /* return to the illegal value itself */ +- result = sourceIllegal; +- break; +- } +- } +- /* Figure out how many bytes the result will require */ +- if (ch < (UTF32)0x80) { bytesToWrite = 1; +- } else if (ch < (UTF32)0x800) { bytesToWrite = 2; +- } else if (ch < (UTF32)0x10000) { bytesToWrite = 3; +- } else if (ch < (UTF32)0x110000) { bytesToWrite = 4; +- } else { bytesToWrite = 3; +- ch = UNI_REPLACEMENT_CHAR; +- } +- +- target += bytesToWrite; +- if (target > targetEnd) { +- source = oldSource; /* Back up source pointer! */ +- target -= bytesToWrite; result = targetExhausted; break; +- } +- switch (bytesToWrite) { /* note: everything falls through. */ +- case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; +- case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; +- case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; +- case 1: *--target = (UTF8)(ch | firstByteMark[bytesToWrite]); +- } +- target += bytesToWrite; +- } +- *sourceStart = source; +- *targetStart = target; +- return result; +-} +- +-/* --------------------------------------------------------------------- */ +- +-/* +- * Utility routine to tell whether a sequence of bytes is legal UTF-8. +- * This must be called with the length pre-determined by the first byte. +- * If not calling this from ConvertUTF8to*, then the length can be set by: +- * length = trailingBytesForUTF8[*source]+1; +- * and the sequence is illegal right away if there aren't that many bytes +- * available. +- * If presented with a length > 4, this returns false. The Unicode +- * definition of UTF-8 goes up to 4-byte sequences. +- */ +- +-static Boolean isLegalUTF8(const UTF8 *source, int length) { +- UTF8 a; +- const UTF8 *srcptr = source+length; +- switch (length) { +- default: return false; +- /* Everything else falls through when "true"... */ +- case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; +- case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; +- case 2: if ((a = (*--srcptr)) > 0xBF) return false; +- +- switch (*source) { +- /* no fall-through in this inner switch */ +- case 0xE0: if (a < 0xA0) return false; break; +- case 0xED: if (a > 0x9F) return false; break; +- case 0xF0: if (a < 0x90) return false; break; +- case 0xF4: if (a > 0x8F) return false; break; +- default: if (a < 0x80) return false; +- } +- +- case 1: if (*source >= 0x80 && *source < 0xC2) return false; +- } +- if (*source > 0xF4) return false; +- return true; +-} +- +-/* --------------------------------------------------------------------- */ +- +-/* +- * Exported function to return whether a UTF-8 sequence is legal or not. +- * This is not used here; it's just exported. +- */ +-Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd) { +- int length = trailingBytesForUTF8[*source]+1; +- if (source+length > sourceEnd) { +- return false; +- } +- return isLegalUTF8(source, length); +-} +- +-/* --------------------------------------------------------------------- */ +- +-ConversionResult ConvertUTF8toUTF16 ( +- const UTF8** sourceStart, const UTF8* sourceEnd, +- UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags) { +- ConversionResult result = conversionOK; +- const UTF8* source = *sourceStart; +- UTF16* target = *targetStart; +- while (source < sourceEnd) { +- UTF32 ch = 0; +- unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; +- if (source + extraBytesToRead >= sourceEnd) { +- result = sourceExhausted; break; +- } +- /* Do this check whether lenient or strict */ +- if (! isLegalUTF8(source, extraBytesToRead+1)) { +- result = sourceIllegal; +- break; +- } +- /* +- * The cases all fall through. See "Note A" below. +- */ +- switch (extraBytesToRead) { +- case 5: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */ +- case 4: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */ +- case 3: ch += *source++; ch <<= 6; +- case 2: ch += *source++; ch <<= 6; +- case 1: ch += *source++; ch <<= 6; +- case 0: ch += *source++; +- } +- ch -= offsetsFromUTF8[extraBytesToRead]; +- +- if (target >= targetEnd) { +- source -= (extraBytesToRead+1); /* Back up source pointer! */ +- result = targetExhausted; break; +- } +- if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */ +- /* UTF-16 surrogate values are illegal in UTF-32 */ +- if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { +- if (flags == strictConversion) { +- source -= (extraBytesToRead+1); /* return to the illegal value itself */ +- result = sourceIllegal; +- break; +- } else { +- *target++ = UNI_REPLACEMENT_CHAR; +- } +- } else { +- *target++ = (UTF16)ch; /* normal case */ +- } +- } else if (ch > UNI_MAX_UTF16) { +- if (flags == strictConversion) { +- result = sourceIllegal; +- source -= (extraBytesToRead+1); /* return to the start */ +- break; /* Bail out; shouldn't continue */ +- } else { +- *target++ = UNI_REPLACEMENT_CHAR; +- } +- } else { +- /* target is a character in range 0xFFFF - 0x10FFFF. */ +- if (target + 1 >= targetEnd) { +- source -= (extraBytesToRead+1); /* Back up source pointer! */ +- result = targetExhausted; break; +- } +- ch -= halfBase; +- *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START); +- *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START); +- } +- } +- *sourceStart = source; +- *targetStart = target; +- return result; +-} +- +-/* --------------------------------------------------------------------- */ +- +-ConversionResult ConvertUTF32toUTF8 ( +- const UTF32** sourceStart, const UTF32* sourceEnd, +- UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags) { +- ConversionResult result = conversionOK; +- const UTF32* source = *sourceStart; +- UTF8* target = *targetStart; +- while (source < sourceEnd) { +- UTF32 ch; +- unsigned short bytesToWrite = 0; +- const UTF32 byteMask = 0xBF; +- const UTF32 byteMark = 0x80; +- ch = *source++; +- if (flags == strictConversion ) { +- /* UTF-16 surrogate values are illegal in UTF-32 */ +- if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { +- --source; /* return to the illegal value itself */ +- result = sourceIllegal; +- break; +- } +- } +- /* +- * Figure out how many bytes the result will require. Turn any +- * illegally large UTF32 things (> Plane 17) into replacement chars. +- */ +- if (ch < (UTF32)0x80) { bytesToWrite = 1; +- } else if (ch < (UTF32)0x800) { bytesToWrite = 2; +- } else if (ch < (UTF32)0x10000) { bytesToWrite = 3; +- } else if (ch <= UNI_MAX_LEGAL_UTF32) { bytesToWrite = 4; +- } else { bytesToWrite = 3; +- ch = UNI_REPLACEMENT_CHAR; +- result = sourceIllegal; +- } +- +- target += bytesToWrite; +- if (target > targetEnd) { +- --source; /* Back up source pointer! */ +- target -= bytesToWrite; result = targetExhausted; break; +- } +- switch (bytesToWrite) { /* note: everything falls through. */ +- case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; +- case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; +- case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; +- case 1: *--target = (UTF8) (ch | firstByteMark[bytesToWrite]); +- } +- target += bytesToWrite; +- } +- *sourceStart = source; +- *targetStart = target; +- return result; +-} +- +-/* --------------------------------------------------------------------- */ +- +-ConversionResult ConvertUTF8toUTF32 ( +- const UTF8** sourceStart, const UTF8* sourceEnd, +- UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags) { +- ConversionResult result = conversionOK; +- const UTF8* source = *sourceStart; +- UTF32* target = *targetStart; +- while (source < sourceEnd) { +- UTF32 ch = 0; +- unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; +- if (source + extraBytesToRead >= sourceEnd) { +- result = sourceExhausted; break; +- } +- /* Do this check whether lenient or strict */ +- if (! isLegalUTF8(source, extraBytesToRead+1)) { +- result = sourceIllegal; +- break; +- } +- /* +- * The cases all fall through. See "Note A" below. +- */ +- switch (extraBytesToRead) { +- case 5: ch += *source++; ch <<= 6; +- case 4: ch += *source++; ch <<= 6; +- case 3: ch += *source++; ch <<= 6; +- case 2: ch += *source++; ch <<= 6; +- case 1: ch += *source++; ch <<= 6; +- case 0: ch += *source++; +- } +- ch -= offsetsFromUTF8[extraBytesToRead]; +- +- if (target >= targetEnd) { +- source -= (extraBytesToRead+1); /* Back up the source pointer! */ +- result = targetExhausted; break; +- } +- if (ch <= UNI_MAX_LEGAL_UTF32) { +- /* +- * UTF-16 surrogate values are illegal in UTF-32, and anything +- * over Plane 17 (> 0x10FFFF) is illegal. +- */ +- if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { +- if (flags == strictConversion) { +- source -= (extraBytesToRead+1); /* return to the illegal value itself */ +- result = sourceIllegal; +- break; +- } else { +- *target++ = UNI_REPLACEMENT_CHAR; +- } +- } else { +- *target++ = ch; +- } +- } else { /* i.e., ch > UNI_MAX_LEGAL_UTF32 */ +- result = sourceIllegal; +- *target++ = UNI_REPLACEMENT_CHAR; +- } +- } +- *sourceStart = source; +- *targetStart = target; +- return result; +-} +- +-/* --------------------------------------------------------------------- +- +- Note A. +- The fall-through switches in UTF-8 reading code save a +- temp variable, some decrements & conditionals. The switches +- are equivalent to the following loop: +- { +- int tmpBytesToRead = extraBytesToRead+1; +- do { +- ch += *source++; +- --tmpBytesToRead; +- if (tmpBytesToRead) ch <<= 6; +- } while (tmpBytesToRead > 0); +- } +- In UTF-8 writing code, the switches on "bytesToWrite" are +- similarly unrolled loops. +- +- --------------------------------------------------------------------- */ +diff --git a/base/ConvertUTF.h b/base/ConvertUTF.h +deleted file mode 100644 +index 538bec6..0000000 +--- a/base/ConvertUTF.h ++++ /dev/null +@@ -1,155 +0,0 @@ +-/* +- * Copyright 2001-2004 Unicode, Inc. +- * +- * Disclaimer +- * +- * This source code is provided as is by Unicode, Inc. No claims are +- * made as to fitness for any particular purpose. No warranties of any +- * kind are expressed or implied. The recipient agrees to determine +- * applicability of information provided. If this file has been +- * purchased on magnetic or optical media from Unicode, Inc., the +- * sole remedy for any claim will be exchange of defective media +- * within 90 days of receipt. +- * +- * Limitations on Rights to Redistribute This Code +- * +- * Unicode, Inc. hereby grants the right to freely use the information +- * supplied in this file in the creation of products supporting the +- * Unicode Standard, and to make copies of this file in any form +- * for internal or external distribution as long as this notice +- * remains attached. +- */ +- +- +-#ifndef ConvertUTF_INCLUDED +-#define ConvertUTF_INCLUDED +- +-/* --------------------------------------------------------------------- +- +- Conversions between UTF32, UTF-16, and UTF-8. Header file. +- +- Several funtions are included here, forming a complete set of +- conversions between the three formats. UTF-7 is not included +- here, but is handled in a separate source file. +- +- Each of these routines takes pointers to input buffers and output +- buffers. The input buffers are const. +- +- Each routine converts the text between *sourceStart and sourceEnd, +- putting the result into the buffer between *targetStart and +- targetEnd. Note: the end pointers are *after* the last item: e.g. +- *(sourceEnd - 1) is the last item. +- +- The return result indicates whether the conversion was successful, +- and if not, whether the problem was in the source or target buffers. +- (Only the first encountered problem is indicated.) +- +- After the conversion, *sourceStart and *targetStart are both +- updated to point to the end of last text successfully converted in +- the respective buffers. +- +- Input parameters: +- sourceStart - pointer to a pointer to the source buffer. +- The contents of this are modified on return so that +- it points at the next thing to be converted. +- targetStart - similarly, pointer to pointer to the target buffer. +- sourceEnd, targetEnd - respectively pointers to the ends of the +- two buffers, for overflow checking only. +- +- These conversion functions take a ConversionFlags argument. When this +- flag is set to strict, both irregular sequences and isolated surrogates +- will cause an error. When the flag is set to lenient, both irregular +- sequences and isolated surrogates are converted. +- +- Whether the flag is strict or lenient, all illegal sequences will cause +- an error return. This includes sequences such as: , , +- or in UTF-8, and values above 0x10FFFF in UTF-32. Conformant code +- must check for illegal sequences. +- +- When the flag is set to lenient, characters over 0x10FFFF are converted +- to the replacement character; otherwise (when the flag is set to strict) +- they constitute an error. +- +- Output parameters: +- The value "sourceIllegal" is returned from some routines if the input +- sequence is malformed. When "sourceIllegal" is returned, the source +- value will point to the illegal value that caused the problem. E.g., +- in UTF-8 when a sequence is malformed, it points to the start of the +- malformed sequence. +- +- Author: Mark E. Davis, 1994. +- Rev History: Rick McGowan, fixes & updates May 2001. +- Fixes & updates, Sept 2001. +- +------------------------------------------------------------------------- */ +- +-/* --------------------------------------------------------------------- +- The following 4 definitions are compiler-specific. +- The C standard does not guarantee that wchar_t has at least +- 16 bits, so wchar_t is no less portable than unsigned short! +- All should be unsigned values to avoid sign extension during +- bit mask & shift operations. +------------------------------------------------------------------------- */ +- +-typedef unsigned long UTF32; /* at least 32 bits */ +-typedef unsigned short UTF16; /* at least 16 bits */ +-typedef unsigned char UTF8; /* typically 8 bits */ +-typedef unsigned char Boolean; /* 0 or 1 */ +- +-/* Some fundamental constants */ +-#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD +-#define UNI_MAX_BMP (UTF32)0x0000FFFF +-#define UNI_MAX_UTF16 (UTF32)0x0010FFFF +-#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF +-#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF +- +-typedef enum { +- conversionOK, /* conversion successful */ +- sourceExhausted, /* partial character in source, but hit end */ +- targetExhausted, /* insuff. room in target for conversion */ +- sourceIllegal /* source sequence is illegal/malformed */ +-} ConversionResult; +- +-typedef enum { +- strictConversion = 0, +- lenientConversion +-} ConversionFlags; +- +-/* This is for C++ and does no harm in C */ +-#ifdef __cplusplus +-extern "C" { +-#endif +- +-ConversionResult ConvertUTF8toUTF16 ( +- const UTF8** sourceStart, const UTF8* sourceEnd, +- UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags); +- +-ConversionResult ConvertUTF16toUTF8 ( +- const UTF16** sourceStart, const UTF16* sourceEnd, +- UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags); +- +-ConversionResult ConvertUTF8toUTF32 ( +- const UTF8** sourceStart, const UTF8* sourceEnd, +- UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags); +- +-ConversionResult ConvertUTF32toUTF8 ( +- const UTF32** sourceStart, const UTF32* sourceEnd, +- UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags); +- +-ConversionResult ConvertUTF16toUTF32 ( +- const UTF16** sourceStart, const UTF16* sourceEnd, +- UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags); +- +-ConversionResult ConvertUTF32toUTF16 ( +- const UTF32** sourceStart, const UTF32* sourceEnd, +- UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags); +- +-Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd); +- +-#ifdef __cplusplus +-} +-#endif +- +-/* --------------------------------------------------------------------- */ +- +-#endif /* ConvertUTF_INCLUDED */ +diff --git a/base/lib.mak b/base/lib.mak +index 173e2c6..2de6565 100644 +--- a/base/lib.mak ++++ b/base/lib.mak +@@ -52,7 +52,6 @@ GLLCMS2CC=$(CC) $(LCMS2_CFLAGS) $(CFLAGS) $(I_)$(GLI_) $(II)$(LCMS2SRCDIR)$(D)in + lcms2_h=$(LCMS2SRCDIR)$(D)include$(D)lcms2.h + lcms2_plugin_h=$(LCMS2SRCDIR)$(D)include$(D)lcms2_plugin.h + +-ConvertUTF_h=$(GLSRC)ConvertUTF.h + gdevdcrd_h=$(GLSRC)gdevdcrd.h + gdevpccm_h=$(GLSRC)gdevpccm.h + +@@ -1097,9 +1096,6 @@ $(GLOBJ)gdevpccm.$(OBJ) : $(GLSRC)gdevpccm.c $(AK)\ + $(gx_h) $(gsmatrix_h) $(gxdevice_h) $(gdevpccm_h) $(LIB_MAK) $(MAKEDIRS) + $(GLCC) $(GLO_)gdevpccm.$(OBJ) $(C_) $(GLSRC)gdevpccm.c + +-$(GLOBJ)ConvertUTF.$(OBJ) : $(GLSRC)ConvertUTF.c $(ConvertUTF_h) $(LIB_MAK) $(MAKEDIRS) +- $(GLCC) $(GLO_)ConvertUTF.$(OBJ) $(C_) $(GLSRC)ConvertUTF.c +- + ### Memory devices + + $(GLOBJ)gdevmem.$(OBJ) : $(GLSRC)gdevmem.c $(AK) $(gx_h) $(gserrors_h) \ +diff --git a/devices/devs.mak b/devices/devs.mak +index ea27ab0..51ec363 100644 +--- a/devices/devs.mak ++++ b/devices/devs.mak +@@ -835,9 +835,8 @@ pdfwrite5_=$(DEVOBJ)gdevpdfm.$(OBJ) + pdfwrite6_=$(DEVOBJ)gdevpdfo.$(OBJ) $(DEVOBJ)gdevpdfp.$(OBJ) $(DEVOBJ)gdevpdft.$(OBJ) + pdfwrite7_=$(DEVOBJ)gdevpdfr.$(OBJ) + pdfwrite8_=$(DEVOBJ)gdevpdfu.$(OBJ) $(DEVOBJ)gdevpdfv.$(OBJ) $(DEVOBJ)gdevagl.$(OBJ) +-pdfwrite9_= $(GLOBJ)ConvertUTF.$(OBJ) +-pdfwrite10_=$(DEVOBJ)gsflip.$(OBJ) +-pdfwrite11_=$(DEVOBJ)scantab.$(OBJ) $(DEVOBJ)sfilter2.$(OBJ) ++pdfwrite9_=$(DEVOBJ)gsflip.$(OBJ) ++pdfwrite10_=$(DEVOBJ)scantab.$(OBJ) $(DEVOBJ)sfilter2.$(OBJ) + pdfwrite_=$(pdfwrite1_) $(pdfwrite2_) $(pdfwrite3_) $(pdfwrite4_)\ + $(pdfwrite5_) $(pdfwrite6_) $(pdfwrite7_) $(pdfwrite8_) $(pdfwrite9_)\ + $(pdfwrite10_) $(pdfwrite11_) +diff --git a/devices/vector/gdevpdf.c b/devices/vector/gdevpdf.c +index 2b3186d..20e0ae8 100644 +--- a/devices/vector/gdevpdf.c ++++ b/devices/vector/gdevpdf.c +@@ -111,14 +111,13 @@ ENUM_PTRS_WITH(device_pdfwrite_enum_ptrs, gx_device_pdf *pdev) + ENUM_PTR(32, gx_device_pdf, pres_soft_mask_dict); + ENUM_PTR(33, gx_device_pdf, PDFXTrimBoxToMediaBoxOffset.data); + ENUM_PTR(34, gx_device_pdf, PDFXBleedBoxToTrimBoxOffset.data); +- ENUM_PTR(35, gx_device_pdf, DSCEncodingToUnicode.data); +- ENUM_PTR(36, gx_device_pdf, Identity_ToUnicode_CMaps[0]); +- ENUM_PTR(37, gx_device_pdf, Identity_ToUnicode_CMaps[1]); +- ENUM_PTR(38, gx_device_pdf, vgstack); +- ENUM_PTR(39, gx_device_pdf, outline_levels); +- ENUM_PTR(40, gx_device_pdf, EmbeddedFiles); +- ENUM_PTR(41, gx_device_pdf, pdf_font_dir); +- ENUM_PTR(42, gx_device_pdf, ExtensionMetadata); ++ ENUM_PTR(35, gx_device_pdf, Identity_ToUnicode_CMaps[0]); ++ ENUM_PTR(36, gx_device_pdf, Identity_ToUnicode_CMaps[1]); ++ ENUM_PTR(37, gx_device_pdf, vgstack); ++ ENUM_PTR(38, gx_device_pdf, outline_levels); ++ ENUM_PTR(39, gx_device_pdf, EmbeddedFiles); ++ ENUM_PTR(40, gx_device_pdf, pdf_font_dir); ++ ENUM_PTR(41, gx_device_pdf, ExtensionMetadata); + #define e1(i,elt) ENUM_PARAM_STRING_PTR(i + gx_device_pdf_num_ptrs, gx_device_pdf, elt); + gx_device_pdf_do_param_strings(e1) + #undef e1 +@@ -165,7 +164,6 @@ static RELOC_PTRS_WITH(device_pdfwrite_reloc_ptrs, gx_device_pdf *pdev) + RELOC_PTR(gx_device_pdf, pres_soft_mask_dict); + RELOC_PTR(gx_device_pdf, PDFXTrimBoxToMediaBoxOffset.data); + RELOC_PTR(gx_device_pdf, PDFXBleedBoxToTrimBoxOffset.data); +- RELOC_PTR(gx_device_pdf, DSCEncodingToUnicode.data); + RELOC_PTR(gx_device_pdf, Identity_ToUnicode_CMaps[0]); + RELOC_PTR(gx_device_pdf, Identity_ToUnicode_CMaps[1]); + RELOC_PTR(gx_device_pdf, vgstack); +diff --git a/devices/vector/gdevpdfb.h b/devices/vector/gdevpdfb.h +index 08f18c5..447f0f5 100644 +--- a/devices/vector/gdevpdfb.h ++++ b/devices/vector/gdevpdfb.h +@@ -141,7 +141,6 @@ const gx_device_pdf PDF_DEVICE_IDENT = + 12000, /* MaxClipPathSize */ /* HP LaserJet 1320 hangs with 14000. */ + 256000, /* MaxShadingBitmapSize */ + PDF_DEVICE_MaxInlineImageSize, /* MaxInlineImageSize */ +- {0, 0}, /* DSCEncodingToUnicode */ + {0, 0, 0}, /* OwnerPassword */ + {0, 0, 0}, /* UserPassword */ + 0, /* KeyLength */ +diff --git a/devices/vector/gdevpdfe.c b/devices/vector/gdevpdfe.c +index 1aa1f25..f23a02d 100644 +--- a/devices/vector/gdevpdfe.c ++++ b/devices/vector/gdevpdfe.c +@@ -26,7 +26,6 @@ + #include "gdevpdfx.h" + #include "gdevpdfg.h" + #include "gdevpdfo.h" +-#include "ConvertUTF.h" + + char PDFDocEncodingLookup [92] = { + 0x20, 0x22, 0x20, 0x20, 0x20, 0x21, 0x20, 0x26, +@@ -343,155 +342,162 @@ decode_escape(const byte *data, int data_length, int *index) + return c; /* A wrong escapement sequence. */ + } + +-static int +-pdf_xmp_write_translated(gx_device_pdf *pdev, stream *s, const byte *data, int data_length, +- void(*write)(stream *s, const byte *data, int data_length)) ++/* ++ * Once the bits are split out into bytes of UTF-8, this is a mask OR-ed ++ * into the first byte, depending on how many bytes follow. There are ++ * as many entries in this table as there are UTF-8 sequence types. ++ * (I.e., one byte sequence, two byte... etc.). Remember that sequencs ++ * for *legal* UTF-8 will be 4 or fewer bytes total. ++ */ ++static const char firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; ++ ++static int gs_ConvertUTF16(char *UTF16, int UTF16Len, unsigned char **UTF8Start, int UTF8Len) + { +- if (pdev->DSCEncodingToUnicode.data == 0) { +- int i, j=0; +- unsigned char *buf0; ++ int i, bytes = 0; ++ short U16; ++ unsigned char *UTF8 = *UTF8Start; ++ unsigned char *UTF8End = UTF8 + UTF8Len; + +- buf0 = (unsigned char *)gs_alloc_bytes(pdev->memory, data_length * sizeof(unsigned char), +- "pdf_xmp_write_translated"); +- if (buf0 == NULL) +- return_error(gs_error_VMerror); +- for (i = 0; i < data_length; i++) { +- byte c = data[i]; ++ if (fabs(UTF16Len % sizeof(short)) != 0) ++ return gs_note_error(gs_error_rangecheck); ++ ++ for (i=0;i= 0xD800 && U16 <= 0xDBFF) { ++ return gs_note_error(gs_error_rangecheck); + } +- if (buf0[0] != 0xfe || buf0[1] != 0xff) { +- unsigned char *buf1; +- /* We must assume that the information is PDFDocEncoding. In this case +- * we need to convert it into UTF-8. If we just convert it to UTF-16 +- * then we can safely fall through to the code below. +- */ +- /* NB the code below skips the BOM in positions 0 and 1, so we need +- * two extra bytes, to be ignored. +- */ +- buf1 = (unsigned char *)gs_alloc_bytes(pdev->memory, (j * sizeof(UTF16)) + 2, +- "pdf_xmp_write_translated"); +- if (buf1 == NULL) { +- gs_free_object(pdev->memory, buf0, "pdf_xmp_write_translated"); +- return_error(gs_error_VMerror); +- } +- memset(buf1, 0x00, (j * sizeof(UTF16)) + 2); +- for (i = 0; i < j; i++) { +- if (buf0[i] <= 0x7f || buf0[i] >= 0xAE) { +- if (buf0[i] == 0x7f) { +- emprintf1(pdev->memory, "PDFDocEncoding %x cannot be represented in Unicode\n", +- buf0[i]); +- } else +- buf1[(i * 2) + 3] = buf0[i]; ++ if (U16 >= 0xDC00 && U16 <= 0xDFFF) { ++ return gs_note_error(gs_error_rangecheck); ++ } ++ ++ if(U16 < 0x80) { ++ bytes = 1; ++ } else { ++ if (U16 < 0x800) { ++ bytes = 2; ++ } else { ++ if (U16 < 0x10000) { ++ bytes = 3; + } else { +- buf1[(i * 2) + 2] = PDFDocEncodingLookup[(buf0[i] - 0x80) * 2]; +- buf1[(i * 2) + 3] = PDFDocEncodingLookup[((buf0[i] - 0x80) * 2) + 1]; +- if (PDFDocEncodingLookup[((buf0[i] - 0x80) * 2) + 1] == 0x00) +- emprintf1(pdev->memory, "PDFDocEncoding %x cannot be represented in Unicode\n", +- PDFDocEncodingLookup[((buf0[i] - 0x80) * 2) + 1]); ++ if (U16 < 0x111000) { ++ bytes = 4; ++ } else { ++ bytes = 3; ++ U16 = 0xFFFD; ++ } + } + } ++ } ++ if (UTF8 + bytes > UTF8End) ++ return gs_note_error(gs_error_VMerror); ++ ++ /* Write from end to beginning, low bytes first */ ++ UTF8 += bytes; ++ ++ switch(bytes) { ++ case 4: ++ *--UTF8 = (unsigned char)((U16 | 0x80) & 0xBF); ++ U16 >>= 6; ++ case 3: ++ *--UTF8 = (unsigned char)((U16 | 0x80) & 0xBF); ++ U16 >>= 6; ++ case 2: ++ *--UTF8 = (unsigned char)((U16 | 0x80) & 0xBF); ++ U16 >>= 6; ++ case 1: ++ *--UTF8 = (unsigned char)(U16 | firstByteMark[bytes]); ++ break; ++ default: ++ return gs_note_error(gs_error_rangecheck); ++ } ++ ++ /* Move to start of next set */ ++ UTF8 += bytes; ++ } ++ *UTF8Start = UTF8; ++ return 0; ++} ++ ++static int ++pdf_xmp_write_translated(gx_device_pdf *pdev, stream *s, const byte *data, int data_length, ++ void(*write)(stream *s, const byte *data, int data_length)) ++{ ++ int i, j=0; ++ unsigned char *buf0; ++ ++ buf0 = (unsigned char *)gs_alloc_bytes(pdev->memory, data_length * sizeof(unsigned char), ++ "pdf_xmp_write_translated"); ++ if (buf0 == NULL) ++ return_error(gs_error_VMerror); ++ for (i = 0; i < data_length; i++) { ++ byte c = data[i]; ++ ++ if (c == '\\') ++ c = decode_escape(data, data_length, &i); ++ buf0[j] = c; ++ j++; ++ } ++ if (buf0[0] != 0xfe || buf0[1] != 0xff) { ++ unsigned char *buf1; ++ /* We must assume that the information is PDFDocEncoding. In this case ++ * we need to convert it into UTF-8. If we just convert it to UTF-16 ++ * then we can safely fall through to the code below. ++ */ ++ /* NB the code below skips the BOM in positions 0 and 1, so we need ++ * two extra bytes, to be ignored. ++ */ ++ buf1 = (unsigned char *)gs_alloc_bytes(pdev->memory, (j * sizeof(short)) + 2, ++ "pdf_xmp_write_translated"); ++ if (buf1 == NULL) { + gs_free_object(pdev->memory, buf0, "pdf_xmp_write_translated"); +- buf0 = buf1; +- data_length = j = (j * 2) + 2; ++ return_error(gs_error_VMerror); + } +- { +- /* Its a Unicode (UTF-16BE) string, convert to UTF-8 */ +- UTF16 *buf0b, U16; +- UTF8 *buf1, *buf1b; +- +- /* A single UTF-16 (2 bytes) can end up as 4 bytes in UTF-8 */ +- buf1 = (UTF8 *)gs_alloc_bytes(pdev->memory, data_length * 2 * sizeof(unsigned char), +- "pdf_xmp_write_translated"); +- if (buf1 == NULL) { +- gs_free_object(pdev->memory, buf0, "pdf_xmp_write_translated"); +- return_error(gs_error_VMerror); +- } +- buf1b = buf1; +- /* Skip the Byte Order Mark (0xfe 0xff) */ +- buf0b = (UTF16 *)(buf0 + 2); +- /* ConvertUTF16to UTF8 expects a buffer of UTF16s in the local +- * endian-ness, but the data is big-endian. In case this is a little-endian +- * machine, process the buffer from big-endian to whatever is right for this platform. +- */ +- for (i = 2; i < j; i+=2) { +- U16 = (buf0[i] << 8) + buf0[i + 1]; +- *(buf0b++) = U16; +- } +- buf0b = (UTF16 *)(buf0 + 2); +- switch (ConvertUTF16toUTF8((const UTF16**)&buf0b, (UTF16 *)(buf0 + j), +- &buf1b, buf1 + (data_length * 2 * sizeof(unsigned char)), strictConversion)) { +- case conversionOK: +- write(s, buf1, buf1b - buf1); +- gs_free_object(pdev->memory, buf1, "pdf_xmp_write_translated"); +- break; +- case sourceExhausted: +- case targetExhausted: +- case sourceIllegal: +- default: +- gs_free_object(pdev->memory, buf0, "pdf_xmp_write_translated"); +- gs_free_object(pdev->memory, buf1, "pdf_xmp_write_translated"); +- return_error(gs_error_rangecheck); ++ memset(buf1, 0x00, (j * sizeof(short)) + 2); ++ for (i = 0; i < j; i++) { ++ if (buf0[i] <= 0x7f || buf0[i] >= 0xAE) { ++ if (buf0[i] == 0x7f) { ++ emprintf1(pdev->memory, "PDFDocEncoding %x cannot be represented in Unicode\n", ++ buf0[i]); ++ } else ++ buf1[(i * 2) + 3] = buf0[i]; ++ } else { ++ buf1[(i * 2) + 2] = PDFDocEncodingLookup[(buf0[i] - 0x80) * 2]; ++ buf1[(i * 2) + 3] = PDFDocEncodingLookup[((buf0[i] - 0x80) * 2) + 1]; ++ if (PDFDocEncodingLookup[((buf0[i] - 0x80) * 2) + 1] == 0x00) ++ emprintf1(pdev->memory, "PDFDocEncoding %x cannot be represented in Unicode\n", ++ PDFDocEncodingLookup[((buf0[i] - 0x80) * 2) + 1]); + } + } + gs_free_object(pdev->memory, buf0, "pdf_xmp_write_translated"); +- return 0; +- } else { +- UTF16 *buf0; +- const UTF16 *buf0b; +- UTF8 *buf1, *buf1b; +- int i, j = 0; +- +- buf0 = (UTF16 *)gs_alloc_bytes(pdev->memory, data_length * sizeof(UTF16), +- "pdf_xmp_write_translated"); +- if (buf0 == NULL) +- return_error(gs_error_VMerror); +- buf1 = (UTF8 *)gs_alloc_bytes(pdev->memory, data_length * 2, +- "pdf_xmp_write_translated"); ++ buf0 = buf1; ++ data_length = j = (j * 2) + 2; ++ } ++ { ++ /* Its a Unicode (UTF-16BE) string, convert to UTF-8 */ ++ short *buf0b; ++ char *buf1, *buf1b; ++ int code; ++ ++ /* A single UTF-16 (2 bytes) can end up as 4 bytes in UTF-8 */ ++ buf1 = (char *)gs_alloc_bytes(pdev->memory, data_length * 2 * sizeof(unsigned char), ++ "pdf_xmp_write_translated"); + if (buf1 == NULL) { + gs_free_object(pdev->memory, buf0, "pdf_xmp_write_translated"); + return_error(gs_error_VMerror); + } +- buf0b = buf0; + buf1b = buf1; +- for (i = 0; i < data_length; i++) { +- byte c = data[i]; +- int v; +- +- if (c == '\\') +- c = decode_escape(data, data_length, &i); +- if (c > pdev->DSCEncodingToUnicode.size) { +- gs_free_object(pdev->memory, buf0, "pdf_xmp_write_translated"); +- gs_free_object(pdev->memory, buf1, "pdf_xmp_write_translated"); +- return_error(gs_error_rangecheck); +- } +- +- v = pdev->DSCEncodingToUnicode.data[c]; +- if (v == -1) +- v = '?'; /* Arbitrary. */ +- buf0[j] = v; +- j++; +- } +- switch (ConvertUTF16toUTF8(&buf0b, buf0 + j, +- &buf1b, buf1 + data_length * 2, strictConversion)) { +- case conversionOK: +- write(s, buf1, buf1b - buf1); +- break; +- case sourceExhausted: +- case targetExhausted: +- case sourceIllegal: +- default: +- gs_free_object(pdev->memory, buf0, "pdf_xmp_write_translated"); +- gs_free_object(pdev->memory, buf1, "pdf_xmp_write_translated"); +- return_error(gs_error_rangecheck); +- } +- gs_free_object(pdev->memory, buf0, "pdf_xmp_write_translated"); +- gs_free_object(pdev->memory, buf1, "pdf_xmp_write_translated"); +- return 0; ++ /* Skip the Byte Order Mark (0xfe 0xff) */ ++ buf0b = (short *)(buf0 + 2); ++ code = gs_ConvertUTF16((char *)buf0b, j - 2, (unsigned char **)&buf1b, data_length * 2 * sizeof(unsigned char)); ++ if (code < 0) ++ return code; ++ write(s, (const byte *)buf1, buf1b - buf1); + } ++ gs_free_object(pdev->memory, buf0, "pdf_xmp_write_translated"); ++ return 0; + } + + static int +diff --git a/devices/vector/gdevpdfp.c b/devices/vector/gdevpdfp.c +index 0fa07e3..6ebcb0d 100644 +--- a/devices/vector/gdevpdfp.c ++++ b/devices/vector/gdevpdfp.c +@@ -77,7 +77,6 @@ static const gs_param_item_t pdf_param_items[] = { + pi("CompressStreams", gs_param_type_bool, CompressStreams), + pi("PrintStatistics", gs_param_type_bool, PrintStatistics), + pi("MaxInlineImageSize", gs_param_type_long, MaxInlineImageSize), +- pi("DSCEncodingToUnicode", gs_param_type_int_array, DSCEncodingToUnicode), + + /* PDF Encryption */ + pi("OwnerPassword", gs_param_type_string, OwnerPassword), +diff --git a/devices/vector/gdevpdfx.h b/devices/vector/gdevpdfx.h +index 308900a..c436220 100644 +--- a/devices/vector/gdevpdfx.h ++++ b/devices/vector/gdevpdfx.h +@@ -601,7 +601,6 @@ struct gx_device_pdf_s { + a bitmap representation of a shading. + (Bigger shadings to be downsampled). */ + long MaxInlineImageSize; +- gs_param_int_array DSCEncodingToUnicode; + /* Encryption parameters */ + gs_param_string OwnerPassword; + gs_param_string UserPassword; +@@ -911,14 +910,14 @@ struct gx_device_pdf_s { + m(28,sbstack) m(29,substream_Resources) m(30,font3)\ + m(31,accumulating_substream_resource) \ + m(32,pres_soft_mask_dict) m(33,PDFXTrimBoxToMediaBoxOffset.data)\ +- m(34,PDFXBleedBoxToTrimBoxOffset.data) m(35, DSCEncodingToUnicode.data)\ +- m(36,Identity_ToUnicode_CMaps[0]) m(37,Identity_ToUnicode_CMaps[1])\ +- m(38,vgstack)\ +- m(39, outline_levels) +- m(40, gx_device_pdf, EmbeddedFiles); +- m(41, gx_device_pdf, pdf_font_dir); +- m(42, gx_device_pdf, Extension_Metadata);*/ +-#define gx_device_pdf_num_ptrs 43 ++ m(34,PDFXBleedBoxToTrimBoxOffset.data) ++ m(35,Identity_ToUnicode_CMaps[0]) m(36,Identity_ToUnicode_CMaps[1])\ ++ m(37,vgstack)\ ++ m(38, outline_levels) ++ m(39, gx_device_pdf, EmbeddedFiles); ++ m(40, gx_device_pdf, pdf_font_dir); ++ m(41, gx_device_pdf, Extension_Metadata);*/ ++#define gx_device_pdf_num_ptrs 42 + #define gx_device_pdf_do_param_strings(m)\ + m(0, OwnerPassword) m(1, UserPassword) m(2, NoEncrypt)\ + m(3, DocumentUUID) m(4, InstanceUUID) +diff --git a/windows/ghostscript.vcproj b/windows/ghostscript.vcproj +index a96d317..450cb26 100644 +--- a/windows/ghostscript.vcproj ++++ b/windows/ghostscript.vcproj +@@ -1794,10 +1794,6 @@ + > + + +- +- + +@@ -3330,10 +3326,6 @@ + > + + +- +- + +diff --git a/windows/ghostscript_rt.vcxproj b/windows/ghostscript_rt.vcxproj +index 2348f08..fae2e1f 100644 +--- a/windows/ghostscript_rt.vcxproj ++++ b/windows/ghostscript_rt.vcxproj +@@ -427,7 +427,6 @@ + + + +- + + + +@@ -1689,7 +1688,6 @@ + + + +- + + + +-- +2.9.3 \ No newline at end of file diff --git a/office/postscript/ghostscript/files/fedora/ghostscript-scripts.patch b/office/postscript/ghostscript/files/fedora/ghostscript-9.20-run-dvipdf-securely.patch similarity index 54% rename from office/postscript/ghostscript/files/fedora/ghostscript-scripts.patch rename to office/postscript/ghostscript/files/fedora/ghostscript-9.20-run-dvipdf-securely.patch index 2f050c26ab..9b010e31f2 100644 --- a/office/postscript/ghostscript/files/fedora/ghostscript-scripts.patch +++ b/office/postscript/ghostscript/files/fedora/ghostscript-9.20-run-dvipdf-securely.patch @@ -1,10 +1,21 @@ -diff -up ghostscript-9.00/lib/dvipdf.scripts ghostscript-9.00/lib/dvipdf ---- ghostscript-9.00/lib/dvipdf.scripts 2010-06-03 01:32:07.000000000 +0100 -+++ ghostscript-9.00/lib/dvipdf 2010-09-23 09:56:35.592796899 +0100 -@@ -44,4 +44,4 @@ fi +From 32d8df77bf3326f708c13d6913547c01ce6d728c Mon Sep 17 00:00:00 2001 +From: "David Kaspar [Dee'Kej]" +Date: Fri, 7 Oct 2016 13:57:01 +0200 +Subject: [PATCH] Make sure 'dvipdf' is being run securely + +--- + lib/dvipdf | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/dvipdf b/lib/dvipdf +index 802aeab..c92dfb0 100755 +--- a/lib/dvipdf ++++ b/lib/dvipdf +@@ -43,4 +43,4 @@ fi # We have to include the options twice because -I only takes effect if it # appears before other options. -exec dvips -Ppdf $DVIPSOPTIONS -q -f "$infile" | $GS_EXECUTABLE $OPTIONS -q -P- -dSAFER -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sstdout=%stderr -sOutputFile="$outfile" $OPTIONS -c .setpdfwrite - +exec dvips -R -Ppdf $DVIPSOPTIONS -q -f "$infile" | $GS_EXECUTABLE $OPTIONS -q -P- -dSAFER -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sstdout=%stderr -sOutputFile="$outfile" $OPTIONS -c .setpdfwrite - - +-- +2.7.4 \ No newline at end of file diff --git a/office/postscript/ghostscript/files/fedora/ghostscript-9.20-runlibfileifexists.patch b/office/postscript/ghostscript/files/fedora/ghostscript-9.20-runlibfileifexists.patch new file mode 100644 index 0000000000..7004bd71aa --- /dev/null +++ b/office/postscript/ghostscript/files/fedora/ghostscript-9.20-runlibfileifexists.patch @@ -0,0 +1,92 @@ +From ea8addd686889af76d70031998680196913243ec Mon Sep 17 00:00:00 2001 +From: "David Kaspar [Dee'Kej]" +Date: Fri, 7 Oct 2016 12:20:29 +0200 +Subject: [PATCH 1/2] Fix error when using ImageMagick's convert: + + Error: /undefined in .runlibfileexists +--- + Resource/Init/gs_fonts.ps | 15 ++++++++++++--- + Resource/Init/gs_init.ps | 9 +++++++++ + 2 files changed, 21 insertions(+), 3 deletions(-) + +diff --git a/Resource/Init/gs_fonts.ps b/Resource/Init/gs_fonts.ps +index a3da615..77814b8 100644 +--- a/Resource/Init/gs_fonts.ps ++++ b/Resource/Init/gs_fonts.ps +@@ -96,10 +96,19 @@ userdict /.nativeFontmap .FontDirectory maxlength dict put + % stack: dict file fontname filename|aliasname + 1 index type /stringtype eq + 1 index type /nametype eq and 1 index xcheck and +- 1 index /run eq 2 index /.runlibfile eq or and { ++ 1 index /run eq 2 index /.runlibfile eq 3 index /.runlibfileifexists eq or or and { + % This is an inclusion entry. +- pop findlibfile { exch pop } { file } ifelse +- 2 index exch .readFontmap pop ++ 0 index /.runlibfileifexists eq { ++ pop findlibfile { ++ exch pop ++ 2 index exch .readFontmap pop ++ } { ++ pop ++ } ifelse ++ } { ++ pop findlibfile { exch pop } { file } ifelse ++ 2 index exch .readFontmap pop ++ } ifelse + } { + % This is a real entry. + % Read and pop tokens until a semicolon. +diff --git a/Resource/Init/gs_init.ps b/Resource/Init/gs_init.ps +index ab7cfed..f9e035b 100644 +--- a/Resource/Init/gs_init.ps ++++ b/Resource/Init/gs_init.ps +@@ -689,6 +689,14 @@ systemdict /internaldict dup .makeinternaldict .makeoperator + { /undefinedfilename signalerror } + ifelse + } bind def ++/runlibfileifexists ++ { % We don't want to bind 'run' into this procedure, ++ % since run may get redefined. ++ findlibfile ++ { exch pop /run .systemvar exec } ++ { pop } ++ ifelse ++ } bind def + /selectdevice + { finddevice setdevice .setdefaultscreen } bind def + /signalerror % signalerror - +@@ -857,6 +865,7 @@ userdict /.currentresourcefile //null put + } bind def + % Temporarily substitute it for the real runlibfile. + /.runlibfile /runlibfile load def ++/.runlibfileifexists /runlibfileifexists load def + /runlibfile /runlibfile0 load def + + % Create the error handling machinery. +-- +2.7.4 + + +From 9878f41a229c67aba2e62ee7ab22ff37c2e5a04f Mon Sep 17 00:00:00 2001 +From: "David Kaspar [Dee'Kej]" +Date: Fri, 7 Oct 2016 12:57:06 +0200 +Subject: [PATCH 2/2] Make sure customizations to + /etc/ghostscript/Fontmap.local are used + + For more info, see: https://bugzilla.redhat.com/show_bug.cgi?id=610301 +--- + Resource/Init/Fontmap | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/Resource/Init/Fontmap b/Resource/Init/Fontmap +index ae5af96..72aeb1f 100644 +--- a/Resource/Init/Fontmap ++++ b/Resource/Init/Fontmap +@@ -2,3 +2,5 @@ + % See Fontmap.GS for the syntax of real Fontmap files. + %% Replace 1 (Fontmap.GS) + (Fontmap.GS) .runlibfile ++% must be at the bottom of line to allow people overriding everything. ++(Fontmap.local) .runlibfileifexists +-- +2.7.4 \ No newline at end of file diff --git a/office/postscript/ghostscript/files/fedora/ghostscript-9.20-urw-fonts-naming.patch b/office/postscript/ghostscript/files/fedora/ghostscript-9.20-urw-fonts-naming.patch new file mode 100644 index 0000000000..11a5d51b85 --- /dev/null +++ b/office/postscript/ghostscript/files/fedora/ghostscript-9.20-urw-fonts-naming.patch @@ -0,0 +1,100 @@ +From 54572e8cf529eeb6a01234341d01a2fd555204e6 Mon Sep 17 00:00:00 2001 +From: "David Kaspar [Dee'Kej]" +Date: Fri, 7 Oct 2016 13:38:13 +0200 +Subject: [PATCH] Use old names of urw-fonts + +--- + Resource/Init/Fontmap.GS | 78 ++++++++++++++++++++++++++---------------------- + 1 file changed, 43 insertions(+), 35 deletions(-) + +diff --git a/Resource/Init/Fontmap.GS b/Resource/Init/Fontmap.GS +index a9fa335..949c152 100644 +--- a/Resource/Init/Fontmap.GS ++++ b/Resource/Init/Fontmap.GS +@@ -81,41 +81,49 @@ + + % Aliases + +-/AvantGarde-BookOblique /URWGothic-BookOblique ; +-/AvantGarde-Book /URWGothic-Book ; +-/AvantGarde-DemiOblique /URWGothic-DemiOblique ; +-/AvantGarde-Demi /URWGothic-Demi ; +-/Bookman-DemiItalic /URWBookman-DemiItalic ; +-/Bookman-Demi /URWBookman-Demi ; +-/Bookman-LightItalic /URWBookman-LightItalic ; +-/Bookman-Light /URWBookman-Light ; +-/Courier-Bold /NimbusMonoPS-Bold ; +-/Courier-BoldOblique /NimbusMonoPS-BoldItalic ; +-/Courier /NimbusMonoPS-Regular ; +-/Courier-Oblique /NimbusMonoPS-Italic ; +-/Helvetica-Bold /NimbusSans-Bold ; +-/Helvetica-BoldOblique /NimbusSans-BoldOblique ; +-/Helvetica-Narrow-Bold /NimbusSansNarrow-Bold ; +-/Helvetica-Narrow-BoldOblique /NimbusSansNarrow-BdOblique ; +-/Helvetica-Narrow /NimbusSansNarrow-Regular ; +-/Helvetica-Narrow-Oblique /NimbusSansNarrow-Oblique ; +-/Helvetica /NimbusSans-Regular ; +-/Helvetica-Oblique /NimbusSans-Oblique ; +-/NewCenturySchlbk-Bold /C059-Bold ; +-/NewCenturySchlbk-BoldItalic /C059-BdIta ; +-/NewCenturySchlbk-Italic /C059-Italic ; +-/NewCenturySchlbk-Roman /C059-Roman ; +-/Palatino-BoldItalic /P052-BoldItalic ; +-/Palatino-Bold /P052-Bold ; +-/Palatino-Italic /P052-Italic ; +-/Palatino-Roman /P052-Roman ; +-/Symbol /StandardSymbolsPS ; +-/Times-BoldItalic /NimbusRoman-BoldItalic ; +-/Times-Bold /NimbusRoman-Bold ; +-/Times-Italic /NimbusRoman-Italic ; +-/Times-Roman /NimbusRoman-Regular ; +-/ZapfChancery-MediumItalic /Z003-MediumItalic ; +-/ZapfDingbats /D050000L ; ++/AvantGarde-BookOblique /URWGothicL-BookObli ; ++/AvantGarde-Book /URWGothicL-Book ; ++/AvantGarde-DemiOblique /URWGothicL-DemiObli ; ++/AvantGarde-Demi /URWGothicL-Demi ; ++ ++/Bookman-DemiItalic /URWBookmanL-DemiBoldItal ; ++/Bookman-Demi /URWBookmanL-DemiBold ; ++/Bookman-LightItalic /URWBookmanL-LighItal ; ++/Bookman-Light /URWBookmanL-Ligh ; ++ ++/Courier-Bold /NimbusMonL-Bold ; ++/Courier-BoldOblique /NimbusMonL-BoldObli ; ++/Courier /NimbusMonL-Regu ; ++/Courier-Oblique /NimbusMonL-ReguObli ; ++ ++/Helvetica-Bold /NimbusSanL-Bold ; ++/Helvetica-BoldOblique /NimbusSanL-BoldItal ; ++/Helvetica-Narrow-Bold /NimbusSanL-BoldCond ; ++/Helvetica-Narrow-BoldOblique /NimbusSanL-BoldCondItal ; ++/Helvetica-Narrow /NimbusSanL-ReguCond ; ++/Helvetica-Narrow-Oblique /NimbusSanL-ReguCondItal ; ++/Helvetica /NimbusSanL-Regu ; ++/Helvetica-Oblique /NimbusSanL-ReguItal ; ++ ++/NewCenturySchlbk-Bold /CenturySchL-Bold ; ++/NewCenturySchlbk-BoldItalic /CenturySchL-BoldItal ; ++/NewCenturySchlbk-Italic /CenturySchL-Ital ; ++/NewCenturySchlbk-Roman /CenturySchL-Roma ; ++ ++/Palatino-Roman /URWPalladioL-Roma ; ++/Palatino-Italic /URWPalladioL-Ital ; ++/Palatino-Bold /URWPalladioL-Bold ; ++/Palatino-BoldItalic /URWPalladioL-BoldItal ; ++ ++/Symbol /StandardSymL ; ++ ++/Times-BoldItalic /NimbusRomNo9L-MediItal ; ++/Times-Bold /NimbusRomNo9L-Medi ; ++/Times-Italic /NimbusRomNo9L-ReguItal ; ++/Times-Roman /NimbusRomNo9L-Regu ; ++ ++/ZapfChancery-MediumItalic /URWChanceryL-MediItal ; ++/ZapfDingbats /Dingbats ; + + % + % +-- +2.7.4 diff --git a/office/postscript/ghostscript/files/fedora/ghostscript-Fontmap.local.patch b/office/postscript/ghostscript/files/fedora/ghostscript-Fontmap.local.patch deleted file mode 100644 index 3d1fee2560..0000000000 --- a/office/postscript/ghostscript/files/fedora/ghostscript-Fontmap.local.patch +++ /dev/null @@ -1,9 +0,0 @@ -diff -up ghostscript-8.71/Resource/Init/Fontmap.Fontmap.local ghostscript-8.71/Resource/Init/Fontmap ---- ghostscript-8.71/Resource/Init/Fontmap.Fontmap.local 2008-08-08 05:22:38.000000000 +0100 -+++ ghostscript-8.71/Resource/Init/Fontmap 2010-09-03 11:53:47.273865979 +0100 -@@ -2,3 +2,5 @@ - % See Fontmap.GS for the syntax of real Fontmap files. - %% Replace 1 (Fontmap.GS) - (Fontmap.GS) .runlibfile -+% must be at the bottom of line to allow people overriding everything. -+(Fontmap.local) .runlibfileifexists diff --git a/office/postscript/ghostscript/files/fedora/ghostscript-gdevcups-debug-uninit.patch b/office/postscript/ghostscript/files/fedora/ghostscript-gdevcups-debug-uninit.patch deleted file mode 100644 index 9122d1fc95..0000000000 --- a/office/postscript/ghostscript/files/fedora/ghostscript-gdevcups-debug-uninit.patch +++ /dev/null @@ -1,11 +0,0 @@ -diff -up ghostscript-9.07/cups/gdevcups.c.gdevcups-debug-uninit ghostscript-9.07/cups/gdevcups.c ---- ghostscript-9.07/cups/gdevcups.c.gdevcups-debug-uninit 2013-02-14 07:58:16.000000000 +0000 -+++ ghostscript-9.07/cups/gdevcups.c 2013-02-14 17:16:59.677951232 +0000 -@@ -830,6 +830,7 @@ cups_get_matrix(gx_device *pdev, /* I - - dmprintf4(pdev->memory, "DEBUG2: PageSize = [ %d %d ], HWResolution = [ %d %d ]\n", - cups->header.PageSize[0], cups->header.PageSize[1], - cups->header.HWResolution[0], cups->header.HWResolution[1]); -+ if (size_set) - dmprintf4(pdev->memory, "DEBUG2: HWMargins = [ %.3f %.3f %.3f %.3f ]\n", - pdev->HWMargins[0], pdev->HWMargins[1], pdev->HWMargins[2], - pdev->HWMargins[3]); diff --git a/office/postscript/ghostscript/files/fedora/ghostscript-gs694154.patch b/office/postscript/ghostscript/files/fedora/ghostscript-gs694154.patch deleted file mode 100644 index 248aebbbe7..0000000000 --- a/office/postscript/ghostscript/files/fedora/ghostscript-gs694154.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -up ghostscript-9.12/base/gsicc.c.gs694154 ghostscript-9.12/base/gsicc.c ---- ghostscript-9.12/base/gsicc.c.gs694154 2014-03-25 08:52:16.000000000 +0000 -+++ ghostscript-9.12/base/gsicc.c 2014-03-26 11:32:31.406034840 +0000 -@@ -468,6 +468,8 @@ gx_remap_ICC_imagelab(const gs_client_co - cmm_dev_profile_t *dev_profile; - - code = dev_proc(dev, get_profile)(dev, &dev_profile); -+ if (dev_profile == NULL) -+ return gs_throw(gs_error_Fatal, "Attempting to do ICC remap with no profile"); - num_des_comps = gsicc_get_device_profile_comps(dev_profile); - rendering_params.black_point_comp = pis->blackptcomp; - rendering_params.graphics_type_tag = dev->graphics_type_tag; diff --git a/office/postscript/ghostscript/files/fedora/ghostscript-icc-missing-check.patch b/office/postscript/ghostscript/files/fedora/ghostscript-icc-missing-check.patch deleted file mode 100644 index 9b9109ae37..0000000000 --- a/office/postscript/ghostscript/files/fedora/ghostscript-icc-missing-check.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -up ghostscript-9.12/base/gsicc_manage.c.icc-missing-check ghostscript-9.12/base/gsicc_manage.c ---- ghostscript-9.12/base/gsicc_manage.c.icc-missing-check 2014-03-26 11:31:11.296570797 +0000 -+++ ghostscript-9.12/base/gsicc_manage.c 2014-03-26 11:32:10.384912584 +0000 -@@ -613,6 +613,8 @@ gsicc_set_srcgtag_struct(gsicc_manager_t - icc_profile = - gsicc_profile_new(str, mem, curr_ptr, strlen(curr_ptr)); - code = sfclose(str); -+ } -+ if (str != NULL && icc_profile != NULL) { - gsicc_init_profile_info(icc_profile); - cmm = gsCMM_DEFAULT; - /* Check if this object is a devicelink profile. diff --git a/office/postscript/ghostscript/files/fedora/ghostscript-iccprofiles-initdir.patch b/office/postscript/ghostscript/files/fedora/ghostscript-iccprofiles-initdir.patch deleted file mode 100644 index b47511ced6..0000000000 --- a/office/postscript/ghostscript/files/fedora/ghostscript-iccprofiles-initdir.patch +++ /dev/null @@ -1,35 +0,0 @@ -diff -up ghostscript-9.06/base/gsicc_manage.c.iccprofiles-initdir ghostscript-9.06/base/gsicc_manage.c ---- ghostscript-9.06/base/gsicc_manage.c.iccprofiles-initdir 2012-08-09 13:58:22.102364807 +0100 -+++ ghostscript-9.06/base/gsicc_manage.c 2012-08-09 14:09:24.495864641 +0100 -@@ -38,6 +38,7 @@ - #include "gsicc_create.h" - #include "gpmisc.h" - #include "gxdevice.h" -+#include "gxiodev.h" - - #define ICC_HEADER_SIZE 128 - -@@ -2176,8 +2177,21 @@ gs_currenticcdirectory(const gs_state * - const gs_lib_ctx_t *lib_ctx = pgs->memory->gs_lib_ctx; - - if (lib_ctx->profiledir == NULL) { -- pval->data = (const byte *)rfs; -- pval->size = strlen(rfs); -+ int have_rom_device = 0; -+ int i; -+ -+ for (i = 0; i < gx_io_device_table_count; i++) { -+ const gx_io_device *iodev = lib_ctx->io_device_table[i]; -+ const char *dname = iodev->dname; -+ -+ if (dname && strlen(dname) == 5 && !memcmp("%rom%", dname, 5)) { -+ have_rom_device = 1; -+ break; -+ } -+ } -+ -+ pval->data = (const byte *)(have_rom_device ? rfs : ""); -+ pval->size = strlen((const char *)pval->data); - pval->persistent = true; - } else { - pval->data = (const byte *)(lib_ctx->profiledir); diff --git a/office/postscript/ghostscript/files/fedora/ghostscript-multilib.patch b/office/postscript/ghostscript/files/fedora/ghostscript-multilib.patch deleted file mode 100644 index 27bf5e663a..0000000000 --- a/office/postscript/ghostscript/files/fedora/ghostscript-multilib.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff -up ghostscript-8.61/ijs/Makefile.am.multilib ghostscript-8.61/ijs/Makefile.am -diff -up ghostscript-8.61/ijs/ijs-config.in.multilib ghostscript-8.61/ijs/ijs-config.in ---- ghostscript-8.61/ijs/ijs-config.in.multilib 2002-01-31 19:09:46.000000000 +0000 -+++ ghostscript-8.61/ijs/ijs-config.in 2007-11-23 09:19:18.000000000 +0000 -@@ -43,8 +43,7 @@ while test $# -gt 0; do - echo $includes - ;; - --libs) -- libdirs=-L@libdir@ -- echo $libdirs -lijs -+ echo -lijs - ;; - *) - echo "${usage}" 1>&2 diff --git a/office/postscript/ghostscript/files/fedora/ghostscript-noopt.patch b/office/postscript/ghostscript/files/fedora/ghostscript-noopt.patch deleted file mode 100644 index 589cf822b5..0000000000 --- a/office/postscript/ghostscript/files/fedora/ghostscript-noopt.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -up ghostscript-8.64/psi/int.mak.noopt ghostscript-8.64/psi/int.mak ---- ghostscript-8.64/psi/int.mak.noopt 2008-12-26 07:25:31.000000000 +0000 -+++ ghostscript-8.64/psi/int.mak 2009-02-04 11:33:48.000000000 +0000 -@@ -111,7 +111,7 @@ $(PSOBJ)igc.$(OBJ) : $(PSSRC)igc.c $(GH) - $(PSOBJ)igcref.$(OBJ) : $(PSSRC)igcref.c $(GH) $(memory__h)\ - $(gsexit_h) $(gsstruct_h)\ - $(iastate_h) $(idebug_h) $(igc_h) $(iname_h) $(ipacked_h) $(store_h) -- $(PSCC) $(PSO_)igcref.$(OBJ) $(C_) $(PSSRC)igcref.c -+ $(PSCC) -O0 $(PSO_)igcref.$(OBJ) $(C_) $(PSSRC)igcref.c - - $(PSOBJ)igcstr.$(OBJ) : $(PSSRC)igcstr.c $(GH) $(memory__h)\ - $(gsmdebug_h) $(gsstruct_h) $(iastate_h) $(igcstr_h) diff --git a/office/postscript/ghostscript/files/fedora/ghostscript-runlibfileifexists.patch b/office/postscript/ghostscript/files/fedora/ghostscript-runlibfileifexists.patch deleted file mode 100644 index 03b731c5d3..0000000000 --- a/office/postscript/ghostscript/files/fedora/ghostscript-runlibfileifexists.patch +++ /dev/null @@ -1,52 +0,0 @@ -diff -up ghostscript-9.12/Resource/Init/gs_fonts.ps.runlibfileifexists ghostscript-9.12/Resource/Init/gs_fonts.ps ---- ghostscript-9.12/Resource/Init/gs_fonts.ps.runlibfileifexists 2014-03-25 08:52:16.000000000 +0000 -+++ ghostscript-9.12/Resource/Init/gs_fonts.ps 2014-03-26 12:01:48.248748767 +0000 -@@ -95,10 +95,19 @@ userdict /Fontmap .FontDirectory maxleng - % stack: dict file fontname filename|aliasname - 1 index type /stringtype eq - 1 index type /nametype eq and 1 index xcheck and -- 1 index /run eq 2 index /.runlibfile eq or and { -+ 1 index /run eq 2 index /.runlibfile eq 3 index /.runlibfileifexists eq or or and { - % This is an inclusion entry. -- pop findlibfile { exch pop } { file } ifelse -- 2 index exch .readFontmap pop -+ 0 index /.runlibfileifexists eq { -+ pop findlibfile { -+ exch pop -+ 2 index exch .readFontmap pop -+ } { -+ pop -+ } ifelse -+ } { -+ pop findlibfile { exch pop } { file } ifelse -+ 2 index exch .readFontmap pop -+ } ifelse - } { - % This is a real entry. - % Read and pop tokens until a semicolon. -diff -up ghostscript-9.12/Resource/Init/gs_init.ps.runlibfileifexists ghostscript-9.12/Resource/Init/gs_init.ps ---- ghostscript-9.12/Resource/Init/gs_init.ps.runlibfileifexists 2014-03-25 08:52:16.000000000 +0000 -+++ ghostscript-9.12/Resource/Init/gs_init.ps 2014-03-26 12:01:48.248748767 +0000 -@@ -681,6 +681,14 @@ systemdict /internaldict dup .makeintern - { /undefinedfilename signalerror } - ifelse - } bind def -+/runlibfileifexists -+ { % We don't want to bind 'run' into this procedure, -+ % since run may get redefined. -+ findlibfile -+ { exch pop /run .systemvar exec } -+ { pop } -+ ifelse -+ } bind def - /selectdevice - { finddevice setdevice .setdefaultscreen } bind def - /signalerror % signalerror - -@@ -849,6 +857,7 @@ userdict /.currentresourcefile //null pu - } bind def - % Temporarily substitute it for the real runlibfile. - /.runlibfile /runlibfile load def -+/.runlibfileifexists /runlibfileifexists load def - /runlibfile /runlibfile0 load def - - % Create the error handling machinery. diff --git a/office/postscript/ghostscript/files/fedora/ghostscript-wrf-snprintf.patch b/office/postscript/ghostscript/files/fedora/ghostscript-wrf-snprintf.patch deleted file mode 100644 index 74d8c2a5c6..0000000000 --- a/office/postscript/ghostscript/files/fedora/ghostscript-wrf-snprintf.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff -up ghostscript-9.07/base/wrfont.c.wrf-snprintf ghostscript-9.07/base/wrfont.c ---- ghostscript-9.07/base/wrfont.c.wrf-snprintf 2013-07-01 13:02:33.373244683 +0100 -+++ ghostscript-9.07/base/wrfont.c 2013-07-01 13:04:55.022864299 +0100 -@@ -72,7 +72,8 @@ WRF_wfloat(WRF_output * a_output, double - { - char buffer[32]; - -- gs_sprintf(buffer, "%f", a_float); -+ if (gs_snprintf(buffer, sizeof (buffer), "%f", a_float) >= sizeof (buffer)) -+ abort(); - WRF_wstring(a_output, buffer); - } - -@@ -81,6 +82,7 @@ WRF_wint(WRF_output * a_output, long a_i - { - char buffer[32]; - -- gs_sprintf(buffer, "%ld", a_int); -+ if (gs_snprintf(buffer, sizeof (buffer), "%ld", a_int) >= sizeof (buffer)) -+ abort(); - WRF_wstring(a_output, buffer); - } diff --git a/office/postscript/ghostscript/pspec.xml b/office/postscript/ghostscript/pspec.xml index 862c708365..e89cb23178 100644 --- a/office/postscript/ghostscript/pspec.xml +++ b/office/postscript/ghostscript/pspec.xml @@ -12,7 +12,7 @@ library A PostScript interpreter and renderer ghostscript is a set of software that provides a PostScript interpreter, a set of C procedures and an interpreter for PDF files. ghostscript is normally used to display PostScript files and to print PostScript files to non-PostScript printers. - https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs919/ghostscript-9.19.tar.gz + https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs920/ghostscript-9.20.tar.xz tiff-devel zlib-devel @@ -21,27 +21,26 @@ libSM-devel freetype-devel libjpeg-turbo-devel - lcms2-devel + lcms2-devel libXt-devel libpng-devel libpaper-devel fontconfig-devel - - - - fedora/ghostscript-sys-zlib.patch - + fedora/ghostscript-9.20-cve-2016-7976.patch + fedora/ghostscript-9.20-cve-2016-7977.patch + fedora/ghostscript-9.20-cve-2016-7978.patch + fedora/ghostscript-9.20-cve-2016-7979.patch + fedora/ghostscript-9.20-cve-2016-8602.patch + fedora/ghostscript-9.20-cve-2016-9601.patch + fedora/ghostscript-9.20-fix-openjpeg-system-build.patch + fedora/ghostscript-9.20-handle-glyphdirectory-correctly.patch + fedora/ghostscript-9.20-remove-and-reimplement-ConvertUTF.patch + fedora/ghostscript-9.20-run-dvipdf-securely.patch + fedora/ghostscript-9.20-runlibfileifexists.patch + fedora/ghostscript-9.20-urw-fonts-naming.patch @@ -54,7 +53,7 @@ freetype libjpeg-turbo tiff - lcms2 + lcms2 libXt libpaper fontconfig @@ -137,6 +136,13 @@ + + 2017-02-05 + 9.20 + Version Bump + Pisi Linux Community + admin@pisilinux.org + 2016-06-09 9.19 diff --git a/office/postscript/poppler-data/pspec.xml b/office/postscript/poppler-data/pspec.xml index 245dc7f1c0..078738b0cb 100644 --- a/office/postscript/poppler-data/pspec.xml +++ b/office/postscript/poppler-data/pspec.xml @@ -26,6 +26,13 @@ + + 2017-02-05 + 0.4.7 + Rebuild. + Pisi Linux Community + admin@pisilinux.org + 2016-06-09 0.4.7 diff --git a/programming/build/llvm/actions.py b/programming/build/llvm/actions.py index ba3da80aa2..f55f71a40a 100644 --- a/programming/build/llvm/actions.py +++ b/programming/build/llvm/actions.py @@ -34,6 +34,8 @@ def setup(): shelltools.export("CC", "gcc") shelltools.export("CXX", "g++") + shelltools.system("patch -Np0 -d projects/compiler-rt < msan-prevent-initialization-failure-with-newer-glibc.patch") + shelltools.system("patch -Rp1 -i AMDGPU-Fix-an-interaction-between-WQM-and-polygon-stippling.patch") if get.buildTYPE() == "emul32": shelltools.export("CC", "gcc -m32") @@ -63,14 +65,17 @@ def setup(): cmaketools.configure("-DCMAKE_BUILD_TYPE=Release \ %s \ - -DCMAKE_INSTALL_PREFIX=/usr \ - -DLLVM_ENABLE_FFI=ON \ - -DCMAKE_BUILD_TYPE=Release \ - -DLLVM_BUILD_LLVM_DYLIB=ON \ - -DLLDB_DISABLE_LIBEDIT=1 \ - -DLLVM_INCLUDEDIR=/usr/include \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DLLVM_BUILD_LLVM_DYLIB=ON \ + -DLLVM_LINK_LLVM_DYLIB=ON \ + -DLLVM_INSTALL_UTILS=ON \ + -DLLVM_ENABLE_RTTI=ON \ + -DLLVM_ENABLE_FFI=ON \ + -DLLDB_DISABLE_LIBEDIT=1 \ + -DLLVM_INCLUDEDIR=/usr/include \ -DFFI_INCLUDE_DIR=/usr/lib/libffi-3.2.1/include \ - -DLLVM_TARGETS_TO_BUILD='host;AMDGPU'" % options, sourceDir=".." ) + -DLLVM_BINUTILS_INCDIR=/usr/include" % options, sourceDir=".." ) def build(): shelltools.makedirs("build") @@ -86,10 +91,10 @@ def install(): if get.buildTYPE() == "emul32": - pisitools.domove("/emul32/lib32/", "/usr/") - pisitools.insinto("/usr/include/llvm/Config/","%s/emul32/include/llvm/Config/llvm-config.h" % get.installDIR(),"llvm-config-32.h") - pisitools.insinto("/usr/bin/","%s/emul32/bin/llvm-config" % get.installDIR(),"llvm-config-32") - pisitools.removeDir("/emul32") + #pisitools.domove("/emul32/lib32/", "/usr/") + pisitools.insinto("/usr/include/llvm/Config/","%s/usr/include/llvm/Config/llvm-config.h" % get.installDIR(),"llvm-config-32.h") + pisitools.insinto("/usr/bin/","%s/usr/bin/llvm-config" % get.installDIR(),"llvm-config-32") + #pisitools.removeDir("/emul32") shelltools.cd ("..") diff --git a/programming/build/llvm/files/AMDGPU-Fix-an-interaction-between-WQM-and-polygon-stippling.patch b/programming/build/llvm/files/AMDGPU-Fix-an-interaction-between-WQM-and-polygon-stippling.patch new file mode 100644 index 0000000000..f23b916828 --- /dev/null +++ b/programming/build/llvm/files/AMDGPU-Fix-an-interaction-between-WQM-and-polygon-stippling.patch @@ -0,0 +1,140 @@ +From 25e2616626caafb896517e18cd8aa724fba2b200 Mon Sep 17 00:00:00 2001 +From: Tom Stellard +Date: Tue, 29 Nov 2016 03:41:28 +0000 +Subject: [PATCH] Merging r280589: + +------------------------------------------------------------------------ +r280589 | nhaehnle | 2016-09-03 05:26:32 -0700 (Sat, 03 Sep 2016) | 19 lines + +AMDGPU: Fix an interaction between WQM and polygon stippling + +Summary: +This fixes a rare bug in polygon stippling with non-monolithic pixel shaders. + +The underlying problem is as follows: the prolog part contains the polygon +stippling sequence, i.e. a kill. The main part then enables WQM based on the +_reduced_ exec mask, effectively undoing most of the polygon stippling. + +Since we cannot know whether polygon stippling will be used, the main part +of a non-monolithic shader must always return to exact mode to fix this +problem. + +Reviewers: arsenm, tstellarAMD, mareko + +Subscribers: arsenm, llvm-commits, kzhuravl + +Differential Revision: https://reviews.llvm.org/D23131 + +------------------------------------------------------------------------ + +git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_39@288105 91177308-0d34-0410-b5e6-96231b3b80d8 +--- + lib/Target/AMDGPU/SIInstructions.td | 1 + + lib/Target/AMDGPU/SIWholeQuadMode.cpp | 7 ----- + test/CodeGen/AMDGPU/wqm.ll | 49 ++++++++++++++++++++++++++++++++--- + 3 files changed, 46 insertions(+), 11 deletions(-) + +diff --git a/lib/Target/AMDGPU/SIInstructions.td b/lib/Target/AMDGPU/SIInstructions.td +index 18b7d5d..dde5f2f 100644 +--- a/lib/Target/AMDGPU/SIInstructions.td ++++ b/lib/Target/AMDGPU/SIInstructions.td +@@ -2029,6 +2029,7 @@ def SI_RETURN : PseudoInstSI < + let hasSideEffects = 1; + let SALU = 1; + let hasNoSchedulingInfo = 1; ++ let DisableWQM = 1; + } + + let Uses = [EXEC], Defs = [EXEC, VCC, M0], +diff --git a/lib/Target/AMDGPU/SIWholeQuadMode.cpp b/lib/Target/AMDGPU/SIWholeQuadMode.cpp +index b200c15..1534d58 100644 +--- a/lib/Target/AMDGPU/SIWholeQuadMode.cpp ++++ b/lib/Target/AMDGPU/SIWholeQuadMode.cpp +@@ -219,13 +219,6 @@ char SIWholeQuadMode::scanInstructions(MachineFunction &MF, + markInstruction(MI, Flags, Worklist); + GlobalFlags |= Flags; + } +- +- if (WQMOutputs && MBB.succ_empty()) { +- // This is a prolog shader. Make sure we go back to exact mode at the end. +- Blocks[&MBB].OutNeeds = StateExact; +- Worklist.push_back(&MBB); +- GlobalFlags |= StateExact; +- } + } + + return GlobalFlags; +diff --git a/test/CodeGen/AMDGPU/wqm.ll b/test/CodeGen/AMDGPU/wqm.ll +index 809a7ba..41e4264 100644 +--- a/test/CodeGen/AMDGPU/wqm.ll ++++ b/test/CodeGen/AMDGPU/wqm.ll +@@ -17,17 +17,18 @@ main_body: + ;CHECK-LABEL: {{^}}test2: + ;CHECK-NEXT: ; %main_body + ;CHECK-NEXT: s_wqm_b64 exec, exec +-;CHECK: image_sample + ;CHECK-NOT: exec +-;CHECK: _load_dword v0, +-define amdgpu_ps float @test2(<8 x i32> inreg %rsrc, <4 x i32> inreg %sampler, float addrspace(1)* inreg %ptr, <4 x i32> %c) { ++define amdgpu_ps void @test2(<8 x i32> inreg %rsrc, <4 x i32> inreg %sampler, float addrspace(1)* inreg %ptr, <4 x i32> %c) { + main_body: + %c.1 = call <4 x float> @llvm.SI.image.sample.v4i32(<4 x i32> %c, <8 x i32> %rsrc, <4 x i32> %sampler, i32 15, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0) + %c.2 = bitcast <4 x float> %c.1 to <4 x i32> + %c.3 = extractelement <4 x i32> %c.2, i32 0 + %gep = getelementptr float, float addrspace(1)* %ptr, i32 %c.3 + %data = load float, float addrspace(1)* %gep +- ret float %data ++ ++ call void @llvm.SI.export(i32 15, i32 1, i32 1, i32 0, i32 1, float %data, float undef, float undef, float undef) ++ ++ ret void + } + + ; ... but disabled for stores (and, in this simple case, not re-enabled). +@@ -414,6 +415,46 @@ entry: + ret void + } + ++; Must return to exact at the end of a non-void returning shader, ++; otherwise the EXEC mask exported by the epilog will be wrong. This is true ++; even if the shader has no kills, because a kill could have happened in a ++; previous shader fragment. ++; ++; CHECK-LABEL: {{^}}test_nonvoid_return: ++; CHECK: s_mov_b64 [[LIVE:s\[[0-9]+:[0-9]+\]]], exec ++; CHECK: s_wqm_b64 exec, exec ++; ++; CHECK: s_and_b64 exec, exec, [[LIVE]] ++; CHECK-NOT: exec ++define amdgpu_ps <4 x float> @test_nonvoid_return() nounwind { ++ %tex = call <4 x float> @llvm.SI.image.sample.v4i32(<4 x i32> undef, <8 x i32> undef, <4 x i32> undef, i32 15, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0) ++ %tex.i = bitcast <4 x float> %tex to <4 x i32> ++ %dtex = call <4 x float> @llvm.SI.image.sample.v4i32(<4 x i32> %tex.i, <8 x i32> undef, <4 x i32> undef, i32 15, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0) ++ ret <4 x float> %dtex ++} ++ ++; CHECK-LABEL: {{^}}test_nonvoid_return_unreachable: ++; CHECK: s_mov_b64 [[LIVE:s\[[0-9]+:[0-9]+\]]], exec ++; CHECK: s_wqm_b64 exec, exec ++; ++; CHECK: s_and_b64 exec, exec, [[LIVE]] ++; CHECK-NOT: exec ++define amdgpu_ps <4 x float> @test_nonvoid_return_unreachable(i32 inreg %c) nounwind { ++entry: ++ %tex = call <4 x float> @llvm.SI.image.sample.v4i32(<4 x i32> undef, <8 x i32> undef, <4 x i32> undef, i32 15, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0) ++ %tex.i = bitcast <4 x float> %tex to <4 x i32> ++ %dtex = call <4 x float> @llvm.SI.image.sample.v4i32(<4 x i32> %tex.i, <8 x i32> undef, <4 x i32> undef, i32 15, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0) ++ ++ %cc = icmp sgt i32 %c, 0 ++ br i1 %cc, label %if, label %else ++ ++if: ++ store volatile <4 x float> %dtex, <4 x float>* undef ++ unreachable ++ ++else: ++ ret <4 x float> %dtex ++} + + declare void @llvm.amdgcn.image.store.v4i32(<4 x float>, <4 x i32>, <8 x i32>, i32, i1, i1, i1, i1) #1 + declare void @llvm.amdgcn.buffer.store.f32(float, <4 x i32>, i32, i32, i1, i1) #1 diff --git a/programming/build/llvm/files/msan-prevent-initialization-failure-with-newer-glibc.patch b/programming/build/llvm/files/msan-prevent-initialization-failure-with-newer-glibc.patch new file mode 100644 index 0000000000..57387a6a12 --- /dev/null +++ b/programming/build/llvm/files/msan-prevent-initialization-failure-with-newer-glibc.patch @@ -0,0 +1,103 @@ +Index: lib/msan/msan_interceptors.cc +=================================================================== +--- lib/msan/msan_interceptors.cc (revision 282231) ++++ lib/msan/msan_interceptors.cc (revision 282232) +@@ -64,6 +64,23 @@ + return in_interceptor_scope; + } + ++static uptr allocated_for_dlsym; ++static const uptr kDlsymAllocPoolSize = 1024; ++static uptr alloc_memory_for_dlsym[kDlsymAllocPoolSize]; ++ ++static bool IsInDlsymAllocPool(const void *ptr) { ++ uptr off = (uptr)ptr - (uptr)alloc_memory_for_dlsym; ++ return off < sizeof(alloc_memory_for_dlsym); ++} ++ ++static void *AllocateFromLocalPool(uptr size_in_bytes) { ++ uptr size_in_words = RoundUpTo(size_in_bytes, kWordSize) / kWordSize; ++ void *mem = (void *)&alloc_memory_for_dlsym[allocated_for_dlsym]; ++ allocated_for_dlsym += size_in_words; ++ CHECK_LT(allocated_for_dlsym, kDlsymAllocPoolSize); ++ return mem; ++} ++ + #define ENSURE_MSAN_INITED() do { \ + CHECK(!msan_init_is_running); \ + if (!msan_inited) { \ +@@ -227,7 +244,7 @@ + + INTERCEPTOR(void, free, void *ptr) { + GET_MALLOC_STACK_TRACE; +- if (!ptr) return; ++ if (!ptr || UNLIKELY(IsInDlsymAllocPool(ptr))) return; + MsanDeallocate(&stack, ptr); + } + +@@ -234,7 +251,7 @@ + #if !SANITIZER_FREEBSD + INTERCEPTOR(void, cfree, void *ptr) { + GET_MALLOC_STACK_TRACE; +- if (!ptr) return; ++ if (!ptr || UNLIKELY(IsInDlsymAllocPool(ptr))) return; + MsanDeallocate(&stack, ptr); + } + #define MSAN_MAYBE_INTERCEPT_CFREE INTERCEPT_FUNCTION(cfree) +@@ -907,27 +924,29 @@ + + INTERCEPTOR(void *, calloc, SIZE_T nmemb, SIZE_T size) { + GET_MALLOC_STACK_TRACE; +- if (UNLIKELY(!msan_inited)) { ++ if (UNLIKELY(!msan_inited)) + // Hack: dlsym calls calloc before REAL(calloc) is retrieved from dlsym. +- const SIZE_T kCallocPoolSize = 1024; +- static uptr calloc_memory_for_dlsym[kCallocPoolSize]; +- static SIZE_T allocated; +- SIZE_T size_in_words = ((nmemb * size) + kWordSize - 1) / kWordSize; +- void *mem = (void*)&calloc_memory_for_dlsym[allocated]; +- allocated += size_in_words; +- CHECK(allocated < kCallocPoolSize); +- return mem; +- } ++ return AllocateFromLocalPool(nmemb * size); + return MsanCalloc(&stack, nmemb, size); + } + + INTERCEPTOR(void *, realloc, void *ptr, SIZE_T size) { + GET_MALLOC_STACK_TRACE; ++ if (UNLIKELY(IsInDlsymAllocPool(ptr))) { ++ uptr offset = (uptr)ptr - (uptr)alloc_memory_for_dlsym; ++ uptr copy_size = Min(size, kDlsymAllocPoolSize - offset); ++ void *new_ptr = AllocateFromLocalPool(size); ++ internal_memcpy(new_ptr, ptr, copy_size); ++ return new_ptr; ++ } + return MsanReallocate(&stack, ptr, size, sizeof(u64), false); + } + + INTERCEPTOR(void *, malloc, SIZE_T size) { + GET_MALLOC_STACK_TRACE; ++ if (UNLIKELY(!msan_inited)) ++ // Hack: dlsym calls malloc before REAL(malloc) is retrieved from dlsym. ++ return AllocateFromLocalPool(size); + return MsanReallocate(&stack, nullptr, size, sizeof(u64), false); + } + +Index: lib/asan/asan_malloc_linux.cc +=================================================================== +--- lib/asan/asan_malloc_linux.cc (revision 282231) ++++ lib/asan/asan_malloc_linux.cc (revision 282232) +@@ -78,7 +78,11 @@ + if (UNLIKELY(IsInDlsymAllocPool(ptr))) { + uptr offset = (uptr)ptr - (uptr)alloc_memory_for_dlsym; + uptr copy_size = Min(size, kDlsymAllocPoolSize - offset); +- void *new_ptr = asan_malloc(size, &stack); ++ void *new_ptr; ++ if (UNLIKELY(!asan_inited)) ++ new_ptr = AllocateFromLocalPool(size); ++ else ++ new_ptr = asan_malloc(size, &stack); + internal_memcpy(new_ptr, ptr, copy_size); + return new_ptr; + } diff --git a/programming/build/llvm/pspec.xml b/programming/build/llvm/pspec.xml index 36068da221..72fef57d0b 100644 --- a/programming/build/llvm/pspec.xml +++ b/programming/build/llvm/pspec.xml @@ -16,6 +16,10 @@ http://releases.llvm.org/3.9.1/clang-tools-extra-3.9.1.src.tar.xz http://releases.llvm.org/3.9.1/lldb-3.9.1.src.tar.xz http://releases.llvm.org/3.9.1/compiler-rt-3.9.1.src.tar.xz + + msan-prevent-initialization-failure-with-newer-glibc.patch + AMDGPU-Fix-an-interaction-between-WQM-and-polygon-stippling.patch + zlib-devel libxml2-devel @@ -201,7 +205,7 @@ - 2017-02-02 + 2017-02-05 3.9.1 Version Bump Pisi Linux Community diff --git a/x11/library/Xaw3d/pspec.xml b/x11/library/Xaw3d/pspec.xml index 9008c39bf9..a5e14fc026 100644 --- a/x11/library/Xaw3d/pspec.xml +++ b/x11/library/Xaw3d/pspec.xml @@ -58,6 +58,13 @@ + + 2017-02-05 + 1.6.2 + Rebuild + PisiLinux Community + admin@pisilinux.org + 2016-04-30 1.6.2 diff --git a/x11/library/libXxf86misc/pspec.xml b/x11/library/libXxf86misc/pspec.xml index ba007fd862..5252cb591a 100644 --- a/x11/library/libXxf86misc/pspec.xml +++ b/x11/library/libXxf86misc/pspec.xml @@ -68,6 +68,13 @@ + + 2017-02-05 + 1.0.3 + Rebuild + PisiLinux Community + admin@pisilinux.org + 2016-04-30 1.0.3 diff --git a/x11/library/libXxf86miscproto/pspec.xml b/x11/library/libXxf86miscproto/pspec.xml index d1d1a0457a..188bfd7148 100644 --- a/x11/library/libXxf86miscproto/pspec.xml +++ b/x11/library/libXxf86miscproto/pspec.xml @@ -43,6 +43,13 @@ + + 2017-02-05 + 0.9.3 + Rebuild + PisiLinux Community + admin@pisilinux.org + 2016-04-30 0.9.3 diff --git a/x11/library/mesa/actions.py b/x11/library/mesa/actions.py index f584892449..01540e3701 100644 --- a/x11/library/mesa/actions.py +++ b/x11/library/mesa/actions.py @@ -32,7 +32,6 @@ def setup(): --enable-gles2 \ --enable-vdpau \ --enable-osmesa \ - --enable-sysfs \ --enable-xvmc \ --enable-glx-tls \ --enable-gallium-llvm \ diff --git a/x11/library/mesa/files/2733e5483e1c2b80e4b0ae21187ec5e3e1579397.diff b/x11/library/mesa/files/2733e5483e1c2b80e4b0ae21187ec5e3e1579397.diff new file mode 100644 index 0000000000..bb46310138 --- /dev/null +++ b/x11/library/mesa/files/2733e5483e1c2b80e4b0ae21187ec5e3e1579397.diff @@ -0,0 +1,78 @@ +diff --git a/src/gallium/drivers/nouveau/nouveau_buffer.c b/src/gallium/drivers/nouveau/nouveau_buffer.c +index 58fa453..a006e9f 100644 +--- a/src/gallium/drivers/nouveau/nouveau_buffer.c ++++ b/src/gallium/drivers/nouveau/nouveau_buffer.c +@@ -80,6 +80,8 @@ release_allocation(struct nouveau_mm_allocation **mm, + inline void + nouveau_buffer_release_gpu_storage(struct nv04_resource *buf) + { ++ if (buf->fence) ++ pipe_mutex_lock(buf->fence->screen->push_mutex); + if (buf->fence && buf->fence->state < NOUVEAU_FENCE_STATE_FLUSHED) { + nouveau_fence_work(buf->fence, nouveau_fence_unref_bo, buf->bo); + buf->bo = NULL; +@@ -89,6 +91,8 @@ nouveau_buffer_release_gpu_storage(struct nv04_resource *buf) + + if (buf->mm) + release_allocation(&buf->mm, buf->fence); ++ if (buf->fence) ++ pipe_mutex_unlock(buf->fence->screen->push_mutex); + + if (buf->domain == NOUVEAU_BO_VRAM) + NOUVEAU_DRV_STAT_RES(buf, buf_obj_current_bytes_vid, -(uint64_t)buf->base.width0); +diff --git a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c +index 7450119..38e4faf 100644 +--- a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c ++++ b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c +@@ -163,10 +163,13 @@ nv50_miptree_destroy(struct pipe_screen *pscreen, struct pipe_resource *pt) + { + struct nv50_miptree *mt = nv50_miptree(pt); + +- if (mt->base.fence && mt->base.fence->state < NOUVEAU_FENCE_STATE_FLUSHED) ++ if (mt->base.fence && mt->base.fence->state < NOUVEAU_FENCE_STATE_FLUSHED) { ++ pipe_mutex_lock(nouveau_screen(pscreen)->push_mutex); + nouveau_fence_work(mt->base.fence, nouveau_fence_unref_bo, mt->base.bo); +- else ++ pipe_mutex_unlock(nouveau_screen(pscreen)->push_mutex); ++ } else { + nouveau_bo_ref(NULL, &mt->base.bo); ++ } + + nouveau_fence_ref(NULL, &mt->base.fence); + nouveau_fence_ref(NULL, &mt->base.fence_wr); +diff --git a/src/gallium/drivers/nouveau/nv50/nv50_query_hw.c b/src/gallium/drivers/nouveau/nv50/nv50_query_hw.c +index 9067bcc..d2ad72e 100644 +--- a/src/gallium/drivers/nouveau/nv50/nv50_query_hw.c ++++ b/src/gallium/drivers/nouveau/nv50/nv50_query_hw.c +@@ -56,9 +56,12 @@ nv50_hw_query_allocate(struct nv50_context *nv50, struct nv50_query *q, + if (hq->mm) { + if (hq->state == NV50_HW_QUERY_STATE_READY) + nouveau_mm_free(hq->mm); +- else ++ else { ++ pipe_mutex_lock(screen->base.push_mutex); + nouveau_fence_work(screen->base.fence.current, + nouveau_mm_free_work, hq->mm); ++ pipe_mutex_unlock(screen->base.push_mutex); ++ } + } + } + if (size) { +diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c b/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c +index f2584cb..4b51a67 100644 +--- a/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c ++++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c +@@ -48,9 +48,12 @@ nvc0_hw_query_allocate(struct nvc0_context *nvc0, struct nvc0_query *q, + if (hq->mm) { + if (hq->state == NVC0_HW_QUERY_STATE_READY) + nouveau_mm_free(hq->mm); +- else ++ else { ++ pipe_mutex_lock(screen->base.push_mutex); + nouveau_fence_work(screen->base.fence.current, + nouveau_mm_free_work, hq->mm); ++ pipe_mutex_unlock(screen->base.push_mutex); ++ } + } + } + if (size) { diff --git a/x11/library/mesa/files/2e6b0e24cfb0f467e8b6d6f394730442a72dcdaf.diff b/x11/library/mesa/files/2e6b0e24cfb0f467e8b6d6f394730442a72dcdaf.diff new file mode 100644 index 0000000000..899c9b4606 --- /dev/null +++ b/x11/library/mesa/files/2e6b0e24cfb0f467e8b6d6f394730442a72dcdaf.diff @@ -0,0 +1,1714 @@ +diff --git a/src/gallium/drivers/nouveau/nouveau_buffer.c b/src/gallium/drivers/nouveau/nouveau_buffer.c +index 7c1421b..58fa453 100644 +--- a/src/gallium/drivers/nouveau/nouveau_buffer.c ++++ b/src/gallium/drivers/nouveau/nouveau_buffer.c +@@ -380,6 +380,7 @@ nouveau_buffer_transfer_map(struct pipe_context *pipe, + struct pipe_transfer **ptransfer) + { + struct nouveau_context *nv = nouveau_context(pipe); ++ struct nouveau_screen *screen = nv->screen; + struct nv04_resource *buf = nv04_resource(resource); + struct nouveau_transfer *tx = MALLOC_STRUCT(nouveau_transfer); + uint8_t *map; +@@ -427,14 +428,19 @@ nouveau_buffer_transfer_map(struct pipe_context *pipe, + buf->data = NULL; + } + nouveau_transfer_staging(nv, tx, false); ++ pipe_mutex_lock(screen->push_mutex); + nouveau_transfer_read(nv, tx); ++ pipe_mutex_unlock(screen->push_mutex); + } else { + /* The buffer is currently idle. Create a staging area for writes, + * and make sure that the cached data is up-to-date. */ + if (usage & PIPE_TRANSFER_WRITE) + nouveau_transfer_staging(nv, tx, true); +- if (!buf->data) ++ if (!buf->data) { ++ pipe_mutex_lock(screen->push_mutex); + nouveau_buffer_cache(nv, buf); ++ pipe_mutex_unlock(screen->push_mutex); ++ } + } + } + return buf->data ? (buf->data + box->x) : tx->map; +@@ -479,7 +485,9 @@ nouveau_buffer_transfer_map(struct pipe_context *pipe, + if (unlikely(usage & PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE)) { + /* Discarding was not possible, must sync because + * subsequent transfers might use UNSYNCHRONIZED. */ ++ pipe_mutex_lock(screen->push_mutex); + nouveau_buffer_sync(nv, buf, usage & PIPE_TRANSFER_READ_WRITE); ++ pipe_mutex_unlock(screen->push_mutex); + } else + if (usage & PIPE_TRANSFER_DISCARD_RANGE) { + /* The whole range is being discarded, so it doesn't matter what was +@@ -488,10 +496,13 @@ nouveau_buffer_transfer_map(struct pipe_context *pipe, + map = tx->map; + } else + if (nouveau_buffer_busy(buf, PIPE_TRANSFER_READ)) { +- if (usage & PIPE_TRANSFER_DONTBLOCK) ++ if (usage & PIPE_TRANSFER_DONTBLOCK) { + map = NULL; +- else ++ } else { ++ pipe_mutex_lock(screen->push_mutex); + nouveau_buffer_sync(nv, buf, usage & PIPE_TRANSFER_READ_WRITE); ++ pipe_mutex_unlock(screen->push_mutex); ++ } + } else { + /* It is expected that the returned buffer be a representation of the + * data in question, so we must copy it over from the buffer. */ +@@ -515,9 +526,13 @@ nouveau_buffer_transfer_flush_region(struct pipe_context *pipe, + { + struct nouveau_transfer *tx = nouveau_transfer(transfer); + struct nv04_resource *buf = nv04_resource(transfer->resource); ++ struct nouveau_screen *screen = nouveau_context(pipe)->screen; + +- if (tx->map) ++ if (tx->map) { ++ pipe_mutex_lock(screen->push_mutex); + nouveau_transfer_write(nouveau_context(pipe), tx, box->x, box->width); ++ pipe_mutex_unlock(screen->push_mutex); ++ } + + util_range_add(&buf->valid_buffer_range, + tx->base.box.x + box->x, +@@ -537,11 +552,15 @@ nouveau_buffer_transfer_unmap(struct pipe_context *pipe, + struct nouveau_context *nv = nouveau_context(pipe); + struct nouveau_transfer *tx = nouveau_transfer(transfer); + struct nv04_resource *buf = nv04_resource(transfer->resource); ++ struct nouveau_screen *screen = nouveau_context(pipe)->screen; + + if (tx->base.usage & PIPE_TRANSFER_WRITE) { + if (!(tx->base.usage & PIPE_TRANSFER_FLUSH_EXPLICIT)) { +- if (tx->map) ++ if (tx->map) { ++ pipe_mutex_lock(screen->push_mutex); + nouveau_transfer_write(nv, tx, 0, tx->base.box.width); ++ pipe_mutex_unlock(screen->push_mutex); ++ } + + util_range_add(&buf->valid_buffer_range, + tx->base.box.x, tx->base.box.x + tx->base.box.width); +diff --git a/src/gallium/drivers/nouveau/nouveau_fence.c b/src/gallium/drivers/nouveau/nouveau_fence.c +index 691553a..9cbfc2a 100644 +--- a/src/gallium/drivers/nouveau/nouveau_fence.c ++++ b/src/gallium/drivers/nouveau/nouveau_fence.c +@@ -71,12 +71,14 @@ nouveau_fence_emit(struct nouveau_fence *fence) + + ++fence->ref; + ++ pipe_mutex_lock(screen->fence.list_mutex); + if (screen->fence.tail) + screen->fence.tail->next = fence; + else + screen->fence.head = fence; + + screen->fence.tail = fence; ++ pipe_mutex_unlock(screen->fence.list_mutex); + + screen->fence.emit(&screen->base, &fence->sequence); + +@@ -90,6 +92,9 @@ nouveau_fence_del(struct nouveau_fence *fence) + struct nouveau_fence *it; + struct nouveau_screen *screen = fence->screen; + ++ /* XXX This can race against fence_update. But fence_update can also call ++ * into this, so ... be have to be careful. ++ */ + if (fence->state == NOUVEAU_FENCE_STATE_EMITTED || + fence->state == NOUVEAU_FENCE_STATE_FLUSHED) { + if (fence == screen->fence.head) { +@@ -123,6 +128,7 @@ nouveau_fence_update(struct nouveau_screen *screen, bool flushed) + return; + screen->fence.sequence_ack = sequence; + ++ pipe_mutex_lock(screen->fence.list_mutex); + for (fence = screen->fence.head; fence; fence = next) { + next = fence->next; + sequence = fence->sequence; +@@ -144,6 +150,7 @@ nouveau_fence_update(struct nouveau_screen *screen, bool flushed) + if (fence->state == NOUVEAU_FENCE_STATE_EMITTED) + fence->state = NOUVEAU_FENCE_STATE_FLUSHED; + } ++ pipe_mutex_unlock(screen->fence.list_mutex); + } + + #define NOUVEAU_FENCE_MAX_SPINS (1 << 31) +@@ -198,18 +205,27 @@ nouveau_fence_wait(struct nouveau_fence *fence, struct pipe_debug_callback *debu + uint32_t spins = 0; + int64_t start = 0; + ++ /* Fast-path for the case where the fence is already signaled to avoid ++ * messing around with mutexes and timing. ++ */ ++ if (fence->state == NOUVEAU_FENCE_STATE_SIGNALLED) ++ return true; ++ + if (debug && debug->debug_message) + start = os_time_get_nano(); + + if (!nouveau_fence_kick(fence)) + return false; + ++ pipe_mutex_unlock(screen->push_mutex); ++ + do { + if (fence->state == NOUVEAU_FENCE_STATE_SIGNALLED) { + if (debug && debug->debug_message) + pipe_debug_message(debug, PERF_INFO, + "stalled %.3f ms waiting for fence", + (os_time_get_nano() - start) / 1000000.f); ++ pipe_mutex_lock(screen->push_mutex); + return true; + } + if (!spins) +@@ -227,6 +243,8 @@ nouveau_fence_wait(struct nouveau_fence *fence, struct pipe_debug_callback *debu + fence->sequence, + screen->fence.sequence_ack, screen->fence.sequence); + ++ pipe_mutex_lock(screen->push_mutex); ++ + return false; + } + +diff --git a/src/gallium/drivers/nouveau/nouveau_fence.h b/src/gallium/drivers/nouveau/nouveau_fence.h +index f10016d..98d021e 100644 +--- a/src/gallium/drivers/nouveau/nouveau_fence.h ++++ b/src/gallium/drivers/nouveau/nouveau_fence.h +@@ -2,6 +2,7 @@ + #ifndef __NOUVEAU_FENCE_H__ + #define __NOUVEAU_FENCE_H__ + ++#include "util/u_atomic.h" + #include "util/u_inlines.h" + #include "util/list.h" + +@@ -47,10 +48,10 @@ static inline void + nouveau_fence_ref(struct nouveau_fence *fence, struct nouveau_fence **ref) + { + if (fence) +- ++fence->ref; ++ p_atomic_inc(&fence->ref); + + if (*ref) { +- if (--(*ref)->ref == 0) ++ if (p_atomic_dec_zero(&(*ref)->ref)) + nouveau_fence_del(*ref); + } + +diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c +index 2c421cc..634fdc3 100644 +--- a/src/gallium/drivers/nouveau/nouveau_screen.c ++++ b/src/gallium/drivers/nouveau/nouveau_screen.c +@@ -73,10 +73,14 @@ nouveau_screen_fence_finish(struct pipe_screen *screen, + struct pipe_fence_handle *pfence, + uint64_t timeout) + { ++ bool ret; + if (!timeout) + return nouveau_fence_signalled(nouveau_fence(pfence)); + +- return nouveau_fence_wait(nouveau_fence(pfence), NULL); ++ pipe_mutex_lock(nouveau_screen(screen)->push_mutex); ++ ret = nouveau_fence_wait(nouveau_fence(pfence), NULL); ++ pipe_mutex_unlock(nouveau_screen(screen)->push_mutex); ++ return ret; + } + + +@@ -153,6 +157,9 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev) + if (nv_dbg) + nouveau_mesa_debug = atoi(nv_dbg); + ++ pipe_mutex_init(screen->push_mutex); ++ pipe_mutex_init(screen->fence.list_mutex); ++ + /* These must be set before any failure is possible, as the cleanup + * paths assume they're responsible for deleting them. + */ +@@ -253,6 +260,9 @@ nouveau_screen_fini(struct nouveau_screen *screen) + nouveau_device_del(&screen->device); + nouveau_drm_del(&screen->drm); + close(fd); ++ ++ pipe_mutex_destroy(screen->push_mutex); ++ pipe_mutex_destroy(screen->fence.list_mutex); + } + + static void +diff --git a/src/gallium/drivers/nouveau/nouveau_screen.h b/src/gallium/drivers/nouveau/nouveau_screen.h +index 28c4760..28c8620 100644 +--- a/src/gallium/drivers/nouveau/nouveau_screen.h ++++ b/src/gallium/drivers/nouveau/nouveau_screen.h +@@ -3,6 +3,7 @@ + + #include "pipe/p_screen.h" + #include "util/u_memory.h" ++#include "os/os_thread.h" + + #ifdef DEBUG + # define NOUVEAU_ENABLE_DRIVER_STATISTICS +@@ -22,6 +23,7 @@ struct nouveau_screen { + struct nouveau_object *channel; + struct nouveau_client *client; + struct nouveau_pushbuf *pushbuf; ++ pipe_mutex push_mutex; + + int refcount; + +@@ -39,6 +41,7 @@ struct nouveau_screen { + struct nouveau_fence *head; + struct nouveau_fence *tail; + struct nouveau_fence *current; ++ pipe_mutex list_mutex; + u32 sequence; + u32 sequence_ack; + void (*emit)(struct pipe_screen *, u32 *sequence); +diff --git a/src/gallium/drivers/nouveau/nv30/nv30_clear.c b/src/gallium/drivers/nouveau/nv30/nv30_clear.c +index c8fa38e..3a72354 100644 +--- a/src/gallium/drivers/nouveau/nv30/nv30_clear.c ++++ b/src/gallium/drivers/nouveau/nv30/nv30_clear.c +@@ -58,8 +58,11 @@ nv30_clear(struct pipe_context *pipe, unsigned buffers, + struct pipe_framebuffer_state *fb = &nv30->framebuffer; + uint32_t colr = 0, zeta = 0, mode = 0; + +- if (!nv30_state_validate(nv30, NV30_NEW_FRAMEBUFFER | NV30_NEW_SCISSOR, true)) ++ pipe_mutex_lock(nv30->screen->base.push_mutex); ++ if (!nv30_state_validate(nv30, NV30_NEW_FRAMEBUFFER | NV30_NEW_SCISSOR, true)) { ++ pipe_mutex_unlock(nv30->screen->base.push_mutex); + return; ++ } + + if (buffers & PIPE_CLEAR_COLOR && fb->nr_cbufs) { + colr = pack_rgba(fb->cbufs[0]->format, color->f); +@@ -96,6 +99,7 @@ nv30_clear(struct pipe_context *pipe, unsigned buffers, + PUSH_DATA (push, mode); + + nv30_state_release(nv30); ++ pipe_mutex_unlock(nv30->screen->base.push_mutex); + } + + static void +@@ -125,11 +129,15 @@ nv30_clear_render_target(struct pipe_context *pipe, struct pipe_surface *ps, + rt_format |= NV30_3D_RT_FORMAT_TYPE_LINEAR; + } + ++ pipe_mutex_lock(nv30->screen->base.push_mutex); ++ + refn.bo = mt->base.bo; + refn.flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_WR; + if (nouveau_pushbuf_space(push, 16, 1, 0) || +- nouveau_pushbuf_refn (push, &refn, 1)) ++ nouveau_pushbuf_refn (push, &refn, 1)) { ++ pipe_mutex_unlock(nv30->screen->base.push_mutex); + return; ++ } + + BEGIN_NV04(push, NV30_3D(RT_ENABLE), 1); + PUSH_DATA (push, NV30_3D_RT_ENABLE_COLOR0); +@@ -154,6 +162,8 @@ nv30_clear_render_target(struct pipe_context *pipe, struct pipe_surface *ps, + NV30_3D_CLEAR_BUFFERS_COLOR_B | + NV30_3D_CLEAR_BUFFERS_COLOR_A); + ++ pipe_mutex_unlock(nv30->screen->base.push_mutex); ++ + nv30->dirty |= NV30_NEW_FRAMEBUFFER | NV30_NEW_SCISSOR; + } + +@@ -189,11 +199,15 @@ nv30_clear_depth_stencil(struct pipe_context *pipe, struct pipe_surface *ps, + if (buffers & PIPE_CLEAR_STENCIL) + mode |= NV30_3D_CLEAR_BUFFERS_STENCIL; + ++ pipe_mutex_lock(nv30->screen->base.push_mutex); ++ + refn.bo = mt->base.bo; + refn.flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_WR; + if (nouveau_pushbuf_space(push, 32, 1, 0) || +- nouveau_pushbuf_refn (push, &refn, 1)) ++ nouveau_pushbuf_refn (push, &refn, 1)) { ++ pipe_mutex_unlock(nv30->screen->base.push_mutex); + return; ++ } + + BEGIN_NV04(push, NV30_3D(RT_ENABLE), 1); + PUSH_DATA (push, 0); +@@ -219,6 +233,8 @@ nv30_clear_depth_stencil(struct pipe_context *pipe, struct pipe_surface *ps, + BEGIN_NV04(push, NV30_3D(CLEAR_BUFFERS), 1); + PUSH_DATA (push, mode); + ++ pipe_mutex_unlock(nv30->screen->base.push_mutex); ++ + nv30->dirty |= NV30_NEW_FRAMEBUFFER | NV30_NEW_SCISSOR; + } + +diff --git a/src/gallium/drivers/nouveau/nv30/nv30_context.c b/src/gallium/drivers/nouveau/nv30/nv30_context.c +index 3ed0889..fbc4136 100644 +--- a/src/gallium/drivers/nouveau/nv30/nv30_context.c ++++ b/src/gallium/drivers/nouveau/nv30/nv30_context.c +@@ -201,6 +201,8 @@ nv30_context_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags) + if (!nv30) + return NULL; + ++ pipe_mutex_lock(screen->base.push_mutex); ++ + nv30->screen = screen; + nv30->base.screen = &screen->base; + nv30->base.copy_data = nv30_transfer_copy_data; +@@ -226,6 +228,7 @@ nv30_context_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags) + ret = nouveau_bufctx_new(nv30->base.client, 64, &nv30->bufctx); + if (ret) { + nv30_context_destroy(pipe); ++ pipe_mutex_unlock(screen->base.push_mutex); + return NULL; + } + +@@ -259,10 +262,13 @@ nv30_context_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags) + nv30->blitter = util_blitter_create(pipe); + if (!nv30->blitter) { + nv30_context_destroy(pipe); ++ pipe_mutex_unlock(screen->base.push_mutex); + return NULL; + } + + nouveau_context_init_vdec(&nv30->base); + ++ pipe_mutex_unlock(screen->base.push_mutex); ++ + return pipe; + } +diff --git a/src/gallium/drivers/nouveau/nv30/nv30_miptree.c b/src/gallium/drivers/nouveau/nv30/nv30_miptree.c +index c6f6965..389bfaa 100644 +--- a/src/gallium/drivers/nouveau/nv30/nv30_miptree.c ++++ b/src/gallium/drivers/nouveau/nv30/nv30_miptree.c +@@ -130,10 +130,12 @@ nv30_resource_copy_region(struct pipe_context *pipe, + struct nv30_context *nv30 = nv30_context(pipe); + struct nv30_rect src, dst; + ++ pipe_mutex_lock(nv30->screen->base.push_mutex); + if (dstres->target == PIPE_BUFFER && srcres->target == PIPE_BUFFER) { + nouveau_copy_buffer(&nv30->base, + nv04_resource(dstres), dstx, + nv04_resource(srcres), src_box->x, src_box->width); ++ pipe_mutex_unlock(nv30->screen->base.push_mutex); + return; + } + +@@ -143,6 +145,7 @@ nv30_resource_copy_region(struct pipe_context *pipe, + src_box->width, src_box->height, &dst); + + nv30_transfer_rect(nv30, NEAREST, &src, &dst); ++ pipe_mutex_unlock(nv30->screen->base.push_mutex); + } + + static void +@@ -163,6 +166,7 @@ nv30_resource_resolve(struct nv30_context *nv30, + y1 = src.y1; + + /* On nv3x we must use sifm which is restricted to 1024x1024 tiles */ ++ pipe_mutex_lock(nv30->screen->base.push_mutex); + for (y = src.y0; y < y1; y += h) { + h = y1 - y; + if (h > 1024) +@@ -193,6 +197,7 @@ nv30_resource_resolve(struct nv30_context *nv30, + nv30_transfer_rect(nv30, BILINEAR, &src, &dst); + } + } ++ pipe_mutex_unlock(nv30->screen->base.push_mutex); + } + + void +@@ -308,8 +313,12 @@ nv30_miptree_transfer_map(struct pipe_context *pipe, struct pipe_resource *pt, + tx->tmp.y1 = tx->tmp.h; + tx->tmp.z = 0; + +- if (usage & PIPE_TRANSFER_READ) ++ if (usage & PIPE_TRANSFER_READ) { ++ pipe_mutex_lock(nv30->screen->base.push_mutex); + nv30_transfer_rect(nv30, NEAREST, &tx->img, &tx->tmp); ++ PUSH_KICK(nv30->base.pushbuf); ++ pipe_mutex_unlock(nv30->screen->base.push_mutex); ++ } + + if (tx->tmp.bo->map) { + *ptransfer = &tx->base; +@@ -340,11 +349,13 @@ nv30_miptree_transfer_unmap(struct pipe_context *pipe, + struct nv30_transfer *tx = nv30_transfer(ptx); + + if (ptx->usage & PIPE_TRANSFER_WRITE) { ++ pipe_mutex_lock(nv30->screen->base.push_mutex); + nv30_transfer_rect(nv30, NEAREST, &tx->tmp, &tx->img); + + /* Allow the copies above to finish executing before freeing the source */ + nouveau_fence_work(nv30->screen->base.fence.current, + nouveau_fence_unref_bo, tx->tmp.bo); ++ pipe_mutex_unlock(nv30->screen->base.push_mutex); + } else { + nouveau_bo_ref(NULL, &tx->tmp.bo); + } +diff --git a/src/gallium/drivers/nouveau/nv30/nv30_query.c b/src/gallium/drivers/nouveau/nv30/nv30_query.c +index aa9a12f..a047e15 100644 +--- a/src/gallium/drivers/nouveau/nv30/nv30_query.c ++++ b/src/gallium/drivers/nouveau/nv30/nv30_query.c +@@ -152,6 +152,7 @@ nv30_query_begin(struct pipe_context *pipe, struct pipe_query *pq) + struct nv30_query *q = nv30_query(pq); + struct nouveau_pushbuf *push = nv30->base.pushbuf; + ++ pipe_mutex_lock(nv30->screen->base.push_mutex); + switch (q->type) { + case PIPE_QUERY_TIME_ELAPSED: + q->qo[0] = nv30_query_object_new(nv30->screen); +@@ -161,7 +162,7 @@ nv30_query_begin(struct pipe_context *pipe, struct pipe_query *pq) + } + break; + case PIPE_QUERY_TIMESTAMP: +- return true; ++ break; + default: + BEGIN_NV04(push, NV30_3D(QUERY_RESET), 1); + PUSH_DATA (push, q->report); +@@ -172,6 +173,7 @@ nv30_query_begin(struct pipe_context *pipe, struct pipe_query *pq) + BEGIN_NV04(push, SUBC_3D(q->enable), 1); + PUSH_DATA (push, 1); + } ++ pipe_mutex_unlock(nv30->screen->base.push_mutex); + return true; + } + +@@ -183,6 +185,7 @@ nv30_query_end(struct pipe_context *pipe, struct pipe_query *pq) + struct nv30_query *q = nv30_query(pq); + struct nouveau_pushbuf *push = nv30->base.pushbuf; + ++ pipe_mutex_lock(nv30->screen->base.push_mutex); + q->qo[1] = nv30_query_object_new(screen); + if (q->qo[1]) { + BEGIN_NV04(push, NV30_3D(QUERY_GET), 1); +@@ -194,6 +197,7 @@ nv30_query_end(struct pipe_context *pipe, struct pipe_query *pq) + PUSH_DATA (push, 0); + } + PUSH_KICK (push); ++ pipe_mutex_unlock(nv30->screen->base.push_mutex); + return true; + } + +@@ -248,9 +252,11 @@ nv40_query_render_condition(struct pipe_context *pipe, + nv30->render_cond_mode = mode; + nv30->render_cond_cond = condition; + ++ pipe_mutex_lock(nv30->screen->base.push_mutex); + if (!pq) { + BEGIN_NV04(push, SUBC_3D(0x1e98), 1); + PUSH_DATA (push, 0x01000000); ++ pipe_mutex_unlock(nv30->screen->base.push_mutex); + return; + } + +@@ -262,6 +268,7 @@ nv40_query_render_condition(struct pipe_context *pipe, + + BEGIN_NV04(push, SUBC_3D(0x1e98), 1); + PUSH_DATA (push, 0x02000000 | q->qo[1]->hw->start); ++ pipe_mutex_unlock(nv30->screen->base.push_mutex); + } + + static void +diff --git a/src/gallium/drivers/nouveau/nv30/nv30_vbo.c b/src/gallium/drivers/nouveau/nv30/nv30_vbo.c +index bc9b9a1..8e3fdee 100644 +--- a/src/gallium/drivers/nouveau/nv30/nv30_vbo.c ++++ b/src/gallium/drivers/nouveau/nv30/nv30_vbo.c +@@ -563,6 +563,8 @@ nv30_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) + if (nv30->vbo_push_hint != !!nv30->vbo_fifo) + nv30->dirty |= NV30_NEW_ARRAYS; + ++ pipe_mutex_lock(nv30->screen->base.push_mutex); ++ + push->user_priv = &nv30->bufctx; + if (nv30->vbo_user && !(nv30->dirty & (NV30_NEW_VERTEX | NV30_NEW_ARRAYS))) + nv30_update_user_vbufs(nv30); +@@ -570,10 +572,12 @@ nv30_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) + nv30_state_validate(nv30, ~0, true); + if (nv30->draw_flags) { + nv30_render_vbo(pipe, info); ++ pipe_mutex_unlock(nv30->screen->base.push_mutex); + return; + } else + if (nv30->vbo_fifo) { + nv30_push_vbo(nv30, info); ++ pipe_mutex_unlock(nv30->screen->base.push_mutex); + return; + } + +@@ -630,6 +634,7 @@ nv30_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) + + nv30_state_release(nv30); + nv30_release_user_vbufs(nv30); ++ pipe_mutex_unlock(nv30->screen->base.push_mutex); + } + + void +diff --git a/src/gallium/drivers/nouveau/nv50/nv50_compute.c b/src/gallium/drivers/nouveau/nv50/nv50_compute.c +index d781f6f..3c174e4 100644 +--- a/src/gallium/drivers/nouveau/nv50/nv50_compute.c ++++ b/src/gallium/drivers/nouveau/nv50/nv50_compute.c +@@ -249,9 +249,11 @@ nv50_launch_grid(struct pipe_context *pipe, const struct pipe_grid_info *info) + struct nv50_program *cp = nv50->compprog; + bool ret; + ++ pipe_mutex_lock(nv50->screen->base.push_mutex); + ret = !nv50_state_validate_cp(nv50, ~0); + if (ret) { + NOUVEAU_ERR("Failed to launch grid !\n"); ++ pipe_mutex_unlock(nv50->screen->base.push_mutex); + return; + } + +@@ -284,6 +286,8 @@ nv50_launch_grid(struct pipe_context *pipe, const struct pipe_grid_info *info) + BEGIN_NV04(push, SUBC_CP(NV50_GRAPH_SERIALIZE), 1); + PUSH_DATA (push, 0); + ++ pipe_mutex_unlock(nv50->screen->base.push_mutex); ++ + /* bind a compute shader clobbers fragment shader state */ + nv50->dirty_3d |= NV50_NEW_3D_FRAGPROG; + } +diff --git a/src/gallium/drivers/nouveau/nv50/nv50_context.c b/src/gallium/drivers/nouveau/nv50/nv50_context.c +index fc852d7..84b5e3f 100644 +--- a/src/gallium/drivers/nouveau/nv50/nv50_context.c ++++ b/src/gallium/drivers/nouveau/nv50/nv50_context.c +@@ -37,7 +37,9 @@ nv50_flush(struct pipe_context *pipe, + if (fence) + nouveau_fence_ref(screen->fence.current, (struct nouveau_fence **)fence); + ++ pipe_mutex_lock(screen->push_mutex); + PUSH_KICK(screen->pushbuf); ++ pipe_mutex_unlock(screen->push_mutex); + + nouveau_context_update_frame_stats(nouveau_context(pipe)); + } +@@ -47,10 +49,12 @@ nv50_texture_barrier(struct pipe_context *pipe) + { + struct nouveau_pushbuf *push = nv50_context(pipe)->base.pushbuf; + ++ pipe_mutex_lock(nouveau_context(pipe)->screen->push_mutex); + BEGIN_NV04(push, SUBC_3D(NV50_GRAPH_SERIALIZE), 1); + PUSH_DATA (push, 0); + BEGIN_NV04(push, NV50_3D(TEX_CACHE_CTL), 1); + PUSH_DATA (push, 0x20); ++ pipe_mutex_unlock(nouveau_context(pipe)->screen->push_mutex); + } + + static void +@@ -107,6 +111,7 @@ nv50_emit_string_marker(struct pipe_context *pipe, const char *str, int len) + data_words = string_words; + else + data_words = string_words + !!(len & 3); ++ pipe_mutex_lock(nouveau_context(pipe)->screen->push_mutex); + BEGIN_NI04(push, SUBC_3D(NV04_GRAPH_NOP), data_words); + if (string_words) + PUSH_DATAp(push, str, string_words); +@@ -115,6 +120,7 @@ nv50_emit_string_marker(struct pipe_context *pipe, const char *str, int len) + memcpy(&data, &str[string_words * 4], len & 3); + PUSH_DATA (push, data); + } ++ pipe_mutex_unlock(nouveau_context(pipe)->screen->push_mutex); + } + + void +@@ -291,6 +297,8 @@ nv50_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags) + return NULL; + pipe = &nv50->base.pipe; + ++ pipe_mutex_lock(screen->base.push_mutex); ++ + if (!nv50_blitctx_create(nv50)) + goto out_err; + +@@ -384,9 +392,12 @@ nv50_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags) + + util_dynarray_init(&nv50->global_residents); + ++ pipe_mutex_unlock(screen->base.push_mutex); ++ + return pipe; + + out_err: ++ pipe_mutex_unlock(screen->base.push_mutex); + if (nv50->bufctx_3d) + nouveau_bufctx_del(&nv50->bufctx_3d); + if (nv50->bufctx_cp) +diff --git a/src/gallium/drivers/nouveau/nv50/nv50_context.h b/src/gallium/drivers/nouveau/nv50/nv50_context.h +index cb94c8e..ba005e1 100644 +--- a/src/gallium/drivers/nouveau/nv50/nv50_context.h ++++ b/src/gallium/drivers/nouveau/nv50/nv50_context.h +@@ -219,6 +219,11 @@ void nv50_default_kick_notify(struct nouveau_pushbuf *); + /* nv50_draw.c */ + extern struct draw_stage *nv50_draw_render_stage(struct nv50_context *); + ++/* nv50_query.c */ ++void nv50_render_condition(struct pipe_context *pipe, ++ struct pipe_query *pq, ++ boolean condition, uint mode); ++ + /* nv50_shader_state.c */ + void nv50_vertprog_validate(struct nv50_context *); + void nv50_gmtyprog_validate(struct nv50_context *); +diff --git a/src/gallium/drivers/nouveau/nv50/nv50_query.c b/src/gallium/drivers/nouveau/nv50/nv50_query.c +index 9a1397a..c90e20e 100644 +--- a/src/gallium/drivers/nouveau/nv50/nv50_query.c ++++ b/src/gallium/drivers/nouveau/nv50/nv50_query.c +@@ -70,7 +70,7 @@ nv50_get_query_result(struct pipe_context *pipe, struct pipe_query *pq, + return q->funcs->get_query_result(nv50_context(pipe), q, wait, result); + } + +-static void ++void + nv50_render_condition(struct pipe_context *pipe, + struct pipe_query *pq, + boolean condition, uint mode) +@@ -145,6 +145,16 @@ nv50_render_condition(struct pipe_context *pipe, + } + + static void ++nv50_render_condition_locked(struct pipe_context *pipe, ++ struct pipe_query *pq, ++ boolean condition, uint mode) ++{ ++ pipe_mutex_lock(nouveau_context(pipe)->screen->push_mutex); ++ nv50_render_condition(pipe, pq, condition, mode); ++ pipe_mutex_unlock(nouveau_context(pipe)->screen->push_mutex); ++} ++ ++static void + nv50_set_active_query_state(struct pipe_context *pipe, boolean enable) + { + } +@@ -160,7 +170,7 @@ nv50_init_query_functions(struct nv50_context *nv50) + pipe->end_query = nv50_end_query; + pipe->get_query_result = nv50_get_query_result; + pipe->set_active_query_state = nv50_set_active_query_state; +- pipe->render_condition = nv50_render_condition; ++ pipe->render_condition = nv50_render_condition_locked; + nv50->cond_condmode = NV50_3D_COND_MODE_ALWAYS; + } + +diff --git a/src/gallium/drivers/nouveau/nv50/nv50_query_hw.c b/src/gallium/drivers/nouveau/nv50/nv50_query_hw.c +index 727b509..9067bcc 100644 +--- a/src/gallium/drivers/nouveau/nv50/nv50_query_hw.c ++++ b/src/gallium/drivers/nouveau/nv50/nv50_query_hw.c +@@ -129,6 +129,7 @@ nv50_hw_begin_query(struct nv50_context *nv50, struct nv50_query *q) + { + struct nouveau_pushbuf *push = nv50->base.pushbuf; + struct nv50_hw_query *hq = nv50_hw_query(q); ++ bool ret = true; + + if (hq->funcs && hq->funcs->begin_query) + return hq->funcs->begin_query(nv50, hq); +@@ -154,6 +155,7 @@ nv50_hw_begin_query(struct nv50_context *nv50, struct nv50_query *q) + if (!hq->is64bit) + hq->data[0] = hq->sequence++; /* the previously used one */ + ++ pipe_mutex_lock(nv50->screen->base.push_mutex); + switch (q->type) { + case PIPE_QUERY_OCCLUSION_COUNTER: + case PIPE_QUERY_OCCLUSION_PREDICATE: +@@ -193,10 +195,13 @@ nv50_hw_begin_query(struct nv50_context *nv50, struct nv50_query *q) + break; + default: + assert(0); +- return false; ++ ret = false; ++ break; + } +- hq->state = NV50_HW_QUERY_STATE_ACTIVE; +- return true; ++ pipe_mutex_unlock(nv50->screen->base.push_mutex); ++ if (ret) ++ hq->state = NV50_HW_QUERY_STATE_ACTIVE; ++ return ret; + } + + static void +@@ -212,6 +217,7 @@ nv50_hw_end_query(struct nv50_context *nv50, struct nv50_query *q) + + hq->state = NV50_HW_QUERY_STATE_ENDED; + ++ pipe_mutex_lock(nv50->screen->base.push_mutex); + switch (q->type) { + case PIPE_QUERY_OCCLUSION_COUNTER: + case PIPE_QUERY_OCCLUSION_PREDICATE: +@@ -264,6 +270,7 @@ nv50_hw_end_query(struct nv50_context *nv50, struct nv50_query *q) + assert(0); + break; + } ++ pipe_mutex_unlock(nv50->screen->base.push_mutex); + if (hq->is64bit) + nouveau_fence_ref(nv50->screen->base.fence.current, &hq->fence); + } +@@ -286,16 +293,21 @@ nv50_hw_get_query_result(struct nv50_context *nv50, struct nv50_query *q, + nv50_hw_query_update(q); + + if (hq->state != NV50_HW_QUERY_STATE_READY) { ++ pipe_mutex_lock(nv50->screen->base.push_mutex); + if (!wait) { + /* for broken apps that spin on GL_QUERY_RESULT_AVAILABLE */ + if (hq->state != NV50_HW_QUERY_STATE_FLUSHED) { + hq->state = NV50_HW_QUERY_STATE_FLUSHED; + PUSH_KICK(nv50->base.pushbuf); + } ++ pipe_mutex_unlock(nv50->screen->base.push_mutex); + return false; + } +- if (nouveau_bo_wait(hq->bo, NOUVEAU_BO_RD, nv50->screen->base.client)) ++ if (nouveau_bo_wait(hq->bo, NOUVEAU_BO_RD, nv50->screen->base.client)) { ++ pipe_mutex_unlock(nv50->screen->base.push_mutex); + return false; ++ } ++ pipe_mutex_unlock(nv50->screen->base.push_mutex); + } + hq->state = NV50_HW_QUERY_STATE_READY; + +diff --git a/src/gallium/drivers/nouveau/nv50/nv50_query_hw_sm.c b/src/gallium/drivers/nouveau/nv50/nv50_query_hw_sm.c +index bcfba9f..31445eb 100644 +--- a/src/gallium/drivers/nouveau/nv50/nv50_query_hw_sm.c ++++ b/src/gallium/drivers/nouveau/nv50/nv50_query_hw_sm.c +@@ -176,6 +176,7 @@ nv50_hw_sm_begin_query(struct nv50_context *nv50, struct nv50_hw_query *hq) + return false; + } + ++ pipe_mutex_lock(screen->base.push_mutex); + assert(cfg->num_counters <= 4); + PUSH_SPACE(push, 4 * 4); + +@@ -208,6 +209,7 @@ nv50_hw_sm_begin_query(struct nv50_context *nv50, struct nv50_hw_query *hq) + BEGIN_NV04(push, NV50_CP(MP_PM_SET(c)), 1); + PUSH_DATA (push, 0); + } ++ pipe_mutex_unlock(screen->base.push_mutex); + return true; + } + +@@ -237,6 +239,7 @@ nv50_hw_sm_end_query(struct nv50_context *nv50, struct nv50_hw_query *hq) + screen->pm.prog = prog; + } + ++ pipe_mutex_lock(screen->base.push_mutex); + /* disable all counting */ + PUSH_SPACE(push, 8); + for (c = 0; c < 4; c++) { +@@ -260,6 +263,7 @@ nv50_hw_sm_end_query(struct nv50_context *nv50, struct nv50_hw_query *hq) + PUSH_SPACE(push, 2); + BEGIN_NV04(push, SUBC_CP(NV50_GRAPH_SERIALIZE), 1); + PUSH_DATA (push, 0); ++ pipe_mutex_unlock(screen->base.push_mutex); + + pipe->bind_compute_state(pipe, screen->pm.prog); + input[0] = hq->bo->offset + hq->base_offset; +@@ -276,6 +280,7 @@ nv50_hw_sm_end_query(struct nv50_context *nv50, struct nv50_hw_query *hq) + + nouveau_bufctx_reset(nv50->bufctx_cp, NV50_BIND_CP_QUERY); + ++ pipe_mutex_lock(screen->base.push_mutex); + /* re-active other counters */ + PUSH_SPACE(push, 8); + mask = 0; +@@ -302,6 +307,7 @@ nv50_hw_sm_end_query(struct nv50_context *nv50, struct nv50_hw_query *hq) + | cfg->ctr[i].unit | cfg->ctr[i].mode); + } + } ++ pipe_mutex_unlock(screen->base.push_mutex); + } + + static inline bool +@@ -343,7 +349,9 @@ nv50_hw_sm_get_query_result(struct nv50_context *nv50, struct nv50_hw_query *hq, + + cfg = nv50_hw_sm_query_get_cfg(nv50, hq); + ++ pipe_mutex_lock(nv50->screen->base.push_mutex); + ret = nv50_hw_sm_query_read_data(count, nv50, wait, hq, cfg, mp_count); ++ pipe_mutex_lock(nv50->screen->base.push_mutex); + if (!ret) + return false; + +diff --git a/src/gallium/drivers/nouveau/nv50/nv50_surface.c b/src/gallium/drivers/nouveau/nv50/nv50_surface.c +index fbb5129..164ec72 100644 +--- a/src/gallium/drivers/nouveau/nv50/nv50_surface.c ++++ b/src/gallium/drivers/nouveau/nv50/nv50_surface.c +@@ -204,10 +204,13 @@ nv50_resource_copy_region(struct pipe_context *pipe, + bool m2mf; + unsigned dst_layer = dstz, src_layer = src_box->z; + ++ pipe_mutex_lock(nv50->screen->base.push_mutex); ++ + if (dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER) { + nouveau_copy_buffer(&nv50->base, + nv04_resource(dst), dstx, + nv04_resource(src), src_box->x, src_box->width); ++ pipe_mutex_unlock(nv50->screen->base.push_mutex); + return; + } + +@@ -247,6 +250,7 @@ nv50_resource_copy_region(struct pipe_context *pipe, + else + srect.base += src_mt->layer_stride; + } ++ pipe_mutex_unlock(nv50->screen->base.push_mutex); + return; + } + +@@ -270,6 +274,7 @@ nv50_resource_copy_region(struct pipe_context *pipe, + break; + } + nouveau_bufctx_reset(nv50->bufctx, NV50_BIND_2D); ++ pipe_mutex_unlock(nv50->screen->base.push_mutex); + } + + static void +@@ -288,14 +293,18 @@ nv50_clear_render_target(struct pipe_context *pipe, + + assert(dst->texture->target != PIPE_BUFFER); + ++ pipe_mutex_lock(nv50->screen->base.push_mutex); ++ + BEGIN_NV04(push, NV50_3D(CLEAR_COLOR(0)), 4); + PUSH_DATAf(push, color->f[0]); + PUSH_DATAf(push, color->f[1]); + PUSH_DATAf(push, color->f[2]); + PUSH_DATAf(push, color->f[3]); + +- if (nouveau_pushbuf_space(push, 32 + sf->depth, 1, 0)) ++ if (nouveau_pushbuf_space(push, 32 + sf->depth, 1, 0)) { ++ pipe_mutex_unlock(nv50->screen->base.push_mutex); + return; ++ } + + PUSH_REFN(push, bo, mt->base.domain | NOUVEAU_BO_WR); + +@@ -353,6 +362,8 @@ nv50_clear_render_target(struct pipe_context *pipe, + BEGIN_NV04(push, NV50_3D(COND_MODE), 1); + PUSH_DATA (push, nv50->cond_condmode); + ++ pipe_mutex_unlock(nv50->screen->base.push_mutex); ++ + nv50->dirty_3d |= NV50_NEW_3D_FRAMEBUFFER | NV50_NEW_3D_SCISSOR; + } + +@@ -376,6 +387,8 @@ nv50_clear_depth_stencil(struct pipe_context *pipe, + assert(dst->texture->target != PIPE_BUFFER); + assert(nouveau_bo_memtype(bo)); /* ZETA cannot be linear */ + ++ pipe_mutex_lock(nv50->screen->base.push_mutex); ++ + if (clear_flags & PIPE_CLEAR_DEPTH) { + BEGIN_NV04(push, NV50_3D(CLEAR_DEPTH), 1); + PUSH_DATAf(push, depth); +@@ -388,8 +401,10 @@ nv50_clear_depth_stencil(struct pipe_context *pipe, + mode |= NV50_3D_CLEAR_BUFFERS_S; + } + +- if (nouveau_pushbuf_space(push, 32 + sf->depth, 1, 0)) ++ if (nouveau_pushbuf_space(push, 32 + sf->depth, 1, 0)) { ++ pipe_mutex_unlock(nv50->screen->base.push_mutex); + return; ++ } + + PUSH_REFN(push, bo, mt->base.domain | NOUVEAU_BO_WR); + +@@ -436,6 +451,8 @@ nv50_clear_depth_stencil(struct pipe_context *pipe, + BEGIN_NV04(push, NV50_3D(COND_MODE), 1); + PUSH_DATA (push, nv50->cond_condmode); + ++ pipe_mutex_unlock(nv50->screen->base.push_mutex); ++ + nv50->dirty_3d |= NV50_NEW_3D_FRAMEBUFFER | NV50_NEW_3D_SCISSOR; + } + +@@ -524,9 +541,12 @@ nv50_clear(struct pipe_context *pipe, unsigned buffers, + unsigned i, j, k; + uint32_t mode = 0; + ++ pipe_mutex_lock(nv50->screen->base.push_mutex); + /* don't need NEW_BLEND, COLOR_MASK doesn't affect CLEAR_BUFFERS */ +- if (!nv50_state_validate_3d(nv50, NV50_NEW_3D_FRAMEBUFFER)) ++ if (!nv50_state_validate_3d(nv50, NV50_NEW_3D_FRAMEBUFFER)) { ++ pipe_mutex_unlock(nv50->screen->base.push_mutex); + return; ++ } + + /* We have to clear ALL of the layers, not up to the min number of layers + * of any attachment. */ +@@ -592,6 +612,7 @@ nv50_clear(struct pipe_context *pipe, unsigned buffers, + /* restore the array mode */ + BEGIN_NV04(push, NV50_3D(RT_ARRAY_MODE), 1); + PUSH_DATA (push, nv50->rt_array_mode); ++ pipe_mutex_unlock(nv50->screen->base.push_mutex); + } + + static void +@@ -719,14 +740,18 @@ nv50_clear_buffer(struct pipe_context *pipe, + + assert(size % data_size == 0); + ++ pipe_mutex_lock(nv50->screen->base.push_mutex); ++ + if (offset & 0xff) { + unsigned fixup_size = MIN2(size, align(offset, 0x100) - offset); + assert(fixup_size % data_size == 0); + nv50_clear_buffer_push(pipe, res, offset, fixup_size, data, data_size); + offset += fixup_size; + size -= fixup_size; +- if (!size) ++ if (!size) { ++ pipe_mutex_unlock(nv50->screen->base.push_mutex); + return; ++ } + } + + elements = size / data_size; +@@ -742,8 +767,10 @@ nv50_clear_buffer(struct pipe_context *pipe, + PUSH_DATAf(push, color.f[2]); + PUSH_DATAf(push, color.f[3]); + +- if (nouveau_pushbuf_space(push, 32, 1, 0)) ++ if (nouveau_pushbuf_space(push, 32, 1, 0)) { ++ pipe_mutex_unlock(nv50->screen->base.push_mutex); + return; ++ } + + PUSH_REFN(push, buf->bo, buf->domain | NOUVEAU_BO_WR); + +@@ -798,6 +825,8 @@ nv50_clear_buffer(struct pipe_context *pipe, + data, data_size); + } + ++ pipe_mutex_unlock(nv50->screen->base.push_mutex); ++ + nv50->dirty_3d |= NV50_NEW_3D_FRAMEBUFFER | NV50_NEW_3D_SCISSOR; + } + +@@ -1714,6 +1743,8 @@ nv50_blit(struct pipe_context *pipe, const struct pipe_blit_info *info) + info->src.box.height != -info->dst.box.height)) + eng3d = true; + ++ pipe_mutex_lock(nv50->screen->base.push_mutex); ++ + if (nv50->screen->num_occlusion_queries_active) { + BEGIN_NV04(push, NV50_3D(SAMPLECNT_ENABLE), 1); + PUSH_DATA (push, 0); +@@ -1728,6 +1759,8 @@ nv50_blit(struct pipe_context *pipe, const struct pipe_blit_info *info) + BEGIN_NV04(push, NV50_3D(SAMPLECNT_ENABLE), 1); + PUSH_DATA (push, 1); + } ++ ++ pipe_mutex_unlock(nv50->screen->base.push_mutex); + } + + static void +diff --git a/src/gallium/drivers/nouveau/nv50/nv50_transfer.c b/src/gallium/drivers/nouveau/nv50/nv50_transfer.c +index 8209f1f..c751ade 100644 +--- a/src/gallium/drivers/nouveau/nv50/nv50_transfer.c ++++ b/src/gallium/drivers/nouveau/nv50/nv50_transfer.c +@@ -304,6 +304,7 @@ nv50_miptree_transfer_map(struct pipe_context *pctx, + unsigned base = tx->rect[0].base; + unsigned z = tx->rect[0].z; + unsigned i; ++ pipe_mutex_lock(nv50->screen->base.push_mutex); + for (i = 0; i < box->depth; ++i) { + nv50_m2mf_transfer_rect(nv50, &tx->rect[1], &tx->rect[0], + tx->nblocksx, tx->nblocksy); +@@ -313,6 +314,9 @@ nv50_miptree_transfer_map(struct pipe_context *pctx, + tx->rect[0].base += mt->layer_stride; + tx->rect[1].base += size; + } ++ /* Kick these reads out so we don't have to reacquire a lock below */ ++ PUSH_KICK(nv50->base.pushbuf); ++ pipe_mutex_unlock(nv50->screen->base.push_mutex); + tx->rect[0].z = z; + tx->rect[0].base = base; + tx->rect[1].base = 0; +@@ -349,6 +353,7 @@ nv50_miptree_transfer_unmap(struct pipe_context *pctx, + unsigned i; + + if (tx->base.usage & PIPE_TRANSFER_WRITE) { ++ pipe_mutex_lock(nv50->screen->base.push_mutex); + for (i = 0; i < tx->base.box.depth; ++i) { + nv50_m2mf_transfer_rect(nv50, &tx->rect[0], &tx->rect[1], + tx->nblocksx, tx->nblocksy); +@@ -362,6 +367,7 @@ nv50_miptree_transfer_unmap(struct pipe_context *pctx, + /* Allow the copies above to finish executing before freeing the source */ + nouveau_fence_work(nv50->screen->base.fence.current, + nouveau_fence_unref_bo, tx->rect[1].bo); ++ pipe_mutex_unlock(nv50->screen->base.push_mutex); + } else { + nouveau_bo_ref(NULL, &tx->rect[1].bo); + } +diff --git a/src/gallium/drivers/nouveau/nv50/nv50_vbo.c b/src/gallium/drivers/nouveau/nv50/nv50_vbo.c +index a11cdf8..f73329c 100644 +--- a/src/gallium/drivers/nouveau/nv50/nv50_vbo.c ++++ b/src/gallium/drivers/nouveau/nv50/nv50_vbo.c +@@ -767,6 +767,8 @@ nv50_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) + bool tex_dirty = false; + int s; + ++ pipe_mutex_lock(nv50->screen->base.push_mutex); ++ + /* NOTE: caller must ensure that (min_index + index_bias) is >= 0 */ + nv50->vb_elt_first = info->min_index + info->index_bias; + nv50->vb_elt_limit = info->max_index - info->min_index; +@@ -827,6 +829,7 @@ nv50_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) + nv50_push_vbo(nv50, info); + push->kick_notify = nv50_default_kick_notify; + nouveau_pushbuf_bufctx(push, NULL); ++ pipe_mutex_unlock(nv50->screen->base.push_mutex); + return; + } + +@@ -886,4 +889,6 @@ nv50_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) + nv50_release_user_vbufs(nv50); + + nouveau_pushbuf_bufctx(push, NULL); ++ ++ pipe_mutex_unlock(nv50->screen->base.push_mutex); + } +diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_compute.c b/src/gallium/drivers/nouveau/nvc0/nvc0_compute.c +index 10a4c83..53a0711 100644 +--- a/src/gallium/drivers/nouveau/nvc0/nvc0_compute.c ++++ b/src/gallium/drivers/nouveau/nvc0/nvc0_compute.c +@@ -423,13 +423,17 @@ void + nvc0_launch_grid(struct pipe_context *pipe, const struct pipe_grid_info *info) + { + struct nvc0_context *nvc0 = nvc0_context(pipe); ++ struct nvc0_screen *screen = nvc0->screen; + struct nouveau_pushbuf *push = nvc0->base.pushbuf; + struct nvc0_program *cp = nvc0->compprog; + int ret; + ++ pipe_mutex_lock(screen->base.push_mutex); ++ + ret = !nvc0_state_validate_cp(nvc0, ~0); + if (ret) { + NOUVEAU_ERR("Failed to launch grid !\n"); ++ pipe_mutex_unlock(screen->base.push_mutex); + return; + } + +@@ -497,4 +501,6 @@ nvc0_launch_grid(struct pipe_context *pipe, const struct pipe_grid_info *info) + nouveau_bufctx_reset(nvc0->bufctx_cp, NVC0_BIND_CP_SUF); + nvc0->dirty_cp |= NVC0_NEW_CP_SURFACES; + nvc0->images_dirty[5] |= nvc0->images_valid[5]; ++ ++ pipe_mutex_unlock(screen->base.push_mutex); + } +diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_context.c b/src/gallium/drivers/nouveau/nvc0/nvc0_context.c +index 1137e6c..28d6fec 100644 +--- a/src/gallium/drivers/nouveau/nvc0/nvc0_context.c ++++ b/src/gallium/drivers/nouveau/nvc0/nvc0_context.c +@@ -38,7 +38,9 @@ nvc0_flush(struct pipe_context *pipe, + if (fence) + nouveau_fence_ref(screen->fence.current, (struct nouveau_fence **)fence); + ++ pipe_mutex_lock(screen->push_mutex); + PUSH_KICK(nvc0->base.pushbuf); /* fencing handled in kick_notify */ ++ pipe_mutex_unlock(screen->push_mutex); + + nouveau_context_update_frame_stats(&nvc0->base); + } +@@ -48,8 +50,10 @@ nvc0_texture_barrier(struct pipe_context *pipe) + { + struct nouveau_pushbuf *push = nvc0_context(pipe)->base.pushbuf; + ++ pipe_mutex_lock(nvc0_context(pipe)->screen->base.push_mutex); + IMMED_NVC0(push, NVC0_3D(SERIALIZE), 0); + IMMED_NVC0(push, NVC0_3D(TEX_CACHE_CTL), 0); ++ pipe_mutex_unlock(nvc0_context(pipe)->screen->base.push_mutex); + } + + static void +@@ -59,6 +63,8 @@ nvc0_memory_barrier(struct pipe_context *pipe, unsigned flags) + struct nouveau_pushbuf *push = nvc0->base.pushbuf; + int i, s; + ++ pipe_mutex_lock(nvc0_context(pipe)->screen->base.push_mutex); ++ + if (flags & PIPE_BARRIER_MAPPED_BUFFER) { + for (i = 0; i < nvc0->num_vtxbufs; ++i) { + if (!nvc0->vtxbuf[i].buffer) +@@ -108,6 +114,8 @@ nvc0_memory_barrier(struct pipe_context *pipe, unsigned flags) + nvc0->cb_dirty = true; + if (flags & (PIPE_BARRIER_VERTEX_BUFFER | PIPE_BARRIER_INDEX_BUFFER)) + nvc0->base.vbo_dirty = true; ++ ++ pipe_mutex_unlock(nvc0_context(pipe)->screen->base.push_mutex); + } + + static void +@@ -124,6 +132,7 @@ nvc0_emit_string_marker(struct pipe_context *pipe, const char *str, int len) + data_words = string_words; + else + data_words = string_words + !!(len & 3); ++ pipe_mutex_lock(nvc0_context(pipe)->screen->base.push_mutex); + BEGIN_NIC0(push, SUBC_3D(NV04_GRAPH_NOP), data_words); + if (string_words) + PUSH_DATAp(push, str, string_words); +@@ -132,6 +141,7 @@ nvc0_emit_string_marker(struct pipe_context *pipe, const char *str, int len) + memcpy(&data, &str[string_words * 4], len & 3); + PUSH_DATA (push, data); + } ++ pipe_mutex_unlock(nvc0_context(pipe)->screen->base.push_mutex); + } + + static void +@@ -362,6 +372,8 @@ nvc0_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags) + return NULL; + pipe = &nvc0->base.pipe; + ++ pipe_mutex_lock(screen->base.push_mutex); ++ + if (!nvc0_blitctx_create(nvc0)) + goto out_err; + +@@ -465,9 +477,12 @@ nvc0_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags) + + util_dynarray_init(&nvc0->global_residents); + ++ pipe_mutex_unlock(screen->base.push_mutex); ++ + return pipe; + + out_err: ++ pipe_mutex_unlock(screen->base.push_mutex); + if (nvc0) { + if (nvc0->bufctx_3d) + nouveau_bufctx_del(&nvc0->bufctx_3d); +diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_context.h b/src/gallium/drivers/nouveau/nvc0/nvc0_context.h +index f6d535a..f169b7f 100644 +--- a/src/gallium/drivers/nouveau/nvc0/nvc0_context.h ++++ b/src/gallium/drivers/nouveau/nvc0/nvc0_context.h +@@ -294,6 +294,11 @@ uint32_t nvc0_program_symbol_offset(const struct nvc0_program *, + uint32_t label); + void nvc0_program_init_tcp_empty(struct nvc0_context *); + ++/* nvc0_query.c */ ++void nvc0_render_condition(struct pipe_context *pipe, ++ struct pipe_query *pq, ++ boolean condition, uint mode); ++ + /* nvc0_shader_state.c */ + void nvc0_vertprog_validate(struct nvc0_context *); + void nvc0_tctlprog_validate(struct nvc0_context *); +diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c +index 91fb72f..55d1dc1 100644 +--- a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c ++++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c +@@ -92,7 +92,7 @@ nvc0_get_query_result_resource(struct pipe_context *pipe, + index, resource, offset); + } + +-static void ++void + nvc0_render_condition(struct pipe_context *pipe, + struct pipe_query *pq, + boolean condition, uint mode) +@@ -161,6 +161,16 @@ nvc0_render_condition(struct pipe_context *pipe, + PUSH_DATA (push, hq->bo->offset + hq->offset); + } + ++static void ++nvc0_render_condition_locked(struct pipe_context *pipe, ++ struct pipe_query *pq, ++ boolean condition, uint mode) ++{ ++ pipe_mutex_lock(nouveau_context(pipe)->screen->push_mutex); ++ nvc0_render_condition(pipe, pq, condition, mode); ++ pipe_mutex_unlock(nouveau_context(pipe)->screen->push_mutex); ++} ++ + int + nvc0_screen_get_driver_query_info(struct pipe_screen *pscreen, + unsigned id, +@@ -272,6 +282,6 @@ nvc0_init_query_functions(struct nvc0_context *nvc0) + pipe->get_query_result = nvc0_get_query_result; + pipe->get_query_result_resource = nvc0_get_query_result_resource; + pipe->set_active_query_state = nvc0_set_active_query_state; +- pipe->render_condition = nvc0_render_condition; ++ pipe->render_condition = nvc0_render_condition_locked; + nvc0->cond_condmode = NVC0_3D_COND_MODE_ALWAYS; + } +diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c b/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c +index 4c34593..f2584cb 100644 +--- a/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c ++++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c +@@ -154,6 +154,7 @@ nvc0_hw_begin_query(struct nvc0_context *nvc0, struct nvc0_query *q) + } + hq->sequence++; + ++ pipe_mutex_lock(nvc0->screen->base.push_mutex); + switch (q->type) { + case PIPE_QUERY_OCCLUSION_COUNTER: + case PIPE_QUERY_OCCLUSION_PREDICATE: +@@ -198,6 +199,7 @@ nvc0_hw_begin_query(struct nvc0_context *nvc0, struct nvc0_query *q) + default: + break; + } ++ pipe_mutex_unlock(nvc0->screen->base.push_mutex); + hq->state = NVC0_HW_QUERY_STATE_ACTIVE; + return ret; + } +@@ -221,6 +223,7 @@ nvc0_hw_end_query(struct nvc0_context *nvc0, struct nvc0_query *q) + } + hq->state = NVC0_HW_QUERY_STATE_ENDED; + ++ pipe_mutex_lock(nvc0->screen->base.push_mutex); + switch (q->type) { + case PIPE_QUERY_OCCLUSION_COUNTER: + case PIPE_QUERY_OCCLUSION_PREDICATE: +@@ -276,6 +279,7 @@ nvc0_hw_end_query(struct nvc0_context *nvc0, struct nvc0_query *q) + default: + break; + } ++ pipe_mutex_unlock(nvc0->screen->base.push_mutex); + if (hq->is64bit) + nouveau_fence_ref(nvc0->screen->base.fence.current, &hq->fence); + } +@@ -298,16 +302,21 @@ nvc0_hw_get_query_result(struct nvc0_context *nvc0, struct nvc0_query *q, + nvc0_hw_query_update(nvc0->screen->base.client, q); + + if (hq->state != NVC0_HW_QUERY_STATE_READY) { ++ pipe_mutex_lock(nvc0->screen->base.push_mutex); + if (!wait) { + if (hq->state != NVC0_HW_QUERY_STATE_FLUSHED) { + hq->state = NVC0_HW_QUERY_STATE_FLUSHED; + /* flush for silly apps that spin on GL_QUERY_RESULT_AVAILABLE */ + PUSH_KICK(nvc0->base.pushbuf); + } ++ pipe_mutex_unlock(nvc0->screen->base.push_mutex); + return false; + } +- if (nouveau_bo_wait(hq->bo, NOUVEAU_BO_RD, nvc0->screen->base.client)) ++ if (nouveau_bo_wait(hq->bo, NOUVEAU_BO_RD, nvc0->screen->base.client)) { ++ pipe_mutex_unlock(nvc0->screen->base.push_mutex); + return false; ++ } ++ pipe_mutex_unlock(nvc0->screen->base.push_mutex); + NOUVEAU_DRV_STAT(&nvc0->screen->base, query_sync_count, 1); + } + hq->state = NVC0_HW_QUERY_STATE_READY; +@@ -374,6 +383,8 @@ nvc0_hw_get_query_result_resource(struct nvc0_context *nvc0, + + assert(!hq->funcs || !hq->funcs->get_query_result); + ++ pipe_mutex_lock(nvc0->screen->base.push_mutex); ++ + if (index == -1) { + /* TODO: Use a macro to write the availability of the query */ + if (hq->state != NVC0_HW_QUERY_STATE_READY) +@@ -382,6 +393,7 @@ nvc0_hw_get_query_result_resource(struct nvc0_context *nvc0, + nvc0->base.push_cb(&nvc0->base, buf, offset, + result_type >= PIPE_QUERY_TYPE_I64 ? 2 : 1, + ready); ++ pipe_mutex_unlock(nvc0->screen->base.push_mutex); + return; + } + +@@ -469,6 +481,8 @@ nvc0_hw_get_query_result_resource(struct nvc0_context *nvc0, + 4 | NVC0_IB_ENTRY_1_NO_PREFETCH); + } + ++ pipe_mutex_unlock(nvc0->screen->base.push_mutex); ++ + if (buf->mm) { + nouveau_fence_ref(nvc0->screen->base.fence.current, &buf->fence); + nouveau_fence_ref(nvc0->screen->base.fence.current, &buf->fence_wr); +diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_sm.c b/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_sm.c +index 27cbbc4..d416e00 100644 +--- a/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_sm.c ++++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_sm.c +@@ -1662,6 +1662,7 @@ nve4_hw_sm_begin_query(struct nvc0_context *nvc0, struct nvc0_hw_query *hq) + return false; + } + ++ pipe_mutex_lock(screen->base.push_mutex); + assert(cfg->num_counters <= 4); + PUSH_SPACE(push, 4 * 8 * + 6); + +@@ -1710,6 +1711,7 @@ nve4_hw_sm_begin_query(struct nvc0_context *nvc0, struct nvc0_hw_query *hq) + BEGIN_NVC0(push, NVE4_CP(MP_PM_SET(c)), 1); + PUSH_DATA (push, 0); + } ++ pipe_mutex_unlock(screen->base.push_mutex); + return true; + } + +@@ -1733,6 +1735,7 @@ nvc0_hw_sm_begin_query(struct nvc0_context *nvc0, struct nvc0_hw_query *hq) + return false; + } + ++ pipe_mutex_lock(screen->base.push_mutex); + assert(cfg->num_counters <= 8); + PUSH_SPACE(push, 8 * 8 + 2); + +@@ -1779,6 +1782,7 @@ nvc0_hw_sm_begin_query(struct nvc0_context *nvc0, struct nvc0_hw_query *hq) + BEGIN_NVC0(push, NVC0_CP(MP_PM_SET(c)), 1); + PUSH_DATA (push, 0); + } ++ pipe_mutex_unlock(screen->base.push_mutex); + return true; + } + +@@ -1866,6 +1870,7 @@ nvc0_hw_sm_end_query(struct nvc0_context *nvc0, struct nvc0_hw_query *hq) + if (unlikely(!screen->pm.prog)) + screen->pm.prog = nvc0_hw_sm_get_program(screen); + ++ pipe_mutex_lock(screen->base.push_mutex); + /* disable all counting */ + PUSH_SPACE(push, 8); + for (c = 0; c < 8; ++c) +@@ -1893,6 +1898,7 @@ nvc0_hw_sm_end_query(struct nvc0_context *nvc0, struct nvc0_hw_query *hq) + + /* upload input data for the compute shader which reads MP counters */ + nvc0_hw_sm_upload_input(nvc0, hq); ++ pipe_mutex_unlock(screen->base.push_mutex); + + pipe->bind_compute_state(pipe, screen->pm.prog); + for (i = 0; i < 3; i++) { +@@ -1906,6 +1912,7 @@ nvc0_hw_sm_end_query(struct nvc0_context *nvc0, struct nvc0_hw_query *hq) + + nouveau_bufctx_reset(nvc0->bufctx_cp, NVC0_BIND_CP_QUERY); + ++ pipe_mutex_lock(screen->base.push_mutex); + /* re-activate other counters */ + PUSH_SPACE(push, 16); + mask = 0; +@@ -1930,6 +1937,7 @@ nvc0_hw_sm_end_query(struct nvc0_context *nvc0, struct nvc0_hw_query *hq) + PUSH_DATA (push, (cfg->ctr[i].func << 4) | cfg->ctr[i].mode); + } + } ++ pipe_mutex_unlock(screen->base.push_mutex); + } + + static inline bool +diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c +index e0bfd3b..2a36d42 100644 +--- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c ++++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c +@@ -494,7 +494,9 @@ nvc0_screen_destroy(struct pipe_screen *pscreen) + * _current_ one, and remove both. + */ + nouveau_fence_ref(screen->base.fence.current, ¤t); ++ pipe_mutex_lock(screen->base.push_mutex); + nouveau_fence_wait(current, NULL); ++ pipe_mutex_unlock(screen->base.push_mutex); + nouveau_fence_ref(NULL, ¤t); + nouveau_fence_ref(NULL, &screen->base.fence.current); + } +diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c b/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c +index 7556e71..8a965fce 100644 +--- a/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c ++++ b/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c +@@ -206,11 +206,14 @@ nvc0_resource_copy_region(struct pipe_context *pipe, + bool m2mf; + unsigned dst_layer = dstz, src_layer = src_box->z; + ++ pipe_mutex_lock(nvc0->screen->base.push_mutex); ++ + if (dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER) { + nouveau_copy_buffer(&nvc0->base, + nv04_resource(dst), dstx, + nv04_resource(src), src_box->x, src_box->width); + NOUVEAU_DRV_STAT(&nvc0->screen->base, buf_copy_bytes, src_box->width); ++ pipe_mutex_unlock(nvc0->screen->base.push_mutex); + return; + } + NOUVEAU_DRV_STAT(&nvc0->screen->base, tex_copy_count, 1); +@@ -251,6 +254,7 @@ nvc0_resource_copy_region(struct pipe_context *pipe, + else + srect.base += src_mt->layer_stride; + } ++ pipe_mutex_unlock(nvc0->screen->base.push_mutex); + return; + } + +@@ -273,6 +277,7 @@ nvc0_resource_copy_region(struct pipe_context *pipe, + break; + } + nouveau_bufctx_reset(nvc0->bufctx, 0); ++ pipe_mutex_unlock(nvc0->screen->base.push_mutex); + } + + static void +@@ -290,8 +295,12 @@ nvc0_clear_render_target(struct pipe_context *pipe, + + assert(dst->texture->target != PIPE_BUFFER); + +- if (!PUSH_SPACE(push, 32 + sf->depth)) ++ pipe_mutex_lock(nvc0->screen->base.push_mutex); ++ ++ if (!PUSH_SPACE(push, 32 + sf->depth)) { ++ pipe_mutex_unlock(nvc0->screen->base.push_mutex); + return; ++ } + + PUSH_REFN (push, res->bo, res->domain | NOUVEAU_BO_WR); + +@@ -354,6 +363,8 @@ nvc0_clear_render_target(struct pipe_context *pipe, + IMMED_NVC0(push, NVC0_3D(COND_MODE), nvc0->cond_condmode); + + nvc0->dirty_3d |= NVC0_NEW_3D_FRAMEBUFFER; ++ ++ pipe_mutex_unlock(nvc0->screen->base.push_mutex); + } + + static void +@@ -539,8 +550,11 @@ nvc0_clear_buffer(struct pipe_context *pipe, + + assert(size % data_size == 0); + ++ pipe_mutex_lock(nvc0->screen->base.push_mutex); ++ + if (data_size == 12) { + nvc0_clear_buffer_push(pipe, res, offset, size, data, data_size); ++ pipe_mutex_unlock(nvc0->screen->base.push_mutex); + return; + } + +@@ -550,8 +564,10 @@ nvc0_clear_buffer(struct pipe_context *pipe, + nvc0_clear_buffer_push(pipe, res, offset, fixup_size, data, data_size); + offset += fixup_size; + size -= fixup_size; +- if (!size) ++ if (!size) { ++ pipe_mutex_unlock(nvc0->screen->base.push_mutex); + return; ++ } + } + + elements = size / data_size; +@@ -561,8 +577,10 @@ nvc0_clear_buffer(struct pipe_context *pipe, + width &= ~0xff; + assert(width > 0); + +- if (!PUSH_SPACE(push, 40)) ++ if (!PUSH_SPACE(push, 40)) { ++ pipe_mutex_unlock(nvc0->screen->base.push_mutex); + return; ++ } + + PUSH_REFN (push, buf->bo, buf->domain | NOUVEAU_BO_WR); + +@@ -610,6 +628,8 @@ nvc0_clear_buffer(struct pipe_context *pipe, + } + + nvc0->dirty_3d |= NVC0_NEW_3D_FRAMEBUFFER; ++ ++ pipe_mutex_unlock(nvc0->screen->base.push_mutex); + } + + static void +@@ -631,8 +651,11 @@ nvc0_clear_depth_stencil(struct pipe_context *pipe, + + assert(dst->texture->target != PIPE_BUFFER); + +- if (!PUSH_SPACE(push, 32 + sf->depth)) ++ pipe_mutex_lock(nvc0->screen->base.push_mutex); ++ if (!PUSH_SPACE(push, 32 + sf->depth)) { ++ pipe_mutex_unlock(nvc0->screen->base.push_mutex); + return; ++ } + + PUSH_REFN (push, mt->base.bo, mt->base.domain | NOUVEAU_BO_WR); + +@@ -679,6 +702,8 @@ nvc0_clear_depth_stencil(struct pipe_context *pipe, + IMMED_NVC0(push, NVC0_3D(COND_MODE), nvc0->cond_condmode); + + nvc0->dirty_3d |= NVC0_NEW_3D_FRAMEBUFFER; ++ ++ pipe_mutex_unlock(nvc0->screen->base.push_mutex); + } + + void +@@ -692,9 +717,13 @@ nvc0_clear(struct pipe_context *pipe, unsigned buffers, + unsigned i, j, k; + uint32_t mode = 0; + ++ pipe_mutex_lock(nvc0->screen->base.push_mutex); ++ + /* don't need NEW_BLEND, COLOR_MASK doesn't affect CLEAR_BUFFERS */ +- if (!nvc0_state_validate_3d(nvc0, NVC0_NEW_3D_FRAMEBUFFER)) ++ if (!nvc0_state_validate_3d(nvc0, NVC0_NEW_3D_FRAMEBUFFER)) { ++ pipe_mutex_unlock(nvc0->screen->base.push_mutex); + return; ++ } + + if (buffers & PIPE_CLEAR_COLOR && fb->nr_cbufs) { + BEGIN_NVC0(push, NVC0_3D(CLEAR_COLOR(0)), 4); +@@ -753,6 +782,8 @@ nvc0_clear(struct pipe_context *pipe, unsigned buffers, + (j << NVC0_3D_CLEAR_BUFFERS_LAYER__SHIFT)); + } + } ++ ++ pipe_mutex_unlock(nvc0->screen->base.push_mutex); + } + + +@@ -1157,8 +1188,8 @@ nvc0_blitctx_post_blit(struct nvc0_blitctx *blit) + nvc0->samplers_dirty[4] |= 3; + + if (nvc0->cond_query && !blit->render_condition_enable) +- nvc0->base.pipe.render_condition(&nvc0->base.pipe, nvc0->cond_query, +- nvc0->cond_cond, nvc0->cond_mode); ++ nvc0_render_condition(&nvc0->base.pipe, nvc0->cond_query, ++ nvc0->cond_cond, nvc0->cond_mode); + + nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_3D_VTX_TMP); + nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_3D_FB); +@@ -1620,6 +1651,8 @@ nvc0_blit(struct pipe_context *pipe, const struct pipe_blit_info *info) + if (info->num_window_rectangles > 0 || info->window_rectangle_include) + eng3d = true; + ++ pipe_mutex_lock(nvc0->screen->base.push_mutex); ++ + if (nvc0->screen->num_occlusion_queries_active) + IMMED_NVC0(push, NVC0_3D(SAMPLECNT_ENABLE), 0); + +@@ -1631,6 +1664,8 @@ nvc0_blit(struct pipe_context *pipe, const struct pipe_blit_info *info) + if (nvc0->screen->num_occlusion_queries_active) + IMMED_NVC0(push, NVC0_3D(SAMPLECNT_ENABLE), 1); + ++ pipe_mutex_unlock(nvc0->screen->base.push_mutex); ++ + NOUVEAU_DRV_STAT(&nvc0->screen->base, tex_blit_count, 1); + } + +diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c b/src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c +index 14fb53c..6cb39a9 100644 +--- a/src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c ++++ b/src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c +@@ -342,16 +342,18 @@ nvc0_mt_sync(struct nvc0_context *nvc0, struct nv50_miptree *mt, unsigned usage) + return !mt->base.fence_wr || nouveau_fence_wait(mt->base.fence_wr, &nvc0->base.debug); + } + +-void * +-nvc0_miptree_transfer_map(struct pipe_context *pctx, +- struct pipe_resource *res, +- unsigned level, +- unsigned usage, +- const struct pipe_box *box, +- struct pipe_transfer **ptransfer) ++static void * ++nvc0_miptree_transfer_map_unlocked( ++ struct pipe_context *pctx, ++ struct pipe_resource *res, ++ unsigned level, ++ unsigned usage, ++ const struct pipe_box *box, ++ struct pipe_transfer **ptransfer) + { + struct nvc0_context *nvc0 = nvc0_context(pctx); +- struct nouveau_device *dev = nvc0->screen->base.device; ++ struct nvc0_screen *screen = nvc0->screen; ++ struct nouveau_device *dev = screen->base.device; + struct nv50_miptree *mt = nv50_miptree(res); + struct nvc0_transfer *tx; + uint32_t size; +@@ -465,9 +467,29 @@ nvc0_miptree_transfer_map(struct pipe_context *pctx, + return tx->rect[1].bo->map; + } + +-void +-nvc0_miptree_transfer_unmap(struct pipe_context *pctx, +- struct pipe_transfer *transfer) ++void * ++nvc0_miptree_transfer_map( ++ struct pipe_context *pctx, ++ struct pipe_resource *res, ++ unsigned level, ++ unsigned usage, ++ const struct pipe_box *box, ++ struct pipe_transfer **ptransfer) ++{ ++ struct nvc0_context *nvc0 = nvc0_context(pctx); ++ struct nvc0_screen *screen = nvc0->screen; ++ ++ pipe_mutex_lock(screen->base.push_mutex); ++ void *ret = nvc0_miptree_transfer_map_unlocked( ++ pctx, res, level, usage, box, ptransfer); ++ pipe_mutex_unlock(screen->base.push_mutex); ++ ++ return ret; ++} ++ ++static void ++nvc0_miptree_transfer_unmap_unlocked(struct pipe_context *pctx, ++ struct pipe_transfer *transfer) + { + struct nvc0_context *nvc0 = nvc0_context(pctx); + struct nvc0_transfer *tx = (struct nvc0_transfer *)transfer; +@@ -507,6 +529,18 @@ nvc0_miptree_transfer_unmap(struct pipe_context *pctx, + FREE(tx); + } + ++void ++nvc0_miptree_transfer_unmap(struct pipe_context *pctx, ++ struct pipe_transfer *transfer) ++{ ++ struct nvc0_context *nvc0 = nvc0_context(pctx); ++ struct nvc0_screen *screen = nvc0->screen; ++ ++ pipe_mutex_lock(screen->base.push_mutex); ++ nvc0_miptree_transfer_unmap_unlocked(pctx, transfer); ++ pipe_mutex_unlock(screen->base.push_mutex); ++} ++ + /* This happens rather often with DTD9/st. */ + static void + nvc0_cb_push(struct nouveau_context *nv, +diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c b/src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c +index 4e40ff5..cae621c 100644 +--- a/src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c ++++ b/src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c +@@ -940,6 +940,8 @@ nvc0_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) + struct nvc0_screen *screen = nvc0->screen; + int s; + ++ pipe_mutex_lock(screen->base.push_mutex); ++ + /* NOTE: caller must ensure that (min_index + index_bias) is >= 0 */ + nvc0->vb_elt_first = info->min_index + info->index_bias; + nvc0->vb_elt_limit = info->max_index - info->min_index; +@@ -1033,6 +1035,7 @@ nvc0_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) + nvc0_push_vbo(nvc0, info); + push->kick_notify = nvc0_default_kick_notify; + nouveau_pushbuf_bufctx(push, NULL); ++ pipe_mutex_unlock(screen->base.push_mutex); + return; + } + +@@ -1085,4 +1088,5 @@ nvc0_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) + nvc0_release_user_vbufs(nvc0); + + nouveau_pushbuf_bufctx(push, NULL); ++ pipe_mutex_unlock(screen->base.push_mutex); + } +diff --git a/src/gallium/drivers/nouveau/nvc0/nve4_compute.c b/src/gallium/drivers/nouveau/nvc0/nve4_compute.c +index 27301a1..1c0528c 100644 +--- a/src/gallium/drivers/nouveau/nvc0/nve4_compute.c ++++ b/src/gallium/drivers/nouveau/nvc0/nve4_compute.c +@@ -530,12 +530,15 @@ void + nve4_launch_grid(struct pipe_context *pipe, const struct pipe_grid_info *info) + { + struct nvc0_context *nvc0 = nvc0_context(pipe); ++ struct nvc0_screen *screen = nvc0->screen; + struct nouveau_pushbuf *push = nvc0->base.pushbuf; + struct nve4_cp_launch_desc *desc; + uint64_t desc_gpuaddr; + struct nouveau_bo *desc_bo; + int ret; + ++ pipe_mutex_lock(screen->base.push_mutex); ++ + desc = nve4_compute_alloc_launch_desc(&nvc0->base, &desc_bo, &desc_gpuaddr); + if (!desc) { + ret = -1; +@@ -616,6 +619,7 @@ nve4_launch_grid(struct pipe_context *pipe, const struct pipe_grid_info *info) + NOUVEAU_ERR("Failed to launch grid !\n"); + nouveau_scratch_done(&nvc0->base); + nouveau_bufctx_reset(nvc0->bufctx_cp, NVC0_BIND_CP_DESC); ++ pipe_mutex_unlock(screen->base.push_mutex); + } diff --git a/x11/library/mesa/files/940b3a773f264f3f52574160f0d06c48f8e8aeb2.diff b/x11/library/mesa/files/940b3a773f264f3f52574160f0d06c48f8e8aeb2.diff new file mode 100644 index 0000000000..6b7e0e86d2 --- /dev/null +++ b/x11/library/mesa/files/940b3a773f264f3f52574160f0d06c48f8e8aeb2.diff @@ -0,0 +1,104 @@ +diff --git a/src/gallium/drivers/nouveau/nv30/nv30_draw.c b/src/gallium/drivers/nouveau/nv30/nv30_draw.c +index 10c9f56..c5761a3 100644 +--- a/src/gallium/drivers/nouveau/nv30/nv30_draw.c ++++ b/src/gallium/drivers/nouveau/nv30/nv30_draw.c +@@ -127,6 +127,8 @@ nv30_render_draw_elements(struct vbuf_render *render, + struct nouveau_pushbuf *push = nv30->screen->base.pushbuf; + unsigned i; + ++ pipe_mutex_lock(nv30->screen->base.push_mutex); ++ + BEGIN_NV04(push, NV30_3D(VTXBUF(0)), r->vertex_info.num_attribs); + for (i = 0; i < r->vertex_info.num_attribs; i++) { + PUSH_RESRC(push, NV30_3D(VTXBUF(i)), BUFCTX_VTXTMP, +@@ -134,8 +136,10 @@ nv30_render_draw_elements(struct vbuf_render *render, + NOUVEAU_BO_LOW | NOUVEAU_BO_RD, 0, NV30_3D_VTXBUF_DMA1); + } + +- if (!nv30_state_validate(nv30, ~0, false)) ++ if (!nv30_state_validate(nv30, ~0, false)) { ++ pipe_mutex_unlock(nv30->screen->base.push_mutex); + return; ++ } + + BEGIN_NV04(push, NV30_3D(VERTEX_BEGIN_END), 1); + PUSH_DATA (push, r->prim); +@@ -160,6 +164,8 @@ nv30_render_draw_elements(struct vbuf_render *render, + BEGIN_NV04(push, NV30_3D(VERTEX_BEGIN_END), 1); + PUSH_DATA (push, NV30_3D_VERTEX_BEGIN_END_STOP); + PUSH_RESET(push, BUFCTX_VTXTMP); ++ ++ pipe_mutex_unlock(nv30->screen->base.push_mutex); + } + + static void +@@ -172,6 +178,8 @@ nv30_render_draw_arrays(struct vbuf_render *render, unsigned start, uint nr) + unsigned ps = fn + (pn ? 1 : 0); + unsigned i; + ++ pipe_mutex_lock(nv30->screen->base.push_mutex); ++ + BEGIN_NV04(push, NV30_3D(VTXBUF(0)), r->vertex_info.num_attribs); + for (i = 0; i < r->vertex_info.num_attribs; i++) { + PUSH_RESRC(push, NV30_3D(VTXBUF(i)), BUFCTX_VTXTMP, +@@ -179,8 +187,10 @@ nv30_render_draw_arrays(struct vbuf_render *render, unsigned start, uint nr) + NOUVEAU_BO_LOW | NOUVEAU_BO_RD, 0, NV30_3D_VTXBUF_DMA1); + } + +- if (!nv30_state_validate(nv30, ~0, false)) ++ if (!nv30_state_validate(nv30, ~0, false)) { ++ pipe_mutex_unlock(nv30->screen->base.push_mutex); + return; ++ } + + BEGIN_NV04(push, NV30_3D(VERTEX_BEGIN_END), 1); + PUSH_DATA (push, r->prim); +@@ -197,6 +207,8 @@ nv30_render_draw_arrays(struct vbuf_render *render, unsigned start, uint nr) + BEGIN_NV04(push, NV30_3D(VERTEX_BEGIN_END), 1); + PUSH_DATA (push, NV30_3D_VERTEX_BEGIN_END_STOP); + PUSH_RESET(push, BUFCTX_VTXTMP); ++ ++ pipe_mutex_unlock(nv30->screen->base.push_mutex); + } + + static void +@@ -386,6 +398,8 @@ nv30_render_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) + + nv30_render_validate(nv30); + ++ pipe_mutex_unlock(nv30->screen->base.push_mutex); ++ + if (nv30->draw_dirty & NV30_NEW_VIEWPORT) + draw_set_viewport_states(draw, 0, 1, &nv30->viewport); + if (nv30->draw_dirty & NV30_NEW_RASTERIZER) +@@ -451,6 +465,8 @@ nv30_render_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) + if (transfer[i]) + pipe_buffer_unmap(pipe, transfer[i]); + ++ pipe_mutex_lock(nv30->screen->base.push_mutex); ++ + nv30->draw_dirty = 0; + nv30_state_release(nv30); + } +diff --git a/src/gallium/drivers/nouveau/nv30/nv30_fragprog.c b/src/gallium/drivers/nouveau/nv30/nv30_fragprog.c +index 6de61bc..fd21f99 100644 +--- a/src/gallium/drivers/nouveau/nv30/nv30_fragprog.c ++++ b/src/gallium/drivers/nouveau/nv30/nv30_fragprog.c +@@ -38,6 +38,8 @@ nv30_fragprog_upload(struct nv30_context *nv30) + struct nv30_fragprog *fp = nv30->fragprog.program; + struct pipe_context *pipe = &nv30->base.pipe; + ++ pipe_mutex_unlock(nv->screen->push_mutex); ++ + if (unlikely(!fp->buffer)) + fp->buffer = pipe_buffer_create(pipe->screen, 0, 0, fp->insn_len * 4); + +@@ -60,6 +62,8 @@ nv30_fragprog_upload(struct nv30_context *nv30) + + if (nv04_resource(fp->buffer)->domain != NOUVEAU_BO_VRAM) + nouveau_buffer_migrate(nv, nv04_resource(fp->buffer), NOUVEAU_BO_VRAM); ++ ++ pipe_mutex_lock(nv->screen->push_mutex); + } + + void diff --git a/x11/library/mesa/pspec.xml b/x11/library/mesa/pspec.xml index dbdf59b023..5a098abb7b 100644 --- a/x11/library/mesa/pspec.xml +++ b/x11/library/mesa/pspec.xml @@ -34,11 +34,16 @@ eudev-devel nettle-devel python-mako - llvm - llvm-libs - llvm-clang-devel + llvm + llvm-libs + llvm-clang-devel libxshmfence-devel + + + 2733e5483e1c2b80e4b0ae21187ec5e3e1579397.diff + 940b3a773f264f3f52574160f0d06c48f8e8aeb2.diff + @@ -66,9 +71,9 @@ libomxil-bellagio nettle libxshmfence - llvm - llvm-clang - llvm-libs + llvm + llvm-clang + llvm-libs /etc @@ -135,7 +140,7 @@ libdrm-nouveau-32bit libxshmfence-32bit nettle-32bit - llvm-32bit + llvm-32bit elfutils-32bit @@ -160,7 +165,7 @@ libdrm-nouveau-32bit wayland-32bit mesa - llvm-32bit + llvm-32bit /usr/lib32 @@ -171,6 +176,13 @@ + + 2017-02-05 + 13.0.4 + llvm update + Alihan Öztürk + alihan@pisilinux.org + 2017-02-02 13.0.4 diff --git a/x11/library/pixman/pspec.xml b/x11/library/pixman/pspec.xml index 366e3d5274..f6d1179dfc 100644 --- a/x11/library/pixman/pspec.xml +++ b/x11/library/pixman/pspec.xml @@ -54,6 +54,13 @@ + + 2017-02-05 + 0.34.0 + Rebuild + Alihan Öztürk + alihan@pisilinux.org + 2016-05-02 0.34.0 diff --git a/x11/library/xcb-util-cursor/pspec.xml b/x11/library/xcb-util-cursor/pspec.xml index 6c4e341681..9f0a86a963 100644 --- a/x11/library/xcb-util-cursor/pspec.xml +++ b/x11/library/xcb-util-cursor/pspec.xml @@ -12,7 +12,7 @@ library XCB cursor library The xcb-util-image module provides a number of libraries which sit on top of libxcb, the core X protocol library, and some of the extension libraries. - http://xcb.freedesktop.org/dist/xcb-util-cursor-0.1.2.tar.bz2 + https://xcb.freedesktop.org/dist/xcb-util-cursor-0.1.3.tar.bz2 util-macros libxcb-devel @@ -55,12 +55,10 @@ emul32 libxcb-32bit - xcb-util-image-32bit xcb-util-renderutil-32bit - libxcb-32bit xcb-util-image-32bit xcb-util-renderutil-32bit @@ -71,6 +69,13 @@ + + 2017-02-05 + 0.1.3 + Version bump + PisiLinux Community + admin@pisilinux.org + 2016-04-30 0.1.2 diff --git a/x11/library/xcb-util-image/pspec.xml b/x11/library/xcb-util-image/pspec.xml index 4199ee41a2..29701ae951 100644 --- a/x11/library/xcb-util-image/pspec.xml +++ b/x11/library/xcb-util-image/pspec.xml @@ -54,10 +54,8 @@ libxcb-32bit xcb-util-32bit - - xcb-util-32bit libxcb-32bit @@ -67,6 +65,13 @@ + + 2017-02-05 + 0.4.0 + Rebuild + PisiLinux Community + admin@pisilinux.org + 2016-04-30 0.4.0 diff --git a/x11/library/xcb-util-keysyms/pspec.xml b/x11/library/xcb-util-keysyms/pspec.xml index d88a873c02..e670875580 100644 --- a/x11/library/xcb-util-keysyms/pspec.xml +++ b/x11/library/xcb-util-keysyms/pspec.xml @@ -64,6 +64,13 @@ + + 2017-02-05 + 0.4.0 + Rebuild + PisiLinux Community + admin@pisilinux.org + 2016-04-30 0.4.0 diff --git a/x11/library/xcb-util-renderutil/pspec.xml b/x11/library/xcb-util-renderutil/pspec.xml index 4c554b810a..90af319d42 100644 --- a/x11/library/xcb-util-renderutil/pspec.xml +++ b/x11/library/xcb-util-renderutil/pspec.xml @@ -49,11 +49,9 @@ 32-bit shared libraries for xcb-util-renderutil emul32 - libxcb-32bit - libxcb-32bit @@ -62,6 +60,13 @@ + + 2017-02-05 + 0.3.9 + Rebuild + PisiLinux Community + admin@pisilinux.org + 2016-04-30 0.3.9 diff --git a/x11/library/xcb-util-wm/pspec.xml b/x11/library/xcb-util-wm/pspec.xml index 3fc7ec326c..f9be7652e6 100644 --- a/x11/library/xcb-util-wm/pspec.xml +++ b/x11/library/xcb-util-wm/pspec.xml @@ -63,6 +63,13 @@ + + 2017-02-05 + 0.4.1 + Rebuild + PisiLinux Community + admin@pisilinux.org + 2016-04-30 0.4.1 diff --git a/x11/library/xcb-util/pspec.xml b/x11/library/xcb-util/pspec.xml index 5af56c0b0b..3535698925 100644 --- a/x11/library/xcb-util/pspec.xml +++ b/x11/library/xcb-util/pspec.xml @@ -64,6 +64,13 @@ + + 2017-02-05 + 0.4.0 + Rebuild + PisiLinux Community + admin@pisilinux.org + 2016-04-30 0.4.0