From cce61d713461616c3050a0863e826899d92dcbe9 Mon Sep 17 00:00:00 2001 From: Cary R Date: Mon, 24 Aug 2009 15:20:42 -0700 Subject: [PATCH] Ignore a zero MCD for $fflush, $fdisplay*, $fwrite* and $fstrobe*. (cherry picked from commit ed4e2eb046df23d875e43b587bd6107e3982d367) --- vpi/sys_display.c | 20 ++++++++++++++++---- vpi/sys_fileio.c | 3 +++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/vpi/sys_display.c b/vpi/sys_display.c index c0f116290..96cef1789 100644 --- a/vpi/sys_display.c +++ b/vpi/sys_display.c @@ -1127,9 +1127,15 @@ static PLI_INT32 sys_display_calltf(PLI_BYTE8 *name) val.format = vpiIntVal; vpi_get_value(arg, &val); fd_mcd = val.value.integer; + + /* If the MCD is zero we have nothing to do so just return. */ + if (fd_mcd == 0) { + vpi_free_object(argv); + return 0; + } + if ((! IS_MCD(fd_mcd) && vpi_get_file(fd_mcd) == NULL) || - ( IS_MCD(fd_mcd) && my_mcd_printf(fd_mcd, "") == EOF) || - (! fd_mcd)) { + ( IS_MCD(fd_mcd) && my_mcd_printf(fd_mcd, "") == EOF)) { vpi_printf("WARNING: %s:%d: ", vpi_get_str(vpiFile, callh), (int)vpi_get(vpiLineNo, callh)); vpi_printf("invalid file descriptor/MCD (0x%x) given " @@ -1241,9 +1247,15 @@ static PLI_INT32 sys_strobe_calltf(PLI_BYTE8*name) val.format = vpiIntVal; vpi_get_value(arg, &val); fd_mcd = val.value.integer; + + /* If the MCD is zero we have nothing to do so just return. */ + if (fd_mcd == 0) { + vpi_free_object(argv); + return 0; + } + if ((! IS_MCD(fd_mcd) && vpi_get_file(fd_mcd) == NULL) || - ( IS_MCD(fd_mcd) && my_mcd_printf(fd_mcd, "") == EOF) || - (! fd_mcd)) { + ( IS_MCD(fd_mcd) && my_mcd_printf(fd_mcd, "") == EOF)) { vpi_printf("WARNING: %s:%d: ", vpi_get_str(vpiFile, callh), (int)vpi_get(vpiLineNo, callh)); vpi_printf("invalid file descriptor/MCD (0x%x) given " diff --git a/vpi/sys_fileio.c b/vpi/sys_fileio.c index f15552d6f..2fccdd49e 100644 --- a/vpi/sys_fileio.c +++ b/vpi/sys_fileio.c @@ -270,6 +270,9 @@ static PLI_INT32 sys_fflush_calltf(PLI_BYTE8*name) vpi_get_value(arg, &val); fd_mcd = val.value.integer; + /* If the MCD is zero we have nothing to do so just return. */ + if (fd_mcd == 0) return 0; + if ((! IS_MCD(fd_mcd) && vpi_get_file(fd_mcd) == NULL) || ( IS_MCD(fd_mcd) && vpi_mcd_printf(fd_mcd, str) == EOF) || (! fd_mcd)) {