summaryrefslogtreecommitdiff
path: root/lib/mesa/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mesa/src/util')
-rw-r--r--lib/mesa/src/util/Makefile.am44
-rw-r--r--lib/mesa/src/util/Makefile.in400
-rw-r--r--lib/mesa/src/util/Makefile.sources32
-rw-r--r--lib/mesa/src/util/SConscript22
-rw-r--r--lib/mesa/src/util/bitscan.c4
-rw-r--r--lib/mesa/src/util/bitscan.h19
-rw-r--r--lib/mesa/src/util/build_id.c137
-rw-r--r--lib/mesa/src/util/build_id.h (renamed from lib/mesa/src/util/strndup.c)33
-rw-r--r--lib/mesa/src/util/crc32.c121
-rw-r--r--lib/mesa/src/util/crc32.h55
-rw-r--r--lib/mesa/src/util/disk_cache.c1217
-rw-r--r--lib/mesa/src/util/disk_cache.h269
-rw-r--r--lib/mesa/src/util/format_r11g11b10f.h5
-rw-r--r--lib/mesa/src/util/format_srgb.py1
-rw-r--r--lib/mesa/src/util/hash_table.c147
-rw-r--r--lib/mesa/src/util/hash_table.h28
-rw-r--r--lib/mesa/src/util/list.h1
-rw-r--r--lib/mesa/src/util/macros.h21
-rw-r--r--lib/mesa/src/util/mesa-sha1.c285
-rw-r--r--lib/mesa/src/util/mesa-sha1.h31
-rw-r--r--lib/mesa/src/util/mesa-sha1_test.c65
-rw-r--r--lib/mesa/src/util/ralloc.c450
-rw-r--r--lib/mesa/src/util/ralloc.h122
-rw-r--r--lib/mesa/src/util/rand_xor.c99
-rw-r--r--lib/mesa/src/util/rand_xor.h (renamed from lib/mesa/src/util/string_to_uint_map.cpp)37
-rw-r--r--lib/mesa/src/util/register_allocate.h12
-rw-r--r--lib/mesa/src/util/set.c4
-rw-r--r--lib/mesa/src/util/sha1/README62
-rw-r--r--lib/mesa/src/util/sha1/sha1.c174
-rw-r--r--lib/mesa/src/util/sha1/sha1.h53
-rw-r--r--lib/mesa/src/util/slab.c3
-rw-r--r--lib/mesa/src/util/string_to_uint_map.h177
-rw-r--r--lib/mesa/src/util/strndup.h30
-rw-r--r--lib/mesa/src/util/strtod.c12
-rw-r--r--lib/mesa/src/util/tests/hash_table/Makefile.in58
-rw-r--r--lib/mesa/src/util/tests/string_buffer/Makefile.in608
-rw-r--r--lib/mesa/src/util/u_atomic.c203
-rw-r--r--lib/mesa/src/util/u_atomic.h20
-rw-r--r--lib/mesa/src/util/u_dynarray.h166
-rw-r--r--lib/mesa/src/util/u_endian.h20
-rw-r--r--lib/mesa/src/util/u_queue.c440
-rw-r--r--lib/mesa/src/util/u_queue.h138
-rw-r--r--lib/mesa/src/util/u_string.h228
-rw-r--r--lib/mesa/src/util/u_thread.h103
-rw-r--r--lib/mesa/src/util/u_vector.c12
-rw-r--r--lib/mesa/src/util/u_vector.h7
-rw-r--r--lib/mesa/src/util/vk_alloc.h75
-rw-r--r--lib/mesa/src/util/xmlconfig.c9
-rw-r--r--lib/mesa/src/util/xmlpool/Makefile.am2
-rw-r--r--lib/mesa/src/util/xmlpool/Makefile.in115
50 files changed, 4970 insertions, 1406 deletions
diff --git a/lib/mesa/src/util/Makefile.am b/lib/mesa/src/util/Makefile.am
index 4234f24cc..f7ca3a568 100644
--- a/lib/mesa/src/util/Makefile.am
+++ b/lib/mesa/src/util/Makefile.am
@@ -19,13 +19,19 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
-SUBDIRS = . tests/hash_table
+SUBDIRS = . \
+ xmlpool \
+ tests/hash_table \
+ tests/string_buffer
include Makefile.sources
-noinst_LTLIBRARIES = libmesautil.la
+noinst_LTLIBRARIES = \
+ libmesautil.la \
+ libxmlconfig.la
AM_CPPFLAGS = \
+ $(PTHREAD_CFLAGS) \
-I$(top_srcdir)/include
libmesautil_la_CPPFLAGS = \
@@ -36,24 +42,48 @@ libmesautil_la_CPPFLAGS = \
-I$(top_srcdir)/src/mesa \
-I$(top_srcdir)/src/gallium/include \
-I$(top_srcdir)/src/gallium/auxiliary \
- $(SHA1_CFLAGS) \
$(VISIBILITY_CFLAGS) \
- $(MSVC2013_COMPAT_CFLAGS)
+ $(MSVC2013_COMPAT_CFLAGS) \
+ $(ZLIB_CFLAGS)
libmesautil_la_SOURCES = \
$(MESA_UTIL_FILES) \
$(MESA_UTIL_GENERATED_FILES)
-libmesautil_la_LIBADD = $(SHA1_LIBS)
+libmesautil_la_LIBADD = \
+ $(PTHREAD_LIBS) \
+ $(CLOCK_LIB) \
+ $(ZLIB_LIBS) \
+ $(LIBATOMIC_LIBS)
+libxmlconfig_la_SOURCES = $(XMLCONFIG_FILES)
+libxmlconfig_la_CFLAGS = \
+ $(DEFINES) \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/src \
+ -DSYSCONFDIR=\"$(sysconfdir)\" \
+ $(VISIBILITY_CFLAGS) \
+ $(EXPAT_CFLAGS)
+libxmlconfig_la_LIBADD = $(EXPAT_LIBS) -lm
+
+sysconf_DATA =
+
+u_atomic_test_LDADD = libmesautil.la
roundeven_test_LDADD = -lm
+mesa_sha1_test_LDADD = libmesautil.la
-check_PROGRAMS = u_atomic_test roundeven_test
+check_PROGRAMS = u_atomic_test roundeven_test mesa-sha1_test
TESTS = $(check_PROGRAMS)
BUILT_SOURCES = $(MESA_UTIL_GENERATED_FILES)
CLEANFILES = $(BUILT_SOURCES)
-EXTRA_DIST = format_srgb.py SConscript
+EXTRA_DIST = \
+ drirc \
+ format_srgb.py \
+ merge_driinfo.py \
+ SConscript \
+ xmlpool.h \
+ sha1/README
if REGEN_SOURCES
PYTHON_GEN = $(AM_V_GEN)$(PYTHON2) $(PYTHON_FLAGS)
diff --git a/lib/mesa/src/util/Makefile.in b/lib/mesa/src/util/Makefile.in
index ad44f530c..dc63f4ec9 100644
--- a/lib/mesa/src/util/Makefile.in
+++ b/lib/mesa/src/util/Makefile.in
@@ -35,6 +35,7 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
+
VPATH = @srcdir@
am__make_dryrun = \
{ \
@@ -74,10 +75,12 @@ host_triplet = @host@
target_triplet = @target@
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(srcdir)/Makefile.sources $(top_srcdir)/bin/depcomp
-check_PROGRAMS = u_atomic_test$(EXEEXT) roundeven_test$(EXEEXT)
+check_PROGRAMS = u_atomic_test$(EXEEXT) roundeven_test$(EXEEXT) \
+ mesa-sha1_test$(EXEEXT)
subdir = src/util
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_gnu_make.m4 \
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_compile_flag.m4 \
+ $(top_srcdir)/m4/ax_check_gnu_make.m4 \
$(top_srcdir)/m4/ax_check_python_mako_module.m4 \
$(top_srcdir)/m4/ax_gcc_builtin.m4 \
$(top_srcdir)/m4/ax_gcc_func_attribute.m4 \
@@ -94,14 +97,20 @@ CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
am__DEPENDENCIES_1 =
-libmesautil_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
-am__objects_1 = libmesautil_la-bitscan.lo libmesautil_la-debug.lo \
- libmesautil_la-half_float.lo libmesautil_la-hash_table.lo \
- libmesautil_la-mesa-sha1.lo libmesautil_la-ralloc.lo \
- libmesautil_la-register_allocate.lo libmesautil_la-rgtc.lo \
- libmesautil_la-set.lo libmesautil_la-slab.lo \
- libmesautil_la-string_to_uint_map.lo libmesautil_la-strndup.lo \
- libmesautil_la-strtod.lo libmesautil_la-u_vector.lo
+libmesautil_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
+am__dirstamp = $(am__leading_dot)dirstamp
+am__objects_1 = libmesautil_la-bitscan.lo libmesautil_la-build_id.lo \
+ libmesautil_la-crc32.lo libmesautil_la-debug.lo \
+ libmesautil_la-disk_cache.lo libmesautil_la-half_float.lo \
+ libmesautil_la-hash_table.lo libmesautil_la-mesa-sha1.lo \
+ sha1/libmesautil_la-sha1.lo libmesautil_la-ralloc.lo \
+ libmesautil_la-rand_xor.lo libmesautil_la-register_allocate.lo \
+ libmesautil_la-rgtc.lo libmesautil_la-set.lo \
+ libmesautil_la-slab.lo libmesautil_la-string_buffer.lo \
+ libmesautil_la-strtod.lo libmesautil_la-u_atomic.lo \
+ libmesautil_la-u_queue.lo libmesautil_la-u_vector.lo
am__objects_2 = libmesautil_la-format_srgb.lo
am_libmesautil_la_OBJECTS = $(am__objects_1) $(am__objects_2)
libmesautil_la_OBJECTS = $(am_libmesautil_la_OBJECTS)
@@ -109,12 +118,23 @@ AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
+libxmlconfig_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
+am__objects_3 = libxmlconfig_la-xmlconfig.lo
+am_libxmlconfig_la_OBJECTS = $(am__objects_3)
+libxmlconfig_la_OBJECTS = $(am_libxmlconfig_la_OBJECTS)
+libxmlconfig_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
+ $(libxmlconfig_la_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
+ -o $@
+mesa_sha1_test_SOURCES = mesa-sha1_test.c
+mesa_sha1_test_OBJECTS = mesa-sha1_test.$(OBJEXT)
+mesa_sha1_test_DEPENDENCIES = libmesautil.la
roundeven_test_SOURCES = roundeven_test.c
roundeven_test_OBJECTS = roundeven_test.$(OBJEXT)
roundeven_test_DEPENDENCIES =
u_atomic_test_SOURCES = u_atomic_test.c
u_atomic_test_OBJECTS = u_atomic_test.$(OBJEXT)
-u_atomic_test_LDADD = $(LDADD)
+u_atomic_test_DEPENDENCIES = libmesautil.la
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
@@ -149,27 +169,10 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
-CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
- $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
-LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
- $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
- $(AM_CXXFLAGS) $(CXXFLAGS)
-AM_V_CXX = $(am__v_CXX_@AM_V@)
-am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
-am__v_CXX_0 = @echo " CXX " $@;
-am__v_CXX_1 =
-CXXLD = $(CXX)
-CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
- $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
-AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
-am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
-am__v_CXXLD_0 = @echo " CXXLD " $@;
-am__v_CXXLD_1 =
-SOURCES = $(libmesautil_la_SOURCES) roundeven_test.c u_atomic_test.c
-DIST_SOURCES = $(libmesautil_la_SOURCES) roundeven_test.c \
- u_atomic_test.c
+SOURCES = $(libmesautil_la_SOURCES) $(libxmlconfig_la_SOURCES) \
+ mesa-sha1_test.c roundeven_test.c u_atomic_test.c
+DIST_SOURCES = $(libmesautil_la_SOURCES) $(libxmlconfig_la_SOURCES) \
+ mesa-sha1_test.c roundeven_test.c u_atomic_test.c
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-dvi-recursive install-exec-recursive \
@@ -182,6 +185,35 @@ am__can_run_installinfo = \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+ $(am__cd) "$$dir" && rm -f $$files; }; \
+ }
+am__installdirs = "$(DESTDIR)$(sysconfdir)"
+DATA = $(sysconf_DATA)
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
@@ -225,6 +257,8 @@ AMDGPU_CFLAGS = @AMDGPU_CFLAGS@
AMDGPU_LIBS = @AMDGPU_LIBS@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+ANDROID_CFLAGS = @ANDROID_CFLAGS@
+ANDROID_LIBS = @ANDROID_LIBS@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
@@ -255,8 +289,6 @@ DLLTOOL = @DLLTOOL@
DLOPEN_LIBS = @DLOPEN_LIBS@
DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
DRI2PROTO_LIBS = @DRI2PROTO_LIBS@
-DRI3PROTO_CFLAGS = @DRI3PROTO_CFLAGS@
-DRI3PROTO_LIBS = @DRI3PROTO_LIBS@
DRIGL_CFLAGS = @DRIGL_CFLAGS@
DRIGL_LIBS = @DRIGL_LIBS@
DRI_DRIVER_INSTALL_DIR = @DRI_DRIVER_INSTALL_DIR@
@@ -269,10 +301,11 @@ ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGL_CFLAGS = @EGL_CFLAGS@
-EGL_CLIENT_APIS = @EGL_CLIENT_APIS@
EGL_LIB_DEPS = @EGL_LIB_DEPS@
EGL_NATIVE_PLATFORM = @EGL_NATIVE_PLATFORM@
EGREP = @EGREP@
+ETNAVIV_CFLAGS = @ETNAVIV_CFLAGS@
+ETNAVIV_LIBS = @ETNAVIV_LIBS@
EXEEXT = @EXEEXT@
EXPAT_CFLAGS = @EXPAT_CFLAGS@
EXPAT_LIBS = @EXPAT_LIBS@
@@ -299,6 +332,8 @@ GL_PC_LIB_PRIV = @GL_PC_LIB_PRIV@
GL_PC_REQ_PRIV = @GL_PC_REQ_PRIV@
GREP = @GREP@
HAVE_XF86VIDMODE = @HAVE_XF86VIDMODE@
+I915_CFLAGS = @I915_CFLAGS@
+I915_LIBS = @I915_LIBS@
INDENT = @INDENT@
INDENT_FLAGS = @INDENT_FLAGS@
INSTALL = @INSTALL@
@@ -306,45 +341,40 @@ INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-INTEL_CFLAGS = @INTEL_CFLAGS@
-INTEL_LIBS = @INTEL_LIBS@
LD = @LD@
LDFLAGS = @LDFLAGS@
LD_NO_UNDEFINED = @LD_NO_UNDEFINED@
LEX = @LEX@
LEXLIB = @LEXLIB@
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBATOMIC_LIBS = @LIBATOMIC_LIBS@
LIBCLC_INCLUDEDIR = @LIBCLC_INCLUDEDIR@
LIBCLC_LIBEXECDIR = @LIBCLC_LIBEXECDIR@
LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
LIBDRM_LIBS = @LIBDRM_LIBS@
LIBELF_CFLAGS = @LIBELF_CFLAGS@
LIBELF_LIBS = @LIBELF_LIBS@
+LIBGLVND_DATADIR = @LIBGLVND_DATADIR@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
-LIBSENSORS_LDFLAGS = @LIBSENSORS_LDFLAGS@
-LIBSHA1_CFLAGS = @LIBSHA1_CFLAGS@
-LIBSHA1_LIBS = @LIBSHA1_LIBS@
+LIBSENSORS_LIBS = @LIBSENSORS_LIBS@
LIBTOOL = @LIBTOOL@
+LIBUNWIND_CFLAGS = @LIBUNWIND_CFLAGS@
+LIBUNWIND_LIBS = @LIBUNWIND_LIBS@
LIB_DIR = @LIB_DIR@
LIB_EXT = @LIB_EXT@
LIPO = @LIPO@
-LLVM_BINDIR = @LLVM_BINDIR@
LLVM_CFLAGS = @LLVM_CFLAGS@
LLVM_CONFIG = @LLVM_CONFIG@
-LLVM_CPPFLAGS = @LLVM_CPPFLAGS@
LLVM_CXXFLAGS = @LLVM_CXXFLAGS@
LLVM_INCLUDEDIR = @LLVM_INCLUDEDIR@
LLVM_LDFLAGS = @LLVM_LDFLAGS@
-LLVM_LIBDIR = @LLVM_LIBDIR@
LLVM_LIBS = @LLVM_LIBS@
-LLVM_VERSION = @LLVM_VERSION@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
-MESA_LLVM = @MESA_LLVM@
MKDIR_P = @MKDIR_P@
MSVC2013_COMPAT_CFLAGS = @MSVC2013_COMPAT_CFLAGS@
MSVC2013_COMPAT_CXXFLAGS = @MSVC2013_COMPAT_CXXFLAGS@
@@ -360,13 +390,11 @@ NVVIEUX_CFLAGS = @NVVIEUX_CFLAGS@
NVVIEUX_LIBS = @NVVIEUX_LIBS@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
-OMX_CFLAGS = @OMX_CFLAGS@
-OMX_LIBS = @OMX_LIBS@
-OMX_LIB_INSTALL_DIR = @OMX_LIB_INSTALL_DIR@
+OMX_BELLAGIO_CFLAGS = @OMX_BELLAGIO_CFLAGS@
+OMX_BELLAGIO_LIBS = @OMX_BELLAGIO_LIBS@
+OMX_BELLAGIO_LIB_INSTALL_DIR = @OMX_BELLAGIO_LIB_INSTALL_DIR@
OPENCL_LIBNAME = @OPENCL_LIBNAME@
OPENCL_VERSION = @OPENCL_VERSION@
-OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
-OPENSSL_LIBS = @OPENSSL_LIBS@
OSMESA_LIB = @OSMESA_LIB@
OSMESA_LIB_DEPS = @OSMESA_LIB_DEPS@
OSMESA_PC_LIB_PRIV = @OSMESA_PC_LIB_PRIV@
@@ -386,8 +414,6 @@ PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
POSIX_SHELL = @POSIX_SHELL@
-PRESENTPROTO_CFLAGS = @PRESENTPROTO_CFLAGS@
-PRESENTPROTO_LIBS = @PRESENTPROTO_LIBS@
PTHREADSTUBS_CFLAGS = @PTHREADSTUBS_CFLAGS@
PTHREADSTUBS_LIBS = @PTHREADSTUBS_LIBS@
PTHREAD_CC = @PTHREAD_CC@
@@ -403,8 +429,6 @@ SED = @SED@
SELINUX_CFLAGS = @SELINUX_CFLAGS@
SELINUX_LIBS = @SELINUX_LIBS@
SET_MAKE = @SET_MAKE@
-SHA1_CFLAGS = @SHA1_CFLAGS@
-SHA1_LIBS = @SHA1_LIBS@
SHELL = @SHELL@
SIMPENROSE_CFLAGS = @SIMPENROSE_CFLAGS@
SIMPENROSE_LIBS = @SIMPENROSE_LIBS@
@@ -413,7 +437,8 @@ STRIP = @STRIP@
SWR_AVX2_CXXFLAGS = @SWR_AVX2_CXXFLAGS@
SWR_AVX_CXXFLAGS = @SWR_AVX_CXXFLAGS@
SWR_CXX11_CXXFLAGS = @SWR_CXX11_CXXFLAGS@
-TIMESTAMP_CMD = @TIMESTAMP_CMD@
+SWR_KNL_CXXFLAGS = @SWR_KNL_CXXFLAGS@
+SWR_SKX_CXXFLAGS = @SWR_SKX_CXXFLAGS@
VALGRIND_CFLAGS = @VALGRIND_CFLAGS@
VALGRIND_LIBS = @VALGRIND_LIBS@
VA_CFLAGS = @VA_CFLAGS@
@@ -421,25 +446,28 @@ VA_LIBS = @VA_LIBS@
VA_LIB_INSTALL_DIR = @VA_LIB_INSTALL_DIR@
VA_MAJOR = @VA_MAJOR@
VA_MINOR = @VA_MINOR@
-VC4_CFLAGS = @VC4_CFLAGS@
-VC4_LIBS = @VC4_LIBS@
+VC5_SIMULATOR_CFLAGS = @VC5_SIMULATOR_CFLAGS@
+VC5_SIMULATOR_LIBS = @VC5_SIMULATOR_LIBS@
VDPAU_CFLAGS = @VDPAU_CFLAGS@
VDPAU_LIBS = @VDPAU_LIBS@
VDPAU_LIB_INSTALL_DIR = @VDPAU_LIB_INSTALL_DIR@
VDPAU_MAJOR = @VDPAU_MAJOR@
VDPAU_MINOR = @VDPAU_MINOR@
VERSION = @VERSION@
-VG_LIB_DEPS = @VG_LIB_DEPS@
VISIBILITY_CFLAGS = @VISIBILITY_CFLAGS@
VISIBILITY_CXXFLAGS = @VISIBILITY_CXXFLAGS@
VL_CFLAGS = @VL_CFLAGS@
VL_LIBS = @VL_LIBS@
VULKAN_ICD_INSTALL_DIR = @VULKAN_ICD_INSTALL_DIR@
-WAYLAND_CFLAGS = @WAYLAND_CFLAGS@
-WAYLAND_LIBS = @WAYLAND_LIBS@
+WAYLAND_CLIENT_CFLAGS = @WAYLAND_CLIENT_CFLAGS@
+WAYLAND_CLIENT_LIBS = @WAYLAND_CLIENT_LIBS@
+WAYLAND_PROTOCOLS_DATADIR = @WAYLAND_PROTOCOLS_DATADIR@
WAYLAND_SCANNER = @WAYLAND_SCANNER@
WAYLAND_SCANNER_CFLAGS = @WAYLAND_SCANNER_CFLAGS@
WAYLAND_SCANNER_LIBS = @WAYLAND_SCANNER_LIBS@
+WAYLAND_SERVER_CFLAGS = @WAYLAND_SERVER_CFLAGS@
+WAYLAND_SERVER_LIBS = @WAYLAND_SERVER_LIBS@
+WNO_OVERRIDE_INIT = @WNO_OVERRIDE_INIT@
X11_INCLUDES = @X11_INCLUDES@
XA_MAJOR = @XA_MAJOR@
XA_MINOR = @XA_MINOR@
@@ -458,9 +486,10 @@ XVMC_LIBS = @XVMC_LIBS@
XVMC_LIB_INSTALL_DIR = @XVMC_LIB_INSTALL_DIR@
XVMC_MAJOR = @XVMC_MAJOR@
XVMC_MINOR = @XVMC_MINOR@
-XXD = @XXD@
YACC = @YACC@
YFLAGS = @YFLAGS@
+ZLIB_CFLAGS = @ZLIB_CFLAGS@
+ZLIB_LIBS = @ZLIB_LIBS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
@@ -521,26 +550,40 @@ target_vendor = @target_vendor@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-SUBDIRS = . tests/hash_table
+SUBDIRS = . \
+ xmlpool \
+ tests/hash_table \
+ tests/string_buffer
+
MESA_UTIL_FILES := \
bitscan.c \
bitscan.h \
bitset.h \
+ build_id.c \
+ build_id.h \
+ crc32.c \
+ crc32.h \
debug.c \
debug.h \
+ disk_cache.c \
+ disk_cache.h \
format_r11g11b10f.h \
format_rgb9e5.h \
format_srgb.h \
half_float.c \
half_float.h \
- hash_table.c \
+ hash_table.c \
hash_table.h \
list.h \
macros.h \
mesa-sha1.c \
mesa-sha1.h \
+ sha1/sha1.c \
+ sha1/sha1.h \
ralloc.c \
ralloc.h \
+ rand_xor.c \
+ rand_xor.h \
register_allocate.c \
register_allocate.h \
rgtc.c \
@@ -551,24 +594,36 @@ MESA_UTIL_FILES := \
simple_list.h \
slab.c \
slab.h \
- string_to_uint_map.h \
- string_to_uint_map.cpp \
- strndup.c \
+ string_buffer.c \
+ string_buffer.h \
strndup.h \
strtod.c \
strtod.h \
texcompress_rgtc_tmp.h \
+ u_atomic.c \
u_atomic.h \
+ u_dynarray.h \
u_endian.h \
+ u_queue.c \
+ u_queue.h \
+ u_string.h \
+ u_thread.h \
u_vector.c \
- u_vector.h \
- vk_alloc.h
+ u_vector.h
MESA_UTIL_GENERATED_FILES = \
format_srgb.c
-noinst_LTLIBRARIES = libmesautil.la
+XMLCONFIG_FILES := \
+ xmlconfig.c \
+ xmlconfig.h
+
+noinst_LTLIBRARIES = \
+ libmesautil.la \
+ libxmlconfig.la
+
AM_CPPFLAGS = \
+ $(PTHREAD_CFLAGS) \
-I$(top_srcdir)/include
libmesautil_la_CPPFLAGS = \
@@ -579,26 +634,51 @@ libmesautil_la_CPPFLAGS = \
-I$(top_srcdir)/src/mesa \
-I$(top_srcdir)/src/gallium/include \
-I$(top_srcdir)/src/gallium/auxiliary \
- $(SHA1_CFLAGS) \
$(VISIBILITY_CFLAGS) \
- $(MSVC2013_COMPAT_CFLAGS)
+ $(MSVC2013_COMPAT_CFLAGS) \
+ $(ZLIB_CFLAGS)
libmesautil_la_SOURCES = \
$(MESA_UTIL_FILES) \
$(MESA_UTIL_GENERATED_FILES)
-libmesautil_la_LIBADD = $(SHA1_LIBS)
+libmesautil_la_LIBADD = \
+ $(PTHREAD_LIBS) \
+ $(CLOCK_LIB) \
+ $(ZLIB_LIBS) \
+ $(LIBATOMIC_LIBS)
+
+libxmlconfig_la_SOURCES = $(XMLCONFIG_FILES)
+libxmlconfig_la_CFLAGS = \
+ $(DEFINES) \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/src \
+ -DSYSCONFDIR=\"$(sysconfdir)\" \
+ $(VISIBILITY_CFLAGS) \
+ $(EXPAT_CFLAGS)
+
+libxmlconfig_la_LIBADD = $(EXPAT_LIBS) -lm
+sysconf_DATA =
+u_atomic_test_LDADD = libmesautil.la
roundeven_test_LDADD = -lm
+mesa_sha1_test_LDADD = libmesautil.la
TESTS = $(check_PROGRAMS)
BUILT_SOURCES = $(MESA_UTIL_GENERATED_FILES)
CLEANFILES = $(BUILT_SOURCES)
-EXTRA_DIST = format_srgb.py SConscript
+EXTRA_DIST = \
+ drirc \
+ format_srgb.py \
+ merge_driinfo.py \
+ SConscript \
+ xmlpool.h \
+ sha1/README
+
@REGEN_SOURCES_TRUE@PYTHON_GEN = $(AM_V_GEN)$(PYTHON2) $(PYTHON_FLAGS)
all: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) all-recursive
.SUFFIXES:
-.SUFFIXES: .c .cpp .lo .o .obj
+.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/Makefile.sources $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
@@ -641,8 +721,18 @@ clean-noinstLTLIBRARIES:
echo rm -f $${locs}; \
rm -f $${locs}; \
}
+sha1/$(am__dirstamp):
+ @$(MKDIR_P) sha1
+ @: > sha1/$(am__dirstamp)
+sha1/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) sha1/$(DEPDIR)
+ @: > sha1/$(DEPDIR)/$(am__dirstamp)
+sha1/libmesautil_la-sha1.lo: sha1/$(am__dirstamp) \
+ sha1/$(DEPDIR)/$(am__dirstamp)
libmesautil.la: $(libmesautil_la_OBJECTS) $(libmesautil_la_DEPENDENCIES) $(EXTRA_libmesautil_la_DEPENDENCIES)
- $(AM_V_CXXLD)$(CXXLINK) $(libmesautil_la_OBJECTS) $(libmesautil_la_LIBADD) $(LIBS)
+ $(AM_V_CCLD)$(LINK) $(libmesautil_la_OBJECTS) $(libmesautil_la_LIBADD) $(LIBS)
+libxmlconfig.la: $(libxmlconfig_la_OBJECTS) $(libxmlconfig_la_DEPENDENCIES) $(EXTRA_libxmlconfig_la_DEPENDENCIES)
+ $(AM_V_CCLD)$(libxmlconfig_la_LINK) $(libxmlconfig_la_OBJECTS) $(libxmlconfig_la_LIBADD) $(LIBS)
clean-checkPROGRAMS:
@list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
@@ -652,6 +742,9 @@ clean-checkPROGRAMS:
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
echo " rm -f" $$list; \
rm -f $$list
+mesa-sha1_test$(EXEEXT): $(mesa_sha1_test_OBJECTS) $(mesa_sha1_test_DEPENDENCIES) $(EXTRA_mesa_sha1_test_DEPENDENCIES)
+ @rm -f mesa-sha1_test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(mesa_sha1_test_OBJECTS) $(mesa_sha1_test_LDADD) $(LIBS)
roundeven_test$(EXEEXT): $(roundeven_test_OBJECTS) $(roundeven_test_DEPENDENCIES) $(EXTRA_roundeven_test_DEPENDENCIES)
@rm -f roundeven_test$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(roundeven_test_OBJECTS) $(roundeven_test_LDADD) $(LIBS)
@@ -661,27 +754,37 @@ u_atomic_test$(EXEEXT): $(u_atomic_test_OBJECTS) $(u_atomic_test_DEPENDENCIES) $
mostlyclean-compile:
-rm -f *.$(OBJEXT)
+ -rm -f sha1/*.$(OBJEXT)
+ -rm -f sha1/*.lo
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmesautil_la-bitscan.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmesautil_la-build_id.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmesautil_la-crc32.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmesautil_la-debug.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmesautil_la-disk_cache.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmesautil_la-format_srgb.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmesautil_la-half_float.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmesautil_la-hash_table.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmesautil_la-mesa-sha1.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmesautil_la-ralloc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmesautil_la-rand_xor.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmesautil_la-register_allocate.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmesautil_la-rgtc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmesautil_la-set.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmesautil_la-slab.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmesautil_la-string_to_uint_map.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmesautil_la-strndup.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmesautil_la-string_buffer.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmesautil_la-strtod.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmesautil_la-u_atomic.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmesautil_la-u_queue.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmesautil_la-u_vector.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libxmlconfig_la-xmlconfig.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mesa-sha1_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/roundeven_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/u_atomic_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@sha1/$(DEPDIR)/libmesautil_la-sha1.Plo@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@@ -714,6 +817,20 @@ libmesautil_la-bitscan.lo: bitscan.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmesautil_la-bitscan.lo `test -f 'bitscan.c' || echo '$(srcdir)/'`bitscan.c
+libmesautil_la-build_id.lo: build_id.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmesautil_la-build_id.lo -MD -MP -MF $(DEPDIR)/libmesautil_la-build_id.Tpo -c -o libmesautil_la-build_id.lo `test -f 'build_id.c' || echo '$(srcdir)/'`build_id.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmesautil_la-build_id.Tpo $(DEPDIR)/libmesautil_la-build_id.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='build_id.c' object='libmesautil_la-build_id.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmesautil_la-build_id.lo `test -f 'build_id.c' || echo '$(srcdir)/'`build_id.c
+
+libmesautil_la-crc32.lo: crc32.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmesautil_la-crc32.lo -MD -MP -MF $(DEPDIR)/libmesautil_la-crc32.Tpo -c -o libmesautil_la-crc32.lo `test -f 'crc32.c' || echo '$(srcdir)/'`crc32.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmesautil_la-crc32.Tpo $(DEPDIR)/libmesautil_la-crc32.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='crc32.c' object='libmesautil_la-crc32.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmesautil_la-crc32.lo `test -f 'crc32.c' || echo '$(srcdir)/'`crc32.c
+
libmesautil_la-debug.lo: debug.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmesautil_la-debug.lo -MD -MP -MF $(DEPDIR)/libmesautil_la-debug.Tpo -c -o libmesautil_la-debug.lo `test -f 'debug.c' || echo '$(srcdir)/'`debug.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmesautil_la-debug.Tpo $(DEPDIR)/libmesautil_la-debug.Plo
@@ -721,6 +838,13 @@ libmesautil_la-debug.lo: debug.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmesautil_la-debug.lo `test -f 'debug.c' || echo '$(srcdir)/'`debug.c
+libmesautil_la-disk_cache.lo: disk_cache.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmesautil_la-disk_cache.lo -MD -MP -MF $(DEPDIR)/libmesautil_la-disk_cache.Tpo -c -o libmesautil_la-disk_cache.lo `test -f 'disk_cache.c' || echo '$(srcdir)/'`disk_cache.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmesautil_la-disk_cache.Tpo $(DEPDIR)/libmesautil_la-disk_cache.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk_cache.c' object='libmesautil_la-disk_cache.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmesautil_la-disk_cache.lo `test -f 'disk_cache.c' || echo '$(srcdir)/'`disk_cache.c
+
libmesautil_la-half_float.lo: half_float.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmesautil_la-half_float.lo -MD -MP -MF $(DEPDIR)/libmesautil_la-half_float.Tpo -c -o libmesautil_la-half_float.lo `test -f 'half_float.c' || echo '$(srcdir)/'`half_float.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmesautil_la-half_float.Tpo $(DEPDIR)/libmesautil_la-half_float.Plo
@@ -742,6 +866,13 @@ libmesautil_la-mesa-sha1.lo: mesa-sha1.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmesautil_la-mesa-sha1.lo `test -f 'mesa-sha1.c' || echo '$(srcdir)/'`mesa-sha1.c
+sha1/libmesautil_la-sha1.lo: sha1/sha1.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sha1/libmesautil_la-sha1.lo -MD -MP -MF sha1/$(DEPDIR)/libmesautil_la-sha1.Tpo -c -o sha1/libmesautil_la-sha1.lo `test -f 'sha1/sha1.c' || echo '$(srcdir)/'`sha1/sha1.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) sha1/$(DEPDIR)/libmesautil_la-sha1.Tpo sha1/$(DEPDIR)/libmesautil_la-sha1.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sha1/sha1.c' object='sha1/libmesautil_la-sha1.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sha1/libmesautil_la-sha1.lo `test -f 'sha1/sha1.c' || echo '$(srcdir)/'`sha1/sha1.c
+
libmesautil_la-ralloc.lo: ralloc.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmesautil_la-ralloc.lo -MD -MP -MF $(DEPDIR)/libmesautil_la-ralloc.Tpo -c -o libmesautil_la-ralloc.lo `test -f 'ralloc.c' || echo '$(srcdir)/'`ralloc.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmesautil_la-ralloc.Tpo $(DEPDIR)/libmesautil_la-ralloc.Plo
@@ -749,6 +880,13 @@ libmesautil_la-ralloc.lo: ralloc.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmesautil_la-ralloc.lo `test -f 'ralloc.c' || echo '$(srcdir)/'`ralloc.c
+libmesautil_la-rand_xor.lo: rand_xor.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmesautil_la-rand_xor.lo -MD -MP -MF $(DEPDIR)/libmesautil_la-rand_xor.Tpo -c -o libmesautil_la-rand_xor.lo `test -f 'rand_xor.c' || echo '$(srcdir)/'`rand_xor.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmesautil_la-rand_xor.Tpo $(DEPDIR)/libmesautil_la-rand_xor.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rand_xor.c' object='libmesautil_la-rand_xor.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmesautil_la-rand_xor.lo `test -f 'rand_xor.c' || echo '$(srcdir)/'`rand_xor.c
+
libmesautil_la-register_allocate.lo: register_allocate.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmesautil_la-register_allocate.lo -MD -MP -MF $(DEPDIR)/libmesautil_la-register_allocate.Tpo -c -o libmesautil_la-register_allocate.lo `test -f 'register_allocate.c' || echo '$(srcdir)/'`register_allocate.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmesautil_la-register_allocate.Tpo $(DEPDIR)/libmesautil_la-register_allocate.Plo
@@ -777,12 +915,12 @@ libmesautil_la-slab.lo: slab.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmesautil_la-slab.lo `test -f 'slab.c' || echo '$(srcdir)/'`slab.c
-libmesautil_la-strndup.lo: strndup.c
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmesautil_la-strndup.lo -MD -MP -MF $(DEPDIR)/libmesautil_la-strndup.Tpo -c -o libmesautil_la-strndup.lo `test -f 'strndup.c' || echo '$(srcdir)/'`strndup.c
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmesautil_la-strndup.Tpo $(DEPDIR)/libmesautil_la-strndup.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='strndup.c' object='libmesautil_la-strndup.lo' libtool=yes @AMDEPBACKSLASH@
+libmesautil_la-string_buffer.lo: string_buffer.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmesautil_la-string_buffer.lo -MD -MP -MF $(DEPDIR)/libmesautil_la-string_buffer.Tpo -c -o libmesautil_la-string_buffer.lo `test -f 'string_buffer.c' || echo '$(srcdir)/'`string_buffer.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmesautil_la-string_buffer.Tpo $(DEPDIR)/libmesautil_la-string_buffer.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='string_buffer.c' object='libmesautil_la-string_buffer.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmesautil_la-strndup.lo `test -f 'strndup.c' || echo '$(srcdir)/'`strndup.c
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmesautil_la-string_buffer.lo `test -f 'string_buffer.c' || echo '$(srcdir)/'`string_buffer.c
libmesautil_la-strtod.lo: strtod.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmesautil_la-strtod.lo -MD -MP -MF $(DEPDIR)/libmesautil_la-strtod.Tpo -c -o libmesautil_la-strtod.lo `test -f 'strtod.c' || echo '$(srcdir)/'`strtod.c
@@ -791,6 +929,20 @@ libmesautil_la-strtod.lo: strtod.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmesautil_la-strtod.lo `test -f 'strtod.c' || echo '$(srcdir)/'`strtod.c
+libmesautil_la-u_atomic.lo: u_atomic.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmesautil_la-u_atomic.lo -MD -MP -MF $(DEPDIR)/libmesautil_la-u_atomic.Tpo -c -o libmesautil_la-u_atomic.lo `test -f 'u_atomic.c' || echo '$(srcdir)/'`u_atomic.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmesautil_la-u_atomic.Tpo $(DEPDIR)/libmesautil_la-u_atomic.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='u_atomic.c' object='libmesautil_la-u_atomic.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmesautil_la-u_atomic.lo `test -f 'u_atomic.c' || echo '$(srcdir)/'`u_atomic.c
+
+libmesautil_la-u_queue.lo: u_queue.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmesautil_la-u_queue.lo -MD -MP -MF $(DEPDIR)/libmesautil_la-u_queue.Tpo -c -o libmesautil_la-u_queue.lo `test -f 'u_queue.c' || echo '$(srcdir)/'`u_queue.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmesautil_la-u_queue.Tpo $(DEPDIR)/libmesautil_la-u_queue.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='u_queue.c' object='libmesautil_la-u_queue.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmesautil_la-u_queue.lo `test -f 'u_queue.c' || echo '$(srcdir)/'`u_queue.c
+
libmesautil_la-u_vector.lo: u_vector.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmesautil_la-u_vector.lo -MD -MP -MF $(DEPDIR)/libmesautil_la-u_vector.Tpo -c -o libmesautil_la-u_vector.lo `test -f 'u_vector.c' || echo '$(srcdir)/'`u_vector.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmesautil_la-u_vector.Tpo $(DEPDIR)/libmesautil_la-u_vector.Plo
@@ -805,42 +957,40 @@ libmesautil_la-format_srgb.lo: format_srgb.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmesautil_la-format_srgb.lo `test -f 'format_srgb.c' || echo '$(srcdir)/'`format_srgb.c
-.cpp.o:
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
-@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
-@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<
-
-.cpp.obj:
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
-@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
-@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
-
-.cpp.lo:
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
-@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
-@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
-
-libmesautil_la-string_to_uint_map.lo: string_to_uint_map.cpp
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libmesautil_la-string_to_uint_map.lo -MD -MP -MF $(DEPDIR)/libmesautil_la-string_to_uint_map.Tpo -c -o libmesautil_la-string_to_uint_map.lo `test -f 'string_to_uint_map.cpp' || echo '$(srcdir)/'`string_to_uint_map.cpp
-@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmesautil_la-string_to_uint_map.Tpo $(DEPDIR)/libmesautil_la-string_to_uint_map.Plo
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='string_to_uint_map.cpp' object='libmesautil_la-string_to_uint_map.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmesautil_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libmesautil_la-string_to_uint_map.lo `test -f 'string_to_uint_map.cpp' || echo '$(srcdir)/'`string_to_uint_map.cpp
+libxmlconfig_la-xmlconfig.lo: xmlconfig.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxmlconfig_la_CFLAGS) $(CFLAGS) -MT libxmlconfig_la-xmlconfig.lo -MD -MP -MF $(DEPDIR)/libxmlconfig_la-xmlconfig.Tpo -c -o libxmlconfig_la-xmlconfig.lo `test -f 'xmlconfig.c' || echo '$(srcdir)/'`xmlconfig.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libxmlconfig_la-xmlconfig.Tpo $(DEPDIR)/libxmlconfig_la-xmlconfig.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='xmlconfig.c' object='libxmlconfig_la-xmlconfig.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxmlconfig_la_CFLAGS) $(CFLAGS) -c -o libxmlconfig_la-xmlconfig.lo `test -f 'xmlconfig.c' || echo '$(srcdir)/'`xmlconfig.c
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
+ -rm -rf sha1/.libs sha1/_libs
+install-sysconfDATA: $(sysconf_DATA)
+ @$(NORMAL_INSTALL)
+ @list='$(sysconf_DATA)'; test -n "$(sysconfdir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(sysconfdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(sysconfdir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(sysconfdir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(sysconfdir)" || exit $$?; \
+ done
+
+uninstall-sysconfDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(sysconf_DATA)'; test -n "$(sysconfdir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ dir='$(DESTDIR)$(sysconfdir)'; $(am__uninstall_files_from_dir)
# This directory's subdirectories are mostly independent; you can cd
# into them and run 'make' without going through this Makefile.
@@ -1121,9 +1271,12 @@ check-am: all-am
$(MAKE) $(AM_MAKEFLAGS) check-TESTS
check: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) check-recursive
-all-am: Makefile $(LTLIBRARIES)
+all-am: Makefile $(LTLIBRARIES) $(DATA)
installdirs: installdirs-recursive
installdirs-am:
+ for dir in "$(DESTDIR)$(sysconfdir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
install: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) install-recursive
install-exec: install-exec-recursive
@@ -1152,6 +1305,8 @@ clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+ -rm -f sha1/$(DEPDIR)/$(am__dirstamp)
+ -rm -f sha1/$(am__dirstamp)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@@ -1163,7 +1318,7 @@ clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
clean-noinstLTLIBRARIES mostlyclean-am
distclean: distclean-recursive
- -rm -rf ./$(DEPDIR)
+ -rm -rf ./$(DEPDIR) sha1/$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
@@ -1186,7 +1341,7 @@ install-dvi: install-dvi-recursive
install-dvi-am:
-install-exec-am:
+install-exec-am: install-sysconfDATA
install-html: install-html-recursive
@@ -1209,7 +1364,7 @@ install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
- -rm -rf ./$(DEPDIR)
+ -rm -rf ./$(DEPDIR) sha1/$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
@@ -1226,7 +1381,7 @@ ps: ps-recursive
ps-am:
-uninstall-am:
+uninstall-am: uninstall-sysconfDATA
.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all check \
check-am cscopelist-recursive ctags-recursive install \
@@ -1242,11 +1397,12 @@ uninstall-am:
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
- install-ps install-ps-am install-strip installcheck \
- installcheck-am installdirs installdirs-am maintainer-clean \
- maintainer-clean-generic mostlyclean mostlyclean-compile \
- mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
- tags tags-recursive uninstall uninstall-am
+ install-ps install-ps-am install-strip install-sysconfDATA \
+ installcheck installcheck-am installdirs installdirs-am \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \
+ uninstall-sysconfDATA
@REGEN_SOURCES_TRUE@format_srgb.c: format_srgb.py
diff --git a/lib/mesa/src/util/Makefile.sources b/lib/mesa/src/util/Makefile.sources
index c5531c82d..c7f6516a9 100644
--- a/lib/mesa/src/util/Makefile.sources
+++ b/lib/mesa/src/util/Makefile.sources
@@ -1,22 +1,32 @@
-MESA_UTIL_FILES := \
+MESA_UTIL_FILES := \
bitscan.c \
bitscan.h \
bitset.h \
+ build_id.c \
+ build_id.h \
+ crc32.c \
+ crc32.h \
debug.c \
debug.h \
+ disk_cache.c \
+ disk_cache.h \
format_r11g11b10f.h \
format_rgb9e5.h \
format_srgb.h \
half_float.c \
half_float.h \
- hash_table.c \
+ hash_table.c \
hash_table.h \
list.h \
macros.h \
mesa-sha1.c \
mesa-sha1.h \
+ sha1/sha1.c \
+ sha1/sha1.h \
ralloc.c \
ralloc.h \
+ rand_xor.c \
+ rand_xor.h \
register_allocate.c \
register_allocate.h \
rgtc.c \
@@ -27,18 +37,26 @@ MESA_UTIL_FILES := \
simple_list.h \
slab.c \
slab.h \
- string_to_uint_map.h \
- string_to_uint_map.cpp \
- strndup.c \
+ string_buffer.c \
+ string_buffer.h \
strndup.h \
strtod.c \
strtod.h \
texcompress_rgtc_tmp.h \
+ u_atomic.c \
u_atomic.h \
+ u_dynarray.h \
u_endian.h \
+ u_queue.c \
+ u_queue.h \
+ u_string.h \
+ u_thread.h \
u_vector.c \
- u_vector.h \
- vk_alloc.h
+ u_vector.h
MESA_UTIL_GENERATED_FILES = \
format_srgb.c
+
+XMLCONFIG_FILES := \
+ xmlconfig.c \
+ xmlconfig.h
diff --git a/lib/mesa/src/util/SConscript b/lib/mesa/src/util/SConscript
index 73f343039..66a0d1c04 100644
--- a/lib/mesa/src/util/SConscript
+++ b/lib/mesa/src/util/SConscript
@@ -10,6 +10,7 @@ env.MSVC2013Compat()
env.Prepend(CPPPATH = [
'#include',
+ xmlpool_options.dir.dir, # Dir to generated xmlpool/options.h
'#src',
'#src/mapi',
'#src/mesa',
@@ -33,12 +34,16 @@ mesautil_sources = (
source_lists['MESA_UTIL_GENERATED_FILES']
)
-# XXX We don't yet have scons support for detecting any of the various
-# HAVE_SHA1_* definitions, so for now simply disable the shader cache.
-if False:
- mesautil_sources += source_lists['MESA_UTIL_SHADER_CACHE_FILES']
+mesautilenv = env.Clone()
-mesautil = env.ConvenienceLibrary(
+if env['dri']:
+ mesautil_sources += source_lists['XMLCONFIG_FILES']
+
+ mesautilenv.AppendUnique(LIBS = [
+ 'expat',
+ ])
+
+mesautil = mesautilenv.ConvenienceLibrary(
target = 'mesautil',
source = mesautil_sources,
)
@@ -58,3 +63,10 @@ roundeven_test = env.Program(
source = ['roundeven_test.c'],
)
env.UnitTest("roundeven_test", roundeven_test)
+
+env.Prepend(LIBS = [mesautil])
+mesa_sha1_test = env.Program(
+ target = 'mesa-sha1_test',
+ source = ['mesa-sha1_test.c'],
+)
+env.UnitTest("mesa-sha1_test", mesa_sha1_test)
diff --git a/lib/mesa/src/util/bitscan.c b/lib/mesa/src/util/bitscan.c
index ceca59eba..7858291bf 100644
--- a/lib/mesa/src/util/bitscan.c
+++ b/lib/mesa/src/util/bitscan.c
@@ -32,7 +32,7 @@
#elif defined(_MSC_VER) && (_M_IX86 || _M_ARM || _M_AMD64 || _M_IA64)
#else
int
-ffs(unsigned i)
+ffs(int i)
{
int bit = 0;
if (!i)
@@ -63,7 +63,7 @@ ffs(unsigned i)
#elif defined(_MSC_VER) && (_M_AMD64 || _M_ARM || _M_IA64)
#else
int
-ffsll(uint64_t val)
+ffsll(long long int val)
{
int bit;
diff --git a/lib/mesa/src/util/bitscan.h b/lib/mesa/src/util/bitscan.h
index a5dfa1f9e..611e81205 100644
--- a/lib/mesa/src/util/bitscan.h
+++ b/lib/mesa/src/util/bitscan.h
@@ -52,7 +52,7 @@ extern "C" {
#define ffs __builtin_ffs
#elif defined(_MSC_VER) && (_M_IX86 || _M_ARM || _M_AMD64 || _M_IA64)
static inline
-int ffs(unsigned i)
+int ffs(int i)
{
unsigned long index;
if (_BitScanForward(&index, i))
@@ -62,14 +62,14 @@ int ffs(unsigned i)
}
#else
extern
-int ffs(unsigned i);
+int ffs(int i);
#endif
#ifdef HAVE___BUILTIN_FFSLL
#define ffsll __builtin_ffsll
#elif defined(_MSC_VER) && (_M_AMD64 || _M_ARM || _M_IA64)
static inline int
-ffsll(uint64_t i)
+ffsll(long long int i)
{
unsigned long index;
if (_BitScanForward64(&index, i))
@@ -79,7 +79,7 @@ ffsll(uint64_t i)
}
#else
extern int
-ffsll(uint64_t val);
+ffsll(long long int val);
#endif
@@ -136,7 +136,7 @@ u_bit_scan_consecutive_range(unsigned *mask, int *start, int *count)
static inline void
u_bit_scan_consecutive_range64(uint64_t *mask, int *start, int *count)
{
- if (*mask == ~0llu) {
+ if (*mask == ~0ull) {
*start = 0;
*count = 64;
*mask = 0;
@@ -226,6 +226,15 @@ u_bit_consecutive(unsigned start, unsigned count)
return ((1u << count) - 1) << start;
}
+static inline uint64_t
+u_bit_consecutive64(unsigned start, unsigned count)
+{
+ assert(start + count <= 64);
+ if (count == 64)
+ return ~(uint64_t)0;
+ return (((uint64_t)1 << count) - 1) << start;
+}
+
#ifdef __cplusplus
}
diff --git a/lib/mesa/src/util/build_id.c b/lib/mesa/src/util/build_id.c
new file mode 100644
index 000000000..fb67d160e
--- /dev/null
+++ b/lib/mesa/src/util/build_id.c
@@ -0,0 +1,137 @@
+/*
+ * Copyright © 2016 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_DL_ITERATE_PHDR
+#include <dlfcn.h>
+#include <link.h>
+#include <stddef.h>
+#include <string.h>
+
+#include "build_id.h"
+
+#ifndef NT_GNU_BUILD_ID
+#define NT_GNU_BUILD_ID 3
+#endif
+
+#ifndef ElfW
+#define ElfW(type) Elf_##type
+#endif
+
+#define ALIGN(val, align) (((val) + (align) - 1) & ~((align) - 1))
+
+struct build_id_note {
+ ElfW(Nhdr) nhdr;
+
+ char name[4]; /* Note name for build-id is "GNU\0" */
+ uint8_t build_id[0];
+};
+
+struct callback_data {
+ /* Base address of shared object, taken from Dl_info::dli_fbase */
+ const void *dli_fbase;
+
+ struct build_id_note *note;
+};
+
+static int
+build_id_find_nhdr_callback(struct dl_phdr_info *info, size_t size, void *data_)
+{
+ struct callback_data *data = data_;
+
+ /* Calculate address where shared object is mapped into the process space.
+ * (Using the base address and the virtual address of the first LOAD segment)
+ */
+ void *map_start = NULL;
+ for (unsigned i = 0; i < info->dlpi_phnum; i++) {
+ if (info->dlpi_phdr[i].p_type == PT_LOAD) {
+ map_start = (void *)(info->dlpi_addr + info->dlpi_phdr[i].p_vaddr);
+ break;
+ }
+ }
+
+ if (map_start != data->dli_fbase)
+ return 0;
+
+ for (unsigned i = 0; i < info->dlpi_phnum; i++) {
+ if (info->dlpi_phdr[i].p_type != PT_NOTE)
+ continue;
+
+ struct build_id_note *note = (void *)(info->dlpi_addr +
+ info->dlpi_phdr[i].p_vaddr);
+ ptrdiff_t len = info->dlpi_phdr[i].p_filesz;
+
+ while (len >= sizeof(struct build_id_note)) {
+ if (note->nhdr.n_type == NT_GNU_BUILD_ID &&
+ note->nhdr.n_descsz != 0 &&
+ note->nhdr.n_namesz == 4 &&
+ memcmp(note->name, "GNU", 4) == 0) {
+ data->note = note;
+ return 1;
+ }
+
+ size_t offset = sizeof(ElfW(Nhdr)) +
+ ALIGN(note->nhdr.n_namesz, 4) +
+ ALIGN(note->nhdr.n_descsz, 4);
+ note = (struct build_id_note *)((char *)note + offset);
+ len -= offset;
+ }
+ }
+
+ return 0;
+}
+
+const struct build_id_note *
+build_id_find_nhdr_for_addr(const void *addr)
+{
+ Dl_info info;
+
+ if (!dladdr(addr, &info))
+ return NULL;
+
+ if (!info.dli_fbase)
+ return NULL;
+
+ struct callback_data data = {
+ .dli_fbase = info.dli_fbase,
+ .note = NULL,
+ };
+
+ if (!dl_iterate_phdr(build_id_find_nhdr_callback, &data))
+ return NULL;
+
+ return data.note;
+}
+
+unsigned
+build_id_length(const struct build_id_note *note)
+{
+ return note->nhdr.n_descsz;
+}
+
+const uint8_t *
+build_id_data(const struct build_id_note *note)
+{
+ return note->build_id;
+}
+
+#endif
diff --git a/lib/mesa/src/util/strndup.c b/lib/mesa/src/util/build_id.h
index 5ceb32fe4..86d611d8d 100644
--- a/lib/mesa/src/util/strndup.c
+++ b/lib/mesa/src/util/build_id.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 Intel Corporation
+ * Copyright © 2016 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -21,27 +21,22 @@
* IN THE SOFTWARE.
*/
-#if defined(_WIN32)
-#include <stdlib.h>
-#include <string.h>
-#include "strndup.h"
+#ifndef BUILD_ID_H
+#define BUILD_ID_H
-char *
-strndup(const char *str, size_t max)
-{
- size_t n;
- char *ptr;
+#ifdef HAVE_DL_ITERATE_PHDR
- if (!str)
- return NULL;
+struct build_id_note;
- n = strnlen(str, max);
- ptr = (char *) calloc(n + 1, sizeof(char));
- if (!ptr)
- return NULL;
+const struct build_id_note *
+build_id_find_nhdr_for_addr(const void *addr);
- memcpy(ptr, str, n);
- return ptr;
-}
+unsigned
+build_id_length(const struct build_id_note *note);
+
+const uint8_t *
+build_id_data(const struct build_id_note *note);
#endif
+
+#endif /* BUILD_ID_H */
diff --git a/lib/mesa/src/util/crc32.c b/lib/mesa/src/util/crc32.c
new file mode 100644
index 000000000..44d637c0f
--- /dev/null
+++ b/lib/mesa/src/util/crc32.c
@@ -0,0 +1,121 @@
+/**************************************************************************
+ *
+ * Copyright 2008 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * @file
+ * CRC32 implementation.
+ *
+ * @author Jose Fonseca
+ */
+
+
+#include "crc32.h"
+
+
+static const uint32_t
+util_crc32_table[256] = {
+ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
+ 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
+ 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
+ 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
+ 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
+ 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
+ 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
+ 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
+ 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
+ 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
+ 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940,
+ 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
+ 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116,
+ 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
+ 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
+ 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
+ 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a,
+ 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
+ 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
+ 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
+ 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
+ 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
+ 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
+ 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
+ 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
+ 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
+ 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
+ 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
+ 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
+ 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
+ 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
+ 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
+ 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
+ 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
+ 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
+ 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
+ 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
+ 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
+ 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
+ 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
+ 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
+ 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
+ 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
+ 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
+ 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
+ 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
+ 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
+ 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
+ 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
+ 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
+ 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
+ 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
+ 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
+ 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
+ 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
+ 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
+ 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
+ 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
+ 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
+ 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
+ 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
+ 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
+ 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
+ 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
+};
+
+
+/**
+ * @sa http://www.w3.org/TR/PNG/#D-CRCAppendix
+ */
+uint32_t
+util_hash_crc32(const void *data, size_t size)
+{
+ uint8_t *p = (uint8_t *)data;
+ uint32_t crc = 0xffffffff;
+
+ while (size--)
+ crc = util_crc32_table[(crc ^ *p++) & 0xff] ^ (crc >> 8);
+
+ return crc;
+}
diff --git a/lib/mesa/src/util/crc32.h b/lib/mesa/src/util/crc32.h
new file mode 100644
index 000000000..b6a21f417
--- /dev/null
+++ b/lib/mesa/src/util/crc32.h
@@ -0,0 +1,55 @@
+/**************************************************************************
+ *
+ * Copyright 2008 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * @file
+ * CRC32 function.
+ *
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
+
+#ifndef CRC32_H_
+#define CRC32_H_
+
+#include <stdlib.h>
+#include <stdint.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+uint32_t
+util_hash_crc32(const void *data, size_t size);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CRC32_H_ */
diff --git a/lib/mesa/src/util/disk_cache.c b/lib/mesa/src/util/disk_cache.c
new file mode 100644
index 000000000..80c8203a7
--- /dev/null
+++ b/lib/mesa/src/util/disk_cache.c
@@ -0,0 +1,1217 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifdef ENABLE_SHADER_CACHE
+
+#include <ctype.h>
+#include <ftw.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/file.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <pwd.h>
+#include <errno.h>
+#include <dirent.h>
+#include "zlib.h"
+
+#include "util/crc32.h"
+#include "util/debug.h"
+#include "util/rand_xor.h"
+#include "util/u_atomic.h"
+#include "util/u_queue.h"
+#include "util/mesa-sha1.h"
+#include "util/ralloc.h"
+#include "main/errors.h"
+
+#include "disk_cache.h"
+
+/* Number of bits to mask off from a cache key to get an index. */
+#define CACHE_INDEX_KEY_BITS 16
+
+/* Mask for computing an index from a key. */
+#define CACHE_INDEX_KEY_MASK ((1 << CACHE_INDEX_KEY_BITS) - 1)
+
+/* The number of keys that can be stored in the index. */
+#define CACHE_INDEX_MAX_KEYS (1 << CACHE_INDEX_KEY_BITS)
+
+/* The cache version should be bumped whenever a change is made to the
+ * structure of cache entries or the index. This will give any 3rd party
+ * applications reading the cache entries a chance to adjust to the changes.
+ *
+ * - The cache version is checked internally when reading a cache entry. If we
+ * ever have a mismatch we are in big trouble as this means we had a cache
+ * collision. In case of such an event please check the skys for giant
+ * asteroids and that the entire Mesa team hasn't been eaten by wolves.
+ *
+ * - There is no strict requirement that cache versions be backwards
+ * compatible but effort should be taken to limit disruption where possible.
+ */
+#define CACHE_VERSION 1
+
+struct disk_cache {
+ /* The path to the cache directory. */
+ char *path;
+
+ /* Thread queue for compressing and writing cache entries to disk */
+ struct util_queue cache_queue;
+
+ /* Seed for rand, which is used to pick a random directory */
+ uint64_t seed_xorshift128plus[2];
+
+ /* A pointer to the mmapped index file within the cache directory. */
+ uint8_t *index_mmap;
+ size_t index_mmap_size;
+
+ /* Pointer to total size of all objects in cache (within index_mmap) */
+ uint64_t *size;
+
+ /* Pointer to stored keys, (within index_mmap). */
+ uint8_t *stored_keys;
+
+ /* Maximum size of all cached objects (in bytes). */
+ uint64_t max_size;
+
+ /* Driver cache keys. */
+ uint8_t *driver_keys_blob;
+ size_t driver_keys_blob_size;
+};
+
+struct disk_cache_put_job {
+ struct util_queue_fence fence;
+
+ struct disk_cache *cache;
+
+ cache_key key;
+
+ /* Copy of cache data to be compressed and written. */
+ void *data;
+
+ /* Size of data to be compressed and written. */
+ size_t size;
+
+ struct cache_item_metadata cache_item_metadata;
+};
+
+/* Create a directory named 'path' if it does not already exist.
+ *
+ * Returns: 0 if path already exists as a directory or if created.
+ * -1 in all other cases.
+ */
+static int
+mkdir_if_needed(const char *path)
+{
+ struct stat sb;
+
+ /* If the path exists already, then our work is done if it's a
+ * directory, but it's an error if it is not.
+ */
+ if (stat(path, &sb) == 0) {
+ if (S_ISDIR(sb.st_mode)) {
+ return 0;
+ } else {
+ fprintf(stderr, "Cannot use %s for shader cache (not a directory)"
+ "---disabling.\n", path);
+ return -1;
+ }
+ }
+
+ int ret = mkdir(path, 0755);
+ if (ret == 0 || (ret == -1 && errno == EEXIST))
+ return 0;
+
+ fprintf(stderr, "Failed to create %s for shader cache (%s)---disabling.\n",
+ path, strerror(errno));
+
+ return -1;
+}
+
+/* Concatenate an existing path and a new name to form a new path. If the new
+ * path does not exist as a directory, create it then return the resulting
+ * name of the new path (ralloc'ed off of 'ctx').
+ *
+ * Returns NULL on any error, such as:
+ *
+ * <path> does not exist or is not a directory
+ * <path>/<name> exists but is not a directory
+ * <path>/<name> cannot be created as a directory
+ */
+static char *
+concatenate_and_mkdir(void *ctx, const char *path, const char *name)
+{
+ char *new_path;
+ struct stat sb;
+
+ if (stat(path, &sb) != 0 || ! S_ISDIR(sb.st_mode))
+ return NULL;
+
+ new_path = ralloc_asprintf(ctx, "%s/%s", path, name);
+
+ if (mkdir_if_needed(new_path) == 0)
+ return new_path;
+ else
+ return NULL;
+}
+
+#define DRV_KEY_CPY(_dst, _src, _src_size) \
+do { \
+ memcpy(_dst, _src, _src_size); \
+ _dst += _src_size; \
+} while (0);
+
+struct disk_cache *
+disk_cache_create(const char *gpu_name, const char *timestamp,
+ uint64_t driver_flags)
+{
+ void *local;
+ struct disk_cache *cache = NULL;
+ char *path, *max_size_str;
+ uint64_t max_size;
+ int fd = -1;
+ struct stat sb;
+ size_t size;
+
+#ifdef __OpenBSD__
+ /* default to no disk shader cache to avoid pledge violations in chromium */
+ return NULL;
+#endif
+
+ /* If running as a users other than the real user disable cache */
+ if (geteuid() != getuid())
+ return NULL;
+
+ /* A ralloc context for transient data during this invocation. */
+ local = ralloc_context(NULL);
+ if (local == NULL)
+ goto fail;
+
+ /* At user request, disable shader cache entirely. */
+ if (env_var_as_boolean("MESA_GLSL_CACHE_DISABLE", false))
+ goto fail;
+
+ /* Determine path for cache based on the first defined name as follows:
+ *
+ * $MESA_GLSL_CACHE_DIR
+ * $XDG_CACHE_HOME/mesa_shader_cache
+ * <pwd.pw_dir>/.cache/mesa_shader_cache
+ */
+ path = getenv("MESA_GLSL_CACHE_DIR");
+ if (path) {
+ if (mkdir_if_needed(path) == -1)
+ goto fail;
+
+ path = concatenate_and_mkdir(local, path, CACHE_DIR_NAME);
+ if (path == NULL)
+ goto fail;
+ }
+
+ if (path == NULL) {
+ char *xdg_cache_home = getenv("XDG_CACHE_HOME");
+
+ if (xdg_cache_home) {
+ if (mkdir_if_needed(xdg_cache_home) == -1)
+ goto fail;
+
+ path = concatenate_and_mkdir(local, xdg_cache_home, CACHE_DIR_NAME);
+ if (path == NULL)
+ goto fail;
+ }
+ }
+
+ if (path == NULL) {
+ char *buf;
+ size_t buf_size;
+ struct passwd pwd, *result;
+
+ buf_size = sysconf(_SC_GETPW_R_SIZE_MAX);
+ if (buf_size == -1)
+ buf_size = 512;
+
+ /* Loop until buf_size is large enough to query the directory */
+ while (1) {
+ buf = ralloc_size(local, buf_size);
+
+ getpwuid_r(getuid(), &pwd, buf, buf_size, &result);
+ if (result)
+ break;
+
+ if (errno == ERANGE) {
+ ralloc_free(buf);
+ buf = NULL;
+ buf_size *= 2;
+ } else {
+ goto fail;
+ }
+ }
+
+ path = concatenate_and_mkdir(local, pwd.pw_dir, ".cache");
+ if (path == NULL)
+ goto fail;
+
+ path = concatenate_and_mkdir(local, path, CACHE_DIR_NAME);
+ if (path == NULL)
+ goto fail;
+ }
+
+ cache = ralloc(NULL, struct disk_cache);
+ if (cache == NULL)
+ goto fail;
+
+ cache->path = ralloc_strdup(cache, path);
+ if (cache->path == NULL)
+ goto fail;
+
+ path = ralloc_asprintf(local, "%s/index", cache->path);
+ if (path == NULL)
+ goto fail;
+
+ fd = open(path, O_RDWR | O_CREAT | O_CLOEXEC, 0644);
+ if (fd == -1)
+ goto fail;
+
+ if (fstat(fd, &sb) == -1)
+ goto fail;
+
+ /* Force the index file to be the expected size. */
+ size = sizeof(*cache->size) + CACHE_INDEX_MAX_KEYS * CACHE_KEY_SIZE;
+ if (sb.st_size != size) {
+ if (ftruncate(fd, size) == -1)
+ goto fail;
+ }
+
+ /* We map this shared so that other processes see updates that we
+ * make.
+ *
+ * Note: We do use atomic addition to ensure that multiple
+ * processes don't scramble the cache size recorded in the
+ * index. But we don't use any locking to prevent multiple
+ * processes from updating the same entry simultaneously. The idea
+ * is that if either result lands entirely in the index, then
+ * that's equivalent to a well-ordered write followed by an
+ * eviction and a write. On the other hand, if the simultaneous
+ * writes result in a corrupt entry, that's not really any
+ * different than both entries being evicted, (since within the
+ * guarantees of the cryptographic hash, a corrupt entry is
+ * unlikely to ever match a real cache key).
+ */
+ cache->index_mmap = mmap(NULL, size, PROT_READ | PROT_WRITE,
+ MAP_SHARED, fd, 0);
+ if (cache->index_mmap == MAP_FAILED)
+ goto fail;
+ cache->index_mmap_size = size;
+
+ close(fd);
+
+ cache->size = (uint64_t *) cache->index_mmap;
+ cache->stored_keys = cache->index_mmap + sizeof(uint64_t);
+
+ max_size = 0;
+
+ max_size_str = getenv("MESA_GLSL_CACHE_MAX_SIZE");
+ if (max_size_str) {
+ char *end;
+ max_size = strtoul(max_size_str, &end, 10);
+ if (end == max_size_str) {
+ max_size = 0;
+ } else {
+ switch (*end) {
+ case 'K':
+ case 'k':
+ max_size *= 1024;
+ break;
+ case 'M':
+ case 'm':
+ max_size *= 1024*1024;
+ break;
+ case '\0':
+ case 'G':
+ case 'g':
+ default:
+ max_size *= 1024*1024*1024;
+ break;
+ }
+ }
+ }
+
+ /* Default to 1GB for maximum cache size. */
+ if (max_size == 0) {
+ max_size = 1024*1024*1024;
+ }
+
+ cache->max_size = max_size;
+
+ /* 1 thread was chosen because we don't really care about getting things
+ * to disk quickly just that it's not blocking other tasks.
+ *
+ * The queue will resize automatically when it's full, so adding new jobs
+ * doesn't stall.
+ */
+ util_queue_init(&cache->cache_queue, "disk_cache", 32, 1,
+ UTIL_QUEUE_INIT_RESIZE_IF_FULL |
+ UTIL_QUEUE_INIT_USE_MINIMUM_PRIORITY);
+
+ uint8_t cache_version = CACHE_VERSION;
+ size_t cv_size = sizeof(cache_version);
+ cache->driver_keys_blob_size = cv_size;
+
+ /* Create driver id keys */
+ size_t ts_size = strlen(timestamp) + 1;
+ size_t gpu_name_size = strlen(gpu_name) + 1;
+ cache->driver_keys_blob_size += ts_size;
+ cache->driver_keys_blob_size += gpu_name_size;
+
+ /* We sometimes store entire structs that contains a pointers in the cache,
+ * use pointer size as a key to avoid hard to debug issues.
+ */
+ uint8_t ptr_size = sizeof(void *);
+ size_t ptr_size_size = sizeof(ptr_size);
+ cache->driver_keys_blob_size += ptr_size_size;
+
+ size_t driver_flags_size = sizeof(driver_flags);
+ cache->driver_keys_blob_size += driver_flags_size;
+
+ cache->driver_keys_blob =
+ ralloc_size(cache, cache->driver_keys_blob_size);
+ if (!cache->driver_keys_blob)
+ goto fail;
+
+ uint8_t *drv_key_blob = cache->driver_keys_blob;
+ DRV_KEY_CPY(drv_key_blob, &cache_version, cv_size)
+ DRV_KEY_CPY(drv_key_blob, timestamp, ts_size)
+ DRV_KEY_CPY(drv_key_blob, gpu_name, gpu_name_size)
+ DRV_KEY_CPY(drv_key_blob, &ptr_size, ptr_size_size)
+ DRV_KEY_CPY(drv_key_blob, &driver_flags, driver_flags_size)
+
+ /* Seed our rand function */
+ s_rand_xorshift128plus(cache->seed_xorshift128plus, true);
+
+ ralloc_free(local);
+
+ return cache;
+
+ fail:
+ if (fd != -1)
+ close(fd);
+ if (cache)
+ ralloc_free(cache);
+ ralloc_free(local);
+
+ return NULL;
+}
+
+void
+disk_cache_destroy(struct disk_cache *cache)
+{
+ if (cache) {
+ util_queue_destroy(&cache->cache_queue);
+ munmap(cache->index_mmap, cache->index_mmap_size);
+ }
+
+ ralloc_free(cache);
+}
+
+/* Return a filename within the cache's directory corresponding to 'key'. The
+ * returned filename is ralloced with 'cache' as the parent context.
+ *
+ * Returns NULL if out of memory.
+ */
+static char *
+get_cache_file(struct disk_cache *cache, const cache_key key)
+{
+ char buf[41];
+ char *filename;
+
+ _mesa_sha1_format(buf, key);
+ if (asprintf(&filename, "%s/%c%c/%s", cache->path, buf[0],
+ buf[1], buf + 2) == -1)
+ return NULL;
+
+ return filename;
+}
+
+/* Create the directory that will be needed for the cache file for \key.
+ *
+ * Obviously, the implementation here must closely match
+ * _get_cache_file above.
+*/
+static void
+make_cache_file_directory(struct disk_cache *cache, const cache_key key)
+{
+ char *dir;
+ char buf[41];
+
+ _mesa_sha1_format(buf, key);
+ if (asprintf(&dir, "%s/%c%c", cache->path, buf[0], buf[1]) == -1)
+ return;
+
+ mkdir_if_needed(dir);
+ free(dir);
+}
+
+/* Given a directory path and predicate function, find the entry with
+ * the oldest access time in that directory for which the predicate
+ * returns true.
+ *
+ * Returns: A malloc'ed string for the path to the chosen file, (or
+ * NULL on any error). The caller should free the string when
+ * finished.
+ */
+static char *
+choose_lru_file_matching(const char *dir_path,
+ bool (*predicate)(const char *dir_path,
+ const struct stat *,
+ const char *, const size_t))
+{
+ DIR *dir;
+ struct dirent *entry;
+ char *filename;
+ char *lru_name = NULL;
+ time_t lru_atime = 0;
+
+ dir = opendir(dir_path);
+ if (dir == NULL)
+ return NULL;
+
+ while (1) {
+ entry = readdir(dir);
+ if (entry == NULL)
+ break;
+
+ struct stat sb;
+ if (fstatat(dirfd(dir), entry->d_name, &sb, 0) == 0) {
+ if (!lru_atime || (sb.st_atime < lru_atime)) {
+ size_t len = strlen(entry->d_name);
+
+ if (!predicate(dir_path, &sb, entry->d_name, len))
+ continue;
+
+ char *tmp = realloc(lru_name, len + 1);
+ if (tmp) {
+ lru_name = tmp;
+ memcpy(lru_name, entry->d_name, len + 1);
+ lru_atime = sb.st_atime;
+ }
+ }
+ }
+ }
+
+ if (lru_name == NULL) {
+ closedir(dir);
+ return NULL;
+ }
+
+ if (asprintf(&filename, "%s/%s", dir_path, lru_name) < 0)
+ filename = NULL;
+
+ free(lru_name);
+ closedir(dir);
+
+ return filename;
+}
+
+/* Is entry a regular file, and not having a name with a trailing
+ * ".tmp"
+ */
+static bool
+is_regular_non_tmp_file(const char *path, const struct stat *sb,
+ const char *d_name, const size_t len)
+{
+ if (!S_ISREG(sb->st_mode))
+ return false;
+
+ if (len >= 4 && strcmp(&d_name[len-4], ".tmp") == 0)
+ return false;
+
+ return true;
+}
+
+/* Returns the size of the deleted file, (or 0 on any error). */
+static size_t
+unlink_lru_file_from_directory(const char *path)
+{
+ struct stat sb;
+ char *filename;
+
+ filename = choose_lru_file_matching(path, is_regular_non_tmp_file);
+ if (filename == NULL)
+ return 0;
+
+ if (stat(filename, &sb) == -1) {
+ free (filename);
+ return 0;
+ }
+
+ unlink(filename);
+ free (filename);
+
+ return sb.st_blocks * 512;
+}
+
+/* Is entry a directory with a two-character name, (and not the
+ * special name of ".."). We also return false if the dir is empty.
+ */
+static bool
+is_two_character_sub_directory(const char *path, const struct stat *sb,
+ const char *d_name, const size_t len)
+{
+ if (!S_ISDIR(sb->st_mode))
+ return false;
+
+ if (len != 2)
+ return false;
+
+ if (strcmp(d_name, "..") == 0)
+ return false;
+
+ char *subdir;
+ if (asprintf(&subdir, "%s/%s", path, d_name) == -1)
+ return false;
+ DIR *dir = opendir(subdir);
+ free(subdir);
+
+ if (dir == NULL)
+ return false;
+
+ unsigned subdir_entries = 0;
+ struct dirent *d;
+ while ((d = readdir(dir)) != NULL) {
+ if(++subdir_entries > 2)
+ break;
+ }
+ closedir(dir);
+
+ /* If dir only contains '.' and '..' it must be empty */
+ if (subdir_entries <= 2)
+ return false;
+
+ return true;
+}
+
+static void
+evict_lru_item(struct disk_cache *cache)
+{
+ char *dir_path;
+
+ /* With a reasonably-sized, full cache, (and with keys generated
+ * from a cryptographic hash), we can choose two random hex digits
+ * and reasonably expect the directory to exist with a file in it.
+ * Provides pseudo-LRU eviction to reduce checking all cache files.
+ */
+ uint64_t rand64 = rand_xorshift128plus(cache->seed_xorshift128plus);
+ if (asprintf(&dir_path, "%s/%02" PRIx64 , cache->path, rand64 & 0xff) < 0)
+ return;
+
+ size_t size = unlink_lru_file_from_directory(dir_path);
+
+ free(dir_path);
+
+ if (size) {
+ p_atomic_add(cache->size, - (uint64_t)size);
+ return;
+ }
+
+ /* In the case where the random choice of directory didn't find
+ * something, we choose the least recently accessed from the
+ * existing directories.
+ *
+ * Really, the only reason this code exists is to allow the unit
+ * tests to work, (which use an artificially-small cache to be able
+ * to force a single cached item to be evicted).
+ */
+ dir_path = choose_lru_file_matching(cache->path,
+ is_two_character_sub_directory);
+ if (dir_path == NULL)
+ return;
+
+ size = unlink_lru_file_from_directory(dir_path);
+
+ free(dir_path);
+
+ if (size)
+ p_atomic_add(cache->size, - (uint64_t)size);
+}
+
+void
+disk_cache_remove(struct disk_cache *cache, const cache_key key)
+{
+ struct stat sb;
+
+ char *filename = get_cache_file(cache, key);
+ if (filename == NULL) {
+ return;
+ }
+
+ if (stat(filename, &sb) == -1) {
+ free(filename);
+ return;
+ }
+
+ unlink(filename);
+ free(filename);
+
+ if (sb.st_blocks)
+ p_atomic_add(cache->size, - (uint64_t)sb.st_blocks * 512);
+}
+
+static ssize_t
+read_all(int fd, void *buf, size_t count)
+{
+ char *in = buf;
+ ssize_t read_ret;
+ size_t done;
+
+ for (done = 0; done < count; done += read_ret) {
+ read_ret = read(fd, in + done, count - done);
+ if (read_ret == -1 || read_ret == 0)
+ return -1;
+ }
+ return done;
+}
+
+static ssize_t
+write_all(int fd, const void *buf, size_t count)
+{
+ const char *out = buf;
+ ssize_t written;
+ size_t done;
+
+ for (done = 0; done < count; done += written) {
+ written = write(fd, out + done, count - done);
+ if (written == -1)
+ return -1;
+ }
+ return done;
+}
+
+/* From the zlib docs:
+ * "If the memory is available, buffers sizes on the order of 128K or 256K
+ * bytes should be used."
+ */
+#define BUFSIZE 256 * 1024
+
+/**
+ * Compresses cache entry in memory and writes it to disk. Returns the size
+ * of the data written to disk.
+ */
+static size_t
+deflate_and_write_to_disk(const void *in_data, size_t in_data_size, int dest,
+ const char *filename)
+{
+ unsigned char out[BUFSIZE];
+
+ /* allocate deflate state */
+ z_stream strm;
+ strm.zalloc = Z_NULL;
+ strm.zfree = Z_NULL;
+ strm.opaque = Z_NULL;
+ strm.next_in = (uint8_t *) in_data;
+ strm.avail_in = in_data_size;
+
+ int ret = deflateInit(&strm, Z_BEST_COMPRESSION);
+ if (ret != Z_OK)
+ return 0;
+
+ /* compress until end of in_data */
+ size_t compressed_size = 0;
+ int flush;
+ do {
+ int remaining = in_data_size - BUFSIZE;
+ flush = remaining > 0 ? Z_NO_FLUSH : Z_FINISH;
+ in_data_size -= BUFSIZE;
+
+ /* Run deflate() on input until the output buffer is not full (which
+ * means there is no more data to deflate).
+ */
+ do {
+ strm.avail_out = BUFSIZE;
+ strm.next_out = out;
+
+ ret = deflate(&strm, flush); /* no bad return value */
+ assert(ret != Z_STREAM_ERROR); /* state not clobbered */
+
+ size_t have = BUFSIZE - strm.avail_out;
+ compressed_size += have;
+
+ ssize_t written = write_all(dest, out, have);
+ if (written == -1) {
+ (void)deflateEnd(&strm);
+ return 0;
+ }
+ } while (strm.avail_out == 0);
+
+ /* all input should be used */
+ assert(strm.avail_in == 0);
+
+ } while (flush != Z_FINISH);
+
+ /* stream should be complete */
+ assert(ret == Z_STREAM_END);
+
+ /* clean up and return */
+ (void)deflateEnd(&strm);
+ return compressed_size;
+}
+
+static struct disk_cache_put_job *
+create_put_job(struct disk_cache *cache, const cache_key key,
+ const void *data, size_t size,
+ struct cache_item_metadata *cache_item_metadata)
+{
+ struct disk_cache_put_job *dc_job = (struct disk_cache_put_job *)
+ malloc(sizeof(struct disk_cache_put_job) + size);
+
+ if (dc_job) {
+ dc_job->cache = cache;
+ memcpy(dc_job->key, key, sizeof(cache_key));
+ dc_job->data = dc_job + 1;
+ memcpy(dc_job->data, data, size);
+ dc_job->size = size;
+
+ /* Copy the cache item metadata */
+ if (cache_item_metadata) {
+ dc_job->cache_item_metadata.type = cache_item_metadata->type;
+ if (cache_item_metadata->type == CACHE_ITEM_TYPE_GLSL) {
+ dc_job->cache_item_metadata.num_keys =
+ cache_item_metadata->num_keys;
+ dc_job->cache_item_metadata.keys = (cache_key *)
+ malloc(cache_item_metadata->num_keys * sizeof(cache_key));
+
+ if (!dc_job->cache_item_metadata.keys)
+ goto fail;
+
+ memcpy(dc_job->cache_item_metadata.keys,
+ cache_item_metadata->keys,
+ sizeof(cache_key) * cache_item_metadata->num_keys);
+ }
+ } else {
+ dc_job->cache_item_metadata.type = CACHE_ITEM_TYPE_UNKNOWN;
+ dc_job->cache_item_metadata.keys = NULL;
+ }
+ }
+
+ return dc_job;
+
+fail:
+ free(dc_job);
+
+ return NULL;
+}
+
+static void
+destroy_put_job(void *job, int thread_index)
+{
+ if (job) {
+ struct disk_cache_put_job *dc_job = (struct disk_cache_put_job *) job;
+ free(dc_job->cache_item_metadata.keys);
+
+ free(job);
+ }
+}
+
+struct cache_entry_file_data {
+ uint32_t crc32;
+ uint32_t uncompressed_size;
+};
+
+static void
+cache_put(void *job, int thread_index)
+{
+ assert(job);
+
+ int fd = -1, fd_final = -1, err, ret;
+ unsigned i = 0;
+ char *filename = NULL, *filename_tmp = NULL;
+ struct disk_cache_put_job *dc_job = (struct disk_cache_put_job *) job;
+
+ filename = get_cache_file(dc_job->cache, dc_job->key);
+ if (filename == NULL)
+ goto done;
+
+ /* If the cache is too large, evict something else first. */
+ while (*dc_job->cache->size + dc_job->size > dc_job->cache->max_size &&
+ i < 8) {
+ evict_lru_item(dc_job->cache);
+ i++;
+ }
+
+ /* Write to a temporary file to allow for an atomic rename to the
+ * final destination filename, (to prevent any readers from seeing
+ * a partially written file).
+ */
+ if (asprintf(&filename_tmp, "%s.tmp", filename) == -1)
+ goto done;
+
+ fd = open(filename_tmp, O_WRONLY | O_CLOEXEC | O_CREAT, 0644);
+
+ /* Make the two-character subdirectory within the cache as needed. */
+ if (fd == -1) {
+ if (errno != ENOENT)
+ goto done;
+
+ make_cache_file_directory(dc_job->cache, dc_job->key);
+
+ fd = open(filename_tmp, O_WRONLY | O_CLOEXEC | O_CREAT, 0644);
+ if (fd == -1)
+ goto done;
+ }
+
+ /* With the temporary file open, we take an exclusive flock on
+ * it. If the flock fails, then another process still has the file
+ * open with the flock held. So just let that file be responsible
+ * for writing the file.
+ */
+ err = flock(fd, LOCK_EX | LOCK_NB);
+ if (err == -1)
+ goto done;
+
+ /* Now that we have the lock on the open temporary file, we can
+ * check to see if the destination file already exists. If so,
+ * another process won the race between when we saw that the file
+ * didn't exist and now. In this case, we don't do anything more,
+ * (to ensure the size accounting of the cache doesn't get off).
+ */
+ fd_final = open(filename, O_RDONLY | O_CLOEXEC);
+ if (fd_final != -1) {
+ unlink(filename_tmp);
+ goto done;
+ }
+
+ /* OK, we're now on the hook to write out a file that we know is
+ * not in the cache, and is also not being written out to the cache
+ * by some other process.
+ */
+
+ /* Write the driver_keys_blob, this can be used find information about the
+ * mesa version that produced the entry or deal with hash collisions,
+ * should that ever become a real problem.
+ */
+ ret = write_all(fd, dc_job->cache->driver_keys_blob,
+ dc_job->cache->driver_keys_blob_size);
+ if (ret == -1) {
+ unlink(filename_tmp);
+ goto done;
+ }
+
+ /* Write the cache item metadata. This data can be used to deal with
+ * hash collisions, as well as providing useful information to 3rd party
+ * tools reading the cache files.
+ */
+ ret = write_all(fd, &dc_job->cache_item_metadata.type,
+ sizeof(uint32_t));
+ if (ret == -1) {
+ unlink(filename_tmp);
+ goto done;
+ }
+
+ if (dc_job->cache_item_metadata.type == CACHE_ITEM_TYPE_GLSL) {
+ ret = write_all(fd, &dc_job->cache_item_metadata.num_keys,
+ sizeof(uint32_t));
+ if (ret == -1) {
+ unlink(filename_tmp);
+ goto done;
+ }
+
+ ret = write_all(fd, dc_job->cache_item_metadata.keys[0],
+ dc_job->cache_item_metadata.num_keys *
+ sizeof(cache_key));
+ if (ret == -1) {
+ unlink(filename_tmp);
+ goto done;
+ }
+ }
+
+ /* Create CRC of the data. We will read this when restoring the cache and
+ * use it to check for corruption.
+ */
+ struct cache_entry_file_data cf_data;
+ cf_data.crc32 = util_hash_crc32(dc_job->data, dc_job->size);
+ cf_data.uncompressed_size = dc_job->size;
+
+ size_t cf_data_size = sizeof(cf_data);
+ ret = write_all(fd, &cf_data, cf_data_size);
+ if (ret == -1) {
+ unlink(filename_tmp);
+ goto done;
+ }
+
+ /* Now, finally, write out the contents to the temporary file, then
+ * rename them atomically to the destination filename, and also
+ * perform an atomic increment of the total cache size.
+ */
+ size_t file_size = deflate_and_write_to_disk(dc_job->data, dc_job->size,
+ fd, filename_tmp);
+ if (file_size == 0) {
+ unlink(filename_tmp);
+ goto done;
+ }
+ ret = rename(filename_tmp, filename);
+ if (ret == -1) {
+ unlink(filename_tmp);
+ goto done;
+ }
+
+ struct stat sb;
+ if (stat(filename, &sb) == -1) {
+ /* Something went wrong remove the file */
+ unlink(filename);
+ goto done;
+ }
+
+ p_atomic_add(dc_job->cache->size, sb.st_blocks * 512);
+
+ done:
+ if (fd_final != -1)
+ close(fd_final);
+ /* This close finally releases the flock, (now that the final file
+ * has been renamed into place and the size has been added).
+ */
+ if (fd != -1)
+ close(fd);
+ free(filename_tmp);
+ free(filename);
+}
+
+void
+disk_cache_put(struct disk_cache *cache, const cache_key key,
+ const void *data, size_t size,
+ struct cache_item_metadata *cache_item_metadata)
+{
+ struct disk_cache_put_job *dc_job =
+ create_put_job(cache, key, data, size, cache_item_metadata);
+
+ if (dc_job) {
+ util_queue_fence_init(&dc_job->fence);
+ util_queue_add_job(&cache->cache_queue, dc_job, &dc_job->fence,
+ cache_put, destroy_put_job);
+ }
+}
+
+/**
+ * Decompresses cache entry, returns true if successful.
+ */
+static bool
+inflate_cache_data(uint8_t *in_data, size_t in_data_size,
+ uint8_t *out_data, size_t out_data_size)
+{
+ z_stream strm;
+
+ /* allocate inflate state */
+ strm.zalloc = Z_NULL;
+ strm.zfree = Z_NULL;
+ strm.opaque = Z_NULL;
+ strm.next_in = in_data;
+ strm.avail_in = in_data_size;
+ strm.next_out = out_data;
+ strm.avail_out = out_data_size;
+
+ int ret = inflateInit(&strm);
+ if (ret != Z_OK)
+ return false;
+
+ ret = inflate(&strm, Z_NO_FLUSH);
+ assert(ret != Z_STREAM_ERROR); /* state not clobbered */
+
+ /* Unless there was an error we should have decompressed everything in one
+ * go as we know the uncompressed file size.
+ */
+ if (ret != Z_STREAM_END) {
+ (void)inflateEnd(&strm);
+ return false;
+ }
+ assert(strm.avail_out == 0);
+
+ /* clean up and return */
+ (void)inflateEnd(&strm);
+ return true;
+}
+
+void *
+disk_cache_get(struct disk_cache *cache, const cache_key key, size_t *size)
+{
+ int fd = -1, ret;
+ struct stat sb;
+ char *filename = NULL;
+ uint8_t *data = NULL;
+ uint8_t *uncompressed_data = NULL;
+ uint8_t *file_header = NULL;
+
+ if (size)
+ *size = 0;
+
+ filename = get_cache_file(cache, key);
+ if (filename == NULL)
+ goto fail;
+
+ fd = open(filename, O_RDONLY | O_CLOEXEC);
+ if (fd == -1)
+ goto fail;
+
+ if (fstat(fd, &sb) == -1)
+ goto fail;
+
+ data = malloc(sb.st_size);
+ if (data == NULL)
+ goto fail;
+
+ size_t ck_size = cache->driver_keys_blob_size;
+ file_header = malloc(ck_size);
+ if (!file_header)
+ goto fail;
+
+ if (sb.st_size < ck_size)
+ goto fail;
+
+ ret = read_all(fd, file_header, ck_size);
+ if (ret == -1)
+ goto fail;
+
+ /* Check for extremely unlikely hash collisions */
+ if (memcmp(cache->driver_keys_blob, file_header, ck_size) != 0) {
+ assert(!"Mesa cache keys mismatch!");
+ goto fail;
+ }
+
+ size_t cache_item_md_size = sizeof(uint32_t);
+ uint32_t md_type;
+ ret = read_all(fd, &md_type, cache_item_md_size);
+ if (ret == -1)
+ goto fail;
+
+ if (md_type == CACHE_ITEM_TYPE_GLSL) {
+ uint32_t num_keys;
+ cache_item_md_size += sizeof(uint32_t);
+ ret = read_all(fd, &num_keys, sizeof(uint32_t));
+ if (ret == -1)
+ goto fail;
+
+ /* The cache item metadata is currently just used for distributing
+ * precompiled shaders, they are not used by Mesa so just skip them for
+ * now.
+ * TODO: pass the metadata back to the caller and do some basic
+ * validation.
+ */
+ cache_item_md_size += num_keys * sizeof(cache_key);
+ ret = lseek(fd, num_keys * sizeof(cache_key), SEEK_CUR);
+ if (ret == -1)
+ goto fail;
+ }
+
+ /* Load the CRC that was created when the file was written. */
+ struct cache_entry_file_data cf_data;
+ size_t cf_data_size = sizeof(cf_data);
+ ret = read_all(fd, &cf_data, cf_data_size);
+ if (ret == -1)
+ goto fail;
+
+ /* Load the actual cache data. */
+ size_t cache_data_size =
+ sb.st_size - cf_data_size - ck_size - cache_item_md_size;
+ ret = read_all(fd, data, cache_data_size);
+ if (ret == -1)
+ goto fail;
+
+ /* Uncompress the cache data */
+ uncompressed_data = malloc(cf_data.uncompressed_size);
+ if (!inflate_cache_data(data, cache_data_size, uncompressed_data,
+ cf_data.uncompressed_size))
+ goto fail;
+
+ /* Check the data for corruption */
+ if (cf_data.crc32 != util_hash_crc32(uncompressed_data,
+ cf_data.uncompressed_size))
+ goto fail;
+
+ free(data);
+ free(filename);
+ free(file_header);
+ close(fd);
+
+ if (size)
+ *size = cf_data.uncompressed_size;
+
+ return uncompressed_data;
+
+ fail:
+ if (data)
+ free(data);
+ if (uncompressed_data)
+ free(uncompressed_data);
+ if (filename)
+ free(filename);
+ if (file_header)
+ free(file_header);
+ if (fd != -1)
+ close(fd);
+
+ return NULL;
+}
+
+void
+disk_cache_put_key(struct disk_cache *cache, const cache_key key)
+{
+ const uint32_t *key_chunk = (const uint32_t *) key;
+ int i = CPU_TO_LE32(*key_chunk) & CACHE_INDEX_KEY_MASK;
+ unsigned char *entry;
+
+ entry = &cache->stored_keys[i * CACHE_KEY_SIZE];
+
+ memcpy(entry, key, CACHE_KEY_SIZE);
+}
+
+/* This function lets us test whether a given key was previously
+ * stored in the cache with disk_cache_put_key(). The implement is
+ * efficient by not using syscalls or hitting the disk. It's not
+ * race-free, but the races are benign. If we race with someone else
+ * calling disk_cache_put_key, then that's just an extra cache miss and an
+ * extra recompile.
+ */
+bool
+disk_cache_has_key(struct disk_cache *cache, const cache_key key)
+{
+ const uint32_t *key_chunk = (const uint32_t *) key;
+ int i = CPU_TO_LE32(*key_chunk) & CACHE_INDEX_KEY_MASK;
+ unsigned char *entry;
+
+ entry = &cache->stored_keys[i * CACHE_KEY_SIZE];
+
+ return memcmp(entry, key, CACHE_KEY_SIZE) == 0;
+}
+
+void
+disk_cache_compute_key(struct disk_cache *cache, const void *data, size_t size,
+ cache_key key)
+{
+ struct mesa_sha1 ctx;
+
+ _mesa_sha1_init(&ctx);
+ _mesa_sha1_update(&ctx, cache->driver_keys_blob,
+ cache->driver_keys_blob_size);
+ _mesa_sha1_update(&ctx, data, size);
+ _mesa_sha1_final(&ctx, key);
+}
+
+#endif /* ENABLE_SHADER_CACHE */
diff --git a/lib/mesa/src/util/disk_cache.h b/lib/mesa/src/util/disk_cache.h
new file mode 100644
index 000000000..488b297ea
--- /dev/null
+++ b/lib/mesa/src/util/disk_cache.h
@@ -0,0 +1,269 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef DISK_CACHE_H
+#define DISK_CACHE_H
+
+#ifdef ENABLE_SHADER_CACHE
+#include <dlfcn.h>
+#endif
+#include <assert.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <sys/stat.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Size of cache keys in bytes. */
+#define CACHE_KEY_SIZE 20
+
+#define CACHE_DIR_NAME "mesa_shader_cache"
+
+typedef uint8_t cache_key[CACHE_KEY_SIZE];
+
+/* WARNING: 3rd party applications might be reading the cache item metadata.
+ * Do not change these values without making the change widely known.
+ * Please contact Valve developers and make them aware of this change.
+ */
+#define CACHE_ITEM_TYPE_UNKNOWN 0x0
+#define CACHE_ITEM_TYPE_GLSL 0x1
+
+struct cache_item_metadata {
+ /**
+ * The cache item type. This could be used to identify a GLSL cache item,
+ * a certain type of IR (tgsi, nir, etc), or signal that it is the final
+ * binary form of the shader.
+ */
+ uint32_t type;
+
+ /** GLSL cache item metadata */
+ cache_key *keys; /* sha1 list of shaders that make up the cache item */
+ uint32_t num_keys;
+};
+
+struct disk_cache;
+
+static inline char *
+disk_cache_format_hex_id(char *buf, const uint8_t *hex_id, unsigned size)
+{
+ static const char hex_digits[] = "0123456789abcdef";
+ unsigned i;
+
+ for (i = 0; i < size; i += 2) {
+ buf[i] = hex_digits[hex_id[i >> 1] >> 4];
+ buf[i + 1] = hex_digits[hex_id[i >> 1] & 0x0f];
+ }
+ buf[i] = '\0';
+
+ return buf;
+}
+
+static inline bool
+disk_cache_get_function_timestamp(void *ptr, uint32_t* timestamp)
+{
+#ifdef ENABLE_SHADER_CACHE
+ Dl_info info;
+ struct stat st;
+ if (!dladdr(ptr, &info) || !info.dli_fname) {
+ return false;
+ }
+ if (stat(info.dli_fname, &st)) {
+ return false;
+ }
+ *timestamp = st.st_mtime;
+ return true;
+#else
+ return false;
+#endif
+}
+
+/* Provide inlined stub functions if the shader cache is disabled. */
+
+#ifdef ENABLE_SHADER_CACHE
+
+/**
+ * Create a new cache object.
+ *
+ * This function creates the handle necessary for all subsequent cache_*
+ * functions.
+ *
+ * This cache provides two distinct operations:
+ *
+ * o Storage and retrieval of arbitrary objects by cryptographic
+ * name (or "key"). This is provided via disk_cache_put() and
+ * disk_cache_get().
+ *
+ * o The ability to store a key alone and check later whether the
+ * key was previously stored. This is provided via disk_cache_put_key()
+ * and disk_cache_has_key().
+ *
+ * The put_key()/has_key() operations are conceptually identical to
+ * put()/get() with no data, but are provided separately to allow for
+ * a more efficient implementation.
+ *
+ * In all cases, the keys are sequences of 20 bytes. It is anticipated
+ * that callers will compute appropriate SHA-1 signatures for keys,
+ * (though nothing in this implementation directly relies on how the
+ * names are computed). See mesa-sha1.h and _mesa_sha1_compute for
+ * assistance in computing SHA-1 signatures.
+ */
+struct disk_cache *
+disk_cache_create(const char *gpu_name, const char *timestamp,
+ uint64_t driver_flags);
+
+/**
+ * Destroy a cache object, (freeing all associated resources).
+ */
+void
+disk_cache_destroy(struct disk_cache *cache);
+
+/**
+ * Remove the item in the cache under the name \key.
+ */
+void
+disk_cache_remove(struct disk_cache *cache, const cache_key key);
+
+/**
+ * Store an item in the cache under the name \key.
+ *
+ * The item can be retrieved later with disk_cache_get(), (unless the item has
+ * been evicted in the interim).
+ *
+ * Any call to disk_cache_put() may cause an existing, random item to be
+ * evicted from the cache.
+ */
+void
+disk_cache_put(struct disk_cache *cache, const cache_key key,
+ const void *data, size_t size,
+ struct cache_item_metadata *cache_item_metadata);
+
+/**
+ * Retrieve an item previously stored in the cache with the name <key>.
+ *
+ * The item must have been previously stored with a call to disk_cache_put().
+ *
+ * If \size is non-NULL, then, on successful return, it will be set to the
+ * size of the object.
+ *
+ * \return A pointer to the stored object if found. NULL if the object
+ * is not found, or if any error occurs, (memory allocation failure,
+ * filesystem error, etc.). The returned data is malloc'ed so the
+ * caller should call free() it when finished.
+ */
+void *
+disk_cache_get(struct disk_cache *cache, const cache_key key, size_t *size);
+
+/**
+ * Store the name \key within the cache, (without any associated data).
+ *
+ * Later this key can be checked with disk_cache_has_key(), (unless the key
+ * has been evicted in the interim).
+ *
+ * Any call to disk_cache_put_key() may cause an existing, random key to be
+ * evicted from the cache.
+ */
+void
+disk_cache_put_key(struct disk_cache *cache, const cache_key key);
+
+/**
+ * Test whether the name \key was previously recorded in the cache.
+ *
+ * Return value: True if disk_cache_put_key() was previously called with
+ * \key, (and the key was not evicted in the interim).
+ *
+ * Note: disk_cache_has_key() will only return true for keys passed to
+ * disk_cache_put_key(). Specifically, a call to disk_cache_put() will not cause
+ * disk_cache_has_key() to return true for the same key.
+ */
+bool
+disk_cache_has_key(struct disk_cache *cache, const cache_key key);
+
+/**
+ * Compute the name \key from \data of given \size.
+ */
+void
+disk_cache_compute_key(struct disk_cache *cache, const void *data, size_t size,
+ cache_key key);
+
+#else
+
+static inline struct disk_cache *
+disk_cache_create(const char *gpu_name, const char *timestamp,
+ uint64_t driver_flags)
+{
+ return NULL;
+}
+
+static inline void
+disk_cache_destroy(struct disk_cache *cache) {
+ return;
+}
+
+static inline void
+disk_cache_put(struct disk_cache *cache, const cache_key key,
+ const void *data, size_t size,
+ struct cache_item_metadata *cache_item_metadata)
+{
+ return;
+}
+
+static inline void
+disk_cache_remove(struct disk_cache *cache, const cache_key key)
+{
+ return;
+}
+
+static inline uint8_t *
+disk_cache_get(struct disk_cache *cache, const cache_key key, size_t *size)
+{
+ return NULL;
+}
+
+static inline void
+disk_cache_put_key(struct disk_cache *cache, const cache_key key)
+{
+ return;
+}
+
+static inline bool
+disk_cache_has_key(struct disk_cache *cache, const cache_key key)
+{
+ return false;
+}
+
+static inline void
+disk_cache_compute_key(struct disk_cache *cache, const void *data, size_t size,
+ const cache_key key)
+{
+ return;
+}
+
+#endif /* ENABLE_SHADER_CACHE */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CACHE_H */
diff --git a/lib/mesa/src/util/format_r11g11b10f.h b/lib/mesa/src/util/format_r11g11b10f.h
index f6cd4ac69..ec5abf961 100644
--- a/lib/mesa/src/util/format_r11g11b10f.h
+++ b/lib/mesa/src/util/format_r11g11b10f.h
@@ -27,6 +27,9 @@
* below.
*/
+#ifndef FORMAT_R11G11B10F_H
+#define FORMAT_R11G11B10F_H
+
#include <stdint.h>
#define UF11(e, m) ((e << 6) | (m))
@@ -225,3 +228,5 @@ static inline void r11g11b10f_to_float3(uint32_t rgb, float retval[3])
retval[1] = uf11_to_f32((rgb >> 11) & 0x7ff);
retval[2] = uf10_to_f32((rgb >> 22) & 0x3ff);
}
+
+#endif /* FORMAT_R11G11B10F_H */
diff --git a/lib/mesa/src/util/format_srgb.py b/lib/mesa/src/util/format_srgb.py
index d5cbcf764..44b35a061 100644
--- a/lib/mesa/src/util/format_srgb.py
+++ b/lib/mesa/src/util/format_srgb.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
CopyRight = '''
/**************************************************************************
diff --git a/lib/mesa/src/util/hash_table.c b/lib/mesa/src/util/hash_table.c
index 9e643af8b..1bda2149b 100644
--- a/lib/mesa/src/util/hash_table.c
+++ b/lib/mesa/src/util/hash_table.c
@@ -47,6 +47,7 @@
#include "hash_table.h"
#include "ralloc.h"
#include "macros.h"
+#include "main/hash.h"
static const uint32_t deleted_key_value;
@@ -502,3 +503,149 @@ _mesa_key_pointer_equal(const void *a, const void *b)
{
return a == b;
}
+
+/**
+ * Hash table wrapper which supports 64-bit keys.
+ *
+ * TODO: unify all hash table implementations.
+ */
+
+struct hash_key_u64 {
+ uint64_t value;
+};
+
+static uint32_t
+key_u64_hash(const void *key)
+{
+ return _mesa_hash_data(key, sizeof(struct hash_key_u64));
+}
+
+static bool
+key_u64_equals(const void *a, const void *b)
+{
+ const struct hash_key_u64 *aa = a;
+ const struct hash_key_u64 *bb = b;
+
+ return aa->value == bb->value;
+}
+
+struct hash_table_u64 *
+_mesa_hash_table_u64_create(void *mem_ctx)
+{
+ struct hash_table_u64 *ht;
+
+ ht = CALLOC_STRUCT(hash_table_u64);
+ if (!ht)
+ return NULL;
+
+ if (sizeof(void *) == 8) {
+ ht->table = _mesa_hash_table_create(mem_ctx, _mesa_hash_pointer,
+ _mesa_key_pointer_equal);
+ } else {
+ ht->table = _mesa_hash_table_create(mem_ctx, key_u64_hash,
+ key_u64_equals);
+ }
+
+ if (ht->table)
+ _mesa_hash_table_set_deleted_key(ht->table, uint_key(DELETED_KEY_VALUE));
+
+ return ht;
+}
+
+void
+_mesa_hash_table_u64_destroy(struct hash_table_u64 *ht,
+ void (*delete_function)(struct hash_entry *entry))
+{
+ if (!ht)
+ return;
+
+ if (ht->deleted_key_data) {
+ if (delete_function) {
+ struct hash_table *table = ht->table;
+ struct hash_entry deleted_entry;
+
+ /* Create a fake entry for the delete function. */
+ deleted_entry.hash = table->key_hash_function(table->deleted_key);
+ deleted_entry.key = table->deleted_key;
+ deleted_entry.data = ht->deleted_key_data;
+
+ delete_function(&deleted_entry);
+ }
+ ht->deleted_key_data = NULL;
+ }
+
+ _mesa_hash_table_destroy(ht->table, delete_function);
+ free(ht);
+}
+
+void
+_mesa_hash_table_u64_insert(struct hash_table_u64 *ht, uint64_t key,
+ void *data)
+{
+ if (key == DELETED_KEY_VALUE) {
+ ht->deleted_key_data = data;
+ return;
+ }
+
+ if (sizeof(void *) == 8) {
+ _mesa_hash_table_insert(ht->table, (void *)(uintptr_t)key, data);
+ } else {
+ struct hash_key_u64 *_key = CALLOC_STRUCT(hash_key_u64);
+
+ if (!_key)
+ return;
+ _key->value = key;
+
+ _mesa_hash_table_insert(ht->table, _key, data);
+ }
+}
+
+static struct hash_entry *
+hash_table_u64_search(struct hash_table_u64 *ht, uint64_t key)
+{
+ if (sizeof(void *) == 8) {
+ return _mesa_hash_table_search(ht->table, (void *)(uintptr_t)key);
+ } else {
+ struct hash_key_u64 _key = { .value = key };
+ return _mesa_hash_table_search(ht->table, &_key);
+ }
+}
+
+void *
+_mesa_hash_table_u64_search(struct hash_table_u64 *ht, uint64_t key)
+{
+ struct hash_entry *entry;
+
+ if (key == DELETED_KEY_VALUE)
+ return ht->deleted_key_data;
+
+ entry = hash_table_u64_search(ht, key);
+ if (!entry)
+ return NULL;
+
+ return entry->data;
+}
+
+void
+_mesa_hash_table_u64_remove(struct hash_table_u64 *ht, uint64_t key)
+{
+ struct hash_entry *entry;
+
+ if (key == DELETED_KEY_VALUE) {
+ ht->deleted_key_data = NULL;
+ return;
+ }
+
+ entry = hash_table_u64_search(ht, key);
+ if (!entry)
+ return;
+
+ if (sizeof(void *) == 8) {
+ _mesa_hash_table_remove(ht->table, entry);
+ } else {
+ struct hash_key *_key = (struct hash_key *)entry->key;
+
+ _mesa_hash_table_remove(ht->table, entry);
+ free(_key);
+ }
+}
diff --git a/lib/mesa/src/util/hash_table.h b/lib/mesa/src/util/hash_table.h
index b35ee871b..cf939130f 100644
--- a/lib/mesa/src/util/hash_table.h
+++ b/lib/mesa/src/util/hash_table.h
@@ -105,7 +105,8 @@ static inline uint32_t _mesa_key_hash_string(const void *key)
static inline uint32_t _mesa_hash_pointer(const void *pointer)
{
- return _mesa_hash_data(&pointer, sizeof(pointer));
+ uintptr_t num = (uintptr_t) pointer;
+ return (uint32_t) ((num >> 2) ^ (num >> 6) ^ (num >> 10) ^ (num >> 14));
}
enum {
@@ -152,6 +153,31 @@ hash_table_call_foreach(struct hash_table *ht,
callback(entry->key, entry->data, closure);
}
+/**
+ * Hash table wrapper which supports 64-bit keys.
+ */
+struct hash_table_u64 {
+ struct hash_table *table;
+ void *deleted_key_data;
+};
+
+struct hash_table_u64 *
+_mesa_hash_table_u64_create(void *mem_ctx);
+
+void
+_mesa_hash_table_u64_destroy(struct hash_table_u64 *ht,
+ void (*delete_function)(struct hash_entry *entry));
+
+void
+_mesa_hash_table_u64_insert(struct hash_table_u64 *ht, uint64_t key,
+ void *data);
+
+void *
+_mesa_hash_table_u64_search(struct hash_table_u64 *ht, uint64_t key);
+
+void
+_mesa_hash_table_u64_remove(struct hash_table_u64 *ht, uint64_t key);
+
#ifdef __cplusplus
} /* extern C */
#endif
diff --git a/lib/mesa/src/util/list.h b/lib/mesa/src/util/list.h
index 07eb9f3e6..6edb75011 100644
--- a/lib/mesa/src/util/list.h
+++ b/lib/mesa/src/util/list.h
@@ -41,6 +41,7 @@
#include <stdbool.h>
#include <stddef.h>
#include <assert.h>
+#include "c99_compat.h"
struct list_head
diff --git a/lib/mesa/src/util/macros.h b/lib/mesa/src/util/macros.h
index efb896f4c..a9a52a1a4 100644
--- a/lib/mesa/src/util/macros.h
+++ b/lib/mesa/src/util/macros.h
@@ -30,7 +30,7 @@
/* Compute the size of an array */
#ifndef ARRAY_SIZE
-# define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
+# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#endif
/* For compatibility with Clang's __has_builtin() */
@@ -136,6 +136,17 @@ do { \
#define MALLOCLIKE
#endif
+/* Forced function inlining */
+#ifndef ALWAYS_INLINE
+# if defined(__GNUC__) || defined(__clang__)
+# define ALWAYS_INLINE inline __attribute__((always_inline))
+# elif defined(_MSC_VER)
+# define ALWAYS_INLINE __forceinline
+# else
+# define ALWAYS_INLINE inline
+# endif
+#endif
+
/* Used to optionally mark structures with misaligned elements or size as
* packed, to trade off performance for space.
*/
@@ -175,6 +186,10 @@ do { \
# if ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)))
# define HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T)
# endif
+# elif defined(_MSC_VER) && !defined(__INTEL_COMPILER)
+# if _MSC_VER >= 1800
+# define HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T)
+# endif
# endif
# ifndef HAS_TRIVIAL_DESTRUCTOR
/* It's always safe (if inefficient) to assume that a
@@ -229,8 +244,8 @@ do { \
/** Compute ceiling of integer quotient of A divided by B. */
#define DIV_ROUND_UP( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 )
-/** Clamp X to [MIN,MAX] */
-#define CLAMP( X, MIN, MAX ) ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) )
+/** Clamp X to [MIN,MAX]. Turn NaN into MIN, arbitrarily. */
+#define CLAMP( X, MIN, MAX ) ( (X)>(MIN) ? ((X)>(MAX) ? (MAX) : (X)) : (MIN) )
/** Minimum of two values: */
#define MIN2( A, B ) ( (A)<(B) ? (A) : (B) )
diff --git a/lib/mesa/src/util/mesa-sha1.c b/lib/mesa/src/util/mesa-sha1.c
index b6a192f4d..fa9284627 100644
--- a/lib/mesa/src/util/mesa-sha1.c
+++ b/lib/mesa/src/util/mesa-sha1.c
@@ -24,289 +24,20 @@
* DEALINGS IN THE SOFTWARE.
*/
+#include "sha1/sha1.h"
#include "mesa-sha1.h"
-#ifdef HAVE_SHA1
-
-#if defined(HAVE_SHA1_IN_LIBMD) /* Use libmd for SHA1 */ \
- || defined(HAVE_SHA1_IN_LIBC) /* Use libc for SHA1 */
-
-#include <sha1.h>
-
-struct mesa_sha1 *
-_mesa_sha1_init(void)
-{
- SHA1_CTX *ctx = malloc(sizeof(*ctx));
-
- if (!ctx)
- return NULL;
-
- SHA1Init(ctx);
- return (struct mesa_sha1 *) ctx;
-}
-
-int
-_mesa_sha1_update(struct mesa_sha1 *ctx, const void *data, int size)
-{
- SHA1_CTX *sha1_ctx = (SHA1_CTX *) ctx;
-
- SHA1Update(sha1_ctx, data, size);
- return 1;
-}
-
-int
-_mesa_sha1_final(struct mesa_sha1 *ctx, unsigned char result[20])
-{
- SHA1_CTX *sha1_ctx = (SHA1_CTX *) ctx;
-
- SHA1Final(result, sha1_ctx);
- free(sha1_ctx);
- return 1;
-}
-
-#elif defined(HAVE_SHA1_IN_COMMONCRYPTO) /* Use CommonCrypto for SHA1 */
-
-#include <CommonCrypto/CommonDigest.h>
-
-struct mesa_sha1 *
-_mesa_sha1_init(void)
-{
- CC_SHA1_CTX *ctx = malloc(sizeof(*ctx));
-
- if (!ctx)
- return NULL;
-
- CC_SHA1_Init(ctx);
- return (struct mesa_sha1 *) ctx;
-}
-
-int
-_mesa_sha1_update(struct mesa_sha1 *ctx, const void *data, int size)
-{
- CC_SHA1_CTX *sha1_ctx = (CC_SHA1_CTX *) ctx;
-
- CC_SHA1_Update(sha1_ctx, data, size);
- return 1;
-}
-
-int
-_mesa_sha1_final(struct mesa_sha1 *ctx, unsigned char result[20])
-{
- CC_SHA1_CTX *sha1_ctx = (CC_SHA1_CTX *) ctx;
-
- CC_SHA1_Final(result, sha1_ctx);
- free(sha1_ctx);
- return 1;
-}
-
-#elif defined(HAVE_SHA1_IN_CRYPTOAPI) /* Use CryptoAPI for SHA1 */
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include <wincrypt.h>
-
-static HCRYPTPROV hProv;
-
-struct mesa_sha1 *
-_mesa_sha1_init(void)
-{
- HCRYPTHASH *ctx = malloc(sizeof(*ctx));
-
- if (!ctx)
- return NULL;
-
- CryptAcquireContext(&hProv, NULL, MS_DEF_PROV, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
- CryptCreateHash(hProv, CALG_SHA1, 0, 0, ctx);
- return (struct mesa_sha1 *) ctx;
-}
-
-int
-_mesa_sha1_update(struct mesa_sha1 *ctx, const void *data, int size)
-{
- HCRYPTHASH *hHash = (HCRYPTHASH *) ctx;
-
- CryptHashData(*hHash, data, size, 0);
- return 1;
-}
-
-int
-_mesa_sha1_final(struct mesa_sha1 *ctx, unsigned char result[20])
-{
- HCRYPTHASH *hHash = (HCRYPTHASH *) ctx;
- DWORD len = 20;
-
- CryptGetHashParam(*hHash, HP_HASHVAL, result, &len, 0);
- CryptDestroyHash(*hHash);
- CryptReleaseContext(hProv, 0);
- free(ctx);
- return 1;
-}
-
-#elif defined(HAVE_SHA1_IN_LIBNETTLE) /* Use libnettle for SHA1 */
-
-#include <nettle/sha.h>
-
-struct mesa_sha1 *
-_mesa_sha1_init(void)
-{
- struct sha1_ctx *ctx = malloc(sizeof(*ctx));
-
- if (!ctx)
- return NULL;
- sha1_init(ctx);
- return (struct mesa_sha1 *) ctx;
-}
-
-int
-_mesa_sha1_update(struct mesa_sha1 *ctx, const void *data, int size)
-{
- sha1_update((struct sha1_ctx *) ctx, size, data);
- return 1;
-}
-
-int
-_mesa_sha1_final(struct mesa_sha1 *ctx, unsigned char result[20])
-{
- sha1_digest((struct sha1_ctx *) ctx, 20, result);
- free(ctx);
- return 1;
-}
-
-#elif defined(HAVE_SHA1_IN_LIBGCRYPT) /* Use libgcrypt for SHA1 */
-
-#include <gcrypt.h>
-#include "c11/threads.h"
-
-static void _mesa_libgcrypt_init(void)
-{
- if (!gcry_check_version(NULL))
- return;
-
- gcry_control(GCRYCTL_DISABLE_SECMEM, 0);
- gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
-}
-
-struct mesa_sha1 *
-_mesa_sha1_init(void)
-{
- static once_flag flag = ONCE_FLAG_INIT;
- gcry_md_hd_t h;
- gcry_error_t err;
-
- call_once(&flag, _mesa_libgcrypt_init);
-
- err = gcry_md_open(&h, GCRY_MD_SHA1, 0);
- if (err)
- return NULL;
- return (struct mesa_sha1 *) h;
-}
-
-int
-_mesa_sha1_update(struct mesa_sha1 *ctx, const void *data, int size)
-{
- gcry_md_hd_t h = (gcry_md_hd_t) ctx;
-
- gcry_md_write(h, data, size);
- return 1;
-}
-
-int
-_mesa_sha1_final(struct mesa_sha1 *ctx, unsigned char result[20])
-{
- gcry_md_hd_t h = (gcry_md_hd_t) ctx;
-
- memcpy(result, gcry_md_read(h, GCRY_MD_SHA1), 20);
- gcry_md_close(h);
- return 1;
-}
-
-#elif defined(HAVE_SHA1_IN_LIBSHA1) /* Use libsha1 */
-
-#include <libsha1.h>
-
-struct mesa_sha1 *
-_mesa_sha1_init(void)
-{
- sha1_ctx *ctx = malloc(sizeof(*ctx));
-
- if (!ctx)
- return NULL;
- sha1_begin(ctx);
- return (struct mesa_sha1 *) ctx;
-}
-
-int
-_mesa_sha1_update(struct mesa_sha1 *ctx, const void *data, int size)
-{
- sha1_hash(data, size, (sha1_ctx *) ctx);
- return 1;
-}
-
-int
-_mesa_sha1_final(struct mesa_sha1 *ctx, unsigned char result[20])
-{
- sha1_end(result, (sha1_ctx *) ctx);
- free(ctx);
- return 1;
-}
-
-#else /* Use OpenSSL's libcrypto */
-
-#include <stddef.h> /* buggy openssl/sha.h wants size_t */
-#include <openssl/sha.h>
-
-struct mesa_sha1 *
-_mesa_sha1_init(void)
-{
- int ret;
- SHA_CTX *ctx = malloc(sizeof(*ctx));
-
- if (!ctx)
- return NULL;
- ret = SHA1_Init(ctx);
- if (!ret) {
- free(ctx);
- return NULL;
- }
- return (struct mesa_sha1 *) ctx;
-}
-
-int
-_mesa_sha1_update(struct mesa_sha1 *ctx, const void *data, int size)
-{
- int ret;
- SHA_CTX *sha_ctx = (SHA_CTX *) ctx;
-
- ret = SHA1_Update(sha_ctx, data, size);
- if (!ret)
- free(sha_ctx);
- return ret;
-}
-
-int
-_mesa_sha1_final(struct mesa_sha1 *ctx, unsigned char result[20])
-{
- int ret;
- SHA_CTX *sha_ctx = (SHA_CTX *) ctx;
-
- ret = SHA1_Final(result, (SHA_CTX *) sha_ctx);
- free(sha_ctx);
- return ret;
-}
-
-#endif
-
void
_mesa_sha1_compute(const void *data, size_t size, unsigned char result[20])
{
- struct mesa_sha1 *ctx;
+ struct mesa_sha1 ctx;
- ctx = _mesa_sha1_init();
- _mesa_sha1_update(ctx, data, size);
- _mesa_sha1_final(ctx, result);
+ _mesa_sha1_init(&ctx);
+ _mesa_sha1_update(&ctx, data, size);
+ _mesa_sha1_final(&ctx, result);
}
-char *
+void
_mesa_sha1_format(char *buf, const unsigned char *sha1)
{
static const char hex_digits[] = "0123456789abcdef";
@@ -317,8 +48,4 @@ _mesa_sha1_format(char *buf, const unsigned char *sha1)
buf[i + 1] = hex_digits[sha1[i >> 1] & 0x0f];
}
buf[i] = '\0';
-
- return buf;
}
-
-#endif
diff --git a/lib/mesa/src/util/mesa-sha1.h b/lib/mesa/src/util/mesa-sha1.h
index 0be5485f3..bde50ba1e 100644
--- a/lib/mesa/src/util/mesa-sha1.h
+++ b/lib/mesa/src/util/mesa-sha1.h
@@ -20,27 +20,38 @@
* DEALINGS IN THE SOFTWARE.
*/
-#ifndef SHA1_H
-#define SHA1_H
+#ifndef MESA_SHA1_H
+#define MESA_SHA1_H
#include <stdlib.h>
+#include "c99_compat.h"
+#include "sha1/sha1.h"
#ifdef __cplusplus
extern "C" {
#endif
-struct mesa_sha1;
+#define mesa_sha1 _SHA1_CTX
-struct mesa_sha1 *
-_mesa_sha1_init(void);
+static inline void
+_mesa_sha1_init(struct mesa_sha1 *ctx)
+{
+ SHA1Init(ctx);
+}
-int
-_mesa_sha1_update(struct mesa_sha1 *ctx, const void *data, int size);
+static inline void
+_mesa_sha1_update(struct mesa_sha1 *ctx, const void *data, size_t size)
+{
+ SHA1Update(ctx, (const unsigned char *)data, size);
+}
-int
-_mesa_sha1_final(struct mesa_sha1 *ctx, unsigned char result[20]);
+static inline void
+_mesa_sha1_final(struct mesa_sha1 *ctx, unsigned char result[20])
+{
+ SHA1Final(result, ctx);
+}
-char *
+void
_mesa_sha1_format(char *buf, const unsigned char *sha1);
void
diff --git a/lib/mesa/src/util/mesa-sha1_test.c b/lib/mesa/src/util/mesa-sha1_test.c
new file mode 100644
index 000000000..9b3b477c7
--- /dev/null
+++ b/lib/mesa/src/util/mesa-sha1_test.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <stdbool.h>
+#include <string.h>
+
+#include "macros.h"
+#include "mesa-sha1.h"
+
+#define SHA1_LENGTH 40
+
+int main(int argc, char *argv[])
+{
+ static const struct {
+ const char *string;
+ const char *sha1;
+ } test_data[] = {
+ {"Mesa Rocks! 273", "7fb99737373d65a73f049cdabc01e73aa6bc60f3"},
+ {"Mesa Rocks! 300", "b2180263e37d3bed6a4be0afe41b1a82ebbcf4c3"},
+ {"Mesa Rocks! 583", "7fb9734108a62503e8a149c1051facd7fb112d05"},
+ };
+
+ bool failed = false;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(test_data); i++) {
+ unsigned char sha1[20];
+ _mesa_sha1_compute(test_data[i].string, strlen(test_data[i].string),
+ sha1);
+
+ char buf[41];
+ _mesa_sha1_format(buf, sha1);
+
+ if (memcmp(test_data[i].sha1, buf, SHA1_LENGTH) != 0) {
+ printf("For string \"%s\", length %zu:\n"
+ "\tExpected: %s\n\t Got: %s\n",
+ test_data[i].string, strlen(test_data[i].string),
+ test_data[i].sha1, buf);
+ failed = true;
+ }
+ }
+
+ return failed;
+}
diff --git a/lib/mesa/src/util/ralloc.c b/lib/mesa/src/util/ralloc.c
index b8fbfbc31..42cfa2e39 100644
--- a/lib/mesa/src/util/ralloc.c
+++ b/lib/mesa/src/util/ralloc.c
@@ -28,11 +28,6 @@
#include <string.h>
#include <stdint.h>
-/* Android defines SIZE_MAX in limits.h, instead of the standard stdint.h */
-#ifdef ANDROID
-#include <limits.h>
-#endif
-
/* Some versions of MinGW are missing _vscprintf's declaration, although they
* still provide the symbol in the import library. */
#ifdef __MINGW32__
@@ -123,25 +118,24 @@ ralloc_context(const void *ctx)
void *
ralloc_size(const void *ctx, size_t size)
{
- /* ralloc_size was originally implemented using calloc, which meant some
- * code accidentally relied on its zero filling behavior.
- *
- * TODO: Make ralloc_size not zero fill memory, and cleanup any code that
- * should instead be using rzalloc.
- */
- return rzalloc_size(ctx, size);
-}
-
-void *
-rzalloc_size(const void *ctx, size_t size)
-{
- void *block = calloc(1, size + sizeof(ralloc_header));
+ void *block = malloc(size + sizeof(ralloc_header));
ralloc_header *info;
ralloc_header *parent;
if (unlikely(block == NULL))
return NULL;
+
info = (ralloc_header *) block;
+ /* measurements have shown that calloc is slower (because of
+ * the multiplication overflow checking?), so clear things
+ * manually
+ */
+ info->parent = NULL;
+ info->child = NULL;
+ info->prev = NULL;
+ info->next = NULL;
+ info->destructor = NULL;
+
parent = ctx != NULL ? get_header(ctx) : NULL;
add_child(parent, info);
@@ -153,6 +147,17 @@ rzalloc_size(const void *ctx, size_t size)
return PTR_FROM_HEADER(info);
}
+void *
+rzalloc_size(const void *ctx, size_t size)
+{
+ void *ptr = ralloc_size(ctx, size);
+
+ if (likely(ptr))
+ memset(ptr, 0, size);
+
+ return ptr;
+}
+
/* helper function - assumes ptr != NULL */
static void *
resize(void *ptr, size_t size)
@@ -280,7 +285,7 @@ ralloc_steal(const void *new_ctx, void *ptr)
return;
info = get_header(ptr);
- parent = get_header(new_ctx);
+ parent = new_ctx ? get_header(new_ctx) : NULL;
unlink_block(info);
@@ -306,10 +311,12 @@ ralloc_adopt(const void *new_ctx, void *old_ctx)
for (child = old_info->child; child->next != NULL; child = child->next) {
child->parent = new_info;
}
+ child->parent = new_info;
/* Connect the two lists together; parent them to new_ctx; make old_ctx empty. */
child->next = new_info->child;
- child->parent = new_info;
+ if (child->next)
+ child->next->prev = child;
new_info->child = old_info->child;
old_info->child = NULL;
}
@@ -326,24 +333,6 @@ ralloc_parent(const void *ptr)
return info->parent ? PTR_FROM_HEADER(info->parent) : NULL;
}
-static void *autofree_context = NULL;
-
-static void
-autofree(void)
-{
- ralloc_free(autofree_context);
-}
-
-void *
-ralloc_autofree_context(void)
-{
- if (unlikely(autofree_context == NULL)) {
- autofree_context = ralloc_context(NULL);
- atexit(autofree);
- }
- return autofree_context;
-}
-
void
ralloc_set_destructor(const void *ptr, void(*destructor)(void *))
{
@@ -413,12 +402,26 @@ ralloc_strcat(char **dest, const char *str)
bool
ralloc_strncat(char **dest, const char *str, size_t n)
{
- /* Clamp n to the string length */
- size_t str_length = strlen(str);
- if (str_length < n)
- n = str_length;
+ return cat(dest, str, strnlen(str, n));
+}
+
+bool
+ralloc_str_append(char **dest, const char *str,
+ size_t existing_length, size_t str_size)
+{
+ char *both;
+ assert(dest != NULL && *dest != NULL);
+
+ both = resize(*dest, existing_length + str_size + 1);
+ if (unlikely(both == NULL))
+ return false;
- return cat(dest, str, n);
+ memcpy(both + existing_length, str, str_size);
+ both[existing_length + str_size] = '\0';
+
+ *dest = both;
+
+ return true;
}
char *
@@ -531,3 +534,364 @@ ralloc_vasprintf_rewrite_tail(char **str, size_t *start, const char *fmt,
*start += new_length;
return true;
}
+
+/***************************************************************************
+ * Linear allocator for short-lived allocations.
+ ***************************************************************************
+ *
+ * The allocator consists of a parent node (2K buffer), which requires
+ * a ralloc parent, and child nodes (allocations). Child nodes can't be freed
+ * directly, because the parent doesn't track them. You have to release
+ * the parent node in order to release all its children.
+ *
+ * The allocator uses a fixed-sized buffer with a monotonically increasing
+ * offset after each allocation. If the buffer is all used, another buffer
+ * is allocated, sharing the same ralloc parent, so all buffers are at
+ * the same level in the ralloc hierarchy.
+ *
+ * The linear parent node is always the first buffer and keeps track of all
+ * other buffers.
+ */
+
+#define ALIGN_POT(x, y) (((x) + (y) - 1) & ~((y) - 1))
+
+#define MIN_LINEAR_BUFSIZE 2048
+#define SUBALLOC_ALIGNMENT sizeof(uintptr_t)
+#define LMAGIC 0x87b9c7d3
+
+struct linear_header {
+#ifdef DEBUG
+ unsigned magic; /* for debugging */
+#endif
+ unsigned offset; /* points to the first unused byte in the buffer */
+ unsigned size; /* size of the buffer */
+ void *ralloc_parent; /* new buffers will use this */
+ struct linear_header *next; /* next buffer if we have more */
+ struct linear_header *latest; /* the only buffer that has free space */
+
+ /* After this structure, the buffer begins.
+ * Each suballocation consists of linear_size_chunk as its header followed
+ * by the suballocation, so it goes:
+ *
+ * - linear_size_chunk
+ * - allocated space
+ * - linear_size_chunk
+ * - allocated space
+ * etc.
+ *
+ * linear_size_chunk is only needed by linear_realloc.
+ */
+};
+
+struct linear_size_chunk {
+ unsigned size; /* for realloc */
+ unsigned _padding;
+};
+
+typedef struct linear_header linear_header;
+typedef struct linear_size_chunk linear_size_chunk;
+
+#define LINEAR_PARENT_TO_HEADER(parent) \
+ (linear_header*) \
+ ((char*)(parent) - sizeof(linear_size_chunk) - sizeof(linear_header))
+
+/* Allocate the linear buffer with its header. */
+static linear_header *
+create_linear_node(void *ralloc_ctx, unsigned min_size)
+{
+ linear_header *node;
+
+ min_size += sizeof(linear_size_chunk);
+
+ if (likely(min_size < MIN_LINEAR_BUFSIZE))
+ min_size = MIN_LINEAR_BUFSIZE;
+
+ node = ralloc_size(ralloc_ctx, sizeof(linear_header) + min_size);
+ if (unlikely(!node))
+ return NULL;
+
+#ifdef DEBUG
+ node->magic = LMAGIC;
+#endif
+ node->offset = 0;
+ node->size = min_size;
+ node->ralloc_parent = ralloc_ctx;
+ node->next = NULL;
+ node->latest = node;
+ return node;
+}
+
+void *
+linear_alloc_child(void *parent, unsigned size)
+{
+ linear_header *first = LINEAR_PARENT_TO_HEADER(parent);
+ linear_header *latest = first->latest;
+ linear_header *new_node;
+ linear_size_chunk *ptr;
+ unsigned full_size;
+
+#ifdef DEBUG
+ assert(first->magic == LMAGIC);
+#endif
+ assert(!latest->next);
+
+ size = ALIGN_POT(size, SUBALLOC_ALIGNMENT);
+ full_size = sizeof(linear_size_chunk) + size;
+
+ if (unlikely(latest->offset + full_size > latest->size)) {
+ /* allocate a new node */
+ new_node = create_linear_node(latest->ralloc_parent, size);
+ if (unlikely(!new_node))
+ return NULL;
+
+ first->latest = new_node;
+ latest->latest = new_node;
+ latest->next = new_node;
+ latest = new_node;
+ }
+
+ ptr = (linear_size_chunk *)((char*)&latest[1] + latest->offset);
+ ptr->size = size;
+ latest->offset += full_size;
+ return &ptr[1];
+}
+
+void *
+linear_alloc_parent(void *ralloc_ctx, unsigned size)
+{
+ linear_header *node;
+
+ if (unlikely(!ralloc_ctx))
+ return NULL;
+
+ size = ALIGN_POT(size, SUBALLOC_ALIGNMENT);
+
+ node = create_linear_node(ralloc_ctx, size);
+ if (unlikely(!node))
+ return NULL;
+
+ return linear_alloc_child((char*)node +
+ sizeof(linear_header) +
+ sizeof(linear_size_chunk), size);
+}
+
+void *
+linear_zalloc_child(void *parent, unsigned size)
+{
+ void *ptr = linear_alloc_child(parent, size);
+
+ if (likely(ptr))
+ memset(ptr, 0, size);
+ return ptr;
+}
+
+void *
+linear_zalloc_parent(void *parent, unsigned size)
+{
+ void *ptr = linear_alloc_parent(parent, size);
+
+ if (likely(ptr))
+ memset(ptr, 0, size);
+ return ptr;
+}
+
+void
+linear_free_parent(void *ptr)
+{
+ linear_header *node;
+
+ if (unlikely(!ptr))
+ return;
+
+ node = LINEAR_PARENT_TO_HEADER(ptr);
+#ifdef DEBUG
+ assert(node->magic == LMAGIC);
+#endif
+
+ while (node) {
+ void *ptr = node;
+
+ node = node->next;
+ ralloc_free(ptr);
+ }
+}
+
+void
+ralloc_steal_linear_parent(void *new_ralloc_ctx, void *ptr)
+{
+ linear_header *node;
+
+ if (unlikely(!ptr))
+ return;
+
+ node = LINEAR_PARENT_TO_HEADER(ptr);
+#ifdef DEBUG
+ assert(node->magic == LMAGIC);
+#endif
+
+ while (node) {
+ ralloc_steal(new_ralloc_ctx, node);
+ node->ralloc_parent = new_ralloc_ctx;
+ node = node->next;
+ }
+}
+
+void *
+ralloc_parent_of_linear_parent(void *ptr)
+{
+ linear_header *node = LINEAR_PARENT_TO_HEADER(ptr);
+#ifdef DEBUG
+ assert(node->magic == LMAGIC);
+#endif
+ return node->ralloc_parent;
+}
+
+void *
+linear_realloc(void *parent, void *old, unsigned new_size)
+{
+ unsigned old_size = 0;
+ ralloc_header *new_ptr;
+
+ new_ptr = linear_alloc_child(parent, new_size);
+
+ if (unlikely(!old))
+ return new_ptr;
+
+ old_size = ((linear_size_chunk*)old)[-1].size;
+
+ if (likely(new_ptr && old_size))
+ memcpy(new_ptr, old, MIN2(old_size, new_size));
+
+ return new_ptr;
+}
+
+/* All code below is pretty much copied from ralloc and only the alloc
+ * calls are different.
+ */
+
+char *
+linear_strdup(void *parent, const char *str)
+{
+ unsigned n;
+ char *ptr;
+
+ if (unlikely(!str))
+ return NULL;
+
+ n = strlen(str);
+ ptr = linear_alloc_child(parent, n + 1);
+ if (unlikely(!ptr))
+ return NULL;
+
+ memcpy(ptr, str, n);
+ ptr[n] = '\0';
+ return ptr;
+}
+
+char *
+linear_asprintf(void *parent, const char *fmt, ...)
+{
+ char *ptr;
+ va_list args;
+ va_start(args, fmt);
+ ptr = linear_vasprintf(parent, fmt, args);
+ va_end(args);
+ return ptr;
+}
+
+char *
+linear_vasprintf(void *parent, const char *fmt, va_list args)
+{
+ unsigned size = printf_length(fmt, args) + 1;
+
+ char *ptr = linear_alloc_child(parent, size);
+ if (ptr != NULL)
+ vsnprintf(ptr, size, fmt, args);
+
+ return ptr;
+}
+
+bool
+linear_asprintf_append(void *parent, char **str, const char *fmt, ...)
+{
+ bool success;
+ va_list args;
+ va_start(args, fmt);
+ success = linear_vasprintf_append(parent, str, fmt, args);
+ va_end(args);
+ return success;
+}
+
+bool
+linear_vasprintf_append(void *parent, char **str, const char *fmt, va_list args)
+{
+ size_t existing_length;
+ assert(str != NULL);
+ existing_length = *str ? strlen(*str) : 0;
+ return linear_vasprintf_rewrite_tail(parent, str, &existing_length, fmt, args);
+}
+
+bool
+linear_asprintf_rewrite_tail(void *parent, char **str, size_t *start,
+ const char *fmt, ...)
+{
+ bool success;
+ va_list args;
+ va_start(args, fmt);
+ success = linear_vasprintf_rewrite_tail(parent, str, start, fmt, args);
+ va_end(args);
+ return success;
+}
+
+bool
+linear_vasprintf_rewrite_tail(void *parent, char **str, size_t *start,
+ const char *fmt, va_list args)
+{
+ size_t new_length;
+ char *ptr;
+
+ assert(str != NULL);
+
+ if (unlikely(*str == NULL)) {
+ *str = linear_vasprintf(parent, fmt, args);
+ *start = strlen(*str);
+ return true;
+ }
+
+ new_length = printf_length(fmt, args);
+
+ ptr = linear_realloc(parent, *str, *start + new_length + 1);
+ if (unlikely(ptr == NULL))
+ return false;
+
+ vsnprintf(ptr + *start, new_length + 1, fmt, args);
+ *str = ptr;
+ *start += new_length;
+ return true;
+}
+
+/* helper routine for strcat/strncat - n is the exact amount to copy */
+static bool
+linear_cat(void *parent, char **dest, const char *str, unsigned n)
+{
+ char *both;
+ unsigned existing_length;
+ assert(dest != NULL && *dest != NULL);
+
+ existing_length = strlen(*dest);
+ both = linear_realloc(parent, *dest, existing_length + n + 1);
+ if (unlikely(both == NULL))
+ return false;
+
+ memcpy(both + existing_length, str, n);
+ both[existing_length + n] = '\0';
+
+ *dest = both;
+ return true;
+}
+
+bool
+linear_strcat(void *parent, char **dest, const char *str)
+{
+ return linear_cat(parent, dest, str, strlen(str));
+}
diff --git a/lib/mesa/src/util/ralloc.h b/lib/mesa/src/util/ralloc.h
index 7587e1190..b91bc4cf5 100644
--- a/lib/mesa/src/util/ralloc.h
+++ b/lib/mesa/src/util/ralloc.h
@@ -247,15 +247,6 @@ void ralloc_adopt(const void *new_ctx, void *old_ctx);
void *ralloc_parent(const void *ptr);
/**
- * Return a context whose memory will be automatically freed at program exit.
- *
- * The first call to this function creates a context and registers a handler
- * to free it using \c atexit. This may cause trouble if used in a library
- * loaded with \c dlopen.
- */
-void *ralloc_autofree_context(void);
-
-/**
* Set a callback to occur just before an object is freed.
*/
void ralloc_set_destructor(const void *ptr, void(*destructor)(void *));
@@ -302,6 +293,24 @@ bool ralloc_strcat(char **dest, const char *str);
bool ralloc_strncat(char **dest, const char *str, size_t n);
/**
+ * Concatenate two strings, allocating the necessary space.
+ *
+ * This appends \p n bytes of \p str to \p *dest, using ralloc_resize
+ * to expand \p *dest to the appropriate size. \p dest will be updated to the
+ * new pointer unless allocation fails.
+ *
+ * The result will always be null-terminated.
+ *
+ * This function differs from ralloc_strcat() and ralloc_strncat() in that it
+ * does not do any strlen() calls which can become costly on large strings.
+ *
+ * \return True unless allocation failed.
+ */
+bool
+ralloc_str_append(char **dest, const char *str,
+ size_t existing_length, size_t str_size);
+
+/**
* Print to a string.
*
* This is analogous to \c sprintf, but allocates enough space (using \p ctx
@@ -407,10 +416,6 @@ bool ralloc_asprintf_append (char **str, const char *fmt, ...)
bool ralloc_vasprintf_append(char **str, const char *fmt, va_list args);
/// @}
-#ifdef __cplusplus
-} /* end of extern "C" */
-#endif
-
/**
* Declare C++ new and delete operators which use ralloc.
*
@@ -421,7 +426,7 @@ bool ralloc_vasprintf_append(char **str, const char *fmt, va_list args);
*
* which is more idiomatic in C++ than calling ralloc.
*/
-#define DECLARE_RALLOC_CXX_OPERATORS(TYPE) \
+#define DECLARE_ALLOC_CXX_OPERATORS_TEMPLATE(TYPE, ALLOC_FUNC, USE_DESTRUCTOR) \
private: \
static void _ralloc_destructor(void *p) \
{ \
@@ -430,9 +435,9 @@ private: \
public: \
static void* operator new(size_t size, void *mem_ctx) \
{ \
- void *p = ralloc_size(mem_ctx, size); \
+ void *p = ALLOC_FUNC(mem_ctx, size); \
assert(p != NULL); \
- if (!HAS_TRIVIAL_DESTRUCTOR(TYPE)) \
+ if (USE_DESTRUCTOR && !HAS_TRIVIAL_DESTRUCTOR(TYPE)) \
ralloc_set_destructor(p, _ralloc_destructor); \
return p; \
} \
@@ -448,5 +453,90 @@ public: \
ralloc_free(p); \
}
+#define DECLARE_RALLOC_CXX_OPERATORS(type) \
+ DECLARE_ALLOC_CXX_OPERATORS_TEMPLATE(type, ralloc_size, true)
+
+#define DECLARE_RZALLOC_CXX_OPERATORS(type) \
+ DECLARE_ALLOC_CXX_OPERATORS_TEMPLATE(type, rzalloc_size, true)
+
+#define DECLARE_LINEAR_ALLOC_CXX_OPERATORS(type) \
+ DECLARE_ALLOC_CXX_OPERATORS_TEMPLATE(type, linear_alloc_child, false)
+
+#define DECLARE_LINEAR_ZALLOC_CXX_OPERATORS(type) \
+ DECLARE_ALLOC_CXX_OPERATORS_TEMPLATE(type, linear_zalloc_child, false)
+
+
+/**
+ * Do a fast allocation from the linear buffer, also known as the child node
+ * from the allocator's point of view. It can't be freed directly. You have
+ * to free the parent or the ralloc parent.
+ *
+ * \param parent parent node of the linear allocator
+ * \param size size to allocate (max 32 bits)
+ */
+void *linear_alloc_child(void *parent, unsigned size);
+
+/**
+ * Allocate a parent node that will hold linear buffers. The returned
+ * allocation is actually the first child node, but it's also the handle
+ * of the parent node. Use it for all child node allocations.
+ *
+ * \param ralloc_ctx ralloc context, must not be NULL
+ * \param size size to allocate (max 32 bits)
+ */
+void *linear_alloc_parent(void *ralloc_ctx, unsigned size);
+
+/**
+ * Same as linear_alloc_child, but also clears memory.
+ */
+void *linear_zalloc_child(void *parent, unsigned size);
+
+/**
+ * Same as linear_alloc_parent, but also clears memory.
+ */
+void *linear_zalloc_parent(void *ralloc_ctx, unsigned size);
+
+/**
+ * Free the linear parent node. This will free all child nodes too.
+ * Freeing the ralloc parent will also free this.
+ */
+void linear_free_parent(void *ptr);
+
+/**
+ * Same as ralloc_steal, but steals the linear parent node.
+ */
+void ralloc_steal_linear_parent(void *new_ralloc_ctx, void *ptr);
+
+/**
+ * Return the ralloc parent of the linear parent node.
+ */
+void *ralloc_parent_of_linear_parent(void *ptr);
+
+/**
+ * Same as realloc except that the linear allocator doesn't free child nodes,
+ * so it's reduced to memory duplication. It's used in places where
+ * reallocation is required. Don't use it often. It's much slower than
+ * realloc.
+ */
+void *linear_realloc(void *parent, void *old, unsigned new_size);
+
+/* The functions below have the same semantics as their ralloc counterparts,
+ * except that they always allocate a linear child node.
+ */
+char *linear_strdup(void *parent, const char *str);
+char *linear_asprintf(void *parent, const char *fmt, ...);
+char *linear_vasprintf(void *parent, const char *fmt, va_list args);
+bool linear_asprintf_append(void *parent, char **str, const char *fmt, ...);
+bool linear_vasprintf_append(void *parent, char **str, const char *fmt,
+ va_list args);
+bool linear_asprintf_rewrite_tail(void *parent, char **str, size_t *start,
+ const char *fmt, ...);
+bool linear_vasprintf_rewrite_tail(void *parent, char **str, size_t *start,
+ const char *fmt, va_list args);
+bool linear_strcat(void *parent, char **dest, const char *str);
+
+#ifdef __cplusplus
+} /* end of extern "C" */
+#endif
#endif
diff --git a/lib/mesa/src/util/rand_xor.c b/lib/mesa/src/util/rand_xor.c
new file mode 100644
index 000000000..09febcc33
--- /dev/null
+++ b/lib/mesa/src/util/rand_xor.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2017 Timothy Arceri
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_GETENTROPY
+
+#ifdef HAVE_SYS_RANDOM_H
+#include <sys/random.h>
+#else
+#include <unistd.h>
+#endif
+
+#elif defined(__linux__)
+#include <sys/file.h>
+#include <unistd.h>
+#include <fcntl.h>
+#else
+#include <time.h>
+#endif
+
+#include "rand_xor.h"
+
+/* Super fast random number generator.
+ *
+ * This rand_xorshift128plus function by Sebastiano Vigna belongs
+ * to the public domain.
+ */
+uint64_t
+rand_xorshift128plus(uint64_t *seed)
+{
+ uint64_t *s = seed;
+
+ uint64_t s1 = s[0];
+ const uint64_t s0 = s[1];
+ s[0] = s0;
+ s1 ^= s1 << 23;
+ s[1] = s1 ^ s0 ^ (s1 >> 18) ^ (s0 >> 5);
+
+ return s[1] + s0;
+}
+
+void
+s_rand_xorshift128plus(uint64_t *seed, bool randomised_seed)
+{
+ if (!randomised_seed)
+ goto fixed_seed;
+
+#ifdef HAVE_GETENTROPY
+ size_t seed_size = sizeof(uint64_t) * 2;
+ if (getentropy(seed, seed_size) == -1)
+ goto fixed_seed;
+ return;
+#elif defined(__linux__)
+ int fd = open("/dev/urandom", O_RDONLY);
+ if (fd < 0)
+ goto fixed_seed;
+
+ size_t seed_size = sizeof(uint64_t) * 2;
+ if (read(fd, seed, seed_size) != seed_size) {
+ close(fd);
+ goto fixed_seed;
+ }
+
+ close(fd);
+ return;
+
+#else
+ seed[0] = 0x3bffb83978e24f88;
+ seed[1] = time(NULL);
+
+ return;
+#endif
+
+fixed_seed:
+
+ /* Fallback to a fixed seed */
+ seed[0] = 0x3bffb83978e24f88;
+ seed[1] = 0x9238d5d56c71cd35;
+}
diff --git a/lib/mesa/src/util/string_to_uint_map.cpp b/lib/mesa/src/util/rand_xor.h
index 35fb76bf7..532d549bc 100644
--- a/lib/mesa/src/util/string_to_uint_map.cpp
+++ b/lib/mesa/src/util/rand_xor.h
@@ -1,5 +1,5 @@
/*
- * Copyright © 2011 Intel Corporation
+ * Copyright 2017 Timothy Arceri
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -16,27 +16,22 @@
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * \file string_to_uint_map.cpp
- * \brief Dumb wrapprs so that C code can create and destroy maps.
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
*
- * \author Ian Romanick <ian.d.romanick@intel.com>
*/
-#include "string_to_uint_map.h"
-extern "C" struct string_to_uint_map *
-string_to_uint_map_ctor()
-{
- return new string_to_uint_map;
-}
+#ifndef RAND_XOR_H
+#define RAND_XOR_H
+
+#include <stdint.h>
+#include <stdbool.h>
+
+uint64_t
+rand_xorshift128plus(uint64_t *seed);
+
+void
+s_rand_xorshift128plus(uint64_t *seed, bool randomised_seed);
-extern "C" void
-string_to_uint_map_dtor(struct string_to_uint_map *map)
-{
- delete map;
-}
+#endif /* RAND_XOR_H */
diff --git a/lib/mesa/src/util/register_allocate.h b/lib/mesa/src/util/register_allocate.h
index 628d2bbbc..7c4054264 100644
--- a/lib/mesa/src/util/register_allocate.h
+++ b/lib/mesa/src/util/register_allocate.h
@@ -25,8 +25,11 @@
*
*/
-#include <stdbool.h>
+#ifndef REGISTER_ALLOCATE_H
+#define REGISTER_ALLOCATE_H
+#include <stdbool.h>
+#include "util/bitset.h"
#ifdef __cplusplus
extern "C" {
@@ -72,6 +75,11 @@ void ra_set_finalize(struct ra_regs *regs, unsigned int **conflicts);
struct ra_graph *ra_alloc_interference_graph(struct ra_regs *regs,
unsigned int count);
void ra_set_node_class(struct ra_graph *g, unsigned int n, unsigned int c);
+void ra_set_select_reg_callback(struct ra_graph *g,
+ unsigned int (*callback)(struct ra_graph *g,
+ BITSET_WORD *regs,
+ void *data),
+ void *data);
void ra_add_node_interference(struct ra_graph *g,
unsigned int n1, unsigned int n2);
/** @} */
@@ -89,3 +97,5 @@ int ra_get_best_spill_node(struct ra_graph *g);
#ifdef __cplusplus
} // extern "C"
#endif
+
+#endif /* REGISTER_ALLOCATE_H */
diff --git a/lib/mesa/src/util/set.c b/lib/mesa/src/util/set.c
index 99abefd06..392506639 100644
--- a/lib/mesa/src/util/set.c
+++ b/lib/mesa/src/util/set.c
@@ -45,8 +45,8 @@
* free to avoid exponential performance degradation as the hash table fills
*/
-uint32_t deleted_key_value;
-const void *deleted_key = &deleted_key_value;
+static const uint32_t deleted_key_value;
+static const void *deleted_key = &deleted_key_value;
static const struct {
uint32_t max_entries, size, rehash;
diff --git a/lib/mesa/src/util/sha1/README b/lib/mesa/src/util/sha1/README
new file mode 100644
index 000000000..f30acf984
--- /dev/null
+++ b/lib/mesa/src/util/sha1/README
@@ -0,0 +1,62 @@
+This local copy of a SHA1 implementation based on the sources below.
+
+Why:
+ - Some libraries suffer from race condition and other issues. For example see
+commit ade3108bb5b0 ("util: Fix race condition on libgcrypt initialization").
+
+ - Fold the handling and detection of _eight_ implementations at configure
+stage and _seven_ different codepaths.
+
+ - Have a single, uniform, code used by developers, testers and users.
+
+ - Avoid conflicts when using software which ships with it's own SHA1 library.
+The latter of which conflicting with the one mesa is build against.
+
+
+
+Source:
+The SHA1 implementation is copied verbatim from the following links.
+At the time of checkout HEAD is 1.25 and 1.24 respectively.
+
+http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/lib/libc/hash/sha1.c?rev=HEAD
+http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/include/sha1.h?rev=HEAD
+
+
+Notes:
+ - The files should not have any local changes. If there are any they should be
+clearly documented below and one should aim to upstream them where possible.
+
+ - Files will be periodically syncronised with the respective upstream sources.
+Updates will be made regularly, but since the code is _not_ aimed as a
+cryptography solution any issues found should not be considered security ones.
+
+
+Local changes:
+ - Removed __bounded__ attribute qualifiers. Unavailable on platforms targeted
+by Mesa. Upstream status: TBD (N/A ?)
+
+ - Pick the sha1.h header from the current folder, by using "" over <> in the
+include directive. Upstream status: TBD
+
+ - Remove unused function prototypes - SHA1End, SHA1File, SHA1FileChunk and
+SHA1Data. Upstream status: TBD
+
+ - Use stdint.h integer types - u_int{8,16,32}_t -> uint{8,16,32}_t and
+u_int -> uint32_t, change header include. Upstream status: TBD
+
+ - Revert sha1.c rev 1.26 change (introduce DEF_WEAK).
+Upstream status: TBD (N/A ?)
+
+ - Add stdint.h include in sha1.h for uint*_t types. Upstream status: TBD
+
+ - Add stddef.h include in sha1.h for size_t type. Upstream status: TBD
+
+ - Use memset over explicit_bzero, since memset_s once isn't widely available.
+Upstream status: TBD (N/A ?)
+
+ - Manually expand __BEGIN_DECLS/__END_DECLS and make sure that they include
+the struct declaration.
+Upstream status: TBD
+
+ - Add non-typedef struct name.
+Upstream status: TBD
diff --git a/lib/mesa/src/util/sha1/sha1.c b/lib/mesa/src/util/sha1/sha1.c
new file mode 100644
index 000000000..f36a77c20
--- /dev/null
+++ b/lib/mesa/src/util/sha1/sha1.c
@@ -0,0 +1,174 @@
+/* $OpenBSD: sha1.c,v 1.26 2015/09/11 09:18:27 guenther Exp $ */
+
+/*
+ * SHA-1 in C
+ * By Steve Reid <steve@edmweb.com>
+ * 100% Public Domain
+ *
+ * Test Vectors (from FIPS PUB 180-1)
+ * "abc"
+ * A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
+ * "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+ * 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
+ * A million repetitions of "a"
+ * 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
+ */
+
+#include <stdint.h>
+#include <string.h>
+#include "u_endian.h"
+#include "sha1.h"
+
+#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
+
+/*
+ * blk0() and blk() perform the initial expand.
+ * I got the idea of expanding during the round function from SSLeay
+ */
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
+# define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
+ |(rol(block->l[i],8)&0x00FF00FF))
+#else
+# define blk0(i) block->l[i]
+#endif
+#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
+ ^block->l[(i+2)&15]^block->l[i&15],1))
+
+/*
+ * (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1
+ */
+#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
+#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
+#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
+
+typedef union {
+ uint8_t c[64];
+ uint32_t l[16];
+} CHAR64LONG16;
+
+/*
+ * Hash a single 512-bit block. This is the core of the algorithm.
+ */
+void
+SHA1Transform(uint32_t state[5], const uint8_t buffer[SHA1_BLOCK_LENGTH])
+{
+ uint32_t a, b, c, d, e;
+ uint8_t workspace[SHA1_BLOCK_LENGTH];
+ CHAR64LONG16 *block = (CHAR64LONG16 *)workspace;
+
+ (void)memcpy(block, buffer, SHA1_BLOCK_LENGTH);
+
+ /* Copy context->state[] to working vars */
+ a = state[0];
+ b = state[1];
+ c = state[2];
+ d = state[3];
+ e = state[4];
+
+ /* 4 rounds of 20 operations each. Loop unrolled. */
+ R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
+ R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
+ R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
+ R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
+ R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
+ R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
+ R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
+ R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
+ R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
+ R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
+ R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
+ R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
+ R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
+ R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
+ R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
+ R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
+ R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
+ R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
+ R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
+ R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
+
+ /* Add the working vars back into context.state[] */
+ state[0] += a;
+ state[1] += b;
+ state[2] += c;
+ state[3] += d;
+ state[4] += e;
+
+ /* Wipe variables */
+ a = b = c = d = e = 0;
+}
+
+
+/*
+ * SHA1Init - Initialize new context
+ */
+void
+SHA1Init(SHA1_CTX *context)
+{
+
+ /* SHA1 initialization constants */
+ context->count = 0;
+ context->state[0] = 0x67452301;
+ context->state[1] = 0xEFCDAB89;
+ context->state[2] = 0x98BADCFE;
+ context->state[3] = 0x10325476;
+ context->state[4] = 0xC3D2E1F0;
+}
+
+
+/*
+ * Run your data through this.
+ */
+void
+SHA1Update(SHA1_CTX *context, const uint8_t *data, size_t len)
+{
+ size_t i, j;
+
+ j = (size_t)((context->count >> 3) & 63);
+ context->count += (len << 3);
+ if ((j + len) > 63) {
+ (void)memcpy(&context->buffer[j], data, (i = 64-j));
+ SHA1Transform(context->state, context->buffer);
+ for ( ; i + 63 < len; i += 64)
+ SHA1Transform(context->state, (uint8_t *)&data[i]);
+ j = 0;
+ } else {
+ i = 0;
+ }
+ (void)memcpy(&context->buffer[j], &data[i], len - i);
+}
+
+
+/*
+ * Add padding and return the message digest.
+ */
+void
+SHA1Pad(SHA1_CTX *context)
+{
+ uint8_t finalcount[8];
+ uint32_t i;
+
+ for (i = 0; i < 8; i++) {
+ finalcount[i] = (uint8_t)((context->count >>
+ ((7 - (i & 7)) * 8)) & 255); /* Endian independent */
+ }
+ SHA1Update(context, (uint8_t *)"\200", 1);
+ while ((context->count & 504) != 448)
+ SHA1Update(context, (uint8_t *)"\0", 1);
+ SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */
+}
+
+void
+SHA1Final(uint8_t digest[SHA1_DIGEST_LENGTH], SHA1_CTX *context)
+{
+ uint32_t i;
+
+ SHA1Pad(context);
+ for (i = 0; i < SHA1_DIGEST_LENGTH; i++) {
+ digest[i] = (uint8_t)
+ ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
+ }
+ memset(context, 0, sizeof(*context));
+}
diff --git a/lib/mesa/src/util/sha1/sha1.h b/lib/mesa/src/util/sha1/sha1.h
new file mode 100644
index 000000000..029a0ae87
--- /dev/null
+++ b/lib/mesa/src/util/sha1/sha1.h
@@ -0,0 +1,53 @@
+/* $OpenBSD: sha1.h,v 1.24 2012/12/05 23:19:57 deraadt Exp $ */
+
+/*
+ * SHA-1 in C
+ * By Steve Reid <steve@edmweb.com>
+ * 100% Public Domain
+ */
+
+#ifndef _SHA1_H
+#define _SHA1_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+#define SHA1_BLOCK_LENGTH 64
+#define SHA1_DIGEST_LENGTH 20
+#define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct _SHA1_CTX {
+ uint32_t state[5];
+ uint64_t count;
+ uint8_t buffer[SHA1_BLOCK_LENGTH];
+} SHA1_CTX;
+
+void SHA1Init(SHA1_CTX *);
+void SHA1Pad(SHA1_CTX *);
+void SHA1Transform(uint32_t [5], const uint8_t [SHA1_BLOCK_LENGTH]);
+void SHA1Update(SHA1_CTX *, const uint8_t *, size_t);
+void SHA1Final(uint8_t [SHA1_DIGEST_LENGTH], SHA1_CTX *);
+
+#define HTONDIGEST(x) do { \
+ x[0] = htonl(x[0]); \
+ x[1] = htonl(x[1]); \
+ x[2] = htonl(x[2]); \
+ x[3] = htonl(x[3]); \
+ x[4] = htonl(x[4]); } while (0)
+
+#define NTOHDIGEST(x) do { \
+ x[0] = ntohl(x[0]); \
+ x[1] = ntohl(x[1]); \
+ x[2] = ntohl(x[2]); \
+ x[3] = ntohl(x[3]); \
+ x[4] = ntohl(x[4]); } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SHA1_H */
diff --git a/lib/mesa/src/util/slab.c b/lib/mesa/src/util/slab.c
index 4264814ca..4ce0e9a34 100644
--- a/lib/mesa/src/util/slab.c
+++ b/lib/mesa/src/util/slab.c
@@ -140,6 +140,9 @@ void slab_create_child(struct slab_child_pool *pool,
*/
void slab_destroy_child(struct slab_child_pool *pool)
{
+ if (!pool->parent)
+ return; /* the slab probably wasn't even created */
+
mtx_lock(&pool->parent->mutex);
while (pool->pages) {
diff --git a/lib/mesa/src/util/string_to_uint_map.h b/lib/mesa/src/util/string_to_uint_map.h
deleted file mode 100644
index e0533ec6e..000000000
--- a/lib/mesa/src/util/string_to_uint_map.h
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright © 2008 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- *
- */
-
-#ifndef STRING_TO_UINT_MAP_H
-#define STRING_TO_UINT_MAP_H
-
-#include <string.h>
-#include <limits.h>
-#include "util/hash_table.h"
-
-struct string_to_uint_map;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct string_to_uint_map *
-string_to_uint_map_ctor();
-
-void
-string_to_uint_map_dtor(struct string_to_uint_map *);
-
-
-#ifdef __cplusplus
-}
-
-struct string_map_iterate_wrapper_closure {
- void (*callback)(const char *key, unsigned value, void *closure);
- void *closure;
-};
-
-/**
- * Map from a string (name) to an unsigned integer value
- *
- * \note
- * Because of the way this class interacts with the \c hash_table
- * implementation, values of \c UINT_MAX cannot be stored in the map.
- */
-struct string_to_uint_map {
-public:
- string_to_uint_map()
- {
- this->ht = _mesa_hash_table_create(NULL, _mesa_key_hash_string,
- _mesa_key_string_equal);
- }
-
- ~string_to_uint_map()
- {
- hash_table_call_foreach(this->ht, delete_key, NULL);
- _mesa_hash_table_destroy(this->ht, NULL);
- }
-
- /**
- * Remove all mappings from this map.
- */
- void clear()
- {
- hash_table_call_foreach(this->ht, delete_key, NULL);
- _mesa_hash_table_clear(this->ht, NULL);
- }
-
- /**
- * Runs a passed callback for the hash
- */
- void iterate(void (*func)(const char *, unsigned, void *), void *closure)
- {
- struct string_map_iterate_wrapper_closure *wrapper;
-
- wrapper = (struct string_map_iterate_wrapper_closure *)
- malloc(sizeof(struct string_map_iterate_wrapper_closure));
- if (wrapper == NULL)
- return;
-
- wrapper->callback = func;
- wrapper->closure = closure;
-
- hash_table_call_foreach(this->ht, subtract_one_wrapper, wrapper);
- free(wrapper);
- }
-
- /**
- * Get the value associated with a particular key
- *
- * \return
- * If \c key is found in the map, \c true is returned. Otherwise \c false
- * is returned.
- *
- * \note
- * If \c key is not found in the table, \c value is not modified.
- */
- bool get(unsigned &value, const char *key)
- {
- hash_entry *entry = _mesa_hash_table_search(this->ht,
- (const void *) key);
-
- if (!entry)
- return false;
-
- const intptr_t v = (intptr_t) entry->data;
- value = (unsigned)(v - 1);
- return true;
- }
-
- void put(unsigned value, const char *key)
- {
- /* The low-level hash table structure returns NULL if key is not in the
- * hash table. However, users of this map might want to store zero as a
- * valid value in the table. Bias the value by +1 so that a
- * user-specified zero is stored as 1. This enables ::get to tell the
- * difference between a user-specified zero (returned as 1 by
- * _mesa_hash_table_search) and the key not in the table (returned as 0 by
- * _mesa_hash_table_search).
- *
- * The net effect is that we can't store UINT_MAX in the table. This is
- * because UINT_MAX+1 = 0.
- */
- assert(value != UINT_MAX);
- char *dup_key = strdup(key);
-
- struct hash_entry *entry = _mesa_hash_table_search(this->ht, dup_key);
- if (entry) {
- entry->data = (void *) (intptr_t) (value + 1);
- } else {
- _mesa_hash_table_insert(this->ht, dup_key,
- (void *) (intptr_t) (value + 1));
- }
-
- if (entry)
- free(dup_key);
- }
-
-private:
- static void delete_key(const void *key, void *data, void *closure)
- {
- (void) data;
- (void) closure;
-
- free((char *)key);
- }
-
- static void subtract_one_wrapper(const void *key, void *data, void *closure)
- {
- struct string_map_iterate_wrapper_closure *wrapper =
- (struct string_map_iterate_wrapper_closure *) closure;
- unsigned value = (intptr_t) data;
-
- value -= 1;
-
- wrapper->callback((const char *) key, value, wrapper->closure);
- }
-
- struct hash_table *ht;
-};
-
-#endif /* __cplusplus */
-#endif /* STRING_TO_UINT_MAP_H */
diff --git a/lib/mesa/src/util/strndup.h b/lib/mesa/src/util/strndup.h
index c5ed7a8c8..dcaa429db 100644
--- a/lib/mesa/src/util/strndup.h
+++ b/lib/mesa/src/util/strndup.h
@@ -21,20 +21,40 @@
* IN THE SOFTWARE.
*/
-#pragma once
-
-#include <stdlib.h> // size_t
+#ifndef STRNDUP_H
+#define STRNDUP_H
#if defined(_WIN32)
+#include <stdlib.h> // size_t
+#include <string.h>
+
#ifdef __cplusplus
extern "C" {
#endif
-char *strndup(const char *str, size_t max);
+static inline char *
+strndup(const char *str, size_t max)
+{
+ size_t n;
+ char *ptr;
+
+ if (!str)
+ return NULL;
+
+ n = strnlen(str, max);
+ ptr = (char *) calloc(n + 1, sizeof(char));
+ if (!ptr)
+ return NULL;
+
+ memcpy(ptr, str, n);
+ return ptr;
+}
#ifdef __cplusplus
}
#endif
-#endif
+#endif /* _WIN32 */
+
+#endif /* STRNDUP_H */
diff --git a/lib/mesa/src/util/strtod.c b/lib/mesa/src/util/strtod.c
index ea7d395e2..de695d64b 100644
--- a/lib/mesa/src/util/strtod.c
+++ b/lib/mesa/src/util/strtod.c
@@ -26,12 +26,12 @@
#include <stdlib.h>
-#ifdef _GNU_SOURCE
+#if defined(_GNU_SOURCE) && defined(HAVE_STRTOD_L)
#include <locale.h>
#ifdef HAVE_XLOCALE_H
#include <xlocale.h>
-static locale_t loc;
#endif
+static locale_t loc;
#endif
#include "strtod.h"
@@ -40,7 +40,7 @@ static locale_t loc;
void
_mesa_locale_init(void)
{
-#if defined(_GNU_SOURCE) && defined(HAVE_XLOCALE_H)
+#if defined(_GNU_SOURCE) && defined(HAVE_STRTOD_L)
loc = newlocale(LC_CTYPE_MASK, "C", NULL);
#endif
}
@@ -48,7 +48,7 @@ _mesa_locale_init(void)
void
_mesa_locale_fini(void)
{
-#if defined(_GNU_SOURCE) && defined(HAVE_XLOCALE_H)
+#if defined(_GNU_SOURCE) && defined(HAVE_STRTOD_L)
freelocale(loc);
#endif
}
@@ -60,7 +60,7 @@ _mesa_locale_fini(void)
double
_mesa_strtod(const char *s, char **end)
{
-#if defined(_GNU_SOURCE) && defined(HAVE_XLOCALE_H)
+#if defined(_GNU_SOURCE) && defined(HAVE_STRTOD_L)
return strtod_l(s, end, loc);
#else
return strtod(s, end);
@@ -75,7 +75,7 @@ _mesa_strtod(const char *s, char **end)
float
_mesa_strtof(const char *s, char **end)
{
-#if defined(_GNU_SOURCE) && defined(HAVE_XLOCALE_H)
+#if defined(_GNU_SOURCE) && defined(HAVE_STRTOD_L)
return strtof_l(s, end, loc);
#elif defined(HAVE_STRTOF)
return strtof(s, end);
diff --git a/lib/mesa/src/util/tests/hash_table/Makefile.in b/lib/mesa/src/util/tests/hash_table/Makefile.in
index f57d20cda..76d687dcc 100644
--- a/lib/mesa/src/util/tests/hash_table/Makefile.in
+++ b/lib/mesa/src/util/tests/hash_table/Makefile.in
@@ -80,7 +80,8 @@ subdir = src/util/tests/hash_table
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(top_srcdir)/bin/depcomp
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_gnu_make.m4 \
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_compile_flag.m4 \
+ $(top_srcdir)/m4/ax_check_gnu_make.m4 \
$(top_srcdir)/m4/ax_check_python_mako_module.m4 \
$(top_srcdir)/m4/ax_gcc_builtin.m4 \
$(top_srcdir)/m4/ax_gcc_func_attribute.m4 \
@@ -223,6 +224,8 @@ AMDGPU_CFLAGS = @AMDGPU_CFLAGS@
AMDGPU_LIBS = @AMDGPU_LIBS@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+ANDROID_CFLAGS = @ANDROID_CFLAGS@
+ANDROID_LIBS = @ANDROID_LIBS@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
@@ -253,8 +256,6 @@ DLLTOOL = @DLLTOOL@
DLOPEN_LIBS = @DLOPEN_LIBS@
DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
DRI2PROTO_LIBS = @DRI2PROTO_LIBS@
-DRI3PROTO_CFLAGS = @DRI3PROTO_CFLAGS@
-DRI3PROTO_LIBS = @DRI3PROTO_LIBS@
DRIGL_CFLAGS = @DRIGL_CFLAGS@
DRIGL_LIBS = @DRIGL_LIBS@
DRI_DRIVER_INSTALL_DIR = @DRI_DRIVER_INSTALL_DIR@
@@ -267,10 +268,11 @@ ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGL_CFLAGS = @EGL_CFLAGS@
-EGL_CLIENT_APIS = @EGL_CLIENT_APIS@
EGL_LIB_DEPS = @EGL_LIB_DEPS@
EGL_NATIVE_PLATFORM = @EGL_NATIVE_PLATFORM@
EGREP = @EGREP@
+ETNAVIV_CFLAGS = @ETNAVIV_CFLAGS@
+ETNAVIV_LIBS = @ETNAVIV_LIBS@
EXEEXT = @EXEEXT@
EXPAT_CFLAGS = @EXPAT_CFLAGS@
EXPAT_LIBS = @EXPAT_LIBS@
@@ -297,6 +299,8 @@ GL_PC_LIB_PRIV = @GL_PC_LIB_PRIV@
GL_PC_REQ_PRIV = @GL_PC_REQ_PRIV@
GREP = @GREP@
HAVE_XF86VIDMODE = @HAVE_XF86VIDMODE@
+I915_CFLAGS = @I915_CFLAGS@
+I915_LIBS = @I915_LIBS@
INDENT = @INDENT@
INDENT_FLAGS = @INDENT_FLAGS@
INSTALL = @INSTALL@
@@ -304,45 +308,40 @@ INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-INTEL_CFLAGS = @INTEL_CFLAGS@
-INTEL_LIBS = @INTEL_LIBS@
LD = @LD@
LDFLAGS = @LDFLAGS@
LD_NO_UNDEFINED = @LD_NO_UNDEFINED@
LEX = @LEX@
LEXLIB = @LEXLIB@
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBATOMIC_LIBS = @LIBATOMIC_LIBS@
LIBCLC_INCLUDEDIR = @LIBCLC_INCLUDEDIR@
LIBCLC_LIBEXECDIR = @LIBCLC_LIBEXECDIR@
LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
LIBDRM_LIBS = @LIBDRM_LIBS@
LIBELF_CFLAGS = @LIBELF_CFLAGS@
LIBELF_LIBS = @LIBELF_LIBS@
+LIBGLVND_DATADIR = @LIBGLVND_DATADIR@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
-LIBSENSORS_LDFLAGS = @LIBSENSORS_LDFLAGS@
-LIBSHA1_CFLAGS = @LIBSHA1_CFLAGS@
-LIBSHA1_LIBS = @LIBSHA1_LIBS@
+LIBSENSORS_LIBS = @LIBSENSORS_LIBS@
LIBTOOL = @LIBTOOL@
+LIBUNWIND_CFLAGS = @LIBUNWIND_CFLAGS@
+LIBUNWIND_LIBS = @LIBUNWIND_LIBS@
LIB_DIR = @LIB_DIR@
LIB_EXT = @LIB_EXT@
LIPO = @LIPO@
-LLVM_BINDIR = @LLVM_BINDIR@
LLVM_CFLAGS = @LLVM_CFLAGS@
LLVM_CONFIG = @LLVM_CONFIG@
-LLVM_CPPFLAGS = @LLVM_CPPFLAGS@
LLVM_CXXFLAGS = @LLVM_CXXFLAGS@
LLVM_INCLUDEDIR = @LLVM_INCLUDEDIR@
LLVM_LDFLAGS = @LLVM_LDFLAGS@
-LLVM_LIBDIR = @LLVM_LIBDIR@
LLVM_LIBS = @LLVM_LIBS@
-LLVM_VERSION = @LLVM_VERSION@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
-MESA_LLVM = @MESA_LLVM@
MKDIR_P = @MKDIR_P@
MSVC2013_COMPAT_CFLAGS = @MSVC2013_COMPAT_CFLAGS@
MSVC2013_COMPAT_CXXFLAGS = @MSVC2013_COMPAT_CXXFLAGS@
@@ -358,13 +357,11 @@ NVVIEUX_CFLAGS = @NVVIEUX_CFLAGS@
NVVIEUX_LIBS = @NVVIEUX_LIBS@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
-OMX_CFLAGS = @OMX_CFLAGS@
-OMX_LIBS = @OMX_LIBS@
-OMX_LIB_INSTALL_DIR = @OMX_LIB_INSTALL_DIR@
+OMX_BELLAGIO_CFLAGS = @OMX_BELLAGIO_CFLAGS@
+OMX_BELLAGIO_LIBS = @OMX_BELLAGIO_LIBS@
+OMX_BELLAGIO_LIB_INSTALL_DIR = @OMX_BELLAGIO_LIB_INSTALL_DIR@
OPENCL_LIBNAME = @OPENCL_LIBNAME@
OPENCL_VERSION = @OPENCL_VERSION@
-OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
-OPENSSL_LIBS = @OPENSSL_LIBS@
OSMESA_LIB = @OSMESA_LIB@
OSMESA_LIB_DEPS = @OSMESA_LIB_DEPS@
OSMESA_PC_LIB_PRIV = @OSMESA_PC_LIB_PRIV@
@@ -384,8 +381,6 @@ PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
POSIX_SHELL = @POSIX_SHELL@
-PRESENTPROTO_CFLAGS = @PRESENTPROTO_CFLAGS@
-PRESENTPROTO_LIBS = @PRESENTPROTO_LIBS@
PTHREADSTUBS_CFLAGS = @PTHREADSTUBS_CFLAGS@
PTHREADSTUBS_LIBS = @PTHREADSTUBS_LIBS@
PTHREAD_CC = @PTHREAD_CC@
@@ -401,8 +396,6 @@ SED = @SED@
SELINUX_CFLAGS = @SELINUX_CFLAGS@
SELINUX_LIBS = @SELINUX_LIBS@
SET_MAKE = @SET_MAKE@
-SHA1_CFLAGS = @SHA1_CFLAGS@
-SHA1_LIBS = @SHA1_LIBS@
SHELL = @SHELL@
SIMPENROSE_CFLAGS = @SIMPENROSE_CFLAGS@
SIMPENROSE_LIBS = @SIMPENROSE_LIBS@
@@ -411,7 +404,8 @@ STRIP = @STRIP@
SWR_AVX2_CXXFLAGS = @SWR_AVX2_CXXFLAGS@
SWR_AVX_CXXFLAGS = @SWR_AVX_CXXFLAGS@
SWR_CXX11_CXXFLAGS = @SWR_CXX11_CXXFLAGS@
-TIMESTAMP_CMD = @TIMESTAMP_CMD@
+SWR_KNL_CXXFLAGS = @SWR_KNL_CXXFLAGS@
+SWR_SKX_CXXFLAGS = @SWR_SKX_CXXFLAGS@
VALGRIND_CFLAGS = @VALGRIND_CFLAGS@
VALGRIND_LIBS = @VALGRIND_LIBS@
VA_CFLAGS = @VA_CFLAGS@
@@ -419,25 +413,28 @@ VA_LIBS = @VA_LIBS@
VA_LIB_INSTALL_DIR = @VA_LIB_INSTALL_DIR@
VA_MAJOR = @VA_MAJOR@
VA_MINOR = @VA_MINOR@
-VC4_CFLAGS = @VC4_CFLAGS@
-VC4_LIBS = @VC4_LIBS@
+VC5_SIMULATOR_CFLAGS = @VC5_SIMULATOR_CFLAGS@
+VC5_SIMULATOR_LIBS = @VC5_SIMULATOR_LIBS@
VDPAU_CFLAGS = @VDPAU_CFLAGS@
VDPAU_LIBS = @VDPAU_LIBS@
VDPAU_LIB_INSTALL_DIR = @VDPAU_LIB_INSTALL_DIR@
VDPAU_MAJOR = @VDPAU_MAJOR@
VDPAU_MINOR = @VDPAU_MINOR@
VERSION = @VERSION@
-VG_LIB_DEPS = @VG_LIB_DEPS@
VISIBILITY_CFLAGS = @VISIBILITY_CFLAGS@
VISIBILITY_CXXFLAGS = @VISIBILITY_CXXFLAGS@
VL_CFLAGS = @VL_CFLAGS@
VL_LIBS = @VL_LIBS@
VULKAN_ICD_INSTALL_DIR = @VULKAN_ICD_INSTALL_DIR@
-WAYLAND_CFLAGS = @WAYLAND_CFLAGS@
-WAYLAND_LIBS = @WAYLAND_LIBS@
+WAYLAND_CLIENT_CFLAGS = @WAYLAND_CLIENT_CFLAGS@
+WAYLAND_CLIENT_LIBS = @WAYLAND_CLIENT_LIBS@
+WAYLAND_PROTOCOLS_DATADIR = @WAYLAND_PROTOCOLS_DATADIR@
WAYLAND_SCANNER = @WAYLAND_SCANNER@
WAYLAND_SCANNER_CFLAGS = @WAYLAND_SCANNER_CFLAGS@
WAYLAND_SCANNER_LIBS = @WAYLAND_SCANNER_LIBS@
+WAYLAND_SERVER_CFLAGS = @WAYLAND_SERVER_CFLAGS@
+WAYLAND_SERVER_LIBS = @WAYLAND_SERVER_LIBS@
+WNO_OVERRIDE_INIT = @WNO_OVERRIDE_INIT@
X11_INCLUDES = @X11_INCLUDES@
XA_MAJOR = @XA_MAJOR@
XA_MINOR = @XA_MINOR@
@@ -456,9 +453,10 @@ XVMC_LIBS = @XVMC_LIBS@
XVMC_LIB_INSTALL_DIR = @XVMC_LIB_INSTALL_DIR@
XVMC_MAJOR = @XVMC_MAJOR@
XVMC_MINOR = @XVMC_MINOR@
-XXD = @XXD@
YACC = @YACC@
YFLAGS = @YFLAGS@
+ZLIB_CFLAGS = @ZLIB_CFLAGS@
+ZLIB_LIBS = @ZLIB_LIBS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
diff --git a/lib/mesa/src/util/tests/string_buffer/Makefile.in b/lib/mesa/src/util/tests/string_buffer/Makefile.in
index a509e8305..ebaa93064 100644
--- a/lib/mesa/src/util/tests/string_buffer/Makefile.in
+++ b/lib/mesa/src/util/tests/string_buffer/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15.1 from Makefile.am.
+# Makefile.in generated by automake 1.12.6 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994-2017 Free Software Foundation, Inc.
+# Copyright (C) 1994-2012 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -35,61 +35,23 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
VPATH = @srcdir@
-am__is_gnu_make = { \
- if test -z '$(MAKELEVEL)'; then \
- false; \
- elif test -n '$(MAKE_HOST)'; then \
- true; \
- elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
- true; \
- else \
- false; \
- fi; \
-}
-am__make_running_with_option = \
- case $${target_option-} in \
- ?) ;; \
- *) echo "am__make_running_with_option: internal error: invalid" \
- "target option '$${target_option-}' specified" >&2; \
- exit 1;; \
- esac; \
- has_opt=no; \
- sane_makeflags=$$MAKEFLAGS; \
- if $(am__is_gnu_make); then \
- sane_makeflags=$$MFLAGS; \
- else \
+am__make_dryrun = \
+ { \
+ am__dry=no; \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
- bs=\\; \
- sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
- | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
- esac; \
- fi; \
- skip_next=no; \
- strip_trailopt () \
- { \
- flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
- }; \
- for flg in $$sane_makeflags; do \
- test $$skip_next = yes && { skip_next=no; continue; }; \
- case $$flg in \
- *=*|--*) continue;; \
- -*I) strip_trailopt 'I'; skip_next=yes;; \
- -*I?*) strip_trailopt 'I';; \
- -*O) strip_trailopt 'O'; skip_next=yes;; \
- -*O?*) strip_trailopt 'O';; \
- -*l) strip_trailopt 'l'; skip_next=yes;; \
- -*l?*) strip_trailopt 'l';; \
- -[dEDm]) skip_next=yes;; \
- -[JT]) skip_next=yes;; \
- esac; \
- case $$flg in \
- *$$target_option*) has_opt=yes; break;; \
+ echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
+ | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+ *) \
+ for am__flg in $$MAKEFLAGS; do \
+ case $$am__flg in \
+ *=*|--*) ;; \
+ *n*) am__dry=yes; break;; \
+ esac; \
+ done;; \
esac; \
- done; \
- test $$has_opt = yes
-am__make_dryrun = (target_option=n; $(am__make_running_with_option))
-am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+ test $$am__dry = yes; \
+ }
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@@ -112,6 +74,8 @@ target_triplet = @target@
TESTS = string_buffer_test$(EXEEXT)
check_PROGRAMS = $(am__EXEEXT_1)
subdir = src/util/tests/string_buffer
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+ $(top_srcdir)/bin/depcomp
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_compile_flag.m4 \
$(top_srcdir)/m4/ax_check_gnu_make.m4 \
@@ -126,7 +90,6 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_compile_flag.m4 \
$(top_srcdir)/VERSION $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
-DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
@@ -183,231 +146,12 @@ am__can_run_installinfo = \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
-am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
-# Read a list of newline-separated strings from the standard input,
-# and print each of them once, without duplicates. Input order is
-# *not* preserved.
-am__uniquify_input = $(AWK) '\
- BEGIN { nonempty = 0; } \
- { items[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in items) print i; }; } \
-'
-# Make sure the list of sources is unique. This is necessary because,
-# e.g., the same source file might be shared among _SOURCES variables
-# for different programs/libraries.
-am__define_uniq_tagged_files = \
- list='$(am__tagged_files)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__tty_colors_dummy = \
mgn= red= grn= lgn= blu= brg= std=; \
am__color_tests=no
-am__tty_colors = { \
- $(am__tty_colors_dummy); \
- if test "X$(AM_COLOR_TESTS)" = Xno; then \
- am__color_tests=no; \
- elif test "X$(AM_COLOR_TESTS)" = Xalways; then \
- am__color_tests=yes; \
- elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \
- am__color_tests=yes; \
- fi; \
- if test $$am__color_tests = yes; then \
- red=''; \
- grn=''; \
- lgn=''; \
- blu=''; \
- mgn=''; \
- brg=''; \
- std=''; \
- fi; \
-}
-am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
-am__vpath_adj = case $$p in \
- $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
- *) f=$$p;; \
- esac;
-am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
-am__install_max = 40
-am__nobase_strip_setup = \
- srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
-am__nobase_strip = \
- for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
-am__nobase_list = $(am__nobase_strip_setup); \
- for p in $$list; do echo "$$p $$p"; done | \
- sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
- $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
- if (++n[$$2] == $(am__install_max)) \
- { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
- END { for (dir in files) print dir, files[dir] }'
-am__base_list = \
- sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
- sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
-am__uninstall_files_from_dir = { \
- test -z "$$files" \
- || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
- || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
- $(am__cd) "$$dir" && rm -f $$files; }; \
- }
-am__recheck_rx = ^[ ]*:recheck:[ ]*
-am__global_test_result_rx = ^[ ]*:global-test-result:[ ]*
-am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]*
-# A command that, given a newline-separated list of test names on the
-# standard input, print the name of the tests that are to be re-run
-# upon "make recheck".
-am__list_recheck_tests = $(AWK) '{ \
- recheck = 1; \
- while ((rc = (getline line < ($$0 ".trs"))) != 0) \
- { \
- if (rc < 0) \
- { \
- if ((getline line2 < ($$0 ".log")) < 0) \
- recheck = 0; \
- break; \
- } \
- else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \
- { \
- recheck = 0; \
- break; \
- } \
- else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \
- { \
- break; \
- } \
- }; \
- if (recheck) \
- print $$0; \
- close ($$0 ".trs"); \
- close ($$0 ".log"); \
-}'
-# A command that, given a newline-separated list of test names on the
-# standard input, create the global log from their .trs and .log files.
-am__create_global_log = $(AWK) ' \
-function fatal(msg) \
-{ \
- print "fatal: making $@: " msg | "cat >&2"; \
- exit 1; \
-} \
-function rst_section(header) \
-{ \
- print header; \
- len = length(header); \
- for (i = 1; i <= len; i = i + 1) \
- printf "="; \
- printf "\n\n"; \
-} \
-{ \
- copy_in_global_log = 1; \
- global_test_result = "RUN"; \
- while ((rc = (getline line < ($$0 ".trs"))) != 0) \
- { \
- if (rc < 0) \
- fatal("failed to read from " $$0 ".trs"); \
- if (line ~ /$(am__global_test_result_rx)/) \
- { \
- sub("$(am__global_test_result_rx)", "", line); \
- sub("[ ]*$$", "", line); \
- global_test_result = line; \
- } \
- else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \
- copy_in_global_log = 0; \
- }; \
- if (copy_in_global_log) \
- { \
- rst_section(global_test_result ": " $$0); \
- while ((rc = (getline line < ($$0 ".log"))) != 0) \
- { \
- if (rc < 0) \
- fatal("failed to read from " $$0 ".log"); \
- print line; \
- }; \
- printf "\n"; \
- }; \
- close ($$0 ".trs"); \
- close ($$0 ".log"); \
-}'
-# Restructured Text title.
-am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; }
-# Solaris 10 'make', and several other traditional 'make' implementations,
-# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it
-# by disabling -e (using the XSI extension "set +e") if it's set.
-am__sh_e_setup = case $$- in *e*) set +e;; esac
-# Default flags passed to test drivers.
-am__common_driver_flags = \
- --color-tests "$$am__color_tests" \
- --enable-hard-errors "$$am__enable_hard_errors" \
- --expect-failure "$$am__expect_failure"
-# To be inserted before the command running the test. Creates the
-# directory for the log if needed. Stores in $dir the directory
-# containing $f, in $tst the test, in $log the log. Executes the
-# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and
-# passes TESTS_ENVIRONMENT. Set up options for the wrapper that
-# will run the test scripts (or their associated LOG_COMPILER, if
-# thy have one).
-am__check_pre = \
-$(am__sh_e_setup); \
-$(am__vpath_adj_setup) $(am__vpath_adj) \
-$(am__tty_colors); \
-srcdir=$(srcdir); export srcdir; \
-case "$@" in \
- */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \
- *) am__odir=.;; \
-esac; \
-test "x$$am__odir" = x"." || test -d "$$am__odir" \
- || $(MKDIR_P) "$$am__odir" || exit $$?; \
-if test -f "./$$f"; then dir=./; \
-elif test -f "$$f"; then dir=; \
-else dir="$(srcdir)/"; fi; \
-tst=$$dir$$f; log='$@'; \
-if test -n '$(DISABLE_HARD_ERRORS)'; then \
- am__enable_hard_errors=no; \
-else \
- am__enable_hard_errors=yes; \
-fi; \
-case " $(XFAIL_TESTS) " in \
- *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \
- am__expect_failure=yes;; \
- *) \
- am__expect_failure=no;; \
-esac; \
-$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT)
-# A shell command to get the names of the tests scripts with any registered
-# extension removed (i.e., equivalently, the names of the test logs, with
-# the '.log' extension removed). The result is saved in the shell variable
-# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly,
-# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)",
-# since that might cause problem with VPATH rewrites for suffix-less tests.
-# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'.
-am__set_TESTS_bases = \
- bases='$(TEST_LOGS)'; \
- bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \
- bases=`echo $$bases`
-RECHECK_LOGS = $(TEST_LOGS)
-AM_RECURSIVE_TARGETS = check recheck
-TEST_SUITE_LOG = test-suite.log
-TEST_EXTENSIONS = @EXEEXT@ .test
-LOG_DRIVER = $(SHELL) $(top_srcdir)/bin/test-driver
-LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS)
-am__set_b = \
- case '$@' in \
- */*) \
- case '$*' in \
- */*) b='$*';; \
- *) b=`echo '$@' | sed 's/\.log$$//'`; \
- esac;; \
- *) \
- b='$*';; \
- esac
-am__test_logs1 = $(TESTS:=.log)
-am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log)
-TEST_LOGS = $(am__test_logs2:.test.log=.log)
-TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/bin/test-driver
-TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
- $(TEST_LOG_FLAGS)
-am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/bin/depcomp \
- $(top_srcdir)/bin/test-driver
+am__tty_colors = $(am__tty_colors_dummy)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDGPU_CFLAGS = @AMDGPU_CFLAGS@
@@ -529,7 +273,7 @@ LLVM_LDFLAGS = @LLVM_LDFLAGS@
LLVM_LIBS = @LLVM_LIBS@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
-LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
+MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
@@ -695,7 +439,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
-runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@@ -727,8 +470,8 @@ string_buffer_test_LDADD = \
all: all-am
.SUFFIXES:
-.SUFFIXES: .cpp .lo .log .o .obj .test .test$(EXEEXT) .trs
-$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
@@ -740,6 +483,7 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/util/tests/string_buffer/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign src/util/tests/string_buffer/Makefile
+.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
@@ -752,9 +496,9 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(top_srcdir)/configure: $(am__configure_deps)
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
@@ -766,7 +510,6 @@ clean-checkPROGRAMS:
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
echo " rm -f" $$list; \
rm -f $$list
-
string_buffer_test$(EXEEXT): $(string_buffer_test_OBJECTS) $(string_buffer_test_DEPENDENCIES) $(EXTRA_string_buffer_test_DEPENDENCIES)
@rm -f string_buffer_test$(EXEEXT)
$(AM_V_CXXLD)$(CXXLINK) $(string_buffer_test_OBJECTS) $(string_buffer_test_LDADD) $(LIBS)
@@ -809,15 +552,26 @@ mostlyclean-libtool:
clean-libtool:
-rm -rf .libs _libs
-ID: $(am__tagged_files)
- $(am__define_uniq_tagged_files); mkid -fID $$unique
-tags: tags-am
-TAGS: tags
-
-tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
set x; \
here=`pwd`; \
- $(am__define_uniq_tagged_files); \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
@@ -829,11 +583,15 @@ tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$$unique; \
fi; \
fi
-ctags: ctags-am
-
-CTAGS: ctags
-ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
- $(am__define_uniq_tagged_files); \
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
@@ -842,10 +600,9 @@ GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
-cscopelist: cscopelist-am
-cscopelist-am: $(am__tagged_files)
- list='$(am__tagged_files)'; \
+cscopelist: $(HEADERS) $(SOURCES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
@@ -861,168 +618,98 @@ cscopelist-am: $(am__tagged_files)
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-# Recover from deleted '.trs' file; this should ensure that
-# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create
-# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells
-# to avoid problems with "make -n".
-.log.trs:
- rm -f $< $@
- $(MAKE) $(AM_MAKEFLAGS) $<
-
-# Leading 'am--fnord' is there to ensure the list of targets does not
-# expand to empty, as could happen e.g. with make check TESTS=''.
-am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck)
-am--force-recheck:
- @:
-
-$(TEST_SUITE_LOG): $(TEST_LOGS)
- @$(am__set_TESTS_bases); \
- am__f_ok () { test -f "$$1" && test -r "$$1"; }; \
- redo_bases=`for i in $$bases; do \
- am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \
- done`; \
- if test -n "$$redo_bases"; then \
- redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \
- redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \
- if $(am__make_dryrun); then :; else \
- rm -f $$redo_logs && rm -f $$redo_results || exit 1; \
- fi; \
- fi; \
- if test -n "$$am__remaking_logs"; then \
- echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
- "recursion detected" >&2; \
- elif test -n "$$redo_logs"; then \
- am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
- fi; \
- if $(am__make_dryrun); then :; else \
- st=0; \
- errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \
- for i in $$redo_bases; do \
- test -f $$i.trs && test -r $$i.trs \
- || { echo "$$errmsg $$i.trs" >&2; st=1; }; \
- test -f $$i.log && test -r $$i.log \
- || { echo "$$errmsg $$i.log" >&2; st=1; }; \
+check-TESTS: $(TESTS)
+ @failed=0; all=0; xfail=0; xpass=0; skip=0; \
+ srcdir=$(srcdir); export srcdir; \
+ list=' $(TESTS) '; \
+ $(am__tty_colors); \
+ if test -n "$$list"; then \
+ for tst in $$list; do \
+ if test -f ./$$tst; then dir=./; \
+ elif test -f $$tst; then dir=; \
+ else dir="$(srcdir)/"; fi; \
+ if $(TESTS_ENVIRONMENT) $${dir}$$tst $(AM_TESTS_FD_REDIRECT); then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xpass=`expr $$xpass + 1`; \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=XPASS; \
+ ;; \
+ *) \
+ col=$$grn; res=PASS; \
+ ;; \
+ esac; \
+ elif test $$? -ne 77; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xfail=`expr $$xfail + 1`; \
+ col=$$lgn; res=XFAIL; \
+ ;; \
+ *) \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=FAIL; \
+ ;; \
+ esac; \
+ else \
+ skip=`expr $$skip + 1`; \
+ col=$$blu; res=SKIP; \
+ fi; \
+ echo "$${col}$$res$${std}: $$tst"; \
done; \
- test $$st -eq 0 || exit 1; \
- fi
- @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \
- ws='[ ]'; \
- results=`for b in $$bases; do echo $$b.trs; done`; \
- test -n "$$results" || results=/dev/null; \
- all=` grep "^$$ws*:test-result:" $$results | wc -l`; \
- pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \
- fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \
- skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \
- xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \
- xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \
- error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \
- if test `expr $$fail + $$xpass + $$error` -eq 0; then \
- success=true; \
- else \
- success=false; \
- fi; \
- br='==================='; br=$$br$$br$$br$$br; \
- result_count () \
- { \
- if test x"$$1" = x"--maybe-color"; then \
- maybe_colorize=yes; \
- elif test x"$$1" = x"--no-color"; then \
- maybe_colorize=no; \
+ if test "$$all" -eq 1; then \
+ tests="test"; \
+ All=""; \
+ else \
+ tests="tests"; \
+ All="All "; \
+ fi; \
+ if test "$$failed" -eq 0; then \
+ if test "$$xfail" -eq 0; then \
+ banner="$$All$$all $$tests passed"; \
+ else \
+ if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
+ banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
+ fi; \
+ else \
+ if test "$$xpass" -eq 0; then \
+ banner="$$failed of $$all $$tests failed"; \
else \
- echo "$@: invalid 'result_count' usage" >&2; exit 4; \
+ if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
+ banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
fi; \
- shift; \
- desc=$$1 count=$$2; \
- if test $$maybe_colorize = yes && test $$count -gt 0; then \
- color_start=$$3 color_end=$$std; \
+ fi; \
+ dashes="$$banner"; \
+ skipped=""; \
+ if test "$$skip" -ne 0; then \
+ if test "$$skip" -eq 1; then \
+ skipped="($$skip test was not run)"; \
else \
- color_start= color_end=; \
+ skipped="($$skip tests were not run)"; \
fi; \
- echo "$${color_start}# $$desc $$count$${color_end}"; \
- }; \
- create_testsuite_report () \
- { \
- result_count $$1 "TOTAL:" $$all "$$brg"; \
- result_count $$1 "PASS: " $$pass "$$grn"; \
- result_count $$1 "SKIP: " $$skip "$$blu"; \
- result_count $$1 "XFAIL:" $$xfail "$$lgn"; \
- result_count $$1 "FAIL: " $$fail "$$red"; \
- result_count $$1 "XPASS:" $$xpass "$$red"; \
- result_count $$1 "ERROR:" $$error "$$mgn"; \
- }; \
- { \
- echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \
- $(am__rst_title); \
- create_testsuite_report --no-color; \
- echo; \
- echo ".. contents:: :depth: 2"; \
- echo; \
- for b in $$bases; do echo $$b; done \
- | $(am__create_global_log); \
- } >$(TEST_SUITE_LOG).tmp || exit 1; \
- mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \
- if $$success; then \
- col="$$grn"; \
- else \
- col="$$red"; \
- test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \
- fi; \
- echo "$${col}$$br$${std}"; \
- echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \
- echo "$${col}$$br$${std}"; \
- create_testsuite_report --maybe-color; \
- echo "$$col$$br$$std"; \
- if $$success; then :; else \
- echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \
- if test -n "$(PACKAGE_BUGREPORT)"; then \
- echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \
- fi; \
- echo "$$col$$br$$std"; \
- fi; \
- $$success || exit 1
-
-check-TESTS:
- @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list
- @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list
- @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
- @set +e; $(am__set_TESTS_bases); \
- log_list=`for i in $$bases; do echo $$i.log; done`; \
- trs_list=`for i in $$bases; do echo $$i.trs; done`; \
- log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \
- $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \
- exit $$?;
-recheck: all $(check_PROGRAMS)
- @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
- @set +e; $(am__set_TESTS_bases); \
- bases=`for i in $$bases; do echo $$i; done \
- | $(am__list_recheck_tests)` || exit 1; \
- log_list=`for i in $$bases; do echo $$i.log; done`; \
- log_list=`echo $$log_list`; \
- $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \
- am__force_recheck=am--force-recheck \
- TEST_LOGS="$$log_list"; \
- exit $$?
-string_buffer_test.log: string_buffer_test$(EXEEXT)
- @p='string_buffer_test$(EXEEXT)'; \
- b='string_buffer_test'; \
- $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
- --log-file $$b.log --trs-file $$b.trs \
- $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
- "$$tst" $(AM_TESTS_FD_REDIRECT)
-.test.log:
- @p='$<'; \
- $(am__set_b); \
- $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
- --log-file $$b.log --trs-file $$b.trs \
- $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
- "$$tst" $(AM_TESTS_FD_REDIRECT)
-@am__EXEEXT_TRUE@.test$(EXEEXT).log:
-@am__EXEEXT_TRUE@ @p='$<'; \
-@am__EXEEXT_TRUE@ $(am__set_b); \
-@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
-@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
-@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
-@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
+ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$skipped"; \
+ fi; \
+ report=""; \
+ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
+ report="Please report to $(PACKAGE_BUGREPORT)"; \
+ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$report"; \
+ fi; \
+ dashes=`echo "$$dashes" | sed s/./=/g`; \
+ if test "$$failed" -eq 0; then \
+ col="$$grn"; \
+ else \
+ col="$$red"; \
+ fi; \
+ echo "$${col}$$dashes$${std}"; \
+ echo "$${col}$$banner$${std}"; \
+ test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \
+ test -z "$$report" || echo "$${col}$$report$${std}"; \
+ echo "$${col}$$dashes$${std}"; \
+ test "$$failed" -eq 0; \
+ else :; fi
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
@@ -1080,9 +767,6 @@ install-strip:
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
- -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS)
- -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs)
- -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
clean-generic:
@@ -1166,9 +850,9 @@ uninstall-am:
.MAKE: check-am install-am install-strip
-.PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \
- clean-checkPROGRAMS clean-generic clean-libtool cscopelist-am \
- ctags ctags-am distclean distclean-compile distclean-generic \
+.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
+ clean-checkPROGRAMS clean-generic clean-libtool cscopelist \
+ ctags distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
@@ -1178,9 +862,7 @@ uninstall-am:
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
- recheck tags tags-am uninstall uninstall-am
-
-.PRECIOUS: Makefile
+ tags uninstall uninstall-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/lib/mesa/src/util/u_atomic.c b/lib/mesa/src/util/u_atomic.c
new file mode 100644
index 000000000..28fae1f16
--- /dev/null
+++ b/lib/mesa/src/util/u_atomic.c
@@ -0,0 +1,203 @@
+/*
+ * Copyright © 2017 Gražvydas Ignotas
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#if (defined(MISSING_32BIT_ATOMICS) || defined(MISSING_64BIT_ATOMICS)) && \
+ defined(HAVE_PTHREAD)
+
+#include <stdint.h>
+#include <pthread.h>
+
+#if defined(HAVE_FUNC_ATTRIBUTE_WEAK) && !defined(__CYGWIN__)
+#define WEAK __attribute__((weak))
+#else
+#define WEAK
+#endif
+
+static pthread_mutex_t sync_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+#ifdef MISSING_32BIT_ATOMICS
+
+WEAK uint8_t
+__sync_add_and_fetch_1(uint8_t *ptr, uint8_t val)
+{
+ uint8_t r;
+
+ pthread_mutex_lock(&sync_mutex);
+ *ptr += val;
+ r = *ptr;
+ pthread_mutex_unlock(&sync_mutex);
+
+ return r;
+}
+
+WEAK uint8_t
+__sync_sub_and_fetch_1(uint8_t *ptr, uint8_t val)
+{
+ uint8_t r;
+
+ pthread_mutex_lock(&sync_mutex);
+ *ptr -= val;
+ r = *ptr;
+ pthread_mutex_unlock(&sync_mutex);
+
+ return r;
+}
+
+WEAK uint8_t
+__sync_val_compare_and_swap_1(uint8_t *ptr, uint8_t oldval, uint8_t newval)
+{
+ uint8_t r;
+
+ pthread_mutex_lock(&sync_mutex);
+ r = *ptr;
+ if (*ptr == oldval)
+ *ptr = newval;
+ pthread_mutex_unlock(&sync_mutex);
+
+ return r;
+}
+
+WEAK uint16_t
+__sync_add_and_fetch_2(uint16_t *ptr, uint16_t val)
+{
+ uint16_t r;
+
+ pthread_mutex_lock(&sync_mutex);
+ *ptr += val;
+ r = *ptr;
+ pthread_mutex_unlock(&sync_mutex);
+
+ return r;
+}
+
+WEAK uint16_t
+__sync_sub_and_fetch_2(uint16_t *ptr, uint16_t val)
+{
+ uint16_t r;
+
+ pthread_mutex_lock(&sync_mutex);
+ *ptr -= val;
+ r = *ptr;
+ pthread_mutex_unlock(&sync_mutex);
+
+ return r;
+}
+
+WEAK uint16_t
+__sync_val_compare_and_swap_2(uint16_t *ptr, uint16_t oldval, uint16_t newval)
+{
+ uint16_t r;
+
+ pthread_mutex_lock(&sync_mutex);
+ r = *ptr;
+ if (*ptr == oldval)
+ *ptr = newval;
+ pthread_mutex_unlock(&sync_mutex);
+
+ return r;
+}
+
+WEAK uint32_t
+__sync_add_and_fetch_4(uint32_t *ptr, uint32_t val)
+{
+ uint32_t r;
+
+ pthread_mutex_lock(&sync_mutex);
+ *ptr += val;
+ r = *ptr;
+ pthread_mutex_unlock(&sync_mutex);
+
+ return r;
+}
+
+WEAK uint32_t
+__sync_sub_and_fetch_4(uint32_t *ptr, uint32_t val)
+{
+ uint32_t r;
+
+ pthread_mutex_lock(&sync_mutex);
+ *ptr -= val;
+ r = *ptr;
+ pthread_mutex_unlock(&sync_mutex);
+
+ return r;
+}
+
+WEAK uint32_t
+__sync_val_compare_and_swap_4(uint32_t *ptr, uint32_t oldval, uint32_t newval)
+{
+ uint32_t r;
+
+ pthread_mutex_lock(&sync_mutex);
+ r = *ptr;
+ if (*ptr == oldval)
+ *ptr = newval;
+ pthread_mutex_unlock(&sync_mutex);
+
+ return r;
+}
+#endif /* MISSING_32BIT_ATOMICS */
+
+WEAK uint64_t
+__sync_add_and_fetch_8(uint64_t *ptr, uint64_t val)
+{
+ uint64_t r;
+
+ pthread_mutex_lock(&sync_mutex);
+ *ptr += val;
+ r = *ptr;
+ pthread_mutex_unlock(&sync_mutex);
+
+ return r;
+}
+
+WEAK uint64_t
+__sync_sub_and_fetch_8(uint64_t *ptr, uint64_t val)
+{
+ uint64_t r;
+
+ pthread_mutex_lock(&sync_mutex);
+ *ptr -= val;
+ r = *ptr;
+ pthread_mutex_unlock(&sync_mutex);
+
+ return r;
+}
+
+#ifdef USE_GCC_ATOMIC_BUILTINS
+WEAK uint64_t
+__sync_val_compare_and_swap_8(uint64_t *ptr, uint64_t oldval, uint64_t newval)
+{
+ uint64_t r;
+
+ pthread_mutex_lock(&sync_mutex);
+ r = *ptr;
+ if (*ptr == oldval)
+ *ptr = newval;
+ pthread_mutex_unlock(&sync_mutex);
+
+ return r;
+}
+#endif /* USE_GCC_ATOMIC_BUILTINS */
+
+#endif
diff --git a/lib/mesa/src/util/u_atomic.h b/lib/mesa/src/util/u_atomic.h
index efa59d207..2a5bbae29 100644
--- a/lib/mesa/src/util/u_atomic.h
+++ b/lib/mesa/src/util/u_atomic.h
@@ -23,8 +23,6 @@
#define PIPE_ATOMIC_OS_SOLARIS
#elif defined(_MSC_VER)
#define PIPE_ATOMIC_MSVC_INTRINSIC
-#elif defined(__hppa__) || defined(__sh__)
-#define PIPE_ATOMIC_UNLOCKED
#elif defined(__GNUC__)
#define PIPE_ATOMIC_GCC_INTRINSIC
#else
@@ -72,25 +70,7 @@
#endif
-#if defined(PIPE_ATOMIC_UNLOCKED)
-#define PIPE_ATOMIC "Unlocked"
-
-#define p_atomic_set(_v, _i) (*(_v) = (_i))
-#define p_atomic_read(_v) (*(_v))
-#define p_atomic_dec_zero(_v) ((*(_v) -= 1) == 0)
-#define p_atomic_inc(_v) (*(_v) += 1)
-#define p_atomic_dec(_v) (*(_v) -= 1)
-#define p_atomic_add(_v, _i) (*(_v) += (_i))
-#define p_atomic_inc_return(_v) (*(_v) += 1)
-#define p_atomic_dec_return(_v) (*(_v) -= 1)
-#define p_atomic_cmpxchg(_v, old, _new) ({ \
- __typeof(*_v) _r = *(_v); \
- if (*(_v) == old) \
- *(_v) = (_new); \
- _r; \
-})
-#endif
/* Unlocked version for single threaded environments, such as some
* windows kernel modules.
diff --git a/lib/mesa/src/util/u_dynarray.h b/lib/mesa/src/util/u_dynarray.h
new file mode 100644
index 000000000..cc316323f
--- /dev/null
+++ b/lib/mesa/src/util/u_dynarray.h
@@ -0,0 +1,166 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Luca Barbieri
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef U_DYNARRAY_H
+#define U_DYNARRAY_H
+
+#include <stdlib.h>
+#include "ralloc.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* A zero-initialized version of this is guaranteed to represent an
+ * empty array.
+ *
+ * Also, size <= capacity and data != 0 if and only if capacity != 0
+ * capacity will always be the allocation size of data
+ */
+struct util_dynarray
+{
+ void *mem_ctx;
+ void *data;
+ unsigned size;
+ unsigned capacity;
+};
+
+static inline void
+util_dynarray_init(struct util_dynarray *buf, void *mem_ctx)
+{
+ memset(buf, 0, sizeof(*buf));
+ buf->mem_ctx = mem_ctx;
+}
+
+static inline void
+util_dynarray_fini(struct util_dynarray *buf)
+{
+ if (buf->data) {
+ if (buf->mem_ctx) {
+ ralloc_free(buf->data);
+ } else {
+ free(buf->data);
+ }
+ util_dynarray_init(buf, buf->mem_ctx);
+ }
+}
+
+static inline void
+util_dynarray_clear(struct util_dynarray *buf)
+{
+ buf->size = 0;
+}
+
+#define DYN_ARRAY_INITIAL_SIZE 64
+
+/* use util_dynarray_trim to reduce the allocated storage */
+static inline void *
+util_dynarray_resize(struct util_dynarray *buf, unsigned newsize)
+{
+ void *p;
+ if (newsize > buf->capacity) {
+ if (buf->capacity == 0)
+ buf->capacity = DYN_ARRAY_INITIAL_SIZE;
+
+ while (newsize > buf->capacity)
+ buf->capacity *= 2;
+
+ if (buf->mem_ctx) {
+ buf->data = reralloc_size(buf->mem_ctx, buf->data, buf->capacity);
+ } else {
+ buf->data = realloc(buf->data, buf->capacity);
+ }
+ }
+
+ p = (void *)((char *)buf->data + buf->size);
+ buf->size = newsize;
+
+ return p;
+}
+
+static inline void *
+util_dynarray_grow(struct util_dynarray *buf, int diff)
+{
+ return util_dynarray_resize(buf, buf->size + diff);
+}
+
+static inline void
+util_dynarray_trim(struct util_dynarray *buf)
+{
+ if (buf->size != buf->capacity) {
+ if (buf->size) {
+ if (buf->mem_ctx) {
+ buf->data = reralloc_size(buf->mem_ctx, buf->data, buf->size);
+ } else {
+ buf->data = realloc(buf->data, buf->size);
+ }
+ buf->capacity = buf->size;
+ } else {
+ if (buf->mem_ctx) {
+ ralloc_free(buf->data);
+ } else {
+ free(buf->data);
+ }
+ buf->data = 0;
+ buf->capacity = 0;
+ }
+ }
+}
+
+#define util_dynarray_append(buf, type, v) do {type __v = (v); memcpy(util_dynarray_grow((buf), sizeof(type)), &__v, sizeof(type));} while(0)
+#define util_dynarray_top_ptr(buf, type) (type*)((char*)(buf)->data + (buf)->size - sizeof(type))
+#define util_dynarray_top(buf, type) *util_dynarray_top_ptr(buf, type)
+#define util_dynarray_pop_ptr(buf, type) (type*)((char*)(buf)->data + ((buf)->size -= sizeof(type)))
+#define util_dynarray_pop(buf, type) *util_dynarray_pop_ptr(buf, type)
+#define util_dynarray_contains(buf, type) ((buf)->size >= sizeof(type))
+#define util_dynarray_element(buf, type, idx) ((type*)(buf)->data + (idx))
+#define util_dynarray_begin(buf) ((buf)->data)
+#define util_dynarray_end(buf) ((void*)util_dynarray_element((buf), char, (buf)->size))
+
+#define util_dynarray_foreach(buf, type, elem) \
+ for (type *elem = (type *)(buf)->data; \
+ elem < (type *)((char *)(buf)->data + (buf)->size); elem++)
+
+#define util_dynarray_delete_unordered(buf, type, v) \
+ do { \
+ unsigned num_elements = (buf)->size / sizeof(type); \
+ unsigned i; \
+ for (i = 0; i < num_elements; i++) { \
+ type __v = *util_dynarray_element((buf), type, (i)); \
+ if (v == __v) { \
+ memcpy(util_dynarray_element((buf), type, (i)), \
+ util_dynarray_pop_ptr((buf), type), sizeof(type)); \
+ break; \
+ } \
+ } \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* U_DYNARRAY_H */
+
diff --git a/lib/mesa/src/util/u_endian.h b/lib/mesa/src/util/u_endian.h
index b9d563dd4..b3da8ac52 100644
--- a/lib/mesa/src/util/u_endian.h
+++ b/lib/mesa/src/util/u_endian.h
@@ -27,12 +27,20 @@
#ifndef U_ENDIAN_H
#define U_ENDIAN_H
-#if defined(__GLIBC__) || defined(ANDROID)
+#ifdef HAVE_ENDIAN_H
#include <endian.h>
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+/* glibc */
+#if defined(__BYTE_ORDER) && (__BYTE_ORDER == __LITTLE_ENDIAN)
# define PIPE_ARCH_LITTLE_ENDIAN
-#elif __BYTE_ORDER == __BIG_ENDIAN
+#elif defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)
+# define PIPE_ARCH_BIG_ENDIAN
+#endif
+
+/* OpenBSD */
+#if defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN)
+# define PIPE_ARCH_LITTLE_ENDIAN
+#elif defined(BYTE_ORDER) && (BYTE_ORDER == BIG_ENDIAN)
# define PIPE_ARCH_BIG_ENDIAN
#endif
@@ -54,7 +62,7 @@
# define PIPE_ARCH_BIG_ENDIAN
#endif
-#elif defined(__OpenBSD__) || defined(__NetBSD__)
+#elif defined(__NetBSD__)
#include <sys/types.h>
#include <machine/endian.h>
@@ -64,6 +72,10 @@
# define PIPE_ARCH_BIG_ENDIAN
#endif
+#elif defined(_MSC_VER)
+
+#define PIPE_ARCH_LITTLE_ENDIAN
+
#endif
#endif
diff --git a/lib/mesa/src/util/u_queue.c b/lib/mesa/src/util/u_queue.c
new file mode 100644
index 000000000..3b05110e9
--- /dev/null
+++ b/lib/mesa/src/util/u_queue.c
@@ -0,0 +1,440 @@
+/*
+ * Copyright © 2016 Advanced Micro Devices, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
+ * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ */
+
+#include "u_queue.h"
+#include "util/u_string.h"
+
+static void util_queue_killall_and_wait(struct util_queue *queue);
+
+/****************************************************************************
+ * Wait for all queues to assert idle when exit() is called.
+ *
+ * Otherwise, C++ static variable destructors can be called while threads
+ * are using the static variables.
+ */
+
+static once_flag atexit_once_flag = ONCE_FLAG_INIT;
+static struct list_head queue_list;
+static mtx_t exit_mutex = _MTX_INITIALIZER_NP;
+
+static void
+atexit_handler(void)
+{
+ struct util_queue *iter;
+
+ mtx_lock(&exit_mutex);
+ /* Wait for all queues to assert idle. */
+ LIST_FOR_EACH_ENTRY(iter, &queue_list, head) {
+ util_queue_killall_and_wait(iter);
+ }
+ mtx_unlock(&exit_mutex);
+}
+
+static void
+global_init(void)
+{
+ LIST_INITHEAD(&queue_list);
+ atexit(atexit_handler);
+}
+
+static void
+add_to_atexit_list(struct util_queue *queue)
+{
+ call_once(&atexit_once_flag, global_init);
+
+ mtx_lock(&exit_mutex);
+ LIST_ADD(&queue->head, &queue_list);
+ mtx_unlock(&exit_mutex);
+}
+
+static void
+remove_from_atexit_list(struct util_queue *queue)
+{
+ struct util_queue *iter, *tmp;
+
+ mtx_lock(&exit_mutex);
+ LIST_FOR_EACH_ENTRY_SAFE(iter, tmp, &queue_list, head) {
+ if (iter == queue) {
+ LIST_DEL(&iter->head);
+ break;
+ }
+ }
+ mtx_unlock(&exit_mutex);
+}
+
+/****************************************************************************
+ * util_queue_fence
+ */
+
+static void
+util_queue_fence_signal(struct util_queue_fence *fence)
+{
+ mtx_lock(&fence->mutex);
+ fence->signalled = true;
+ cnd_broadcast(&fence->cond);
+ mtx_unlock(&fence->mutex);
+}
+
+void
+util_queue_fence_wait(struct util_queue_fence *fence)
+{
+ mtx_lock(&fence->mutex);
+ while (!fence->signalled)
+ cnd_wait(&fence->cond, &fence->mutex);
+ mtx_unlock(&fence->mutex);
+}
+
+void
+util_queue_fence_init(struct util_queue_fence *fence)
+{
+ memset(fence, 0, sizeof(*fence));
+ (void) mtx_init(&fence->mutex, mtx_plain);
+ cnd_init(&fence->cond);
+ fence->signalled = true;
+}
+
+void
+util_queue_fence_destroy(struct util_queue_fence *fence)
+{
+ assert(fence->signalled);
+
+ /* Ensure that another thread is not in the middle of
+ * util_queue_fence_signal (having set the fence to signalled but still
+ * holding the fence mutex).
+ *
+ * A common contract between threads is that as soon as a fence is signalled
+ * by thread A, thread B is allowed to destroy it. Since
+ * util_queue_fence_is_signalled does not lock the fence mutex (for
+ * performance reasons), we must do so here.
+ */
+ mtx_lock(&fence->mutex);
+ mtx_unlock(&fence->mutex);
+
+ cnd_destroy(&fence->cond);
+ mtx_destroy(&fence->mutex);
+}
+
+/****************************************************************************
+ * util_queue implementation
+ */
+
+struct thread_input {
+ struct util_queue *queue;
+ int thread_index;
+};
+
+static int
+util_queue_thread_func(void *input)
+{
+ struct util_queue *queue = ((struct thread_input*)input)->queue;
+ int thread_index = ((struct thread_input*)input)->thread_index;
+
+ free(input);
+
+ if (queue->name) {
+ char name[16];
+ util_snprintf(name, sizeof(name), "%s:%i", queue->name, thread_index);
+ u_thread_setname(name);
+ }
+
+ while (1) {
+ struct util_queue_job job;
+
+ mtx_lock(&queue->lock);
+ assert(queue->num_queued >= 0 && queue->num_queued <= queue->max_jobs);
+
+ /* wait if the queue is empty */
+ while (!queue->kill_threads && queue->num_queued == 0)
+ cnd_wait(&queue->has_queued_cond, &queue->lock);
+
+ if (queue->kill_threads) {
+ mtx_unlock(&queue->lock);
+ break;
+ }
+
+ job = queue->jobs[queue->read_idx];
+ memset(&queue->jobs[queue->read_idx], 0, sizeof(struct util_queue_job));
+ queue->read_idx = (queue->read_idx + 1) % queue->max_jobs;
+
+ queue->num_queued--;
+ cnd_signal(&queue->has_space_cond);
+ mtx_unlock(&queue->lock);
+
+ if (job.job) {
+ job.execute(job.job, thread_index);
+ util_queue_fence_signal(job.fence);
+ if (job.cleanup)
+ job.cleanup(job.job, thread_index);
+ }
+ }
+
+ /* signal remaining jobs before terminating */
+ mtx_lock(&queue->lock);
+ for (unsigned i = queue->read_idx; i != queue->write_idx;
+ i = (i + 1) % queue->max_jobs) {
+ if (queue->jobs[i].job) {
+ util_queue_fence_signal(queue->jobs[i].fence);
+ queue->jobs[i].job = NULL;
+ }
+ }
+ queue->read_idx = queue->write_idx;
+ queue->num_queued = 0;
+ mtx_unlock(&queue->lock);
+ return 0;
+}
+
+bool
+util_queue_init(struct util_queue *queue,
+ const char *name,
+ unsigned max_jobs,
+ unsigned num_threads,
+ unsigned flags)
+{
+ unsigned i;
+
+ memset(queue, 0, sizeof(*queue));
+ queue->name = name;
+ queue->flags = flags;
+ queue->num_threads = num_threads;
+ queue->max_jobs = max_jobs;
+
+ queue->jobs = (struct util_queue_job*)
+ calloc(max_jobs, sizeof(struct util_queue_job));
+ if (!queue->jobs)
+ goto fail;
+
+ (void) mtx_init(&queue->lock, mtx_plain);
+
+ queue->num_queued = 0;
+ cnd_init(&queue->has_queued_cond);
+ cnd_init(&queue->has_space_cond);
+
+ queue->threads = (thrd_t*) calloc(num_threads, sizeof(thrd_t));
+ if (!queue->threads)
+ goto fail;
+
+ /* start threads */
+ for (i = 0; i < num_threads; i++) {
+ struct thread_input *input =
+ (struct thread_input *) malloc(sizeof(struct thread_input));
+ input->queue = queue;
+ input->thread_index = i;
+
+ queue->threads[i] = u_thread_create(util_queue_thread_func, input);
+
+ if (!queue->threads[i]) {
+ free(input);
+
+ if (i == 0) {
+ /* no threads created, fail */
+ goto fail;
+ } else {
+ /* at least one thread created, so use it */
+ queue->num_threads = i;
+ break;
+ }
+ }
+
+ if (flags & UTIL_QUEUE_INIT_USE_MINIMUM_PRIORITY) {
+ #if defined(__linux__) && defined(SCHED_IDLE)
+ struct sched_param sched_param = {0};
+
+ /* The nice() function can only set a maximum of 19.
+ * SCHED_IDLE is the same as nice = 20.
+ *
+ * Note that Linux only allows decreasing the priority. The original
+ * priority can't be restored.
+ */
+ pthread_setschedparam(queue->threads[i], SCHED_IDLE, &sched_param);
+ #endif
+ }
+ }
+
+ add_to_atexit_list(queue);
+ return true;
+
+fail:
+ free(queue->threads);
+
+ if (queue->jobs) {
+ cnd_destroy(&queue->has_space_cond);
+ cnd_destroy(&queue->has_queued_cond);
+ mtx_destroy(&queue->lock);
+ free(queue->jobs);
+ }
+ /* also util_queue_is_initialized can be used to check for success */
+ memset(queue, 0, sizeof(*queue));
+ return false;
+}
+
+static void
+util_queue_killall_and_wait(struct util_queue *queue)
+{
+ unsigned i;
+
+ /* Signal all threads to terminate. */
+ mtx_lock(&queue->lock);
+ queue->kill_threads = 1;
+ cnd_broadcast(&queue->has_queued_cond);
+ mtx_unlock(&queue->lock);
+
+ for (i = 0; i < queue->num_threads; i++)
+ thrd_join(queue->threads[i], NULL);
+ queue->num_threads = 0;
+}
+
+void
+util_queue_destroy(struct util_queue *queue)
+{
+ util_queue_killall_and_wait(queue);
+ remove_from_atexit_list(queue);
+
+ cnd_destroy(&queue->has_space_cond);
+ cnd_destroy(&queue->has_queued_cond);
+ mtx_destroy(&queue->lock);
+ free(queue->jobs);
+ free(queue->threads);
+}
+
+void
+util_queue_add_job(struct util_queue *queue,
+ void *job,
+ struct util_queue_fence *fence,
+ util_queue_execute_func execute,
+ util_queue_execute_func cleanup)
+{
+ struct util_queue_job *ptr;
+
+ assert(fence->signalled);
+
+ mtx_lock(&queue->lock);
+ if (queue->kill_threads) {
+ mtx_unlock(&queue->lock);
+ /* well no good option here, but any leaks will be
+ * short-lived as things are shutting down..
+ */
+ return;
+ }
+
+ fence->signalled = false;
+
+ assert(queue->num_queued >= 0 && queue->num_queued <= queue->max_jobs);
+
+ if (queue->num_queued == queue->max_jobs) {
+ if (queue->flags & UTIL_QUEUE_INIT_RESIZE_IF_FULL) {
+ /* If the queue is full, make it larger to avoid waiting for a free
+ * slot.
+ */
+ unsigned new_max_jobs = queue->max_jobs + 8;
+ struct util_queue_job *jobs =
+ (struct util_queue_job*)calloc(new_max_jobs,
+ sizeof(struct util_queue_job));
+ assert(jobs);
+
+ /* Copy all queued jobs into the new list. */
+ unsigned num_jobs = 0;
+ unsigned i = queue->read_idx;
+
+ do {
+ jobs[num_jobs++] = queue->jobs[i];
+ i = (i + 1) % queue->max_jobs;
+ } while (i != queue->write_idx);
+
+ assert(num_jobs == queue->num_queued);
+
+ free(queue->jobs);
+ queue->jobs = jobs;
+ queue->read_idx = 0;
+ queue->write_idx = num_jobs;
+ queue->max_jobs = new_max_jobs;
+ } else {
+ /* Wait until there is a free slot. */
+ while (queue->num_queued == queue->max_jobs)
+ cnd_wait(&queue->has_space_cond, &queue->lock);
+ }
+ }
+
+ ptr = &queue->jobs[queue->write_idx];
+ assert(ptr->job == NULL);
+ ptr->job = job;
+ ptr->fence = fence;
+ ptr->execute = execute;
+ ptr->cleanup = cleanup;
+ queue->write_idx = (queue->write_idx + 1) % queue->max_jobs;
+
+ queue->num_queued++;
+ cnd_signal(&queue->has_queued_cond);
+ mtx_unlock(&queue->lock);
+}
+
+/**
+ * Remove a queued job. If the job hasn't started execution, it's removed from
+ * the queue. If the job has started execution, the function waits for it to
+ * complete.
+ *
+ * In all cases, the fence is signalled when the function returns.
+ *
+ * The function can be used when destroying an object associated with the job
+ * when you don't care about the job completion state.
+ */
+void
+util_queue_drop_job(struct util_queue *queue, struct util_queue_fence *fence)
+{
+ bool removed = false;
+
+ if (util_queue_fence_is_signalled(fence))
+ return;
+
+ mtx_lock(&queue->lock);
+ for (unsigned i = queue->read_idx; i != queue->write_idx;
+ i = (i + 1) % queue->max_jobs) {
+ if (queue->jobs[i].fence == fence) {
+ if (queue->jobs[i].cleanup)
+ queue->jobs[i].cleanup(queue->jobs[i].job, -1);
+
+ /* Just clear it. The threads will treat as a no-op job. */
+ memset(&queue->jobs[i], 0, sizeof(queue->jobs[i]));
+ removed = true;
+ break;
+ }
+ }
+ mtx_unlock(&queue->lock);
+
+ if (removed)
+ util_queue_fence_signal(fence);
+ else
+ util_queue_fence_wait(fence);
+}
+
+int64_t
+util_queue_get_thread_time_nano(struct util_queue *queue, unsigned thread_index)
+{
+ /* Allow some flexibility by not raising an error. */
+ if (thread_index >= queue->num_threads)
+ return 0;
+
+ return u_thread_get_time_nano(queue->threads[thread_index]);
+}
diff --git a/lib/mesa/src/util/u_queue.h b/lib/mesa/src/util/u_queue.h
new file mode 100644
index 000000000..ff713ae54
--- /dev/null
+++ b/lib/mesa/src/util/u_queue.h
@@ -0,0 +1,138 @@
+/*
+ * Copyright © 2016 Advanced Micro Devices, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
+ * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ */
+
+/* Job queue with execution in a separate thread.
+ *
+ * Jobs can be added from any thread. After that, the wait call can be used
+ * to wait for completion of the job.
+ */
+
+#ifndef U_QUEUE_H
+#define U_QUEUE_H
+
+#include <string.h>
+
+#include "util/list.h"
+#include "util/u_thread.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define UTIL_QUEUE_INIT_USE_MINIMUM_PRIORITY (1 << 0)
+#define UTIL_QUEUE_INIT_RESIZE_IF_FULL (1 << 1)
+
+/* Job completion fence.
+ * Put this into your job structure.
+ */
+struct util_queue_fence {
+ mtx_t mutex;
+ cnd_t cond;
+ int signalled;
+};
+
+typedef void (*util_queue_execute_func)(void *job, int thread_index);
+
+struct util_queue_job {
+ void *job;
+ struct util_queue_fence *fence;
+ util_queue_execute_func execute;
+ util_queue_execute_func cleanup;
+};
+
+/* Put this into your context. */
+struct util_queue {
+ const char *name;
+ mtx_t lock;
+ cnd_t has_queued_cond;
+ cnd_t has_space_cond;
+ thrd_t *threads;
+ unsigned flags;
+ int num_queued;
+ unsigned num_threads;
+ int kill_threads;
+ int max_jobs;
+ int write_idx, read_idx; /* ring buffer pointers */
+ struct util_queue_job *jobs;
+
+ /* for cleanup at exit(), protected by exit_mutex */
+ struct list_head head;
+};
+
+bool util_queue_init(struct util_queue *queue,
+ const char *name,
+ unsigned max_jobs,
+ unsigned num_threads,
+ unsigned flags);
+void util_queue_destroy(struct util_queue *queue);
+void util_queue_fence_init(struct util_queue_fence *fence);
+void util_queue_fence_destroy(struct util_queue_fence *fence);
+
+/* optional cleanup callback is called after fence is signaled: */
+void util_queue_add_job(struct util_queue *queue,
+ void *job,
+ struct util_queue_fence *fence,
+ util_queue_execute_func execute,
+ util_queue_execute_func cleanup);
+void util_queue_drop_job(struct util_queue *queue,
+ struct util_queue_fence *fence);
+
+void util_queue_fence_wait(struct util_queue_fence *fence);
+int64_t util_queue_get_thread_time_nano(struct util_queue *queue,
+ unsigned thread_index);
+
+/* util_queue needs to be cleared to zeroes for this to work */
+static inline bool
+util_queue_is_initialized(struct util_queue *queue)
+{
+ return queue->threads != NULL;
+}
+
+static inline bool
+util_queue_fence_is_signalled(struct util_queue_fence *fence)
+{
+ return fence->signalled != 0;
+}
+
+/* Convenient structure for monitoring the queue externally and passing
+ * the structure between Mesa components. The queue doesn't use it directly.
+ */
+struct util_queue_monitoring
+{
+ /* For querying the thread busyness. */
+ struct util_queue *queue;
+
+ /* Counters updated by the user of the queue. */
+ unsigned num_offloaded_items;
+ unsigned num_direct_items;
+ unsigned num_syncs;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lib/mesa/src/util/u_string.h b/lib/mesa/src/util/u_string.h
new file mode 100644
index 000000000..fa0241e54
--- /dev/null
+++ b/lib/mesa/src/util/u_string.h
@@ -0,0 +1,228 @@
+/**************************************************************************
+ *
+ * Copyright 2008 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * @file
+ * Platform independent functions for string manipulation.
+ *
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
+
+#ifndef U_STRING_H_
+#define U_STRING_H_
+
+#if !defined(XF86_LIBC_H)
+#include <stdio.h>
+#endif
+#include <stdlib.h>
+#include <stddef.h>
+#include <stdarg.h>
+#include <string.h>
+
+#include "util/macros.h" // PRINTFLIKE
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef _GNU_SOURCE
+
+#define util_strchrnul strchrnul
+
+#else
+
+static inline char *
+util_strchrnul(const char *s, char c)
+{
+ for (; *s && *s != c; ++s);
+
+ return (char *)s;
+}
+
+#endif
+
+#ifdef _WIN32
+
+static inline int
+util_vsnprintf(char *str, size_t size, const char *format, va_list ap)
+{
+ /* We need to use _vscprintf to calculate the length as vsnprintf returns -1
+ * if the number of characters to write is greater than count.
+ */
+ va_list ap_copy;
+ int ret;
+ va_copy(ap_copy, ap);
+ ret = _vsnprintf(str, size, format, ap);
+ if (ret < 0) {
+ ret = _vscprintf(format, ap_copy);
+ }
+ return ret;
+}
+
+static inline int
+ PRINTFLIKE(3, 4)
+util_snprintf(char *str, size_t size, const char *format, ...)
+{
+ va_list ap;
+ int ret;
+ va_start(ap, format);
+ ret = util_vsnprintf(str, size, format, ap);
+ va_end(ap);
+ return ret;
+}
+
+static inline void
+util_vsprintf(char *str, const char *format, va_list ap)
+{
+ util_vsnprintf(str, (size_t)-1, format, ap);
+}
+
+static inline void
+ PRINTFLIKE(2, 3)
+util_sprintf(char *str, const char *format, ...)
+{
+ va_list ap;
+ va_start(ap, format);
+ util_vsnprintf(str, (size_t)-1, format, ap);
+ va_end(ap);
+}
+
+static inline int
+util_vasprintf(char **ret, const char *format, va_list ap)
+{
+ va_list ap_copy;
+
+ /* Compute length of output string first */
+ va_copy(ap_copy, ap);
+ int r = util_vsnprintf(NULL, 0, format, ap);
+ va_end(ap_copy);
+
+ if (r < 0)
+ return -1;
+
+ *ret = (char *) malloc(r + 1);
+ if (!ret)
+ return -1;
+
+ /* Print to buffer */
+ return util_vsnprintf(*ret, r + 1, format, ap);
+}
+
+static inline char *
+util_strchr(const char *s, char c)
+{
+ char *p = util_strchrnul(s, c);
+
+ return *p ? p : NULL;
+}
+
+static inline char*
+util_strncat(char *dst, const char *src, size_t n)
+{
+ char *p = dst + strlen(dst);
+ const char *q = src;
+ size_t i;
+
+ for (i = 0; i < n && *q != '\0'; ++i)
+ *p++ = *q++;
+ *p = '\0';
+
+ return dst;
+}
+
+static inline int
+util_strcmp(const char *s1, const char *s2)
+{
+ unsigned char u1, u2;
+
+ while (1) {
+ u1 = (unsigned char) *s1++;
+ u2 = (unsigned char) *s2++;
+ if (u1 != u2)
+ return u1 - u2;
+ if (u1 == '\0')
+ return 0;
+ }
+ return 0;
+}
+
+static inline int
+util_strncmp(const char *s1, const char *s2, size_t n)
+{
+ unsigned char u1, u2;
+
+ while (n-- > 0) {
+ u1 = (unsigned char) *s1++;
+ u2 = (unsigned char) *s2++;
+ if (u1 != u2)
+ return u1 - u2;
+ if (u1 == '\0')
+ return 0;
+ }
+ return 0;
+}
+
+static inline char *
+util_strstr(const char *haystack, const char *needle)
+{
+ const char *p = haystack;
+ size_t len = strlen(needle);
+
+ for (; (p = util_strchr(p, *needle)) != 0; p++) {
+ if (util_strncmp(p, needle, len) == 0) {
+ return (char *)p;
+ }
+ }
+ return NULL;
+}
+
+
+#define util_strcasecmp stricmp
+
+#else
+
+#define util_vsnprintf vsnprintf
+#define util_snprintf snprintf
+#define util_vsprintf vsprintf
+#define util_vasprintf vasprintf
+#define util_sprintf sprintf
+#define util_strchr strchr
+#define util_strcmp strcmp
+#define util_strncmp strncmp
+#define util_strncat strncat
+#define util_strstr strstr
+#define util_strcasecmp strcasecmp
+
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* U_STRING_H_ */
diff --git a/lib/mesa/src/util/u_thread.h b/lib/mesa/src/util/u_thread.h
new file mode 100644
index 000000000..79b02b528
--- /dev/null
+++ b/lib/mesa/src/util/u_thread.h
@@ -0,0 +1,103 @@
+/**************************************************************************
+ *
+ * Copyright 1999-2006 Brian Paul
+ * Copyright 2008 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef U_THREAD_H_
+#define U_THREAD_H_
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "c11/threads.h"
+
+#ifdef HAVE_PTHREAD
+#include <signal.h>
+#endif
+
+
+static inline thrd_t u_thread_create(int (*routine)(void *), void *param)
+{
+ thrd_t thread;
+#ifdef HAVE_PTHREAD
+ sigset_t saved_set, new_set;
+ int ret;
+
+ sigfillset(&new_set);
+ pthread_sigmask(SIG_SETMASK, &new_set, &saved_set);
+ ret = thrd_create( &thread, routine, param );
+ pthread_sigmask(SIG_SETMASK, &saved_set, NULL);
+#else
+ int ret;
+ ret = thrd_create( &thread, routine, param );
+#endif
+ if (ret)
+ return 0;
+
+ return thread;
+}
+
+static inline void u_thread_setname( const char *name )
+{
+#if defined(HAVE_PTHREAD)
+# if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__) && \
+ (__GLIBC__ >= 3 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 12))
+ pthread_setname_np(pthread_self(), name);
+# endif
+#endif
+ (void)name;
+}
+
+/*
+ * Thread statistics.
+ */
+
+/* Return the time of a thread's CPU time clock. */
+static inline int64_t
+u_thread_get_time_nano(thrd_t thread)
+{
+#if defined(HAVE_PTHREAD)
+ struct timespec ts;
+ clockid_t cid;
+
+ pthread_getcpuclockid(thread, &cid);
+ clock_gettime(cid, &ts);
+ return (int64_t)ts.tv_sec * 1000000000 + ts.tv_nsec;
+#else
+ return 0;
+#endif
+}
+
+static inline bool u_thread_is_self(thrd_t thread)
+{
+#if defined(HAVE_PTHREAD)
+# if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__) && \
+ (__GLIBC__ >= 3 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 12))
+ return pthread_equal(pthread_self(), thread);
+# endif
+#endif
+ return false;
+}
+
+#endif /* U_THREAD_H_ */
diff --git a/lib/mesa/src/util/u_vector.c b/lib/mesa/src/util/u_vector.c
index 37c4245eb..0de492ccf 100644
--- a/lib/mesa/src/util/u_vector.c
+++ b/lib/mesa/src/util/u_vector.c
@@ -20,8 +20,20 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
+
+#include <string.h>
+#include "util/u_math.h"
#include "util/u_vector.h"
+/** @file u_vector.c
+ *
+ * A dynamically growable, circular buffer. Elements are added at head and
+ * removed from tail. head and tail are free-running uint32_t indices and we
+ * only compute the modulo with size when accessing the array. This way,
+ * number of bytes in the queue is always head - tail, even in case of
+ * wraparound.
+ */
+
int
u_vector_init(struct u_vector *vector, uint32_t element_size, uint32_t size)
{
diff --git a/lib/mesa/src/util/u_vector.h b/lib/mesa/src/util/u_vector.h
index 8fa4ec483..cd8a95dcb 100644
--- a/lib/mesa/src/util/u_vector.h
+++ b/lib/mesa/src/util/u_vector.h
@@ -31,14 +31,13 @@
#include <stdint.h>
#include <stdlib.h>
-#include "util/u_math.h"
#include "util/macros.h"
/* TODO - move to u_math.h - name it better etc */
static inline uint32_t
u_align_u32(uint32_t v, uint32_t a)
{
- assert(a != 0 && a == (a & -a));
+ assert(a != 0 && a == (a & -((int32_t) a)));
return (v + a - 1) & ~(a - 1);
}
@@ -82,9 +81,9 @@ u_vector_finish(struct u_vector *queue)
}
#define u_vector_foreach(elem, queue) \
- static_assert(__builtin_types_compatible_p(__typeof__(queue), struct u_vector *), ""); \
+ STATIC_ASSERT(__builtin_types_compatible_p(__typeof__(queue), struct u_vector *)); \
for (uint32_t __u_vector_offset = (queue)->tail; \
- elem = (queue)->data + (__u_vector_offset & ((queue)->size - 1)), __u_vector_offset < (queue)->head; \
+ elem = (void *)((char *)(queue)->data + (__u_vector_offset & ((queue)->size - 1))), __u_vector_offset < (queue)->head; \
__u_vector_offset += (queue)->element_size)
diff --git a/lib/mesa/src/util/vk_alloc.h b/lib/mesa/src/util/vk_alloc.h
deleted file mode 100644
index a8e21cade..000000000
--- a/lib/mesa/src/util/vk_alloc.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright © 2015 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- */
-#ifndef VK_ALLOC_H
-#define VK_ALLOC_H
-
-/* common allocation inlines for vulkan drivers */
-
-#include <vulkan/vulkan.h>
-
-static inline void *
-vk_alloc(const VkAllocationCallbacks *alloc,
- size_t size, size_t align,
- VkSystemAllocationScope scope)
-{
- return alloc->pfnAllocation(alloc->pUserData, size, align, scope);
-}
-
-static inline void *
-vk_realloc(const VkAllocationCallbacks *alloc,
- void *ptr, size_t size, size_t align,
- VkSystemAllocationScope scope)
-{
- return alloc->pfnReallocation(alloc->pUserData, ptr, size, align, scope);
-}
-
-static inline void
-vk_free(const VkAllocationCallbacks *alloc, void *data)
-{
- alloc->pfnFree(alloc->pUserData, data);
-}
-
-static inline void *
-vk_alloc2(const VkAllocationCallbacks *parent_alloc,
- const VkAllocationCallbacks *alloc,
- size_t size, size_t align,
- VkSystemAllocationScope scope)
-{
- if (alloc)
- return vk_alloc(alloc, size, align, scope);
- else
- return vk_alloc(parent_alloc, size, align, scope);
-}
-
-static inline void
-vk_free2(const VkAllocationCallbacks *parent_alloc,
- const VkAllocationCallbacks *alloc,
- void *data)
-{
- if (alloc)
- vk_free(alloc, data);
- else
- vk_free(parent_alloc, data);
-}
-
-#endif
diff --git a/lib/mesa/src/util/xmlconfig.c b/lib/mesa/src/util/xmlconfig.c
index 60a6331c8..3be843827 100644
--- a/lib/mesa/src/util/xmlconfig.c
+++ b/lib/mesa/src/util/xmlconfig.c
@@ -988,6 +988,14 @@ void
driParseConfigFiles(driOptionCache *cache, const driOptionCache *info,
int screenNum, const char *driverName)
{
+#if defined(__OpenBSD__)
+ /*
+ * Opening drirc files is disabled by default so sandboxed
+ * browser processes with OpenGL contexts can drop the ability
+ * to read files.
+ */
+ initOptionCache (cache, info);
+#else
char *filenames[2] = { SYSCONFDIR "/drirc", NULL};
char *home;
uint32_t i;
@@ -1033,6 +1041,7 @@ driParseConfigFiles(driOptionCache *cache, const driOptionCache *info,
}
free(filenames[1]);
+#endif
}
void
diff --git a/lib/mesa/src/util/xmlpool/Makefile.am b/lib/mesa/src/util/xmlpool/Makefile.am
index dfd8fb8dc..da4463e7f 100644
--- a/lib/mesa/src/util/xmlpool/Makefile.am
+++ b/lib/mesa/src/util/xmlpool/Makefile.am
@@ -68,8 +68,10 @@ CLEANFILES = \
# Default target options.h
LOCALEDIR := .
+if REGEN_SOURCES
options.h: t_options.h $(MOS)
$(AM_V_GEN) $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/gen_xmlpool.py $(srcdir)/t_options.h $(LOCALEDIR) $(LANGS) > options.h
+endif
# Update .mo files from the corresponding .po files.
%/LC_MESSAGES/options.mo: %.po
diff --git a/lib/mesa/src/util/xmlpool/Makefile.in b/lib/mesa/src/util/xmlpool/Makefile.in
index 3bb8efbf1..64bc94d34 100644
--- a/lib/mesa/src/util/xmlpool/Makefile.in
+++ b/lib/mesa/src/util/xmlpool/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15.1 from Makefile.am.
+# Makefile.in generated by automake 1.12.6 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994-2017 Free Software Foundation, Inc.
+# Copyright (C) 1994-2012 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -56,61 +56,23 @@
# More information:
# - info gettext
VPATH = @srcdir@
-am__is_gnu_make = { \
- if test -z '$(MAKELEVEL)'; then \
- false; \
- elif test -n '$(MAKE_HOST)'; then \
- true; \
- elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
- true; \
- else \
- false; \
- fi; \
-}
-am__make_running_with_option = \
- case $${target_option-} in \
- ?) ;; \
- *) echo "am__make_running_with_option: internal error: invalid" \
- "target option '$${target_option-}' specified" >&2; \
- exit 1;; \
- esac; \
- has_opt=no; \
- sane_makeflags=$$MAKEFLAGS; \
- if $(am__is_gnu_make); then \
- sane_makeflags=$$MFLAGS; \
- else \
+am__make_dryrun = \
+ { \
+ am__dry=no; \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
- bs=\\; \
- sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
- | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
- esac; \
- fi; \
- skip_next=no; \
- strip_trailopt () \
- { \
- flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
- }; \
- for flg in $$sane_makeflags; do \
- test $$skip_next = yes && { skip_next=no; continue; }; \
- case $$flg in \
- *=*|--*) continue;; \
- -*I) strip_trailopt 'I'; skip_next=yes;; \
- -*I?*) strip_trailopt 'I';; \
- -*O) strip_trailopt 'O'; skip_next=yes;; \
- -*O?*) strip_trailopt 'O';; \
- -*l) strip_trailopt 'l'; skip_next=yes;; \
- -*l?*) strip_trailopt 'l';; \
- -[dEDm]) skip_next=yes;; \
- -[JT]) skip_next=yes;; \
- esac; \
- case $$flg in \
- *$$target_option*) has_opt=yes; break;; \
+ echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
+ | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+ *) \
+ for am__flg in $$MAKEFLAGS; do \
+ case $$am__flg in \
+ *=*|--*) ;; \
+ *n*) am__dry=yes; break;; \
+ esac; \
+ done;; \
esac; \
- done; \
- test $$has_opt = yes
-am__make_dryrun = (target_option=n; $(am__make_running_with_option))
-am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+ test $$am__dry = yes; \
+ }
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@@ -131,6 +93,7 @@ build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
subdir = src/util/xmlpool
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_compile_flag.m4 \
$(top_srcdir)/m4/ax_check_gnu_make.m4 \
@@ -145,7 +108,6 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_compile_flag.m4 \
$(top_srcdir)/VERSION $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
-DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
@@ -168,8 +130,6 @@ am__can_run_installinfo = \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
-am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
-am__DIST_COMMON = $(srcdir)/Makefile.in
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDGPU_CFLAGS = @AMDGPU_CFLAGS@
@@ -291,7 +251,7 @@ LLVM_LDFLAGS = @LLVM_LDFLAGS@
LLVM_LIBS = @LLVM_LIBS@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
-LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
+MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
@@ -457,7 +417,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
-runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@@ -499,7 +458,7 @@ all: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) all-am
.SUFFIXES:
-$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
@@ -511,6 +470,7 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/util/xmlpool/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign src/util/xmlpool/Makefile
+.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
@@ -523,9 +483,9 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(top_srcdir)/configure: $(am__configure_deps)
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
@@ -534,9 +494,11 @@ mostlyclean-libtool:
clean-libtool:
-rm -rf .libs _libs
-tags TAGS:
+tags: TAGS
+TAGS:
-ctags CTAGS:
+ctags: CTAGS
+CTAGS:
cscope cscopelist:
@@ -678,25 +640,22 @@ uninstall-am:
.MAKE: all check install install-am install-strip
.PHONY: all all-am check check-am clean clean-generic clean-libtool \
- cscopelist-am ctags-am distclean distclean-generic \
- distclean-libtool distdir dvi dvi-am html html-am info info-am \
- install install-am install-data install-data-am install-dvi \
- install-dvi-am install-exec install-exec-am install-html \
- install-html-am install-info install-info-am install-man \
- install-pdf install-pdf-am install-ps install-ps-am \
- install-strip installcheck installcheck-am installdirs \
- maintainer-clean maintainer-clean-generic mostlyclean \
- mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
- tags-am uninstall uninstall-am
-
-.PRECIOUS: Makefile
+ distclean distclean-generic distclean-libtool distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-generic \
+ mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am
.PHONY: all clean pot po mo
$(POS) \
$(MOS)
-options.h: t_options.h $(MOS)
- $(AM_V_GEN) $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/gen_xmlpool.py $(srcdir)/t_options.h $(LOCALEDIR) $(LANGS) > options.h
+@REGEN_SOURCES_TRUE@options.h: t_options.h $(MOS)
+@REGEN_SOURCES_TRUE@ $(AM_V_GEN) $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/gen_xmlpool.py $(srcdir)/t_options.h $(LOCALEDIR) $(LANGS) > options.h
# Update .mo files from the corresponding .po files.
%/LC_MESSAGES/options.mo: %.po