Commit bb84fa14 authored by Eric Engestrom's avatar Eric Engestrom Committed by Eric Engestrom

util: use C99 declaration in the for-loop hash_table_foreach() macro

Signed-off-by: Eric Engestrom's avatarEric Engestrom <eric@engestrom.ch>
Reviewed-by: Timothy Arceri's avatarTimothy Arceri <tarceri@itsqueeze.com>
parent 3d261cf7
......@@ -3635,7 +3635,6 @@ static void visit_post_phi(struct ac_nir_context *ctx,
static void phi_post_pass(struct ac_nir_context *ctx)
{
struct hash_entry *entry;
hash_table_foreach(ctx->phis, entry) {
visit_post_phi(ctx, (nir_phi_instr*)entry->key,
(LLVMValueRef)entry->data);
......
......@@ -180,8 +180,6 @@ vir_setup_def(struct v3d_compile *c, struct qblock *block, int ip,
static void
sf_state_clear(struct hash_table *partial_update_ht)
{
struct hash_entry *entry;
hash_table_foreach(partial_update_ht, entry) {
struct partial_update_state *state = entry->data;
......
......@@ -134,7 +134,6 @@ vir_lower_uniforms(struct v3d_compile *c)
*/
uint32_t max_count = 0;
uint32_t max_index = 0;
struct hash_entry *entry;
hash_table_foreach(ht, entry) {
uint32_t count = (uintptr_t)entry->data;
uint32_t index = (uintptr_t)entry->key - 1;
......
......@@ -6645,7 +6645,6 @@ ast_case_statement_list::hir(exec_list *instructions,
* if default should be chosen or not.
*/
if (!default_case.is_empty()) {
struct hash_entry *entry;
ir_factory body(instructions, state);
ir_expression *cmp = NULL;
......
......@@ -362,7 +362,6 @@ create_buffer_blocks(void *mem_ctx, struct gl_context *ctx,
ctx->Const.UseSTD430AsDefaultPacking);
unsigned i = 0;
struct hash_entry *entry;
hash_table_foreach (block_hash, entry) {
const struct link_uniform_block_active *const b =
(const struct link_uniform_block_active *) entry->data;
......@@ -429,7 +428,6 @@ link_uniform_blocks(void *mem_ctx,
unsigned num_ubo_variables = 0;
unsigned num_ssbo_variables = 0;
count_block_size block_size;
struct hash_entry *entry;
hash_table_foreach (block_hash, entry) {
struct link_uniform_block_active *const b =
......
......@@ -380,7 +380,6 @@ ir_constant_propagation_visitor::visit_enter(ir_if *ir)
acp->make_empty();
killed_all = true;
} else {
hash_entry *htk;
hash_table_foreach(new_kills, htk)
kill((ir_variable *) htk->key, (uintptr_t) htk->data);
}
......@@ -420,7 +419,6 @@ ir_constant_propagation_visitor::handle_loop(ir_loop *ir, bool keep_acp)
this->acp = orig_acp;
this->killed_all = this->killed_all || orig_killed_all;
hash_entry *htk;
hash_table_foreach(new_kills, htk) {
kill((ir_variable *) htk->key, (uintptr_t) htk->data);
}
......
......@@ -190,7 +190,6 @@ do_constant_variable(exec_list *instructions)
_mesa_key_pointer_equal);
v.run(instructions);
struct hash_entry *hte;
hash_table_foreach(v.ht, hte) {
struct assignment_entry *entry = (struct assignment_entry *) hte->data;
......
......@@ -50,7 +50,6 @@ do_dead_code(exec_list *instructions, bool uniform_locations_assigned)
v.run(instructions);
struct hash_entry *e;
hash_table_foreach(v.ht, e) {
ir_variable_refcount_entry *entry = (ir_variable_refcount_entry *)e->data;
......
......@@ -160,7 +160,6 @@ validate_variables_in_hash_table(struct hash_table *ht,
va_end(args);
struct hash_entry *entry;
hash_table_foreach(ht, entry) {
const ir_instruction *const ir = (ir_instruction *) entry->key;
const ir_variable *const v = ir->as_variable();
......
......@@ -85,7 +85,6 @@ nir_lower_global_vars_to_local(nir_shader *shader)
}
}
struct hash_entry *entry;
hash_table_foreach(var_func_table, entry) {
nir_variable *var = (void *)entry->key;
nir_function_impl *impl = entry->data;
......
......@@ -359,7 +359,6 @@ nir_lower_io_arrays_to_elements_no_indirects(nir_shader *shader,
patch_indirects, split_inputs, true);
/* Remove old input from the shaders inputs list */
struct hash_entry *entry;
hash_table_foreach(split_inputs, entry) {
nir_variable *var = (nir_variable *) entry->key;
exec_node_remove(&var->node);
......@@ -369,7 +368,6 @@ nir_lower_io_arrays_to_elements_no_indirects(nir_shader *shader,
}
/* Remove old output from the shaders outputs list */
struct hash_entry *entry;
hash_table_foreach(split_outputs, entry) {
nir_variable *var = (nir_variable *) entry->key;
exec_node_remove(&var->node);
......@@ -406,7 +404,6 @@ nir_lower_io_arrays_to_elements(nir_shader *producer, nir_shader *consumer)
patch_indirects, split_inputs, false);
/* Remove old input from the shaders inputs list */
struct hash_entry *entry;
hash_table_foreach(split_inputs, entry) {
nir_variable *var = (nir_variable *) entry->key;
exec_node_remove(&var->node);
......
......@@ -360,7 +360,6 @@ nir_lower_io_to_scalar_early(nir_shader *shader, nir_variable_mode mask)
}
/* Remove old input from the shaders inputs list */
struct hash_entry *entry;
hash_table_foreach(split_inputs, entry) {
nir_variable *var = (nir_variable *) entry->key;
exec_node_remove(&var->node);
......
......@@ -201,7 +201,6 @@ gather_vars_written(struct copy_prop_var_state *state,
/* Merge new information to the parent control flow node. */
if (written) {
written->modes |= new_written->modes;
struct hash_entry *new_entry;
hash_table_foreach(new_written->derefs, new_entry) {
struct hash_entry *old_entry =
_mesa_hash_table_search_pre_hashed(written->derefs, new_entry->hash,
......@@ -575,7 +574,6 @@ invalidate_copies_for_cf_node(struct copy_prop_var_state *state,
}
}
struct hash_entry *entry;
hash_table_foreach (written->derefs, entry) {
nir_deref_instr *deref_written = (nir_deref_instr *)entry->key;
kill_aliases(copies, deref_written, (uintptr_t)entry->data);
......
......@@ -727,7 +727,6 @@ validate_block(nir_block *block, validate_state *state)
}
}
struct set_entry *entry;
set_foreach(block->predecessors, entry) {
const nir_block *pred = entry->key;
validate_assert(state, pred->successors[0] == block ||
......@@ -936,7 +935,6 @@ postvalidate_reg_decl(nir_register *reg, validate_state *state)
if (reg_state->uses->entries != 0) {
printf("extra entries in register uses:\n");
struct set_entry *entry;
set_foreach(reg_state->uses, entry)
printf("%p\n", entry->key);
......@@ -951,7 +949,6 @@ postvalidate_reg_decl(nir_register *reg, validate_state *state)
if (reg_state->if_uses->entries != 0) {
printf("extra entries in register if_uses:\n");
struct set_entry *entry;
set_foreach(reg_state->if_uses, entry)
printf("%p\n", entry->key);
......@@ -966,7 +963,6 @@ postvalidate_reg_decl(nir_register *reg, validate_state *state)
if (reg_state->defs->entries != 0) {
printf("extra entries in register defs:\n");
struct set_entry *entry;
set_foreach(reg_state->defs, entry)
printf("%p\n", entry->key);
......@@ -1033,7 +1029,6 @@ postvalidate_ssa_def(nir_ssa_def *def, void *void_state)
if (def_state->uses->entries != 0) {
printf("extra entries in SSA def uses:\n");
struct set_entry *entry;
set_foreach(def_state->uses, entry)
printf("%p\n", entry->key);
......@@ -1048,7 +1043,6 @@ postvalidate_ssa_def(nir_ssa_def *def, void *void_state)
if (def_state->if_uses->entries != 0) {
printf("extra entries in SSA def uses:\n");
struct set_entry *entry;
set_foreach(def_state->if_uses, entry)
printf("%p\n", entry->key);
......@@ -1157,7 +1151,6 @@ dump_errors(validate_state *state)
if (_mesa_hash_table_num_entries(errors) > 0) {
fprintf(stderr, "%d additional errors:\n",
_mesa_hash_table_num_entries(errors));
struct hash_entry *entry;
hash_table_foreach(errors, entry) {
fprintf(stderr, "%s\n", (char *)entry->data);
}
......
......@@ -151,7 +151,6 @@ fd6_sampler_state_delete(struct pipe_context *pctx, void *hwcso)
struct fd6_context *fd6_ctx = fd6_context(fd_context(pctx));
struct fd6_sampler_stateobj *samp = hwcso;
struct hash_entry *entry;
hash_table_foreach(fd6_ctx->tex_cache, entry) {
struct fd6_texture_state *state = entry->data;
......@@ -344,7 +343,6 @@ fd6_sampler_view_destroy(struct pipe_context *pctx,
struct fd6_context *fd6_ctx = fd6_context(fd_context(pctx));
struct fd6_pipe_sampler_view *view = fd6_pipe_sampler_view(_view);
struct hash_entry *entry;
hash_table_foreach(fd6_ctx->tex_cache, entry) {
struct fd6_texture_state *state = entry->data;
......@@ -508,7 +506,6 @@ fd6_texture_fini(struct pipe_context *pctx)
{
struct fd6_context *fd6_ctx = fd6_context(fd_context(pctx));
struct hash_entry *entry;
hash_table_foreach(fd6_ctx->tex_cache, entry) {
fd6_texture_state_destroy(entry->data);
}
......
......@@ -76,7 +76,6 @@ struct ir3_cache * ir3_cache_create(const struct ir3_cache_funcs *funcs, void *d
void ir3_cache_destroy(struct ir3_cache *cache)
{
/* _mesa_hash_table_destroy is so *almost* useful.. */
struct hash_entry *entry;
hash_table_foreach(cache->ht, entry) {
cache->funcs->destroy_state(cache->data, entry->data);
}
......@@ -117,7 +116,6 @@ ir3_cache_lookup(struct ir3_cache *cache, const struct ir3_cache_key *key,
*/
void ir3_cache_invalidate(struct ir3_cache *cache, void *stobj)
{
struct hash_entry *entry;
hash_table_foreach(cache->ht, entry) {
const struct ir3_cache_key *key = entry->key;
if ((key->fs == stobj) || (key->vs == stobj)) {
......
......@@ -43,7 +43,6 @@ v3d_flush(struct pipe_context *pctx)
{
struct v3d_context *v3d = v3d_context(pctx);
struct hash_entry *entry;
hash_table_foreach(v3d->jobs, entry) {
struct v3d_job *job = entry->data;
v3d_job_submit(v3d, job);
......
......@@ -47,8 +47,6 @@ remove_from_ht(struct hash_table *ht, void *key)
static void
v3d_job_free(struct v3d_context *v3d, struct v3d_job *job)
{
struct set_entry *entry;
set_foreach(job->bos, entry) {
struct v3d_bo *bo = (struct v3d_bo *)entry->key;
v3d_bo_unreference(&bo);
......@@ -57,8 +55,6 @@ v3d_job_free(struct v3d_context *v3d, struct v3d_job *job)
remove_from_ht(v3d->jobs, &job->key);
if (job->write_prscs) {
struct set_entry *entry;
set_foreach(job->write_prscs, entry) {
const struct pipe_resource *prsc = entry->key;
......@@ -175,7 +171,6 @@ v3d_flush_jobs_reading_resource(struct v3d_context *v3d,
v3d_flush_jobs_writing_resource(v3d, prsc);
struct hash_entry *entry;
hash_table_foreach(v3d->jobs, entry) {
struct v3d_job *job = entry->data;
......@@ -351,7 +346,6 @@ v3d_clif_dump(struct v3d_context *v3d, struct v3d_job *job)
stderr,
V3D_DEBUG & V3D_DEBUG_CL);
struct set_entry *entry;
set_foreach(job->bos, entry) {
struct v3d_bo *bo = (void *)entry->key;
char *name = ralloc_asprintf(NULL, "%s_0x%x",
......
......@@ -618,7 +618,6 @@ v3d_shader_state_delete(struct pipe_context *pctx, void *hwcso)
struct v3d_context *v3d = v3d_context(pctx);
struct v3d_uncompiled_shader *so = hwcso;
struct hash_entry *entry;
hash_table_foreach(v3d->fs_cache, entry) {
delete_from_cache_if_matches(v3d->fs_cache, &v3d->prog.fs,
entry, so);
......@@ -673,7 +672,6 @@ v3d_program_fini(struct pipe_context *pctx)
{
struct v3d_context *v3d = v3d_context(pctx);
struct hash_entry *entry;
hash_table_foreach(v3d->fs_cache, entry) {
struct v3d_compiled_shader *shader = entry->data;
v3d_bo_unreference(&shader->bo);
......
......@@ -42,7 +42,6 @@ vc4_flush(struct pipe_context *pctx)
{
struct vc4_context *vc4 = vc4_context(pctx);
struct hash_entry *entry;
hash_table_foreach(vc4->jobs, entry) {
struct vc4_job *job = entry->data;
vc4_job_submit(vc4, job);
......
......@@ -118,7 +118,6 @@ vc4_flush_jobs_reading_resource(struct vc4_context *vc4,
vc4_flush_jobs_writing_resource(vc4, prsc);
struct hash_entry *entry;
hash_table_foreach(vc4->jobs, entry) {
struct vc4_job *job = entry->data;
......
......@@ -2975,7 +2975,6 @@ vc4_shader_state_delete(struct pipe_context *pctx, void *hwcso)
struct vc4_context *vc4 = vc4_context(pctx);
struct vc4_uncompiled_shader *so = hwcso;
struct hash_entry *entry;
hash_table_foreach(vc4->fs_cache, entry) {
delete_from_cache_if_matches(vc4->fs_cache, &vc4->prog.fs,
entry, so);
......
......@@ -173,8 +173,6 @@ qir_setup_def(struct vc4_compile *c, struct qblock *block, int ip,
static void
sf_state_clear(struct hash_table *partial_update_ht)
{
struct hash_entry *entry;
hash_table_foreach(partial_update_ht, entry) {
struct partial_update_state *state = entry->data;
......
......@@ -136,7 +136,6 @@ qir_lower_uniforms(struct vc4_compile *c)
*/
uint32_t max_count = 0;
uint32_t max_index = 0;
struct hash_entry *entry;
hash_table_foreach(ht, entry) {
uint32_t count = (uintptr_t)entry->data;
uint32_t index = (uintptr_t)entry->key - 1;
......
......@@ -702,8 +702,6 @@ void gen_spec_destroy(struct gen_spec *spec)
struct gen_group *
gen_spec_find_instruction(struct gen_spec *spec, const uint32_t *p)
{
struct hash_entry *entry;
hash_table_foreach(spec->commands, entry) {
struct gen_group *command = entry->data;
uint32_t opcode = *p & command->opcode_mask;
......
......@@ -245,7 +245,6 @@ brw_nir_analyze_ubo_ranges(const struct brw_compiler *compiler,
struct util_dynarray ranges;
util_dynarray_init(&ranges, mem_ctx);
struct hash_entry *entry;
hash_table_foreach(state.blocks, entry) {
const int b = entry->hash - 1;
const struct ubo_block_info *info = entry->data;
......
......@@ -839,7 +839,6 @@ display_registers_window(struct window *win)
filter.Draw();
ImGui::BeginChild(ImGui::GetID("##block"));
struct hash_entry *entry;
hash_table_foreach(context.file->spec->registers_by_name, entry) {
struct gen_group *reg = (struct gen_group *) entry->data;
if (filter.PassFilter(reg->name) &&
......@@ -895,7 +894,6 @@ display_commands_window(struct window *win)
if (ImGui::Button("Dwords")) show_dwords ^= 1;
ImGui::BeginChild(ImGui::GetID("##block"));
struct hash_entry *entry;
hash_table_foreach(context.file->spec->commands, entry) {
struct gen_group *cmd = (struct gen_group *) entry->data;
if ((cmd_filter.PassFilter(cmd->name) &&
......
......@@ -237,7 +237,6 @@ anv_pipeline_cache_finish(struct anv_pipeline_cache *cache)
* going away, the shader cache has to hold a reference to all shader
* binaries it contains. We unref them when we destroy the cache.
*/
struct hash_entry *entry;
hash_table_foreach(cache->cache, entry)
anv_shader_bin_unref(cache->device, entry->data);
......@@ -499,7 +498,6 @@ VkResult anv_GetPipelineCacheData(
VkResult result = VK_SUCCESS;
if (cache->cache) {
struct hash_entry *entry;
hash_table_foreach(cache->cache, entry) {
struct anv_shader_bin *shader = entry->data;
......@@ -540,7 +538,6 @@ VkResult anv_MergePipelineCaches(
if (!src->cache)
continue;
struct hash_entry *entry;
hash_table_foreach(src->cache, entry) {
struct anv_shader_bin *bin = entry->data;
assert(bin);
......
......@@ -1848,7 +1848,6 @@ static bool
kernel_has_dynamic_config_support(struct brw_context *brw)
{
__DRIscreen *screen = brw->screen->driScrnPriv;
struct hash_entry *entry;
hash_table_foreach(brw->perfquery.oa_metrics_table, entry) {
struct brw_perf_query_info *query = entry->data;
......@@ -1872,7 +1871,6 @@ static void
init_oa_configs(struct brw_context *brw)
{
__DRIscreen *screen = brw->screen->driScrnPriv;
struct hash_entry *entry;
hash_table_foreach(brw->perfquery.oa_metrics_table, entry) {
const struct brw_perf_query_info *query = entry->data;
......
......@@ -979,11 +979,9 @@ intel_renderbuffer_move_to_temp(struct brw_context *brw,
void
brw_cache_sets_clear(struct brw_context *brw)
{
struct hash_entry *render_entry;
hash_table_foreach(brw->render_cache, render_entry)
_mesa_hash_table_remove(brw->render_cache, render_entry);
struct set_entry *depth_entry;
set_foreach(brw->depth_cache, depth_entry)
_mesa_set_remove(brw->depth_cache, depth_entry);
}
......
......@@ -283,8 +283,6 @@ _mesa_HashDeleteAll(struct _mesa_HashTable *table,
void (*callback)(GLuint key, void *data, void *userData),
void *userData)
{
struct hash_entry *entry;
assert(callback);
_mesa_HashLockMutex(table);
table->InDeleteAll = GL_TRUE;
......@@ -316,7 +314,6 @@ hash_walk_unlocked(const struct _mesa_HashTable *table,
assert(table);
assert(callback);
struct hash_entry *entry;
hash_table_foreach(table->ht, entry) {
callback((uintptr_t)entry->key, entry->data, userData);
}
......
......@@ -177,8 +177,6 @@ _mesa_hash_table_destroy(struct hash_table *ht,
return;
if (delete_function) {
struct hash_entry *entry;
hash_table_foreach(ht, entry) {
delete_function(entry);
}
......@@ -284,7 +282,7 @@ static void
_mesa_hash_table_rehash(struct hash_table *ht, unsigned new_size_index)
{
struct hash_table old_ht;
struct hash_entry *table, *entry;
struct hash_entry *table;
if (new_size_index >= ARRAY_SIZE(hash_sizes))
return;
......
......@@ -139,9 +139,9 @@ _mesa_fnv32_1a_accumulate_block(uint32_t hash, const void *data, size_t size)
* an entry's data with the deleted marker), but not against insertion
* (which may rehash the table, making entry a dangling pointer).
*/
#define hash_table_foreach(ht, entry) \
for (entry = _mesa_hash_table_next_entry(ht, NULL); \
entry != NULL; \
#define hash_table_foreach(ht, entry) \
for (struct hash_entry *entry = _mesa_hash_table_next_entry(ht, NULL); \
entry != NULL; \
entry = _mesa_hash_table_next_entry(ht, entry))
static inline void
......@@ -151,8 +151,6 @@ hash_table_call_foreach(struct hash_table *ht,
void *closure),
void *closure)
{
struct hash_entry *entry;
hash_table_foreach(ht, entry)
callback(entry->key, entry->data, closure);
}
......
......@@ -53,7 +53,6 @@ static void delete_function(struct hash_entry *entry)
int main()
{
struct hash_table *ht;
struct hash_entry *entry;
const uint32_t size = 1000;
bool flags[size];
uint32_t i;
......
......@@ -37,7 +37,7 @@ main(int argc, char **argv)
const char *str1 = "test1";
const char *str2 = "test2";
const char *str3 = "test3";
struct hash_entry *entry1, *entry2, *search_entry;
struct hash_entry *entry1, *entry2;
uint32_t bad_hash = 5;
int i;
......
......@@ -1545,7 +1545,6 @@ wsi_x11_finish_wsi(struct wsi_device *wsi_device,
(struct wsi_x11 *)wsi_device->wsi[VK_ICD_WSI_PLATFORM_XCB];
if (wsi) {
struct hash_entry *entry;
hash_table_foreach(wsi->connections, entry)
wsi_x11_connection_destroy(wsi_device, entry->data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment