summaryrefslogtreecommitdiff
path: root/src/util
AgeCommit message (Collapse)AuthorFilesLines
2017-06-26mesa/glthread: add glthread "perf" counters and pass them to gallium HUDMarek Olšák1-0/+14
for HUD integration in following commits. This valuable profiling data will allow us to see on the HUD how well glthread is able to utilize parallelism. This is better than benchmarking, because you can see exactly what's happening and you don't have to be CPU-bound. u_threaded_context has the same counters. Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
2017-06-26util: move pipe_thread_is_self from gallium to src/utilMarek Olšák1-0/+12
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
2017-06-18mesa/util: add util_dynarray_clear() helperSamuel Pitoiset1-0/+6
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-06-14mesa/util: add a hash table wrapper which support 64-bit keysSamuel Pitoiset2-0/+172
Needed for bindless handles which are represented using 64-bit unsigned integers. All hash table implementations should be uniformized later on. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2017-06-14mesa/util: add new util_dynarray_delete_unordered helperSamuel Pitoiset1-0/+14
This helper function will be used for managing dynamic arrays of resident texture/image handles. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2017-06-13u_dynarray: fix coverity warning about ignoring return value from rerallocDave Airlie1-1/+1
>>> Ignoring storage allocated by "reralloc_size(buf->mem_ctx, buf->data, buf->size)" leaks it. Reviewed-by: Thomas Helland<thomashelland90@gmail.com> Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
2017-06-08util: make set's deleted_key_value declaration consistent with hash table oneVlad Golovkin1-2/+2
This also silences following clang warnings: no previous extern declaration for non-static variable 'deleted_key' [-Werror,-Wmissing-variable-declarations] const void *deleted_key = &deleted_key_value; ^ no previous extern declaration for non-static variable 'deleted_key_value' [-Werror,-Wmissing-variable-declarations] uint32_t deleted_key_value; ^ Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2017-06-07util/u_queue: fix a use-before-initialization race for queue->threadsMarek Olšák2-17/+14
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
2017-06-07util: Add extern c to u_dynarray.hThomas Helland1-0/+8
Reviewed-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2017-06-07util: Port nir_array functionality to u_dynarrayThomas Helland1-10/+37
Reviewed-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2017-06-07util: Remove unused includes and convert to lower-case memory opsThomas Helland1-15/+12
Also, prepare for the next commit by correcting some coding style changes. This should be all non-functional changes. Reviewed-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2017-06-07util: Move u_dynarray to src/utilThomas Helland2-0/+115
This will be used as the basis for unification Reviewed-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2017-06-07util/u_queue: add an option to set the minimum thread priorityMarek Olšák3-3/+24
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2017-06-07util/u_queue: add a way to remove a job when we just want to destroy itMarek Olšák2-6/+49
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2017-06-06util/vulkan: Move Vulkan utilities to src/vulkan/utilAlex Smith3-297/+1
We have Vulkan utilities in both src/util and src/vulkan/util. The latter seems a more appropriate place for Vulkan-specific things, so move them there. v2: Android build system changes (from Tapani Pälli) Signed-off-by: Alex Smith <asmith@feralinteractive.com> Reviewed-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> Acked-by: Jason Ekstrand <jason@jlekstrand.net>
2017-06-01util/rand_xor: add missing include statementsNicolas Dechesne1-0/+1
Fixes for: src/util/rand_xor.c:60:13: error: implicit declaration of function 'open' [-Werror=implicit-function-declaration] int fd = open("/dev/urandom", O_RDONLY); ^~~~ src/util/rand_xor.c:60:34: error: 'O_RDONLY' undeclared (first use in this function) int fd = open("/dev/urandom", O_RDONLY); ^~~~~~~~ Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2017-05-31mesa/util: fix arithmetic use of 'void *' in u_vector_foreachSamuel Pitoiset1-1/+1
u_vector_foreach is currently only used by the Intel Vulkan driver but when this macro is used in mesa core, GCC reports a compile-time error. Probably because some compiler options are different. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2017-05-29util: slab_destroy_child should check whether it's been initializedMarek Olšák1-0/+3
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2017-05-25util: remove unneeded Android ifdef from ralloc.cRob Herring1-5/+0
SIZE_MAX has been defined in stdint.h on Android since 2013, so this ifdef is no longer needed. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Emil Velikov <emil.velikov@collabora.com> Signed-off-by: Rob Herring <robh@kernel.org>
2017-05-23util/disk_cache: add new driver_flags param to cache keysTimothy Arceri2-3/+11
This will be used for things such as adding driver specific environment variables to the key. Allowing us to set environment vars that change the shader and not have the driver ignore them if it finds existing shaders in the cache. Reviewed-by: Eduardo Lima Mitev <elima@igalia.com>
2017-05-22ralloc: Use strnlen() inside of strncat()Vladislav Egorov1-6/+1
If the str is long or isn't null-terminated, strlen() could take a lot of time or even crash. I don't know why was it used in the first place, maybe for platforms without strnlen(), but strnlen() is already used inside of ralloc_strndup(), so this change should not additionally break anything. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
2017-05-22util: Change the pointer hashing functionThomas Helland1-1/+2
Use our knowledge that pointers are at least 4 byte aligned to remove the useless digits. Then shift by 6, 10, and 14 bits and add this to the original pointer, effectively folding in the entropy of the higher bits of the pointer into a 4-bit section. Stopping at 14 means we can add the entropy from 18 bits, or at least a 600Kbyte section of memory. Assuming that ralloc allocates from a linearly allocated heap less than this we can make a very efficient pointer hashing function for our usecase. Even if we are not on an architecture that is 4 byte aligned, there is still a high big chance that the thing we are allocating is at least 8 bytes in size, so even then we will have entropy into the third bit. The 4 bit increment on the shifts is chosen rather arbitrarily; if we had chosen a 3 bit increment we would need to add another xor to cover a decently sized memorypool. Increasing it to 5 bits would spread our entropy more, possibly hurting us with more collisions on hash tables of size less than 32. With a hash table of size 16 there are a max of 11 entries, and we can assume that with such a small table collisions are not that painfull. This allows us to hash the whole 32 or 64 bit pointer at once, instead of running FNV1a, looping through each byte and doing increments, decrements, muls, and xors on every byte. This cuts _mesa_hash_data from 1.5 % on profiles, to making _mesa_hash_pointer show up with a 0.09% share. Collisions on insertion actually seems to be ever so slightly lower with this hash function, as found by printing a loop counter and sorting the data. perf stat shows a 1.5% reduction in instruction count, and a 5% reduction in stalled cycles. Shader-db runtime goes from 225 to 220 seconds. No instruction-count changes in shader-db, but there are some minor changes in cycle-count that is likely caused by nir walking a set in some of its passes, and this causing a different ordering. That might eventually lead to a difference in register allocation. However, the effect is a net positive; total cycles in shared programs: 24739550 -> 24738482 (-0.00%) cycles in affected programs: 374468 -> 373400 (-0.29%) helped: 178 HURT: 49 Reviewed-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Eric Anholt <eric@anholt.net>
2017-05-17Android: correct libz dependencyChih-Wei Huang1-0/+1
Commit 6facb0c0 ("android: fix libz dynamic library dependencies") unconditionally adds libz as a dependency to all shared libraries. That is unnecessary. Commit 85a9b1b5 introduced libz as a dependency to libmesa_util. So only the shared libraries that use libmesa_util need libz. Fix Android Lollipop build by adding the include path of zlib to libmesa_util explicitly instead of getting the path implicitly from zlib since it doesn't export the include path in Lollipop. Fixes: 6facb0c0 "android: fix libz dynamic library dependencies" Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw> Reviewed-by: Tapani Pälli <tapani.palli@intel.com> Reviewed-by: Rob Herring <robh@kernel.org>
2017-05-09util: move ALWAYS_INLINE macro to util/macro.hTimothy Arceri1-0/+11
Also added clang check. macro.h is include by p_compiler.h so no other change is needed. Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2017-04-28util/disk_cache: remove percentage based max cache limitTimothy Arceri1-6/+2
The more I think about it the more this seems like a bad idea. When we were deleting old cache dirs this wasn't so bad as it was unlikely we would ever hit the actual limit before things were cleaned up. Now that we only start cleaning up old cache items once the limit is reached the a percentage based max cache limit is more risky. For the inital release of shader cache I think its better to stick to a more conservative cache limit, at least until we have some way of cleaning up the cache more aggressively. Cc: "17.1" <mesa-stable@lists.freedesktop.org> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2017-04-27disk_cache: use block size rather than file sizeTimothy Arceri1-5/+11
The majority of cache files are less than 1kb this resulted in us greatly miscalculating the amount of disk space used by the cache. Using the number of blocks allocated to the file is more conservative and less likely to cause issues. This change will result in cache sizes being miscalculated further until old items added with the previous calculation have all been removed. However I don't see anyway around that, the previous patch should help limit that problem. Cc: "17.1" <mesa-stable@lists.freedesktop.org> Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer@amd.com>
2017-04-27disk_cache: reduce default cache size to 5% of filesystemTimothy Arceri1-2/+2
Modern disks are extremely large and are only going to get bigger. Usage has shown frequent Mesa upgrades can result in the cache growing very fast i.e. wasting a lot of disk space unnecessarily. 5% seems like a more reasonable default. Cc: "17.1" <mesa-stable@lists.freedesktop.org> Acked-by: Michel Dänzer <michel.daenzer@amd.com>
2017-04-18util/queue: don't hang at exitRob Clark1-1/+10
So atexit() is horrible and 4aea8fe7 is probably not a good idea. But add an extra layer of duct-tape to the problem. Otherwise we hit a situation where app using an atexit() handler that runs later than ours doesn't hang when trying to tear down a context. (gdb) bt #0 util_queue_killall_and_wait (queue=queue@entry=0x52bc80) at ../../../src/util/u_queue.c:264 #1 0x0000007fb6c380c0 in atexit_handler () at ../../../src/util/u_queue.c:51 #2 0x0000007fb7730e2c in __run_exit_handlers () from /lib64/libc.so.6 #3 0x0000007fb7730e5c in exit () from /lib64/libc.so.6 #4 0x0000007fb7ce17dc in piglit_report_result (result=PIGLIT_PASS) at /home/robclark/src/piglit/tests/util/piglit-util.c:267 #5 0x0000007fb7ef99f8 in process_next_event (x11_fw=0x432c20) at /home/robclark/src/piglit/tests/util/piglit-framework-gl/piglit_x11_framework.c:139 #6 0x0000007fb7ef9a90 in enter_event_loop (winsys_fw=0x432c20) at /home/robclark/src/piglit/tests/util/piglit-framework-gl/piglit_x11_framework.c:153 #7 0x0000007fb7ef8e50 in run_test (gl_fw=0x432c20, argc=1, argv=0x7ffffff588) at /home/robclark/src/piglit/tests/util/piglit-framework-gl/piglit_winsys_framework.c:88 #8 0x0000007fb7edb890 in piglit_gl_test_run (argc=1, argv=0x7ffffff588, config=0x7ffffff400) at /home/robclark/src/piglit/tests/util/piglit-framework-gl.c:203 #9 0x0000000000401224 in main (argc=1, argv=0x7ffffff588) at /home/robclark/src/piglit/tests/bugs/drawbuffer-modes.c:46 (gdb) c Continuing. [Thread 0x7fb67580c0 (LWP 3471) exited] ^C Thread 1 "drawbuffer-mode" received signal SIGINT, Interrupt. 0x0000007fb72dda34 in pthread_cond_wait@@GLIBC_2.17 () from /lib64/libpthread.so.0 (gdb) bt #0 0x0000007fb72dda34 in pthread_cond_wait@@GLIBC_2.17 () from /lib64/libpthread.so.0 #1 0x0000007fb6c38304 in cnd_wait (mtx=0x5bdc90, cond=0x5bdcc0) at ../../../include/c11/threads_posix.h:159 #2 util_queue_fence_wait (fence=0x5bdc90) at ../../../src/util/u_queue.c:106 #3 0x0000007fb6daac70 in fd_batch_sync (batch=0x5bdc70) at ../../../../../src/gallium/drivers/freedreno/freedreno_batch.c:233 #4 batch_reset (batch=batch@entry=0x5bdc70) at ../../../../../src/gallium/drivers/freedreno/freedreno_batch.c:183 #5 0x0000007fb6daa5e0 in batch_flush (batch=0x5bdc70) at ../../../../../src/gallium/drivers/freedreno/freedreno_batch.c:290 #6 fd_batch_flush (batch=0x5bdc70, sync=<optimized out>) at ../../../../../src/gallium/drivers/freedreno/freedreno_batch.c:308 #7 0x0000007fb6daba2c in fd_bc_flush (cache=0x461220, ctx=0x52b920) at ../../../../../src/gallium/drivers/freedreno/freedreno_batch_cache.c:141 #8 0x0000007fb6dac954 in fd_context_flush (pctx=0x52b920, fence=0x0, flags=<optimized out>) at ../../../../../src/gallium/drivers/freedreno/freedreno_context.c:54 #9 0x0000007fb6b43294 in st_glFlush (ctx=<optimized out>) at ../../../src/mesa/state_tracker/st_cb_flush.c:121 #10 0x0000007fb69a84e8 in _mesa_make_current (newCtx=newCtx@entry=0x0, drawBuffer=drawBuffer@entry=0x0, readBuffer=readBuffer@entry=0x0) at ../../../src/mesa/main/context.c:1654 #11 0x0000007fb6b7ca58 in st_api_make_current (stapi=<optimized out>, stctxi=0x0, stdrawi=0x0, streadi=0x0) at ../../../src/mesa/state_tracker/st_manager.c:827 #12 0x0000007fb6cc87e8 in dri_unbind_context (cPriv=<optimized out>) at ../../../../../src/gallium/state_trackers/dri/dri_context.c:217 #13 0x0000007fb6cc80b0 in driUnbindContext (pcp=0x5271e0) at ../../../../../../src/mesa/drivers/dri/common/dri_util.c:591 #14 0x0000007fb7d1da08 in MakeContextCurrent (dpy=0x433380, draw=0, read=0, gc_user=0x0) at ../../../src/glx/glxcurrent.c:214 #15 0x0000007fb7a8d5e0 in glx_platform_make_current () from /lib64/libwaffle-1.so.0 #16 0x0000007fb7a894e4 in waffle_make_current () from /lib64/libwaffle-1.so.0 #17 0x0000007fb7ef8c60 in piglit_wfl_framework_teardown (wfl_fw=0x432c20) at /home/robclark/src/piglit/tests/util/piglit-framework-gl/piglit_wfl_framework.c:628 #18 0x0000007fb7ef939c in piglit_winsys_framework_teardown (winsys_fw=0x432c20) at /home/robclark/src/piglit/tests/util/piglit-framework-gl/piglit_winsys_framework.c:238 #19 0x0000007fb7ef9c30 in destroy (gl_fw=0x432c20) at /home/robclark/src/piglit/tests/util/piglit-framework-gl/piglit_x11_framework.c:212 #20 0x0000007fb7edb7c4 in destroy () at /home/robclark/src/piglit/tests/util/piglit-framework-gl.c:184 #21 0x0000007fb7730e2c in __run_exit_handlers () from /lib64/libc.so.6 #22 0x0000007fb7730e5c in exit () from /lib64/libc.so.6 #23 0x0000007fb7ce17dc in piglit_report_result (result=PIGLIT_PASS) at /home/robclark/src/piglit/tests/util/piglit-util.c:267 #24 0x0000007fb7ef99f8 in process_next_event (x11_fw=0x432c20) at /home/robclark/src/piglit/tests/util/piglit-framework-gl/piglit_x11_framework.c:139 #25 0x0000007fb7ef9a90 in enter_event_loop (winsys_fw=0x432c20) at /home/robclark/src/piglit/tests/util/piglit-framework-gl/piglit_x11_framework.c:153 #26 0x0000007fb7ef8e50 in run_test (gl_fw=0x432c20, argc=1, argv=0x7ffffff588) at /home/robclark/src/piglit/tests/util/piglit-framework-gl/piglit_winsys_framework.c:88 #27 0x0000007fb7edb890 in piglit_gl_test_run (argc=1, argv=0x7ffffff588, config=0x7ffffff400) at /home/robclark/src/piglit/tests/util/piglit-framework-gl.c:203 #28 0x0000000000401224 in main (argc=1, argv=0x7ffffff588) at /home/robclark/src/piglit/tests/bugs/drawbuffer-modes.c:46 (gdb) r Fixes: 4aea8fe7 ("gallium/u_queue: fix random crashes when the app calls exit()") Signed-off-by: Rob Clark <robdclark@gmail.com> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2017-04-03util: fix MSVC warning in u_align_u32()Brian Paul1-1/+1
To silence C:\Users\Brian\projects\mesa\src\util/u_vector.h(41) : warning C4146: unary minus operator applied to unsigned type, result still unsigned Reviewed-by: Jose Fonseca <jfonseca@vmware.com> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2017-04-03util: #include "c99_compat.h" to fix Windows buildBrian Paul2-0/+2
Otherwise, we were getting the definition for 'inline' by chance from some other preceeding #include. Reviewed-by: Jose Fonseca <jfonseca@vmware.com> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2017-04-03util: s/SHA1_H/MESA_SHA1_H/Brian Paul1-2/+2
To follow the convention of other header include guards. Reviewed-by: Jose Fonseca <jfonseca@vmware.com> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2017-04-03util/u_atomic: provide 64bit atomics where they're missingGrazvydas Ignotas2-0/+76
There are still some distributions trying to support unfortunate people with old or exotic CPUs that don't have 64bit atomic operations. When compiling for such a machine, gcc conveniently inserts a library call to a helper, but it's implementation is missing and we get a linker error. This allows us to provide our own implementation, which is marked weak to prefer a better implementation, should one exist. v2: changed copyright, some style adjustments v3: [mattst88] Print results with AC_MSG_CHECKING/AC_MSG_RESULT Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93089 Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> Reviewed-by: Matt Turner <mattst88@gmail.com>
2017-03-25util/disk_cache: don't deadlock on premature EOFGrazvydas Ignotas1-17/+26
If we get EOF earlier than expected, the current read loops will deadlock. This may easily happen if the disk cache gets corrupted. Fix it by using a helper function that handles EOF. Steps to reproduce (on a build with asserts disabled): $ glxgears $ find ~/.cache/mesa/ -type f -exec truncate -s 0 '{}' \; $ glxgears # deadlock Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
2017-03-24util/disk_cache: write cache entry keys to file headerTimothy Arceri1-6/+44
This can be used to deal with key hash collisions from different versions (should we find that to actually happen) and to find which mesa version produced the cache entry. V2: use blob created at cache creation. v3: remove left over var from v1. Reviewed-by: Grazvydas Ignotas <notasas@gmail.com>
2017-03-24util/disk_cache: hash pointer size and gpu name into cache keysGrazvydas Ignotas2-43/+15
This allows to get rid of the arch and gpu name directories. v2: (Timothy Arceri) don't use an opaque data type to store pointer size and gpu name. v3: (Timothy Arceri) use blob to store driver keys just make sure to store null terminator for strings, and make sure blob is defined by disk_cache and not it's users. v4: (Timothy Arceri) fix typo, and make ptr_size a uint8_t. Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2017-03-24util/disk_cache: hash timestamps into the cache keysGrazvydas Ignotas1-51/+26
Instead of using a directory, hash the timestamps into the cache keys themselves. Since there is no more timestamp directory, there is no more need for deleting the cache of other mesa versions and we rely on eviction to clean up the old cache entries. This solves the problem of using several incarnations of disk_cache at the same time, where one deletes a directory belonging to the other, like when both OpenGL and gallium nine are used simultaneously (or several different mesa installations). v2: using additional blob instead of trying to clone sha1 state v3: (Timothy Arceri) don't use an opaque data type to store timestamp. V4: (Timothy Arceri) use blob to store driver keys just make sure to store null terminator for strings, and make sure blob is defined by disk_cache and not it's users. Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100091
2017-03-23util/disk_cache: use rand_xorshift128plus() to get our random intTimothy Arceri1-8/+10
Otherwise for apps that don't seed the regular rand() we will always remove old cache entries from the same dirs. V2: assume bits returned by rand are independent uniformly distributed bits and grab our hex value without taking the modulus of the whole value, this also fixes a bug where 'f' was always missing. Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2017-03-23util/rand_xor: add function to seed randTimothy Arceri2-0/+69
V2: pass the seed to the seed function so that we can isolate its uses. Stop leaking fd when urandom couldn't be read. Reviewed-by: Grazvydas Ignotas <notasas@gmail.com> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2017-03-23util: move rand_xorshift128plus() to utilsTimothy Arceri3-0/+55
V2: pass the seed to rand_xorshift128plus() so that we can isolate its uses. Reviewed-by: Grazvydas Ignotas <notasas@gmail.com> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2017-03-22Android: remove host libmesa_utilRob Herring1-35/+0
The host libmesa_util is never used for Android builds, so remove it. Signed-off-by: Rob Herring <robh@kernel.org> Reviewed-by: Tapani Pälli <tapani.palli@intel.com> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2017-03-22util: automake: beautify sources listEmil Velikov1-3/+3
Remove trailing tabs and sort alphabetically. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Acked-by: Vedran Miletić <vedran@miletic.net> Acked-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com> Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
2017-03-22util/strndup: move header inclusion as applicableEmil Velikov1-2/+1
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Acked-by: Vedran Miletić <vedran@miletic.net> Acked-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com> Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
2017-03-22util: inline strndup implementation in the headerEmil Velikov3-50/+20
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Acked-by: Vedran Miletić <vedran@miletic.net> Acked-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com> Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
2017-03-22util: consistently use ifndef guards over pragma onceEmil Velikov4-2/+19
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Acked-by: Vedran Miletić <vedran@miletic.net> Acked-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com> Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
2017-03-22util/sha1: harmonize _mesa_sha1_* wrappersGrazvydas Ignotas2-9/+10
Rather than using 3 different ways to wrap _mesa_sha1_*() to SHA1*() functions (a macro, prototype with implementation in .c and an inline function), make all 3 inline functions. Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2017-03-21util/disk_cache: fix build on platforms where shader cache is disabledTimothy Arceri1-1/+1
2017-03-21util/disk_cache: add a write helperGrazvydas Ignotas1-14/+23
Simplifies the write code a bit and handles EINTR. V2: (Timothy Arceri) Drop EINTR handling. To do it properly we would need a retry limit but it's probably best to just avoid trying to write if we hit EINTR and try again next time we see the program. Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
2017-03-21util/disk_cache: use a helper to compute cache keysGrazvydas Ignotas2-0/+21
This will allow to hash additional data into the cache keys or even change the hashing algorithm easily, should we decide to do so. v2: don't try to compute key (and crash) if cache is disabled Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
2017-03-20util/disk_cache: check rename resultGrazvydas Ignotas1-2/+6
I haven't seen this causing problems in practice, but for correctness we should also check if rename succeeded to avoid breaking accounting and leaving a .tmp file behind. Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
2017-03-20util/disk_cache: delete .tmp if target existsGrazvydas Ignotas1-1/+3
At the time of target file check, .tmp file is already created and file lock is held, so we should remove the .tmp, like in other error paths. With this, piglit no longer leaves large amount of empty .tmp files behind, which waste directory entries and may interfere with eviction. Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>