V0.9: Fix shadow warnings found on OpenBSD.

gcc on OpenBSD reported shadow warnings for variables, arguments named
log, time and exp. This patch renanes those variables to logic, timerec
and expr.
This commit is contained in:
Cary R 2010-06-11 19:25:22 -07:00 committed by Stephen Williams
parent 34c34e33cf
commit b2fd383d05
10 changed files with 335 additions and 327 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2009 Michael Ruff (mruff at chiaro.com)
* Copyright (c) 2002-2010 Michael Ruff (mruff at chiaro.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -45,34 +45,34 @@ scale(int high, int low, void*obj) {
PLI_INT32 tf_gettime(void)
{
s_vpi_time time;
time.type = vpiSimTime;
vpi_get_time (0, &time);
return scale(time.high, time.low, 0) & 0xffffffff;
s_vpi_time timerec;
timerec.type = vpiSimTime;
vpi_get_time (0, &timerec);
return scale(timerec.high, timerec.low, 0) & 0xffffffff;
}
char *tf_strgettime(void)
{
static char buf[32];
s_vpi_time time;
s_vpi_time timerec;
time.type = vpiSimTime;
vpi_get_time (0, &time);
if (time.high)
snprintf(buf, sizeof(buf)-1, "%u%08u", (unsigned int)time.high,
(unsigned int)time.low);
timerec.type = vpiSimTime;
vpi_get_time (0, &timerec);
if (timerec.high)
snprintf(buf, sizeof(buf)-1, "%u%08u", (unsigned int)timerec.high,
(unsigned int)timerec.low);
else
snprintf(buf, sizeof(buf)-1, "%u", (unsigned int)time.low);
snprintf(buf, sizeof(buf)-1, "%u", (unsigned int)timerec.low);
return buf;
}
PLI_INT32 tf_igetlongtime(PLI_INT32 *high, void*obj)
{
s_vpi_time time;
s_vpi_time timerec;
ivl_u64_t scaled;
time.type = vpiSimTime;
vpi_get_time ((vpiHandle)obj, &time);
scaled = scale(time.high, time.low, obj);
timerec.type = vpiSimTime;
vpi_get_time ((vpiHandle)obj, &timerec);
scaled = scale(timerec.high, timerec.low, obj);
*high = (scaled >> 32) & 0xffffffff;
return scaled & 0xffffffff;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2009 Stephen Williams (steve@icarus.com)
* Copyright (c) 2000-2010 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -1143,7 +1143,7 @@ static void show_nexus_details(ivl_signal_t net, ivl_nexus_t nex)
for (idx = 0 ; idx < ivl_nexus_ptrs(nex) ; idx += 1) {
ivl_net_const_t con;
ivl_net_logic_t log;
ivl_net_logic_t logic;
ivl_lpm_t lpm;
ivl_signal_t sig;
ivl_switch_t swt;
@ -1170,10 +1170,10 @@ static void show_nexus_details(ivl_signal_t net, ivl_nexus_t nex)
fprintf(out, "\n");
} else if ((log = ivl_nexus_ptr_log(ptr))) {
} else if ((logic = ivl_nexus_ptr_log(ptr))) {
fprintf(out, " LOG %s.%s[%u] (%s0, %s1)\n",
ivl_scope_name(ivl_logic_scope(log)),
ivl_logic_basename(log),
ivl_scope_name(ivl_logic_scope(logic)),
ivl_logic_basename(logic),
ivl_nexus_ptr_pin(ptr), dr0, dr1);
} else if ((lpm = ivl_nexus_ptr_lpm(ptr))) {
@ -1341,9 +1341,9 @@ static void show_signal(ivl_signal_t net)
}
static void test_expr_is_delay(ivl_expr_t exp)
static void test_expr_is_delay(ivl_expr_t expr)
{
switch (ivl_expr_type(exp)) {
switch (ivl_expr_type(expr)) {
case IVL_EX_ULONG:
return;
case IVL_EX_NUMBER:

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005-2009 Stephen Williams (steve@icarus.com)
* Copyright (c) 2005-2010 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -22,7 +22,7 @@
# include <stdlib.h>
# include <assert.h>
static void function_argument_logic(ivl_signal_t port, ivl_expr_t exp)
static void function_argument_logic(ivl_signal_t port, ivl_expr_t expr)
{
struct vector_info res;
unsigned ewidth, pwidth;
@ -30,13 +30,13 @@ static void function_argument_logic(ivl_signal_t port, ivl_expr_t exp)
/* ports cannot be arrays. */
assert(ivl_signal_dimensions(port) == 0);
ewidth = ivl_expr_width(exp);
ewidth = ivl_expr_width(expr);
pwidth = ivl_signal_width(port);
/* Just like a normal assignment the function arguments need to
* be evaluated at either their width or the argument width if
* it is larger. */
if (ewidth < pwidth) ewidth = pwidth;
res = draw_eval_expr_wid(exp, ewidth, 0);
res = draw_eval_expr_wid(expr, ewidth, 0);
/* We could have extra bits so only select the ones we need. */
fprintf(vvp_out, " %%set/v v%p_0, %u, %u;\n", port, res.base, pwidth);
@ -44,9 +44,9 @@ static void function_argument_logic(ivl_signal_t port, ivl_expr_t exp)
clr_vector(res);
}
static void function_argument_real(ivl_signal_t port, ivl_expr_t exp)
static void function_argument_real(ivl_signal_t port, ivl_expr_t expr)
{
int res = draw_eval_real(exp);
int res = draw_eval_real(expr);
/* ports cannot be arrays. */
assert(ivl_signal_dimensions(port) == 0);
@ -55,15 +55,15 @@ static void function_argument_real(ivl_signal_t port, ivl_expr_t exp)
clr_word(res);
}
static void draw_function_argument(ivl_signal_t port, ivl_expr_t exp)
static void draw_function_argument(ivl_signal_t port, ivl_expr_t expr)
{
ivl_variable_type_t dtype = ivl_signal_data_type(port);
switch (dtype) {
case IVL_VT_LOGIC:
function_argument_logic(port, exp);
function_argument_logic(port, expr);
break;
case IVL_VT_REAL:
function_argument_real(port, exp);
function_argument_real(port, expr);
break;
default:
fprintf(stderr, "XXXX function argument %s type=%d?!\n",
@ -83,11 +83,11 @@ static void draw_function_argument(ivl_signal_t port, ivl_expr_t exp)
* parameter 0 of the function definition.
*/
struct vector_info draw_ufunc_expr(ivl_expr_t exp, unsigned wid)
struct vector_info draw_ufunc_expr(ivl_expr_t expr, unsigned wid)
{
unsigned idx;
unsigned swid = ivl_expr_width(exp);
ivl_scope_t def = ivl_expr_def(exp);
unsigned swid = ivl_expr_width(expr);
ivl_scope_t def = ivl_expr_def(expr);
ivl_signal_t retval = ivl_scope_port(def, 0);
struct vector_info res;
unsigned load_wid;
@ -100,10 +100,10 @@ struct vector_info draw_ufunc_expr(ivl_expr_t exp, unsigned wid)
/* evaluate the expressions and send the results to the
function ports. */
assert(ivl_expr_parms(exp) == (ivl_scope_ports(def)-1));
for (idx = 0 ; idx < ivl_expr_parms(exp) ; idx += 1) {
assert(ivl_expr_parms(expr) == (ivl_scope_ports(def)-1));
for (idx = 0 ; idx < ivl_expr_parms(expr) ; idx += 1) {
ivl_signal_t port = ivl_scope_port(def, idx+1);
draw_function_argument(port, ivl_expr_parm(exp,idx));
draw_function_argument(port, ivl_expr_parm(expr, idx));
}
@ -124,7 +124,7 @@ struct vector_info draw_ufunc_expr(ivl_expr_t exp, unsigned wid)
if (res.base == 0) {
fprintf(stderr, "%s:%u: vvp.tgt error: "
"Unable to allocate %u thread bits for function result.\n",
ivl_expr_file(exp), ivl_expr_lineno(exp), wid);
ivl_expr_file(expr), ivl_expr_lineno(expr), wid);
vvp_errors += 1;
return res;
}
@ -141,7 +141,7 @@ struct vector_info draw_ufunc_expr(ivl_expr_t exp, unsigned wid)
/* Pad the signal value with zeros. */
if (load_wid < wid)
pad_expr_in_place(exp, res, swid);
pad_expr_in_place(expr, res, swid);
/* If this is an automatic function, free the local storage. */
if (ivl_scope_is_auto(def)) {
@ -151,9 +151,9 @@ struct vector_info draw_ufunc_expr(ivl_expr_t exp, unsigned wid)
return res;
}
int draw_ufunc_real(ivl_expr_t exp)
int draw_ufunc_real(ivl_expr_t expr)
{
ivl_scope_t def = ivl_expr_def(exp);
ivl_scope_t def = ivl_expr_def(expr);
ivl_signal_t retval = ivl_scope_port(def, 0);
int res = 0;
int idx;
@ -163,10 +163,10 @@ int draw_ufunc_real(ivl_expr_t exp)
fprintf(vvp_out, " %%alloc S_%p;\n", def);
}
assert(ivl_expr_parms(exp) == (ivl_scope_ports(def)-1));
for (idx = 0 ; idx < ivl_expr_parms(exp) ; idx += 1) {
assert(ivl_expr_parms(expr) == (ivl_scope_ports(def)-1));
for (idx = 0 ; idx < ivl_expr_parms(expr) ; idx += 1) {
ivl_signal_t port = ivl_scope_port(def, idx+1);
draw_function_argument(port, ivl_expr_parm(exp,idx));
draw_function_argument(port, ivl_expr_parm(expr, idx));
}

File diff suppressed because it is too large Load Diff

View File

@ -48,15 +48,16 @@ static __inline__ unsigned peek_exp_bit(unsigned addr)
return allocation_map[addr].exp_bit;
}
static __inline__ void set_exp(unsigned addr, ivl_expr_t exp, unsigned ebit)
static __inline__ void set_exp(unsigned addr, ivl_expr_t expr, unsigned ebit)
{
allocation_map[addr].exp = exp;
allocation_map[addr].exp = expr;
allocation_map[addr].exp_bit = ebit;
}
static __inline__ void set_sig(unsigned addr, ivl_signal_t exp, unsigned sig_word, unsigned ebit)
static __inline__ void set_sig(unsigned addr, ivl_signal_t expr,
unsigned sig_word, unsigned ebit)
{
allocation_map[addr].sig = exp;
allocation_map[addr].sig = expr;
allocation_map[addr].sig_word = sig_word;
allocation_map[addr].sig_bit = ebit;
}
@ -151,9 +152,9 @@ void clear_expression_lookaside(void)
lookaside_top = 0;
}
static int test_expression_savable(ivl_expr_t exp)
static int test_expression_savable(ivl_expr_t expr)
{
switch (ivl_expr_type(exp)) {
switch (ivl_expr_type(expr)) {
case IVL_EX_NUMBER:
case IVL_EX_STRING:
@ -164,7 +165,7 @@ static int test_expression_savable(ivl_expr_t exp)
}
}
void save_expression_lookaside(unsigned addr, ivl_expr_t exp, unsigned wid)
void save_expression_lookaside(unsigned addr, ivl_expr_t expr, unsigned wid)
{
unsigned idx;
assert(addr >= 8);
@ -178,11 +179,11 @@ void save_expression_lookaside(unsigned addr, ivl_expr_t exp, unsigned wid)
set_sig(addr+idx, 0, 0, 0);
/* Only certain types of expressions are savable. */
if ( ! test_expression_savable(exp))
if ( ! test_expression_savable(expr))
return;
for (idx = 0 ; idx < wid ; idx += 1) {
set_exp(addr+idx, exp, idx);
set_exp(addr+idx, expr, idx);
}
if ((addr+wid) > lookaside_top)
@ -280,7 +281,7 @@ static int compare_exp(ivl_expr_t l, ivl_expr_t r)
return 0;
}
static unsigned find_expression_lookaside(ivl_expr_t exp, unsigned wid)
static unsigned find_expression_lookaside(ivl_expr_t expr, unsigned wid)
{
unsigned top;
unsigned idx, match;
@ -292,10 +293,10 @@ static unsigned find_expression_lookaside(ivl_expr_t exp, unsigned wid)
top = lookaside_top - wid + 1;
/* Look in the expression lookaside for this expression. */
assert(exp);
assert(expr);
match = 0;
for (idx = 8 ; idx < lookaside_top ; idx += 1) {
if (! compare_exp(allocation_map[idx].exp, exp)) {
if (! compare_exp(allocation_map[idx].exp, expr)) {
match = 0;
continue;
}
@ -313,10 +314,10 @@ static unsigned find_expression_lookaside(ivl_expr_t exp, unsigned wid)
/* The general expression lookup failed. If this is an
IVL_EX_SIGNAL, then look again in the variable lookaside
(which is saved l-values) for the expression. */
if (ivl_expr_type(exp) != IVL_EX_SIGNAL)
if (ivl_expr_type(expr) != IVL_EX_SIGNAL)
return 0;
sig = ivl_expr_signal(exp);
sig = ivl_expr_signal(expr);
/* Only reg signals (variables) will be in the signal
lookaside, because only blocking assigned values are in the
@ -352,11 +353,11 @@ static unsigned find_expression_lookaside(ivl_expr_t exp, unsigned wid)
* caller will not need to evaluate the expression. If this function
* returns 0, then the expression is not found and nothing is allocated.
*/
unsigned allocate_vector_exp(ivl_expr_t exp, unsigned wid,
unsigned allocate_vector_exp(ivl_expr_t expr, unsigned wid,
int exclusive_flag)
{
unsigned idx;
unsigned la = find_expression_lookaside(exp, wid);
unsigned la = find_expression_lookaside(expr, wid);
if (la == 0)
return 0;

View File

@ -1,7 +1,7 @@
#ifndef __vvp_priv_H
#define __vvp_priv_H
/*
* Copyright (c) 2001-2009 Stephen Williams (steve@icarus.com)
* Copyright (c) 2001-2010 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -83,10 +83,11 @@ extern int draw_scope(ivl_scope_t scope, ivl_scope_t parent);
extern void draw_lpm_mux(ivl_lpm_t net);
extern struct vector_info draw_ufunc_expr(ivl_expr_t exp, unsigned wid);
extern int draw_ufunc_real(ivl_expr_t exp);
extern struct vector_info draw_ufunc_expr(ivl_expr_t expr, unsigned wid);
extern int draw_ufunc_real(ivl_expr_t expr);
extern void pad_expr_in_place(ivl_expr_t exp, struct vector_info res, unsigned swid);
extern void pad_expr_in_place(ivl_expr_t expr, struct vector_info res,
unsigned swid);
/*
* modpath.c symbols.
@ -110,9 +111,9 @@ extern void cleanup_modpath(void);
*/
extern void draw_vpi_task_call(ivl_statement_t net);
extern struct vector_info draw_vpi_func_call(ivl_expr_t exp,
extern struct vector_info draw_vpi_func_call(ivl_expr_t expr,
unsigned wid);
extern int draw_vpi_rfunc_call(ivl_expr_t exp);
extern int draw_vpi_rfunc_call(ivl_expr_t expr);
/*
* Switches (tran)
@ -194,8 +195,8 @@ extern const char*draw_input_from_net(ivl_nexus_t nex);
* therefore might be multiply allocated if allowed.
*/
extern struct vector_info draw_eval_expr(ivl_expr_t exp, int stuff_ok_flag);
extern struct vector_info draw_eval_expr_wid(ivl_expr_t exp, unsigned w,
extern struct vector_info draw_eval_expr(ivl_expr_t expr, int stuff_ok_flag);
extern struct vector_info draw_eval_expr_wid(ivl_expr_t expr, unsigned w,
int stuff_ok_flag);
#define STUFF_OK_XZ 0x0001
#define STUFF_OK_47 0x0002
@ -260,13 +261,13 @@ extern void clr_vector(struct vector_info vec);
extern void clear_expression_lookaside(void);
extern void save_expression_lookaside(unsigned addr,
ivl_expr_t exp,
ivl_expr_t expr,
unsigned wid);
extern void save_signal_lookaside(unsigned addr,
ivl_signal_t sig, unsigned use_word,
unsigned wid);
extern unsigned allocate_vector_exp(ivl_expr_t exp, unsigned wid,
extern unsigned allocate_vector_exp(ivl_expr_t expr, unsigned wid,
int exclusive_flag);
extern int number_is_unknown(ivl_expr_t ex);

View File

@ -865,8 +865,8 @@ static int show_stmt_block_named(ivl_statement_t net, ivl_scope_t scope)
static int show_stmt_case(ivl_statement_t net, ivl_scope_t sscope)
{
int rc = 0;
ivl_expr_t exp = ivl_stmt_cond_expr(net);
struct vector_info cond = draw_eval_expr(exp, 0);
ivl_expr_t expr = ivl_stmt_cond_expr(net);
struct vector_info cond = draw_eval_expr(expr, 0);
unsigned count = ivl_stmt_case_count(net);
unsigned local_base = local_count;
@ -982,8 +982,8 @@ static int show_stmt_case(ivl_statement_t net, ivl_scope_t sscope)
static int show_stmt_case_r(ivl_statement_t net, ivl_scope_t sscope)
{
int rc = 0;
ivl_expr_t exp = ivl_stmt_cond_expr(net);
int cond = draw_eval_real(exp);
ivl_expr_t expr = ivl_stmt_cond_expr(net);
int cond = draw_eval_real(expr);
unsigned count = ivl_stmt_case_count(net);
unsigned local_base = local_count;
@ -1322,9 +1322,9 @@ static int show_stmt_condit(ivl_statement_t net, ivl_scope_t sscope)
{
int rc = 0;
unsigned lab_false, lab_out;
ivl_expr_t exp = ivl_stmt_cond_expr(net);
ivl_expr_t expr = ivl_stmt_cond_expr(net);
struct vector_info cond
= draw_eval_expr(exp, STUFF_OK_XZ|STUFF_OK_47|STUFF_OK_RO);
= draw_eval_expr(expr, STUFF_OK_XZ|STUFF_OK_47|STUFF_OK_RO);
assert(cond.wid == 1);
@ -1395,14 +1395,14 @@ static int show_stmt_delay(ivl_statement_t net, ivl_scope_t sscope)
static int show_stmt_delayx(ivl_statement_t net, ivl_scope_t sscope)
{
int rc = 0;
ivl_expr_t exp = ivl_stmt_delay_expr(net);
ivl_expr_t expr = ivl_stmt_delay_expr(net);
ivl_statement_t stmt = ivl_stmt_sub_stmt(net);
switch (ivl_expr_value(exp)) {
switch (ivl_expr_value(expr)) {
case IVL_VT_BOOL:
case IVL_VT_LOGIC: {
struct vector_info del = draw_eval_expr(exp, 0);
struct vector_info del = draw_eval_expr(expr, 0);
fprintf(vvp_out, " %%ix/get 0, %u, %u;\n",
del.base, del.wid);
clr_vector(del);
@ -1410,7 +1410,7 @@ static int show_stmt_delayx(ivl_statement_t net, ivl_scope_t sscope)
}
case IVL_VT_REAL: {
int word = draw_eval_real(exp);
int word = draw_eval_real(expr);
fprintf(vvp_out, " %%cvt/ir 0, %d;\n", word);
clr_word(word);
break;
@ -1632,9 +1632,9 @@ static int show_stmt_repeat(ivl_statement_t net, ivl_scope_t sscope)
{
int rc = 0;
unsigned lab_top = local_count++, lab_out = local_count++;
ivl_expr_t exp = ivl_stmt_cond_expr(net);
struct vector_info cnt = draw_eval_expr(exp, 0);
char *sign = ivl_expr_signed(exp) ? "s" : "u";
ivl_expr_t expr = ivl_stmt_cond_expr(net);
struct vector_info cnt = draw_eval_expr(expr, 0);
char *sign = ivl_expr_signed(expr) ? "s" : "u";
/* Test that 0 < expr */
fprintf(vvp_out, "T_%u.%u %%cmp/%s 0, %u, %u;\n", thread_count,

View File

@ -1230,7 +1230,7 @@ static PLI_INT32 sys_strobe_calltf(PLI_BYTE8*name)
{
vpiHandle callh, argv, scope;
struct t_cb_data cb;
struct t_vpi_time time;
struct t_vpi_time timerec;
struct strobe_cb_info*info;
PLI_UINT32 fd_mcd;
@ -1280,13 +1280,13 @@ static PLI_INT32 sys_strobe_calltf(PLI_BYTE8*name)
info->scope= scope;
array_from_iterator(info, argv);
time.type = vpiSimTime;
time.low = 0;
time.high = 0;
timerec.type = vpiSimTime;
timerec.low = 0;
timerec.high = 0;
cb.reason = cbReadOnlySynch;
cb.cb_rtn = strobe_cb;
cb.time = &time;
cb.time = &timerec;
cb.obj = 0;
cb.value = 0;
cb.user_data = (char*)info;
@ -1339,7 +1339,7 @@ static PLI_INT32 monitor_cb_2(p_cb_data cb)
static PLI_INT32 monitor_cb_1(p_cb_data cause)
{
struct t_cb_data cb;
struct t_vpi_time time;
struct t_vpi_time timerec;
if (monitor_enabled == 0) return 0;
if (monitor_scheduled) return 0;
@ -1348,13 +1348,13 @@ static PLI_INT32 monitor_cb_1(p_cb_data cause)
the monitor to happen at the end of the time slice and mark
it as scheduled. */
monitor_scheduled += 1;
time.type = vpiSimTime;
time.low = 0;
time.high = 0;
timerec.type = vpiSimTime;
timerec.low = 0;
timerec.high = 0;
cb.reason = cbReadOnlySynch;
cb.cb_rtn = monitor_cb_2;
cb.time = &time;
cb.time = &timerec;
cb.obj = 0;
cb.value = 0;
vpi_register_cb(&cb);
@ -1376,7 +1376,7 @@ static PLI_INT32 sys_monitor_calltf(PLI_BYTE8*name)
vpiHandle callh, argv, scope;
unsigned idx;
struct t_cb_data cb;
struct t_vpi_time time;
struct t_vpi_time timerec;
callh = vpi_handle(vpiSysTfCall, 0);
argv = vpi_iterate(vpiArgument, callh);
@ -1412,10 +1412,10 @@ static PLI_INT32 sys_monitor_calltf(PLI_BYTE8*name)
/* Attach callbacks to all the parameters that might change. */
monitor_callbacks = calloc(monitor_info.nitems, sizeof(vpiHandle));
time.type = vpiSuppressTime;
timerec.type = vpiSuppressTime;
cb.reason = cbValueChange;
cb.cb_rtn = monitor_cb_1;
cb.time = &time;
cb.time = &timerec;
cb.value = NULL;
for (idx = 0 ; idx < monitor_info.nitems ; idx += 1) {

View File

@ -23,13 +23,13 @@
#include <stdlib.h>
#include <string.h>
PLI_UINT64 timerec_to_time64(const struct t_vpi_time*time)
PLI_UINT64 timerec_to_time64(const struct t_vpi_time*timerec)
{
PLI_UINT64 tmp;
tmp = time->high;
tmp = timerec->high;
tmp <<= 32;
tmp |= (PLI_UINT64) time->low;
tmp |= (PLI_UINT64) timerec->low;
return tmp;
}

View File

@ -1,7 +1,7 @@
#ifndef __vpi_sys_priv_H
#define __vpi_sys_priv_H
/*
* Copyright (c) 2002-2009 Stephen Williams (steve@icarus.com)
* Copyright (c) 2002-2010 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -33,7 +33,7 @@ struct context_s {
extern void sgenrand(struct context_s *context, unsigned long seed);
extern unsigned long genrand(struct context_s *context);
extern PLI_UINT64 timerec_to_time64(const struct t_vpi_time*time);
extern PLI_UINT64 timerec_to_time64(const struct t_vpi_time*timerec);
extern char *as_escaped(char *arg);
extern char *get_filename(vpiHandle callh, char *name, vpiHandle file);