diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2017-08-26 16:59:42 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2017-08-26 16:59:42 +0000 |
commit | 81ece42815e80818f160cdd85fab57d65b56ad15 (patch) | |
tree | 1059ff094da1aa50334115952fcb1cfcbda3acc6 /lib/mesa/src/util | |
parent | b0244145d5bb49623d58f6b5cab8143ada692b60 (diff) |
Revert to Mesa 13.0.6 to hopefully address rendering issues a handful of
people have reported with xpdf/fvwm on ivy bridge with modesetting driver.
Diffstat (limited to 'lib/mesa/src/util')
29 files changed, 272 insertions, 3478 deletions
diff --git a/lib/mesa/src/util/Makefile.am b/lib/mesa/src/util/Makefile.am index cfc2377df..4234f24cc 100644 --- a/lib/mesa/src/util/Makefile.am +++ b/lib/mesa/src/util/Makefile.am @@ -36,15 +36,15 @@ 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) \ - $(ZLIB_CFLAGS) + $(MSVC2013_COMPAT_CFLAGS) libmesautil_la_SOURCES = \ $(MESA_UTIL_FILES) \ $(MESA_UTIL_GENERATED_FILES) -libmesautil_la_LIBADD = $(ZLIB_LIBS) +libmesautil_la_LIBADD = $(SHA1_LIBS) roundeven_test_LDADD = -lm @@ -53,10 +53,7 @@ TESTS = $(check_PROGRAMS) BUILT_SOURCES = $(MESA_UTIL_GENERATED_FILES) CLEANFILES = $(BUILT_SOURCES) -EXTRA_DIST = \ - format_srgb.py \ - SConscript \ - sha1/README +EXTRA_DIST = format_srgb.py SConscript 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 e0ab1114b..ad44f530c 100644 --- a/lib/mesa/src/util/Makefile.in +++ b/lib/mesa/src/util/Makefile.in @@ -95,17 +95,13 @@ CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) am__DEPENDENCIES_1 = libmesautil_la_DEPENDENCIES = $(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_to_uint_map.lo \ - libmesautil_la-strtod.lo libmesautil_la-u_atomic.lo \ - libmesautil_la-u_queue.lo libmesautil_la-u_vector.lo +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 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) @@ -229,8 +225,6 @@ 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@ @@ -261,6 +255,8 @@ 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@ @@ -273,11 +269,10 @@ 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@ @@ -325,27 +320,31 @@ 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_LIBS = @LIBSENSORS_LIBS@ +LIBSENSORS_LDFLAGS = @LIBSENSORS_LDFLAGS@ +LIBSHA1_CFLAGS = @LIBSHA1_CFLAGS@ +LIBSHA1_LIBS = @LIBSHA1_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@ @@ -366,6 +365,8 @@ OMX_LIBS = @OMX_LIBS@ OMX_LIB_INSTALL_DIR = @OMX_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@ @@ -385,6 +386,8 @@ 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@ @@ -400,6 +403,8 @@ 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@ @@ -408,6 +413,7 @@ STRIP = @STRIP@ SWR_AVX2_CXXFLAGS = @SWR_AVX2_CXXFLAGS@ SWR_AVX_CXXFLAGS = @SWR_AVX_CXXFLAGS@ SWR_CXX11_CXXFLAGS = @SWR_CXX11_CXXFLAGS@ +TIMESTAMP_CMD = @TIMESTAMP_CMD@ VALGRIND_CFLAGS = @VALGRIND_CFLAGS@ VALGRIND_LIBS = @VALGRIND_LIBS@ VA_CFLAGS = @VA_CFLAGS@ @@ -423,6 +429,7 @@ 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@ @@ -451,10 +458,9 @@ 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@ @@ -520,31 +526,21 @@ 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 \ @@ -555,23 +551,18 @@ MESA_UTIL_FILES := \ simple_list.h \ slab.c \ slab.h \ - string_to_uint_map.cpp \ string_to_uint_map.h \ + string_to_uint_map.cpp \ + strndup.c \ strndup.h \ strtod.c \ strtod.h \ texcompress_rgtc_tmp.h \ - u_atomic.c \ u_atomic.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 \ - vk_util.h + vk_alloc.h MESA_UTIL_GENERATED_FILES = \ format_srgb.c @@ -588,24 +579,20 @@ 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) \ - $(ZLIB_CFLAGS) + $(MSVC2013_COMPAT_CFLAGS) libmesautil_la_SOURCES = \ $(MESA_UTIL_FILES) \ $(MESA_UTIL_GENERATED_FILES) -libmesautil_la_LIBADD = $(ZLIB_LIBS) +libmesautil_la_LIBADD = $(SHA1_LIBS) roundeven_test_LDADD = -lm TESTS = $(check_PROGRAMS) BUILT_SOURCES = $(MESA_UTIL_GENERATED_FILES) CLEANFILES = $(BUILT_SOURCES) -EXTRA_DIST = \ - format_srgb.py \ - SConscript \ - sha1/README - +EXTRA_DIST = format_srgb.py SConscript @REGEN_SOURCES_TRUE@PYTHON_GEN = $(AM_V_GEN)$(PYTHON2) $(PYTHON_FLAGS) all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) all-recursive @@ -654,14 +641,6 @@ 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) @@ -682,35 +661,27 @@ 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-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)/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$$||'`;\ @@ -743,20 +714,6 @@ 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 @@ -764,13 +721,6 @@ 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 @@ -792,13 +742,6 @@ 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 @@ -806,13 +749,6 @@ 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 @@ -841,6 +777,13 @@ 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@ +@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 + 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 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmesautil_la-strtod.Tpo $(DEPDIR)/libmesautil_la-strtod.Plo @@ -848,20 +791,6 @@ 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 @@ -912,7 +841,6 @@ mostlyclean-libtool: clean-libtool: -rm -rf .libs _libs - -rm -rf sha1/.libs sha1/_libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. @@ -1224,8 +1152,6 @@ 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" @@ -1237,7 +1163,7 @@ clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ clean-noinstLTLIBRARIES mostlyclean-am distclean: distclean-recursive - -rm -rf ./$(DEPDIR) sha1/$(DEPDIR) + -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags @@ -1283,7 +1209,7 @@ install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive - -rm -rf ./$(DEPDIR) sha1/$(DEPDIR) + -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic diff --git a/lib/mesa/src/util/Makefile.sources b/lib/mesa/src/util/Makefile.sources index 1f5386a00..c5531c82d 100644 --- a/lib/mesa/src/util/Makefile.sources +++ b/lib/mesa/src/util/Makefile.sources @@ -1,10 +1,20 @@ MESA_UTIL_FILES := \ + bitscan.c \ + bitscan.h \ bitset.h \ + debug.c \ + debug.h \ + format_r11g11b10f.h \ + format_rgb9e5.h \ format_srgb.h \ + half_float.c \ + half_float.h \ hash_table.c \ hash_table.h \ list.h \ macros.h \ + mesa-sha1.c \ + mesa-sha1.h \ ralloc.c \ ralloc.h \ register_allocate.c \ @@ -15,10 +25,20 @@ MESA_UTIL_FILES := \ set.c \ set.h \ simple_list.h \ + slab.c \ + slab.h \ + string_to_uint_map.h \ + string_to_uint_map.cpp \ + strndup.c \ + strndup.h \ strtod.c \ strtod.h \ texcompress_rgtc_tmp.h \ - u_atomic.h + u_atomic.h \ + u_endian.h \ + u_vector.c \ + u_vector.h \ + vk_alloc.h MESA_UTIL_GENERATED_FILES = \ format_srgb.c diff --git a/lib/mesa/src/util/SConscript b/lib/mesa/src/util/SConscript index bd8fb1727..73f343039 100644 --- a/lib/mesa/src/util/SConscript +++ b/lib/mesa/src/util/SConscript @@ -6,7 +6,7 @@ from sys import executable as python_cmd env = env.Clone() -env.MSVC2008Compat() +env.MSVC2013Compat() env.Prepend(CPPPATH = [ '#include', @@ -33,6 +33,11 @@ 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'] + mesautil = env.ConvenienceLibrary( target = 'mesautil', source = mesautil_sources, @@ -42,17 +47,14 @@ env.Alias('mesautil', mesautil) Export('mesautil') -# http://www.scons.org/wiki/UnitTests u_atomic_test = env.Program( target = 'u_atomic_test', source = ['u_atomic_test.c'], ) -alias = env.Alias("u_atomic_test", u_atomic_test, u_atomic_test[0].abspath) -AlwaysBuild(alias) +env.UnitTest("u_atomic_test", u_atomic_test) roundeven_test = env.Program( target = 'roundeven_test', source = ['roundeven_test.c'], ) -alias = env.Alias("roundeven_test", roundeven_test, roundeven_test[0].abspath) -AlwaysBuild(alias) +env.UnitTest("roundeven_test", roundeven_test) diff --git a/lib/mesa/src/util/build_id.c b/lib/mesa/src/util/build_id.c deleted file mode 100644 index 898a15f2b..000000000 --- a/lib/mesa/src/util/build_id.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - * 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 <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 { - const char *filename; - 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_; - - /* The first object visited by callback is the main program. - * Android's libc returns a NULL pointer for the first executable. - */ - if (info->dlpi_name == NULL) - return 0; - - char *ptr = strstr(info->dlpi_name, data->filename); - if (ptr == NULL || ptr[strlen(data->filename)] != '\0') - 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(const char *filename) -{ - struct callback_data data = { - .filename = filename, - .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/crc32.c b/lib/mesa/src/util/crc32.c deleted file mode 100644 index 44d637c0f..000000000 --- a/lib/mesa/src/util/crc32.c +++ /dev/null @@ -1,121 +0,0 @@ -/************************************************************************** - * - * 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 deleted file mode 100644 index b6a21f417..000000000 --- a/lib/mesa/src/util/crc32.h +++ /dev/null @@ -1,55 +0,0 @@ -/************************************************************************** - * - * 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 deleted file mode 100644 index cf5d518f0..000000000 --- a/lib/mesa/src/util/disk_cache.c +++ /dev/null @@ -1,1097 +0,0 @@ -/* - * 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/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) - -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; -}; - -/* 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; -} - -struct disk_cache * -disk_cache_create(const char *gpu_name, const char *timestamp) -{ - 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; - - /* 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 (getenv("MESA_GLSL_CACHE_DISABLE")) - goto fail; - - /* Determine path for cache based on the first defined name as follows: - * - * $MESA_GLSL_CACHE_DIR - * $XDG_CACHE_HOME/mesa - * <pwd.pw_dir>/.cache/mesa - */ - path = getenv("MESA_GLSL_CACHE_DIR"); - if (path) { - if (mkdir_if_needed(path) == -1) - goto fail; - - path = concatenate_and_mkdir(local, path, "mesa"); - 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, "mesa"); - 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, "mesa"); - 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; - - /* A limit of 32 jobs was choosen as observations of Deus Ex start-up times - * showed that we reached at most 11 jobs on an Intel i5-6400 CPU@2.70GHz - * (a fairly modest desktop CPU). 1 thread was chosen because we don't - * really care about getting things to disk quickly just that it's not - * blocking other tasks. - */ - util_queue_init(&cache->cache_queue, "disk_cache", 32, 1); - - /* 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; - - cache->driver_keys_blob = - ralloc_size(cache, cache->driver_keys_blob_size); - if (!cache->driver_keys_blob) - goto fail; - - memcpy(cache->driver_keys_blob, timestamp, ts_size); - memcpy(cache->driver_keys_blob + ts_size, gpu_name, gpu_name_size); - memcpy(cache->driver_keys_blob + ts_size + gpu_name_size, &ptr_size, - ptr_size_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 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; - } - - return dc_job; -} - -static void -destroy_put_job(void *job, int thread_index) -{ - if (job) { - 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; - } - - /* 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); - if (filename_tmp) - free(filename_tmp); - if (filename) - free(filename); -} - -void -disk_cache_put(struct disk_cache *cache, const cache_key key, - const void *data, size_t size) -{ - struct disk_cache_put_job *dc_job = - create_put_job(cache, key, data, size); - - 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; - - 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; -#ifndef NDEBUG - uint8_t *file_header = malloc(ck_size); - if (!file_header) - goto fail; - - assert(sb.st_size > ck_size); - ret = read_all(fd, file_header, ck_size); - if (ret == -1) { - free(file_header); - goto fail; - } - - assert(memcmp(cache->driver_keys_blob, file_header, ck_size) == 0); - - free(file_header); -#else - /* The cache keys are currently just used for distributing precompiled - * shaders, they are not used by Mesa so just skip them for now. - */ - ret = lseek(fd, ck_size, SEEK_CUR); - if (ret == -1) - goto fail; -#endif - - /* 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; - 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); - 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 (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 = *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 = *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 deleted file mode 100644 index 2bb1cf537..000000000 --- a/lib/mesa/src/util/disk_cache.h +++ /dev/null @@ -1,228 +0,0 @@ -/* - * 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 - -typedef uint8_t cache_key[CACHE_KEY_SIZE]; - -struct disk_cache; - -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); - -/** - * 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); - -/** - * 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 cache_record() 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) -{ - 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) -{ - 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/list.h b/lib/mesa/src/util/list.h index b98ce59ff..07eb9f3e6 100644 --- a/lib/mesa/src/util/list.h +++ b/lib/mesa/src/util/list.h @@ -71,12 +71,18 @@ static inline void list_addtail(struct list_head *item, struct list_head *list) list->prev = item; } +static inline bool list_empty(struct list_head *list); + static inline void list_replace(struct list_head *from, struct list_head *to) { - to->prev = from->prev; - to->next = from->next; - from->next->prev = to; - from->prev->next = to; + if (list_empty(from)) { + list_inithead(to); + } else { + to->prev = from->prev; + to->next = from->next; + from->next->prev = to; + from->prev->next = to; + } } static inline void list_del(struct list_head *item) @@ -99,6 +105,14 @@ static inline bool list_empty(struct list_head *list) return list->next == list; } +/** + * Returns whether the list has exactly one element. + */ +static inline bool list_is_singular(const struct list_head *list) +{ + return list->next != NULL && list->next != list && list->next->next == list; +} + static inline unsigned list_length(struct list_head *list) { struct list_head *node; @@ -108,6 +122,28 @@ static inline unsigned list_length(struct list_head *list) return length; } +static inline void list_splice(struct list_head *src, struct list_head *dst) +{ + if (list_empty(src)) + return; + + src->next->prev = dst; + src->prev->next = dst->next; + dst->next->prev = src->prev; + dst->next = src->next; +} + +static inline void list_splicetail(struct list_head *src, struct list_head *dst) +{ + if (list_empty(src)) + return; + + src->prev->next = dst; + src->next->prev = dst->prev; + dst->prev->next = src->next; + dst->prev = src->prev; +} + static inline void list_validate(struct list_head *list) { struct list_head *node; diff --git a/lib/mesa/src/util/macros.h b/lib/mesa/src/util/macros.h index 84e4f182b..efb896f4c 100644 --- a/lib/mesa/src/util/macros.h +++ b/lib/mesa/src/util/macros.h @@ -24,6 +24,10 @@ #ifndef UTIL_MACROS_H #define UTIL_MACROS_H +#include <assert.h> + +#include "c99_compat.h" + /* Compute the size of an array */ #ifndef ARRAY_SIZE # define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) @@ -150,6 +154,12 @@ do { \ #define ATTRIBUTE_PURE #endif +#ifdef HAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL +#define ATTRIBUTE_RETURNS_NONNULL __attribute__((__returns_nonnull__)) +#else +#define ATTRIBUTE_RETURNS_NONNULL +#endif + #ifdef __cplusplus /** * Macro function that evaluates to true if T is a trivially @@ -157,12 +167,12 @@ do { \ * performs no action and all member variables and base classes are * trivially destructible themselves. */ -# if defined(__GNUC__) -# if ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3))) +# if (defined(__clang__) && defined(__has_feature)) +# if __has_feature(has_trivial_destructor) # define HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T) # endif -# elif (defined(__clang__) && defined(__has_feature)) -# if __has_feature(has_trivial_destructor) +# elif defined(__GNUC__) +# if ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3))) # define HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T) # endif # endif @@ -184,7 +194,7 @@ do { \ * inline a static function that we later use in an alias. - ajax */ #ifndef PUBLIC -# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +# if defined(__GNUC__) # define PUBLIC __attribute__((visibility("default"))) # define USED __attribute__((used)) # elif defined(_MSC_VER) @@ -202,13 +212,34 @@ do { \ #define UNUSED #endif +#define MAYBE_UNUSED UNUSED + #ifdef HAVE_FUNC_ATTRIBUTE_WARN_UNUSED_RESULT #define MUST_CHECK __attribute__((warn_unused_result)) #else #define MUST_CHECK #endif +#if defined(__GNUC__) +#define ATTRIBUTE_NOINLINE __attribute__((noinline)) +#else +#define ATTRIBUTE_NOINLINE +#endif + /** 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)) ) + +/** Minimum of two values: */ +#define MIN2( A, B ) ( (A)<(B) ? (A) : (B) ) + +/** Maximum of two values: */ +#define MAX2( A, B ) ( (A)>(B) ? (A) : (B) ) + +/** Minimum and maximum of three values: */ +#define MIN3( A, B, C ) ((A) < (B) ? MIN2(A, C) : MIN2(B, C)) +#define MAX3( A, B, C ) ((A) > (B) ? MAX2(A, C) : MAX2(B, C)) + #endif /* UTIL_MACROS_H */ diff --git a/lib/mesa/src/util/mesa-sha1.c b/lib/mesa/src/util/mesa-sha1.c index faa1c871b..b6a192f4d 100644 --- a/lib/mesa/src/util/mesa-sha1.c +++ b/lib/mesa/src/util/mesa-sha1.c @@ -175,21 +175,25 @@ _mesa_sha1_final(struct mesa_sha1 *ctx, unsigned char result[20]) #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 int init; + static once_flag flag = ONCE_FLAG_INIT; gcry_md_hd_t h; gcry_error_t err; - if (!init) { - if (!gcry_check_version(NULL)) - return NULL; - gcry_control(GCRYCTL_DISABLE_SECMEM, 0); - gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0); - init = 1; - } + call_once(&flag, _mesa_libgcrypt_init); err = gcry_md_open(&h, GCRY_MD_SHA1, 0); if (err) diff --git a/lib/mesa/src/util/mesa-sha1.h b/lib/mesa/src/util/mesa-sha1.h index 1599405cd..0be5485f3 100644 --- a/lib/mesa/src/util/mesa-sha1.h +++ b/lib/mesa/src/util/mesa-sha1.h @@ -23,12 +23,12 @@ #ifndef SHA1_H #define SHA1_H +#include <stdlib.h> + #ifdef __cplusplus extern "C" { #endif -#include <stdlib.h> - struct mesa_sha1; struct mesa_sha1 * diff --git a/lib/mesa/src/util/ralloc.c b/lib/mesa/src/util/ralloc.c index 01719c888..b8fbfbc31 100644 --- a/lib/mesa/src/util/ralloc.c +++ b/lib/mesa/src/util/ralloc.c @@ -51,7 +51,20 @@ _CRTIMP int _vscprintf(const char *format, va_list argptr); #define CANARY 0x5A1106 -struct ralloc_header +/* Align the header's size so that ralloc() allocations will return with the + * same alignment as a libc malloc would have (8 on 32-bit GLIBC, 16 on + * 64-bit), avoiding performance penalities on x86 and alignment faults on + * ARM. + */ +struct +#ifdef _MSC_VER + __declspec(align(8)) +#elif defined(__LP64__) + __attribute__((aligned(16))) +#else + __attribute__((aligned(8))) +#endif + ralloc_header { #ifdef DEBUG /* A canary value used to determine whether a pointer is ralloc'd. */ @@ -110,6 +123,18 @@ 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)); ralloc_header *info; ralloc_header *parent; @@ -128,15 +153,6 @@ ralloc_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 != NULL)) - memset(ptr, 0, size); - return ptr; -} - /* helper function - assumes ptr != NULL */ static void * resize(void *ptr, size_t size) @@ -293,6 +309,7 @@ ralloc_adopt(const void *new_ctx, void *old_ctx) /* Connect the two lists together; parent them to new_ctx; make old_ctx empty. */ child->next = new_info->child; + child->parent = new_info; new_info->child = old_info->child; old_info->child = NULL; } @@ -359,10 +376,7 @@ ralloc_strndup(const void *ctx, const char *str, size_t max) if (unlikely(str == NULL)) return NULL; - n = strlen(str); - if (n > max) - n = max; - + n = strnlen(str, max); ptr = ralloc_array(ctx, char, n + 1); memcpy(ptr, str, n); ptr[n] = '\0'; @@ -502,6 +516,7 @@ ralloc_vasprintf_rewrite_tail(char **str, size_t *start, const char *fmt, if (unlikely(*str == NULL)) { // Assuming a NULL context is probably bad, but it's expected behavior. *str = ralloc_vasprintf(NULL, fmt, args); + *start = strlen(*str); return true; } diff --git a/lib/mesa/src/util/ralloc.h b/lib/mesa/src/util/ralloc.h index 1b5cbd368..7587e1190 100644 --- a/lib/mesa/src/util/ralloc.h +++ b/lib/mesa/src/util/ralloc.h @@ -247,6 +247,15 @@ 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 *)); @@ -398,6 +407,10 @@ 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. * @@ -408,7 +421,7 @@ bool ralloc_vasprintf_append(char **str, const char *fmt, va_list args); * * which is more idiomatic in C++ than calling ralloc. */ -#define DECLARE_ALLOC_CXX_OPERATORS_TEMPLATE(TYPE, ALLOC_FUNC, USE_DESTRUCTOR) \ +#define DECLARE_RALLOC_CXX_OPERATORS(TYPE) \ private: \ static void _ralloc_destructor(void *p) \ { \ @@ -417,9 +430,9 @@ private: \ public: \ static void* operator new(size_t size, void *mem_ctx) \ { \ - void *p = ALLOC_FUNC(mem_ctx, size); \ + void *p = ralloc_size(mem_ctx, size); \ assert(p != NULL); \ - if (USE_DESTRUCTOR && !HAS_TRIVIAL_DESTRUCTOR(TYPE)) \ + if (!HAS_TRIVIAL_DESTRUCTOR(TYPE)) \ ralloc_set_destructor(p, _ralloc_destructor); \ return p; \ } \ @@ -435,90 +448,5 @@ 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 deleted file mode 100644 index 09febcc33..000000000 --- a/lib/mesa/src/util/rand_xor.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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/rand_xor.h b/lib/mesa/src/util/rand_xor.h deleted file mode 100644 index 532d549bc..000000000 --- a/lib/mesa/src/util/rand_xor.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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. - * - */ - -#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); - -#endif /* RAND_XOR_H */ diff --git a/lib/mesa/src/util/sha1/README b/lib/mesa/src/util/sha1/README deleted file mode 100644 index f30acf984..000000000 --- a/lib/mesa/src/util/sha1/README +++ /dev/null @@ -1,62 +0,0 @@ -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 deleted file mode 100644 index ef59ea1df..000000000 --- a/lib/mesa/src/util/sha1/sha1.c +++ /dev/null @@ -1,173 +0,0 @@ -/* $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 "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 - */ -#if BYTE_ORDER == 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 deleted file mode 100644 index 029a0ae87..000000000 --- a/lib/mesa/src/util/sha1/sha1.h +++ /dev/null @@ -1,53 +0,0 @@ -/* $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/build_id.h b/lib/mesa/src/util/strndup.c index 18641c44a..5ceb32fe4 100644 --- a/lib/mesa/src/util/build_id.h +++ b/lib/mesa/src/util/strndup.c @@ -1,5 +1,5 @@ /* - * Copyright © 2016 Intel Corporation + * Copyright (c) 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"), @@ -21,22 +21,27 @@ * IN THE SOFTWARE. */ -#ifndef BUILD_ID_H -#define BUILD_ID_H +#if defined(_WIN32) +#include <stdlib.h> +#include <string.h> +#include "strndup.h" -#ifdef HAVE_DL_ITERATE_PHDR +char * +strndup(const char *str, size_t max) +{ + size_t n; + char *ptr; -struct build_id_note; + if (!str) + return NULL; -const struct build_id_note * -build_id_find_nhdr(const char *filename); + n = strnlen(str, max); + ptr = (char *) calloc(n + 1, sizeof(char)); + if (!ptr) + return NULL; -unsigned -build_id_length(const struct build_id_note *note); - -const uint8_t * -build_id_data(const struct build_id_note *note); + memcpy(ptr, str, n); + return ptr; +} #endif - -#endif /* BUILD_ID_H */ diff --git a/lib/mesa/src/util/tests/hash_table/Makefile.in b/lib/mesa/src/util/tests/hash_table/Makefile.in index a73e6980e..f57d20cda 100644 --- a/lib/mesa/src/util/tests/hash_table/Makefile.in +++ b/lib/mesa/src/util/tests/hash_table/Makefile.in @@ -223,8 +223,6 @@ 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,6 +253,8 @@ 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,11 +267,10 @@ 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@ @@ -319,27 +318,31 @@ 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_LIBS = @LIBSENSORS_LIBS@ +LIBSENSORS_LDFLAGS = @LIBSENSORS_LDFLAGS@ +LIBSHA1_CFLAGS = @LIBSHA1_CFLAGS@ +LIBSHA1_LIBS = @LIBSHA1_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,6 +363,8 @@ OMX_LIBS = @OMX_LIBS@ OMX_LIB_INSTALL_DIR = @OMX_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@ @@ -379,6 +384,8 @@ 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@ @@ -394,6 +401,8 @@ 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@ @@ -402,6 +411,7 @@ STRIP = @STRIP@ SWR_AVX2_CXXFLAGS = @SWR_AVX2_CXXFLAGS@ SWR_AVX_CXXFLAGS = @SWR_AVX_CXXFLAGS@ SWR_CXX11_CXXFLAGS = @SWR_CXX11_CXXFLAGS@ +TIMESTAMP_CMD = @TIMESTAMP_CMD@ VALGRIND_CFLAGS = @VALGRIND_CFLAGS@ VALGRIND_LIBS = @VALGRIND_LIBS@ VA_CFLAGS = @VA_CFLAGS@ @@ -417,6 +427,7 @@ 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@ @@ -445,10 +456,9 @@ 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/u_atomic.c b/lib/mesa/src/util/u_atomic.c deleted file mode 100644 index 8419c6318..000000000 --- a/lib/mesa/src/util/u_atomic.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - * 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 -__atomic_fetch_add_8(uint64_t *ptr, uint64_t val, int memorder) -{ - return __sync_add_and_fetch(ptr, val); -} - -WEAK uint64_t -__atomic_fetch_sub_8(uint64_t *ptr, uint64_t val, int memorder) -{ - return __sync_sub_and_fetch(ptr, val); -} -#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 2a5bbae29..e873a21b0 100644 --- a/lib/mesa/src/util/u_atomic.h +++ b/lib/mesa/src/util/u_atomic.h @@ -23,6 +23,8 @@ #define PIPE_ATOMIC_OS_SOLARIS #elif defined(_MSC_VER) #define PIPE_ATOMIC_MSVC_INTRINSIC +#elif defined(__arm__) || defined(__hppa__) || defined(__sh__) +#define PIPE_ATOMIC_UNLOCKED #elif defined(__GNUC__) #define PIPE_ATOMIC_GCC_INTRINSIC #else @@ -70,7 +72,25 @@ #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_queue.c b/lib/mesa/src/util/u_queue.c deleted file mode 100644 index 8db09b027..000000000 --- a/lib/mesa/src/util/u_queue.c +++ /dev/null @@ -1,340 +0,0 @@ -/* - * 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); - 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); - while (queue->jobs[queue->read_idx].job) { - util_queue_fence_signal(queue->jobs[queue->read_idx].fence); - - queue->jobs[queue->read_idx].job = NULL; - queue->read_idx = (queue->read_idx + 1) % queue->max_jobs; - } - queue->num_queued = 0; /* reset this when exiting the thread */ - mtx_unlock(&queue->lock); - return 0; -} - -bool -util_queue_init(struct util_queue *queue, - const char *name, - unsigned max_jobs, - unsigned num_threads) -{ - unsigned i; - - memset(queue, 0, sizeof(*queue)); - queue->name = name; - 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; - } - } - } - - 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 the queue is full, wait until there is space */ - 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); -} - -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 deleted file mode 100644 index 4aec1f204..000000000 --- a/lib/mesa/src/util/u_queue.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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 - -/* 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; - 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); -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_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; -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/mesa/src/util/u_string.h b/lib/mesa/src/util/u_string.h deleted file mode 100644 index e88e13f42..000000000 --- a/lib/mesa/src/util/u_string.h +++ /dev/null @@ -1,204 +0,0 @@ -/************************************************************************** - * - * 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 <stddef.h> -#include <stdarg.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 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_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 deleted file mode 100644 index 8eab3a5b9..000000000 --- a/lib/mesa/src/util/u_thread.h +++ /dev/null @@ -1,91 +0,0 @@ -/************************************************************************** - * - * 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 "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(__linux__) && 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 -} - -#endif /* U_THREAD_H_ */ diff --git a/lib/mesa/src/util/vk_util.h b/lib/mesa/src/util/vk_util.h deleted file mode 100644 index 5ff1f0019..000000000 --- a/lib/mesa/src/util/vk_util.h +++ /dev/null @@ -1,200 +0,0 @@ -/* - * 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. - */ -#ifndef VK_UTIL_H -#define VK_UTIL_H - -/* common inlines and macros for vulkan drivers */ - -#include <vulkan/vulkan.h> - -struct vk_struct_common { - VkStructureType sType; - struct vk_struct_common *pNext; -}; - -#define vk_foreach_struct(__iter, __start) \ - for (struct vk_struct_common *__iter = (struct vk_struct_common *)(__start); \ - __iter; __iter = __iter->pNext) - -#define vk_foreach_struct_const(__iter, __start) \ - for (const struct vk_struct_common *__iter = (const struct vk_struct_common *)(__start); \ - __iter; __iter = __iter->pNext) - -/** - * A wrapper for a Vulkan output array. A Vulkan output array is one that - * follows the convention of the parameters to - * vkGetPhysicalDeviceQueueFamilyProperties(). - * - * Example Usage: - * - * VkResult - * vkGetPhysicalDeviceQueueFamilyProperties( - * VkPhysicalDevice physicalDevice, - * uint32_t* pQueueFamilyPropertyCount, - * VkQueueFamilyProperties* pQueueFamilyProperties) - * { - * VK_OUTARRAY_MAKE(props, pQueueFamilyProperties, - * pQueueFamilyPropertyCount); - * - * vk_outarray_append(&props, p) { - * p->queueFlags = ...; - * p->queueCount = ...; - * } - * - * vk_outarray_append(&props, p) { - * p->queueFlags = ...; - * p->queueCount = ...; - * } - * - * return vk_outarray_status(&props); - * } - */ -struct __vk_outarray { - /** May be null. */ - void *data; - - /** - * Capacity, in number of elements. Capacity is unlimited (UINT32_MAX) if - * data is null. - */ - uint32_t cap; - - /** - * Count of elements successfully written to the array. Every write is - * considered successful if data is null. - */ - uint32_t *filled_len; - - /** - * Count of elements that would have been written to the array if its - * capacity were sufficient. Vulkan functions often return VK_INCOMPLETE - * when `*filled_len < wanted_len`. - */ - uint32_t wanted_len; -}; - -static inline void -__vk_outarray_init(struct __vk_outarray *a, - void *data, uint32_t *restrict len) -{ - a->data = data; - a->cap = *len; - a->filled_len = len; - *a->filled_len = 0; - a->wanted_len = 0; - - if (a->data == NULL) - a->cap = UINT32_MAX; -} - -static inline VkResult -__vk_outarray_status(const struct __vk_outarray *a) -{ - if (*a->filled_len < a->wanted_len) - return VK_INCOMPLETE; - else - return VK_SUCCESS; -} - -static inline void * -__vk_outarray_next(struct __vk_outarray *a, size_t elem_size) -{ - void *p = NULL; - - a->wanted_len += 1; - - if (*a->filled_len >= a->cap) - return NULL; - - if (a->data != NULL) - p = a->data + (*a->filled_len) * elem_size; - - *a->filled_len += 1; - - return p; -} - -#define vk_outarray(elem_t) \ - struct { \ - struct __vk_outarray base; \ - elem_t meta[]; \ - } - -#define vk_outarray_typeof_elem(a) __typeof__((a)->meta[0]) -#define vk_outarray_sizeof_elem(a) sizeof((a)->meta[0]) - -#define vk_outarray_init(a, data, len) \ - __vk_outarray_init(&(a)->base, (data), (len)) - -#define VK_OUTARRAY_MAKE(name, data, len) \ - vk_outarray(__typeof__((data)[0])) name; \ - vk_outarray_init(&name, (data), (len)) - -#define vk_outarray_status(a) \ - __vk_outarray_status(&(a)->base) - -#define vk_outarray_next(a) \ - ((vk_outarray_typeof_elem(a) *) \ - __vk_outarray_next(&(a)->base, vk_outarray_sizeof_elem(a))) - -/** - * Append to a Vulkan output array. - * - * This is a block-based macro. For example: - * - * vk_outarray_append(&a, elem) { - * elem->foo = ...; - * elem->bar = ...; - * } - * - * The array `a` has type `vk_outarray(elem_t) *`. It is usually declared with - * VK_OUTARRAY_MAKE(). The variable `elem` is block-scoped and has type - * `elem_t *`. - * - * The macro unconditionally increments the array's `wanted_len`. If the array - * is not full, then the macro also increment its `filled_len` and then - * executes the block. When the block is executed, `elem` is non-null and - * points to the newly appended element. - */ -#define vk_outarray_append(a, elem) \ - for (vk_outarray_typeof_elem(a) *elem = vk_outarray_next(a); \ - elem != NULL; elem = NULL) - -static inline void * -__vk_find_struct(void *start, VkStructureType sType) -{ - vk_foreach_struct(s, start) { - if (s->sType == sType) - return s; - } - - return NULL; -} - -#define vk_find_struct(__start, __sType) \ - __vk_find_struct((__start), VK_STRUCTURE_TYPE_##__sType) - -#define vk_find_struct_const(__start, __sType) \ - (const void *)__vk_find_struct((void *)(__start), VK_STRUCTURE_TYPE_##__sType) - -#endif /* VK_UTIL_H */ |