util: Rename util_cpu_detect to _util_cpu_detect_local

Add comment about _util_cpu_detect_local that it's can only be called by util_get_cpu_caps
Add comment about util_cpu_caps that it's can only by accessed by util_get_cpu_caps

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17803>
This commit is contained in:
Yonggang Luo 2022-07-30 12:36:45 +08:00 committed by Marge Bot
parent 38dad17294
commit e51fa10f53
3 changed files with 7 additions and 8 deletions

View file

@ -43,9 +43,6 @@ class AddImm : public testing::Test {
protected:
AddImm() {
mem_ctx = ralloc_context(NULL);
/* For bi_imm_f16 */
util_cpu_detect();
}
~AddImm() {

View file

@ -92,7 +92,7 @@
DEBUG_GET_ONCE_BOOL_OPTION(dump_cpu, "GALLIUM_DUMP_CPU", false)
/* Do not try to access util_cpu_caps directly, call to util_get_cpu_caps instead */
struct util_cpu_caps_t util_cpu_caps;
#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
@ -867,8 +867,11 @@ util_cpu_detect_once(void)
static once_flag cpu_once_flag = ONCE_FLAG_INIT;
void _util_cpu_detect_local(void);
/* Do not call to this function directly, using util_get_cpu_caps instead */
void
util_cpu_detect(void)
_util_cpu_detect_local(void)
{
call_once(&cpu_once_flag, util_cpu_detect_once);
}

View file

@ -134,11 +134,10 @@ struct util_cpu_caps_t {
#define U_CPU_INVALID_L3 0xffff
void util_cpu_detect(void);
static inline ATTRIBUTE_CONST const struct util_cpu_caps_t *
util_get_cpu_caps(void)
{
extern void _util_cpu_detect_local(void);
extern struct util_cpu_caps_t util_cpu_caps;
/* On most CPU architectures, an atomic read is simply a regular memory
@ -165,7 +164,7 @@ util_get_cpu_caps(void)
* value with the same internal data every time.
*/
if (unlikely(!p_atomic_read(&util_cpu_caps.detect_done)))
util_cpu_detect();
_util_cpu_detect_local();
return &util_cpu_caps;
}