mesa: update to the latest u_memory.h

Elements is replaced by ARRAY_SIZE.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Acked-by: Gert Wollny <gert.wollny@collabora.com>
macos/master
Chia-I Wu 3 years ago
parent 2c0715b42a
commit 049ee8ff40
  1. 2
      src/gallium/auxiliary/tgsi/tgsi_info.c
  2. 6
      src/gallium/auxiliary/tgsi/tgsi_scan.c
  3. 16
      src/gallium/auxiliary/tgsi/tgsi_strings.c
  4. 8
      src/gallium/auxiliary/tgsi/tgsi_text.c
  5. 1
      src/gallium/auxiliary/util/u_hash_table.c
  6. 1
      src/gallium/meson.build
  7. 25
      src/mesa/util/u_memory.h
  8. 1
      vtest/vtest_renderer.c

@ -308,7 +308,7 @@ tgsi_get_opcode_info( uint opcode )
if (firsttime) { if (firsttime) {
unsigned i; unsigned i;
firsttime = 0; firsttime = 0;
for (i = 0; i < Elements(opcode_info); i++) for (i = 0; i < ARRAY_SIZE(opcode_info); i++)
assert(opcode_info[i].opcode == i); assert(opcode_info[i].opcode == i);
} }

@ -61,7 +61,7 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
memset(info, 0, sizeof(*info)); memset(info, 0, sizeof(*info));
for (i = 0; i < TGSI_FILE_COUNT; i++) for (i = 0; i < TGSI_FILE_COUNT; i++)
info->file_max[i] = -1; info->file_max[i] = -1;
for (i = 0; i < Elements(info->const_file_max); i++) for (i = 0; i < ARRAY_SIZE(info->const_file_max); i++)
info->const_file_max[i] = -1; info->const_file_max[i] = -1;
info->properties[TGSI_PROPERTY_GS_INVOCATIONS] = 1; info->properties[TGSI_PROPERTY_GS_INVOCATIONS] = 1;
@ -209,7 +209,7 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
/* MSAA samplers */ /* MSAA samplers */
if (src->Register.File == TGSI_FILE_SAMPLER) { if (src->Register.File == TGSI_FILE_SAMPLER) {
assert(fullinst->Instruction.Texture); assert(fullinst->Instruction.Texture);
assert((unsigned)src->Register.Index < Elements(info->is_msaa_sampler)); assert((unsigned)src->Register.Index < ARRAY_SIZE(info->is_msaa_sampler));
if (fullinst->Instruction.Texture && if (fullinst->Instruction.Texture &&
(fullinst->Texture.Texture == TGSI_TEXTURE_2D_MSAA || (fullinst->Texture.Texture == TGSI_TEXTURE_2D_MSAA ||
@ -430,7 +430,7 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
unsigned name = fullprop->Property.PropertyName; unsigned name = fullprop->Property.PropertyName;
unsigned value = fullprop->u[0].Data; unsigned value = fullprop->u[0].Data;
assert(name < Elements(info->properties)); assert(name < ARRAY_SIZE(info->properties));
info->properties[name] = value; info->properties[name] = value;
switch (name) { switch (name) {

@ -231,12 +231,12 @@ const char *tgsi_memory_names[3] =
static inline void UNUSED static inline void UNUSED
tgsi_strings_check(void) tgsi_strings_check(void)
{ {
STATIC_ASSERT(Elements(tgsi_semantic_names) == TGSI_SEMANTIC_COUNT); STATIC_ASSERT(ARRAY_SIZE(tgsi_semantic_names) == TGSI_SEMANTIC_COUNT);
STATIC_ASSERT(Elements(tgsi_texture_names) == TGSI_TEXTURE_COUNT); STATIC_ASSERT(ARRAY_SIZE(tgsi_texture_names) == TGSI_TEXTURE_COUNT);
STATIC_ASSERT(Elements(tgsi_property_names) == TGSI_PROPERTY_COUNT); STATIC_ASSERT(ARRAY_SIZE(tgsi_property_names) == TGSI_PROPERTY_COUNT);
STATIC_ASSERT(Elements(tgsi_primitive_names) == PIPE_PRIM_MAX); STATIC_ASSERT(ARRAY_SIZE(tgsi_primitive_names) == PIPE_PRIM_MAX);
STATIC_ASSERT(Elements(tgsi_interpolate_names) == TGSI_INTERPOLATE_COUNT); STATIC_ASSERT(ARRAY_SIZE(tgsi_interpolate_names) == TGSI_INTERPOLATE_COUNT);
STATIC_ASSERT(Elements(tgsi_return_type_names) == TGSI_RETURN_TYPE_COUNT); STATIC_ASSERT(ARRAY_SIZE(tgsi_return_type_names) == TGSI_RETURN_TYPE_COUNT);
(void) tgsi_processor_type_names; (void) tgsi_processor_type_names;
(void) tgsi_return_type_names; (void) tgsi_return_type_names;
(void) tgsi_immediate_type_names; (void) tgsi_immediate_type_names;
@ -248,8 +248,8 @@ tgsi_strings_check(void)
const char * const char *
tgsi_file_name(unsigned file) tgsi_file_name(unsigned file)
{ {
STATIC_ASSERT(Elements(tgsi_file_names) == TGSI_FILE_COUNT); STATIC_ASSERT(ARRAY_SIZE(tgsi_file_names) == TGSI_FILE_COUNT);
if (file < Elements(tgsi_file_names)) if (file < ARRAY_SIZE(tgsi_file_names))
return tgsi_file_names[file]; return tgsi_file_names[file];
else else
return "invalid file"; return "invalid file";

@ -1642,11 +1642,11 @@ static boolean parse_immediate( struct translate_ctx *ctx )
report_error( ctx, "Syntax error" ); report_error( ctx, "Syntax error" );
return FALSE; return FALSE;
} }
for (type = 0; type < Elements(tgsi_immediate_type_names); ++type) { for (type = 0; type < ARRAY_SIZE(tgsi_immediate_type_names); ++type) {
if (str_match_nocase_whole(&ctx->cur, tgsi_immediate_type_names[type])) if (str_match_nocase_whole(&ctx->cur, tgsi_immediate_type_names[type]))
break; break;
} }
if (type == Elements(tgsi_immediate_type_names)) { if (type == ARRAY_SIZE(tgsi_immediate_type_names)) {
report_error( ctx, "Expected immediate type" ); report_error( ctx, "Expected immediate type" );
return FALSE; return FALSE;
} }
@ -1692,7 +1692,7 @@ parse_fs_coord_origin( const char **pcur, uint *fs_coord_origin )
{ {
uint i; uint i;
for (i = 0; i < Elements(tgsi_fs_coord_origin_names); i++) { for (i = 0; i < ARRAY_SIZE(tgsi_fs_coord_origin_names); i++) {
const char *cur = *pcur; const char *cur = *pcur;
if (str_match_nocase_whole( &cur, tgsi_fs_coord_origin_names[i])) { if (str_match_nocase_whole( &cur, tgsi_fs_coord_origin_names[i])) {
@ -1709,7 +1709,7 @@ parse_fs_coord_pixel_center( const char **pcur, uint *fs_coord_pixel_center )
{ {
uint i; uint i;
for (i = 0; i < Elements(tgsi_fs_coord_pixel_center_names); i++) { for (i = 0; i < ARRAY_SIZE(tgsi_fs_coord_pixel_center_names); i++) {
const char *cur = *pcur; const char *cur = *pcur;
if (str_match_nocase_whole( &cur, tgsi_fs_coord_pixel_center_names[i])) { if (str_match_nocase_whole( &cur, tgsi_fs_coord_pixel_center_names[i])) {

@ -44,6 +44,7 @@
#include "cso_cache/cso_hash.h" #include "cso_cache/cso_hash.h"
#include "util/u_memory.h" #include "util/u_memory.h"
#include "util/u_pointer.h"
#include "util/u_hash_table.h" #include "util/u_hash_table.h"
#define XXH_INLINE_ALL #define XXH_INLINE_ALL

@ -30,7 +30,6 @@ sources_libgallium = [
'include/pipe/p_screen.h', 'include/pipe/p_screen.h',
'include/pipe/p_video_enums.h', 'include/pipe/p_video_enums.h',
'auxiliary/util/u_format.h', 'auxiliary/util/u_format.h',
'auxiliary/util/u_memory.h',
'auxiliary/util/u_rect.h', 'auxiliary/util/u_rect.h',
'auxiliary/util/u_surface.h', 'auxiliary/util/u_surface.h',
'auxiliary/util/u_math.h', 'auxiliary/util/u_math.h',

@ -34,8 +34,6 @@
#ifndef U_MEMORY_H #ifndef U_MEMORY_H
#define U_MEMORY_H #define U_MEMORY_H
#include "util/u_pointer.h"
#include "util/u_debug.h" #include "util/u_debug.h"
#include "util/os_memory.h" #include "util/os_memory.h"
@ -62,13 +60,22 @@ extern "C" {
#define align_malloc(_size, _alignment) os_malloc_aligned(_size, _alignment) #define align_malloc(_size, _alignment) os_malloc_aligned(_size, _alignment)
#define align_free(_ptr) os_free_aligned(_ptr) #define align_free(_ptr) os_free_aligned(_ptr)
#define align_realloc(_ptr, _oldsize, _newsize, _alignment) os_realloc_aligned(_ptr, _oldsize, _newsize, _alignment)
static inline void *
align_calloc(size_t size, unsigned long alignment)
{
void *ptr = align_malloc(size, alignment);
if (ptr)
memset(ptr, 0, size);
return ptr;
}
/** /**
* Duplicate a block of memory. * Duplicate a block of memory.
*/ */
static inline void * static inline void *
mem_dup(const void *src, uint size) mem_dup(const void *src, size_t size)
{ {
void *dup = MALLOC(size); void *dup = MALLOC(size);
if (dup) if (dup)
@ -77,18 +84,6 @@ mem_dup(const void *src, uint size)
} }
/**
* Number of elements in an array.
*/
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
#endif
#ifndef Elements
#define Elements(x) (sizeof(x)/sizeof((x)[0]))
#endif
/** /**
* Offset of a field in a struct, in bytes. * Offset of a field in a struct, in bytes.
*/ */

@ -53,6 +53,7 @@
#include "util/u_double_list.h" #include "util/u_double_list.h"
#include "util/u_math.h" #include "util/u_math.h"
#include "util/u_memory.h" #include "util/u_memory.h"
#include "util/u_pointer.h"
#include "util/u_hash_table.h" #include "util/u_hash_table.h"
#define VTEST_MAX_SYNC_QUEUE_COUNT 64 #define VTEST_MAX_SYNC_QUEUE_COUNT 64

Loading…
Cancel
Save