util: Fixes thread safety of DEBUG_GET_ONCE_*_OPTION macros
authorYonggang Luo <luoyonggang@gmail.com>
Sat, 5 Nov 2022 20:32:05 +0000 (04:32 +0800)
committerMarge Bot <emma+marge@anholt.net>
Fri, 16 Dec 2022 19:30:19 +0000 (19:30 +0000)
commitcba819d65e890ca1db9e9c81f5e44125711d78a8
tree98cc13786396b7b852718f6bdce4ac8955b3e168
parentcdad035cfd9193776667eefb0b4fba9883914bca
util: Fixes thread safety of DEBUG_GET_ONCE_*_OPTION macros

Pick DEBUG_GET_ONCE_BOOL_OPTION as a example:
The intention of DEBUG_GET_ONCE_BOOL_OPTION are returned the same value across
thread, before this commit, on different thread call the function generated by
DEBUG_GET_ONCE_BOOL_OPTION may return different value if called setenv in the
middle of debug_get_bool_option, so use debug_get_option_cached along with
new exposed function debug_parse_bool_option to solve this issue

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19554>
src/util/u_debug.c
src/util/u_debug.h