#include <ctype.h>
#include <stddef.h>
+#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
+
typedef char char4 [4];
/* Table containing equivalences between ISO_639_1 codes and their ISO_639_3
static char*
iso_639_1_to_639_3(char* iso_639_1_code) {
- int len = sizeof(iso_639)/sizeof(iso_639[0]);
+ int len = ARRAY_SIZE (iso_639);
char **p = iso_639;
int j;
static char*
language_name_to_639_3(char* name) {
- int len = sizeof(iso_639)/sizeof(iso_639[0]);
+ int len = ARRAY_SIZE (iso_639);
char **p = iso_639;
int j;
static char*
country_name_to_3166 (char* name) {
- int len = sizeof(iso_3166)/sizeof(iso_3166[0]);
+ int len = ARRAY_SIZE (iso_3166);
char **p = iso_3166;
int j;
= {"azure", "coral", "cornsilk", "lightblue", "yellow",
"honeydew", "lightpink", "lightsalmon", "palegreen1",
"wheat", "seashell"};
- const int num_colors = sizeof (colors) / sizeof (colors[0]);
+ const int num_colors = ARRAY_SIZE (colors);
return colors[total_sm_state % num_colors];
}
else
"getwc_unlocked",
"putc_unlocked"
};
- const size_t count = sizeof(example) / sizeof (example[0]);
+ const size_t count = ARRAY_SIZE (example);
function_set fs (example, count);
fs.assert_sorted ();
fs.assert_sane ();
"ungetc",
"vfprintf"
};
- const size_t count
- = sizeof(funcnames) / sizeof (funcnames[0]);
+ const size_t count = ARRAY_SIZE (funcnames);
function_set fs (funcnames, count);
return fs;
}
/* This array must be kept sorted. */
"strsep",
};
- const size_t count
- = sizeof(funcnames) / sizeof (funcnames[0]);
+ const size_t count = ARRAY_SIZE (funcnames);
function_set fs (funcnames, count);
if (fs.contains_decl_p (fndecl))
"vsnprintf",
"vsprintf"
};
- const size_t count
- = sizeof(async_signal_unsafe_fns) / sizeof (async_signal_unsafe_fns[0]);
+ const size_t count = ARRAY_SIZE (async_signal_unsafe_fns);
function_set fs (async_signal_unsafe_fns, count);
return fs;
}
/* Iterate over the mutually exclusive attribute names and verify
that the symbol doesn't contain it. */
- for (unsigned i = 0; i != sizeof attrs / sizeof *attrs; ++i)
+ for (unsigned i = 0; i != ARRAY_SIZE (attrs); ++i)
{
if (!attrs[i])
continue;
};
for (unsigned i = 0; i != 2; ++i)
- for (unsigned j = 0; j != sizeof whitelist / sizeof *whitelist; ++j)
+ for (unsigned j = 0; j != ARRAY_SIZE (whitelist); ++j)
if (lookup_attribute (whitelist[j], tmpl_attrs[i])
|| lookup_attribute (whitelist[j], decl_attrs[i]))
return 0;
if (eltsize != tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (src)))))
return NULL_TREE;
- /* Set MAXELTS to sizeof (SRC) / sizeof (*SRC) - 1, the maximum possible
+ /* Set MAXELTS to ARRAY_SIZE (SRC) - 1, the maximum possible
length of SRC. Prefer TYPE_SIZE() to TREE_STRING_LENGTH() if possible
in case the latter is less than the size of the array, such as when
SRC refers to a short string literal used to initialize a large array.
int imode;
{
- const int nmodes =
- sizeof attr_access::mode_names / sizeof *attr_access::mode_names;
+ const int nmodes = ARRAY_SIZE (attr_access::mode_names);
for (imode = 0; imode != nmodes; ++imode)
if (!strncmp (ps, attr_access::mode_names[imode],
{ "null_resettable", RID_NULL_RESETTABLE, D_OBJC },
};
-const unsigned int num_c_common_reswords =
- sizeof c_common_reswords / sizeof (struct c_common_resword);
+const unsigned int num_c_common_reswords = ARRAY_SIZE (c_common_reswords);
/* Return identifier for address space AS. */
/* Make fileptr_type_node a distinct void * type until
FILE type is defined. Likewise for const struct tm*. */
- for (unsigned i = 0;
- i < sizeof (builtin_structptr_types) / sizeof (builtin_structptr_type);
- ++i)
+ for (unsigned i = 0; i < ARRAY_SIZE (builtin_structptr_types); ++i)
builtin_structptr_types[i].node
= build_variant_type_copy (builtin_structptr_types[i].base);
else
{
/* Diagnose some common misspellings. */
- for (unsigned i = 0; i != sizeof badwords / sizeof *badwords; ++i)
+ for (unsigned i = 0; i != ARRAY_SIZE (badwords); ++i)
{
unsigned badwlen = strspn (badwords[i].name, " -");
if (wlen >= badwlen
if (ISPUNCT (format_chars[0]))
{
- size_t nelts = sizeof c_opers / sizeof *c_opers;
+ size_t nelts = ARRAY_SIZE (c_opers);
if (const char *ret = check_tokens (c_opers, nelts,
format_string_loc, format_string_cst,
orig_format_chars, format_chars,
baltoks))
return ret;
- nelts = c_dialect_cxx () ? sizeof cxx_opers / sizeof *cxx_opers : 0;
+ nelts = c_dialect_cxx () ? ARRAY_SIZE (cxx_opers) : 0;
if (const char *ret = check_tokens (cxx_opers, nelts,
format_string_loc, format_string_cst,
orig_format_chars, format_chars,
if (ISALPHA (format_chars[0]))
{
- size_t nelts = sizeof c_keywords / sizeof *c_keywords;
+ size_t nelts = ARRAY_SIZE (c_keywords);
if (const char *ret = check_tokens (c_keywords, nelts,
format_string_loc, format_string_cst,
orig_format_chars, format_chars,
baltoks))
return ret;
- nelts = c_dialect_cxx () ? sizeof cxx_keywords / sizeof *cxx_keywords : 0;
+ nelts = c_dialect_cxx () ? ARRAY_SIZE (cxx_keywords) : 0;
if (const char *ret = check_tokens (cxx_keywords, nelts,
format_string_loc, format_string_cst,
orig_format_chars, format_chars,
&& ISALPHA (format_chars[1]))
{
/* Diagnose a subset of contractions that are best avoided. */
- for (unsigned i = 0; i != sizeof contrs / sizeof *contrs; ++i)
+ for (unsigned i = 0; i != ARRAY_SIZE (contrs); ++i)
{
const char *apos = strchr (contrs[i].name, '\'');
gcc_assert (apos != NULL);
void
c_pp_lookup_pragma (unsigned int id, const char **space, const char **name)
{
- const int n_oacc_pragmas = sizeof (oacc_pragmas) / sizeof (*oacc_pragmas);
- const int n_omp_pragmas = sizeof (omp_pragmas) / sizeof (*omp_pragmas);
+ const int n_oacc_pragmas = ARRAY_SIZE (oacc_pragmas);
+ const int n_omp_pragmas = ARRAY_SIZE (omp_pragmas);
const int n_omp_pragmas_simd = sizeof (omp_pragmas_simd)
/ sizeof (*omp_pragmas);
int i;
{
if (flag_openacc)
{
- const int n_oacc_pragmas
- = sizeof (oacc_pragmas) / sizeof (*oacc_pragmas);
+ const int n_oacc_pragmas = ARRAY_SIZE (oacc_pragmas);
int i;
for (i = 0; i < n_oacc_pragmas; ++i)
if (flag_openmp)
{
- const int n_omp_pragmas = sizeof (omp_pragmas) / sizeof (*omp_pragmas);
+ const int n_omp_pragmas = ARRAY_SIZE (omp_pragmas);
int i;
for (i = 0; i < n_omp_pragmas; ++i)
if ((lib == STDLIB_C && flag_isoc99)
|| (lib == STDLIB_CPLUSPLUS && cxx_dialect >= cxx11 ))
{
- const size_t num_c99_cxx11_macros
- = sizeof (c99_cxx11_macros) / sizeof (c99_cxx11_macros[0]);
+ const size_t num_c99_cxx11_macros = ARRAY_SIZE (c99_cxx11_macros);
for (size_t i = 0; i < num_c99_cxx11_macros; i++)
if (strcmp (name, c99_cxx11_macros[i]) == 0)
return lib == STDLIB_C ? "<inttypes.h>" : "<cinttypes>";
{"WCHAR_MAX", {"<wchar.h>", "<cwchar>"} },
{"WCHAR_MIN", {"<wchar.h>", "<cwchar>"} }
};
- const size_t num_hints = sizeof (hints) / sizeof (hints[0]);
+ const size_t num_hints = ARRAY_SIZE (hints);
for (size_t i = 0; i < num_hints; i++)
if (strcmp (name, hints[i].name) == 0)
return hints[i].header[lib];
Used only by match_builtin_function_types. */
static const unsigned builtin_structptr_type_count
- = sizeof builtin_structptr_types / sizeof builtin_structptr_types[0];
+ = ARRAY_SIZE (builtin_structptr_types);
static GTY(()) tree last_structptr_types[builtin_structptr_type_count];
tree newargs = TYPE_ARG_TYPES (newtype);
tree tryargs = newargs;
- const unsigned nlst
- = sizeof last_structptr_types / sizeof last_structptr_types[0];
- const unsigned nbst
- = sizeof builtin_structptr_types / sizeof builtin_structptr_types[0];
+ const unsigned nlst = ARRAY_SIZE (last_structptr_types);
+ const unsigned nbst = ARRAY_SIZE (builtin_structptr_types);
gcc_checking_assert (nlst == nbst);
NULL
#undef DEF_BASIC_BLOCK_FLAG
};
- const unsigned n_bitnames = sizeof (bb_bitnames) / sizeof (char *);
+ const unsigned n_bitnames = ARRAY_SIZE (bb_bitnames);
bool first;
char *s_indent = (char *) alloca ((size_t) indent + 1);
memset ((void *) s_indent, ' ', (size_t) indent);
pop and attribute change (arm_neon headers, lto etc all cause this to
happen quite frequently). It is a trade-off between time and space and
so time won. */
- int n_extensions
- = sizeof (all_extensions) / sizeof (struct aarch64_option_extension);
+ int n_extensions = ARRAY_SIZE (all_extensions);
qsort (&all_extensions_by_on, n_extensions,
sizeof (struct aarch64_option_extension), opt_ext_cmp);
}
enum aarch64_type_qualifiers q)
{
int i;
- int nelts = sizeof (aarch64_simd_types) / sizeof (aarch64_simd_types[0]);
+ int nelts = ARRAY_SIZE (aarch64_simd_types);
/* Non-poly scalar modes map to standard types not in the table. */
if (q != qualifier_poly && !VECTOR_MODE_P (mode))
aarch64_init_simd_builtin_types (void)
{
int i;
- int nelts = sizeof (aarch64_simd_types) / sizeof (aarch64_simd_types[0]);
+ int nelts = ARRAY_SIZE (aarch64_simd_types);
tree tdecl;
/* Init all the element types built by the front-end. */
};
builtin_decls_data *bdd = bdda;
- builtin_decls_data *bdd_end = bdd + (sizeof (bdda) / sizeof (builtin_decls_data));
+ builtin_decls_data *bdd_end = bdd + (ARRAY_SIZE (bdda));
for (; bdd < bdd_end; bdd++)
{
TYPE_SMMLA, TYPE_UMLAL, TYPE_UMLALS,TYPE_SMLSD, TYPE_SMLSDX, TYPE_SMLSLD
};
- for (i = 0; i < sizeof (mlatypes) / sizeof (enum attr_type); i++)
+ for (i = 0; i < ARRAY_SIZE (mlatypes); i++)
{
if (t1 == mlatypes[i])
return true;
enum arm_type_qualifiers q)
{
int i;
- int nelts = sizeof (arm_simd_types) / sizeof (arm_simd_types[0]);
+ int nelts = ARRAY_SIZE (arm_simd_types);
/* Non-poly scalar modes map to standard types not in the table. */
if (q != qualifier_poly && !VECTOR_MODE_P (mode))
arm_init_simd_builtin_types (void)
{
int i;
- int nelts = sizeof (arm_simd_types) / sizeof (arm_simd_types[0]);
+ int nelts = ARRAY_SIZE (arm_simd_types);
tree tdecl;
/* Poly types are a world of their own. In order to maintain legacy
#define IN_GEN_AVR_MMCU_TEXI
+#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
+
#include "avr-devices.cc"
static const avr_mcu_t*
-mcus[sizeof avr_mcu_types / sizeof avr_mcu_types[0]];
+mcus[ARRAY_SIZE (avr_mcu_types)];
static int letter (char c)
{
"attiny", "atmega", "atxmega", "ata", "at90"
};
- int i, n = (int) (sizeof (prefixes) / sizeof (*prefixes));
+ int i, n = (int) (ARRAY_SIZE (prefixes));
for (i = 0; i < n; i++)
if (str_prefix_p (str, prefixes[i]))
print_mcus (n_mcus);
n_mcus = 0;
- for (i = 0; i < sizeof (avr_texinfo) / sizeof (*avr_texinfo); i++)
+ for (i = 0; i < ARRAY_SIZE (avr_texinfo); i++)
if (arch_id == avr_texinfo[i].arch_id)
printf ("@item %s\n%s\n", mcu->name, avr_texinfo[i].texinfo);
}
REG_B14, REG_A15
};
-#define N_SAVE_ORDER (sizeof reg_save_order / sizeof *reg_save_order)
+#define N_SAVE_ORDER (ARRAY_SIZE (reg_save_order))
/* Compute the layout of the stack frame and store it in FRAME. */
size_t i;
/* Setup default search path for frameworks. */
- for (i=0; i<sizeof (framework_defaults)/sizeof(const char *); ++i)
+ for (i = 0; i < ARRAY_SIZE (framework_defaults); ++i)
{
char *str;
if (sysroot)
" unsigned global_variable_count;\n"
"} target_data = {\n"
" &gcn_image,\n"
- " sizeof (gcn_kernels) / sizeof (gcn_kernels[0]),\n"
+ " ARRAY_SIZE (gcn_kernels),\n"
" gcn_kernels,\n"
" gcn_num_vars\n"
"};\n\n");
enum feature_priority priority = P_NONE;
- static unsigned int NUM_FEATURES
- = sizeof (isa_names_table) / sizeof (_isa_names_table);
+ static unsigned int NUM_FEATURES = ARRAY_SIZE (isa_names_table);
unsigned int i;
tree final;
unsigned int field_val = 0;
- unsigned int NUM_ISA_NAMES
- = sizeof (isa_names_table) / sizeof (struct _isa_names_table);
+ unsigned int NUM_ISA_NAMES = ARRAY_SIZE (isa_names_table);
for (i = 0; i < NUM_ISA_NAMES; i++)
if (strcmp (isa_names_table[i].name,
{ FB_REGNO, 0x01, 2, 4 }
};
-#define PUSHM_N (sizeof(pushm_info)/sizeof(pushm_info[0]))
+#define PUSHM_N (ARRAY_SIZE (pushm_info))
/* Returns TRUE if we need to save/restore the given register. We
save everything for exception handlers, so that any register can be
" const struct nvptx_fn *fn_names;\n"
" unsigned fn_num;\n"
"} target_data = {\n"
- " ptx_objs, sizeof (ptx_objs) / sizeof (ptx_objs[0]),\n"
+ " ptx_objs, ARRAY_SIZE (ptx_objs),\n"
" var_mappings,"
- " sizeof (var_mappings) / sizeof (var_mappings[0]),\n"
+ " ARRAY_SIZE (var_mappings),\n"
" func_mappings,"
- " sizeof (func_mappings) / sizeof (func_mappings[0])\n"
+ " ARRAY_SIZE (func_mappings)\n"
"};\n\n");
fprintf (out, "#ifdef __cplusplus\n"
if (assembler)
{
- for (i = 0; i < sizeof (asm_names) / sizeof (asm_names[0]); i++)
+ for (i = 0; i < ARRAY_SIZE (asm_names); i++)
{
if (!asm_names[i].cpu || !strcmp (asm_names[i].cpu, cpu))
return asm_names[i].asm_sw;
QImode,
V1QImode
};
-#define NR_C_MODES (sizeof (constant_modes) / sizeof (constant_modes[0]))
+#define NR_C_MODES (ARRAY_SIZE (constant_modes))
struct constant
{
const Operator *const prev_op = s.m_exprs[num_vals - 1].m_op;
const int prev_top_index = (prev_op != NULL) ? prev_op->m_top_index : -1;
- for (size_t f = 0; f < sizeof ops / sizeof ops[0]; f++)
+ for (size_t f = 0; f < ARRAY_SIZE (ops); f++)
{
const Operator *const op = &ops[f];
printf ("const enum insn_code %s_multiply_insn_seq_decode_opcode[] = {\n"
" CODE_FOR_nothing /* must be first */ ", ARCH);
- for (size_t i = 0; i < sizeof ops / sizeof ops[0]; i++)
+ for (size_t i = 0; i < ARRAY_SIZE (ops); i++)
{
Operator *op = &ops[i];
int index = -1;
/* Number of entires in the above array. */
-#define NBR_CRTL_NAMES (sizeof (vms_crtl_names) / sizeof (*vms_crtl_names))
+#define NBR_CRTL_NAMES (ARRAY_SIZE (vms_crtl_names))
/* List of aliased identifiers. They must be persistent across gc. */
{"decl", "specialization", "partial", "using",
"namespace", "redirect", "binding"};
entity_kind kind = get_entity_kind ();
- gcc_checking_assert (kind < sizeof (names) / sizeof(names[0]));
+ gcc_checking_assert (kind < ARRAY_SIZE (names));
return names[kind];
}
/* <vector>. */
{"vector", "<vector>", cxx98},
};
- const size_t num_hints = sizeof (hints) / sizeof (hints[0]);
+ const size_t num_hints = ARRAY_SIZE (hints);
for (size_t i = 0; i < num_hints; i++)
{
if (strcmp (name, hints[i].name) == 0)
{
/* Initialize the binops_by_token so that we can get the tree
directly from the token. */
- for (unsigned i = 0; i < sizeof (binops) / sizeof (binops[0]); i++)
+ for (unsigned i = 0; i < ARRAY_SIZE (binops); i++)
binops_by_token[binops[i].token_type] = binops[i];
cp_parser *parser = ggc_cleared_alloc<cp_parser> ();
{"byte-column", DIAGNOSTICS_COLUMN_UNIT_BYTE}
};
int the_column = INT_MIN;
- for (int i = 0; i != sizeof column_fields / sizeof (*column_fields); ++i)
+ for (int i = 0; i != ARRAY_SIZE (column_fields); ++i)
{
context->column_unit = column_fields[i].unit;
const int col = diagnostic_converted_column (context, exploc);
{ TYPE_QUAL_RESTRICT, DW_TAG_restrict_type },
{ TYPE_QUAL_ATOMIC, DW_TAG_atomic_type }
};
-static const unsigned int dwarf_qual_info_size
- = sizeof (dwarf_qual_info) / sizeof (dwarf_qual_info[0]);
+static const unsigned int dwarf_qual_info_size = ARRAY_SIZE (dwarf_qual_info);
/* If DIE is a qualified DIE of some base DIE with the same parent,
return the base DIE, otherwise return NULL. Set MASK to the
WALK_SUBEXPR (co->ext.omp_clauses->detach);
for (idx = 0; idx < OMP_IF_LAST; idx++)
WALK_SUBEXPR (co->ext.omp_clauses->if_exprs[idx]);
- for (idx = 0;
- idx < sizeof (list_types) / sizeof (list_types[0]);
- idx++)
+ for (idx = 0; idx < ARRAY_SIZE (list_types); idx++)
for (n = co->ext.omp_clauses->lists[list_types[idx]];
n; n = n->next)
WALK_SUBEXPR (n->expr);
match m;
const char *selector_sets[] = { "construct", "device",
"implementation", "user" };
- const int selector_set_count
- = sizeof (selector_sets) / sizeof (*selector_sets);
+ const int selector_set_count = ARRAY_SIZE (selector_sets);
int i;
char buf[GFC_MAX_SYMBOL_LEN + 1];
enum built_in_function code, int nargs)
{
tree args[2];
- gcc_assert ((unsigned) nargs <= sizeof(args)/sizeof(args[0]));
+ gcc_assert ((unsigned) nargs <= ARRAY_SIZE (args));
conv_ieee_function_args (se, expr, args, nargs);
se->expr = build_call_expr_loc_array (input_location,
}
rank = GFC_TYPE_ARRAY_RANK (type);
- if (rank >= (int) (sizeof (info->dimen) / sizeof (info->dimen[0])))
+ if (rank >= (int) (ARRAY_SIZE (info->dimen)))
return false;
etype = GFC_TYPE_ARRAY_DATAPTR_TYPE (type);
}
fclose (f);
/* For each hook in hook_array, if it is a start hook, store its position. */
- for (i = 0; i < (int) (sizeof hook_array / sizeof hook_array[0]); i++)
+ for (i = 0; i < (int) (ARRAY_SIZE (hook_array)); i++)
{
struct s_hook sh, *shp;
void *p;
/* POD-valued hooks sometimes come in groups with common
documentation.*/
for (j = i + 1;
- j < (int) (sizeof hook_array / sizeof hook_array[0])
+ j < (int) (ARRAY_SIZE (hook_array))
&& hook_array[j].doc == 0 && hook_array[j].type; j++)
{
char *namex = upstrdup (hook_array[j].name);
printf ("\n@end %s", deftype);
}
}
- if (++i >= (int) (sizeof hook_array / sizeof hook_array[0])
- || !hook_array[i].doc)
+ if (++i >= (int) (ARRAY_SIZE (hook_array)) || !hook_array[i].doc)
break;
free (name);
sh.name = name = upstrdup (hook_array[i].name);
for (print_nest = 0; print_nest <= MAX_NEST; print_nest++)
{
- for (i = 0; i < (int) (sizeof hook_array / sizeof hook_array[0]); i++)
+ for (i = 0; i < (int) (ARRAY_SIZE (hook_array)); i++)
{
char *name = upstrdup (hook_array[i].name);
&res.range.min, &res.range.max
};
- for (int i = 0; i != sizeof minmax / sizeof *minmax; ++i)
+ for (int i = 0; i != ARRAY_SIZE (minmax); ++i)
{
/* Convert the GCC real value representation with the precision
of the real type to the mpfr_t format rounding down in the
{
val = memmodel_base (val);
- for (unsigned i = 0; i != sizeof memory_models / sizeof *memory_models; ++i)
+ for (unsigned i = 0; i != ARRAY_SIZE (memory_models); ++i)
{
if (val == memory_models[i].modval)
return memory_models[i].modname;
keyword_hash_init (class godump_container *container)
{
size_t i;
- size_t count = sizeof (keywords) / sizeof (keywords[0]);
+ size_t count = ARRAY_SIZE (keywords);
void **slot;
for (i = 0; i < count; i++)
hash_table_higher_prime_index (unsigned long n)
{
unsigned int low = 0;
- unsigned int high = sizeof (prime_tab) / sizeof (prime_tab[0]);
+ unsigned int high = ARRAY_SIZE (prime_tab);
while (low != high)
{
{
/* ...and use each of the "interesting" location values as
the starting location within line_table. */
- const int num_boundary_locations
- = sizeof (boundary_locations) / sizeof (boundary_locations[0]);
+ const int num_boundary_locations = ARRAY_SIZE (boundary_locations);
for (int loc_idx = 0; loc_idx < num_boundary_locations; loc_idx++)
{
line_table_case c (default_range_bits, boundary_locations[loc_idx]);
free_lang_data_in_cgraph (&fld);
/* Create gimple variants for common types. */
- for (unsigned i = 0;
- i < sizeof (builtin_structptr_types) / sizeof (builtin_structptr_type);
- ++i)
+ for (unsigned i = 0; i < ARRAY_SIZE (builtin_structptr_types); ++i)
builtin_structptr_types[i].node = builtin_structptr_types[i].base;
/* Reset some langhooks. Do not reset types_compatible_p, it may
SANITIZE_POINTER_SUBTRACT
};
- for (unsigned i = 0; i < sizeof (codes) / sizeof (codes[0]); i++)
+ for (unsigned i = 0; i < ARRAY_SIZE (codes); i++)
if (sanitize_flags_p (codes[i], caller)
!= sanitize_flags_p (codes[i], callee))
return false;
We start at index 1 to skip the initial entry (BUILT_IN_NONE), which
has a NULL name. */
- for (unsigned int i = 1;
- i < sizeof (builtin_data) / sizeof (builtin_data[0]);
- i++)
+ for (unsigned int i = 1; i < ARRAY_SIZE (builtin_data); i++)
{
const struct builtin_data& bd = builtin_data[i];
if (matches_builtin (in_name, bd))
static const char *
get_string_for_type_id (enum jit_builtin_type type_id)
{
- gcc_assert (type_id < sizeof (type_names)/sizeof(type_names[0]));
+ gcc_assert (type_id < ARRAY_SIZE (type_names));
return type_names[type_id];
}
if (parent_ctxt)
{
/* Inherit options from parent. */
- for (unsigned i = 0;
- i < sizeof (m_str_options) / sizeof (m_str_options[0]);
- i++)
+ for (unsigned i = 0; i < ARRAY_SIZE (m_str_options); i++)
{
const char *parent_opt = parent_ctxt->m_str_options[i];
m_str_options[i] = parent_opt ? xstrdup (parent_opt) : NULL;
char r_str[27];
enum ld_plugin_symbol_resolution r = (enum ld_plugin_symbol_resolution) 0;
unsigned int j;
- unsigned int lto_resolution_str_len
- = sizeof (lto_resolution_str) / sizeof (char *);
+ unsigned int lto_resolution_str_len = ARRAY_SIZE (lto_resolution_str);
res_pair rp;
t = fscanf (resolution, "%u " HOST_WIDE_INT_PRINT_HEX_PURE
distinction should only be relevant to the front-end, so we
always use the C definition here in lto1.
Likewise for const struct tm*. */
- for (unsigned i = 0;
- i < sizeof (builtin_structptr_types) / sizeof (builtin_structptr_type);
- ++i)
+ for (unsigned i = 0; i < ARRAY_SIZE (builtin_structptr_types); ++i)
{
gcc_assert (builtin_structptr_types[i].node
== builtin_structptr_types[i].base);
}
if (has_target_explicit_mask) {
- print " for (size_t i = 0; i < sizeof (ptr1->explicit_mask) / sizeof (ptr1->explicit_mask[0]); i++)";
+ print " for (size_t i = 0; i < ARRAY_SIZE (ptr1->explicit_mask); i++)";
print " if (ptr1->explicit_mask[i] != ptr2->explicit_mask[i])";
print " return false;"
}
print " hstate.add_hwi (ptr->" name");";
}
if (has_target_explicit_mask) {
- print " for (size_t i = 0; i < sizeof (ptr->explicit_mask) / sizeof (ptr->explicit_mask[0]); i++)";
+ print " for (size_t i = 0; i < ARRAY_SIZE (ptr->explicit_mask); i++)";
print " hstate.add_hwi (ptr->explicit_mask[i]);";
}
}
if (has_target_explicit_mask) {
- print " for (size_t i = 0; i < sizeof (ptr->explicit_mask) / sizeof (ptr->explicit_mask[0]); i++)";
+ print " for (size_t i = 0; i < ARRAY_SIZE (ptr->explicit_mask); i++)";
print " bp_pack_value (bp, ptr->explicit_mask[i], 64);";
}
}
if (has_target_explicit_mask) {
- print " for (size_t i = 0; i < sizeof (ptr->explicit_mask) / sizeof (ptr->explicit_mask[0]); i++)";
+ print " for (size_t i = 0; i < ARRAY_SIZE (ptr->explicit_mask); i++)";
print " ptr->explicit_mask[i] = bp_unpack_value (bp, 64);";
}
else
print " hstate.add_hwi (ptr->" name");";
}
-print " for (size_t i = 0; i < sizeof (ptr->explicit_mask) / sizeof (ptr->explicit_mask[0]); i++)";
+print " for (size_t i = 0; i < ARRAY_SIZE (ptr->explicit_mask); i++)";
print " hstate.add_hwi (ptr->explicit_mask[i]);";
print " return hstate.end ();";
print "}";
print " return false;";
}
}
-print " for (size_t i = 0; i < sizeof (ptr1->explicit_mask) / sizeof (ptr1->explicit_mask[0]); i++)";
+print " for (size_t i = 0; i < ARRAY_SIZE (ptr1->explicit_mask); i++)";
print " if (ptr1->explicit_mask[i] != ptr2->explicit_mask[i])";
print " return false;"
print " return true;";
}
}
}
-print " for (size_t i = 0; i < sizeof (ptr->explicit_mask) / sizeof (ptr->explicit_mask[0]); i++)";
+print " for (size_t i = 0; i < ARRAY_SIZE (ptr->explicit_mask); i++)";
print " bp_pack_value (bp, ptr->explicit_mask[i], 64);";
print "}";
}
}
}
-print " for (size_t i = 0; i < sizeof (ptr->explicit_mask) / sizeof (ptr->explicit_mask[0]); i++)";
+print " for (size_t i = 0; i < ARRAY_SIZE (ptr->explicit_mask); i++)";
print " ptr->explicit_mask[i] = bp_unpack_value (bp, 64);";
print "}";
print "/* Free heap memory used by optimization options */";
static void
test_metric_conditions ()
{
- const int num_test_cases = sizeof (test_data) / sizeof (test_data[0]);
+ const int num_test_cases = ARRAY_SIZE (test_data);
for (int i = 0; i < num_test_cases; i++)
{
#undef SLP_PATTERN
/* Set the number of SLP pattern matchers available. */
-size_t num__slp_patterns = sizeof(slp_patterns)/sizeof(vect_pattern_decl_t);
+size_t num__slp_patterns = ARRAY_SIZE (slp_patterns);
ptr_type_node = build_pointer_type (void_type_node);
const_ptr_type_node
= build_pointer_type (build_type_variant (void_type_node, 1, 0));
- for (unsigned i = 0;
- i < sizeof (builtin_structptr_types) / sizeof (builtin_structptr_type);
- ++i)
+ for (unsigned i = 0; i < ARRAY_SIZE (builtin_structptr_types); ++i)
builtin_structptr_types[i].node = builtin_structptr_types[i].base;
pointer_sized_int_node = build_nonstandard_integer_type (POINTER_SIZE, 1);