From ca880c73fc6909f369ca63e6589a0ea22d96d3ce Mon Sep 17 00:00:00 2001 From: Cary R Date: Wed, 14 May 2008 14:59:38 -0700 Subject: [PATCH 1/3] Fix $ungetc() arguments to be in the correct order. The arguments to $ungetc() were backwards! This patch fixes that and adds a bit more checking to the compile_tf routine. It still needs more work, but that can wait for the major system function clean up I have planned when I can find the time. --- vpi/sys_fileio.c | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/vpi/sys_fileio.c b/vpi/sys_fileio.c index 9bbd5bb1c..996566640 100644 --- a/vpi/sys_fileio.c +++ b/vpi/sys_fileio.c @@ -480,23 +480,40 @@ static PLI_INT32 sys_ungetc_compiletf(PLI_BYTE8*name) vpiHandle item = vpi_scan(argv); if (item == 0) { - vpi_printf("%s: mcd parameter missing.\n", name); + vpi_printf("%s: character parameter missing.\n", name); return 0; } - type = vpi_get(vpiType, item); switch (type) { case vpiReg: - case vpiRealVal: + case vpiRealVal: // Is this correct? case vpiIntegerVar: break; default: - vpi_printf("ERROR: %s mcd parameter must be of integral", name); - vpi_printf(", got vpiType=%d\n", type); + vpi_printf("ERROR: %s character parameter must be ", name); + vpi_printf("integral, got vpiType=%d\n", type); vpi_free_object(argv); return 0; } + item = vpi_scan(argv); + type = vpi_get(vpiType, item); + switch (type) { + case vpiReg: + case vpiRealVal: // Is this correct? + case vpiIntegerVar: + break; + default: + vpi_printf("ERROR: %s mcd parameter must be integral, ", name); + vpi_printf("got vpiType=%d\n", type); + vpi_free_object(argv); + return 0; + } + + /* That should be all the arguments. */ + item = vpi_scan(argv); + assert(item == 0); + return 0; } @@ -504,7 +521,7 @@ static PLI_INT32 sys_ungetc_calltf(PLI_BYTE8*name) { unsigned int mcd; unsigned char x; - s_vpi_value value, xvalue, rval; + s_vpi_value val, rval; vpiHandle sys = vpi_handle(vpiSysTfCall, 0); vpiHandle argv = vpi_iterate(vpiArgument, sys); vpiHandle item = vpi_scan(argv); @@ -512,11 +529,15 @@ static PLI_INT32 sys_ungetc_calltf(PLI_BYTE8*name) rval.format = vpiIntVal; - assert(item); + val.format = vpiIntVal; + vpi_get_value(item, &val); + x = val.value.integer; - value.format = vpiIntVal; - vpi_get_value(item, &value); - mcd = value.value.integer; + item = vpi_scan(argv); + + val.format = vpiIntVal; + vpi_get_value(item, &val); + mcd = val.value.integer; if (IS_MCD(mcd)) { rval.value.integer = EOF; @@ -524,12 +545,6 @@ static PLI_INT32 sys_ungetc_calltf(PLI_BYTE8*name) return 0; } - item = vpi_scan(argv); - - xvalue.format = vpiIntVal; - vpi_get_value(item, &xvalue); - x = xvalue.value.integer; - fp = vpi_get_file(mcd); if ( !fp ) { rval.value.integer = EOF; From 72b42568724bf8132a6dbce3ef40fce1b441d9c2 Mon Sep 17 00:00:00 2001 From: Cary R Date: Thu, 15 May 2008 10:36:43 -0700 Subject: [PATCH 2/3] Return 0 when vpi_handle_by_name() is called with an unsupported object. vpi_handle_by_name() was assuming it was always given a valid scope object. In the context of vpi_chk_error() this is not required and some users use/abuse the interface by calling the function with invalid objects expecting a 0 return value. This patch adds an explicit check for the supported types vpiScope and as an extension vpiModule. Anything else should be flagged as an error once we have vpi_chk_error() implemented, but for now it just returns 0. --- vvp/vpi_priv.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/vvp/vpi_priv.cc b/vvp/vpi_priv.cc index ec629c0cb..ee863a8cb 100644 --- a/vvp/vpi_priv.cc +++ b/vvp/vpi_priv.cc @@ -863,10 +863,16 @@ vpiHandle vpi_handle_by_name(const char *name, vpiHandle scope) */ if (scope) { /* Some implementations support either a module or a scope. */ - if (vpi_get(vpiType, scope ) == vpiScope) { + switch (vpi_get(vpiType, scope)) { + case vpiScope: hand = vpi_handle(vpiModule, scope); - } else { + break; + case vpiModule: hand = scope; + break; + default: + // Use vpi_chk_error() here when it is implemented. + return 0; } } else { hand = find_scope(name, NULL, 0); From 311339259439e54290624fa87f17d7808ced5df8 Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Thu, 15 May 2008 16:59:08 -0700 Subject: [PATCH 3/3] Minor improvement to mingw.txt --- mingw.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mingw.txt b/mingw.txt index 19e861d7d..d90d32542 100644 --- a/mingw.txt +++ b/mingw.txt @@ -47,6 +47,8 @@ critical, but these are the versions I use. msys-1.0 msysDTK-1.0 Mingw32-5.x + ... including the sub-packages binutils, gcc-core and gcc-g++ + if you are given the option. readline-4.2-20010727.zip bzip2-1.0.3 zlib-1.2.3