Report any failures in $fclose()

This commit is contained in:
Cary R 2020-05-18 22:34:53 -07:00
parent 19d63f0c96
commit a1518b5761
1 changed files with 23 additions and 0 deletions

View File

@ -223,6 +223,29 @@ static PLI_INT32 sys_fclose_calltf(ICARUS_VPI_CONST PLI_BYTE8*name)
* generation when needed. */
fd_mcd = vpi_mcd_close(fd_mcd);
if (fd_mcd) {
char *fd_mcd_name;
switch(fd_mcd) {
case 0x00000001: // MCD STDOUT
case 0x80000001: // FD STDOUT
fd_mcd_name = "STDOUT ";
break;
case 0x80000000: // FD STDIN
fd_mcd_name = "STDIN ";
break;
case 0x80000002: // FD STDERR
fd_mcd_name = "STDERR ";
break;
default:
fd_mcd_name = "";
}
vpi_printf("WARNING: %s:%d: ", vpi_get_str(vpiFile, callh),
(int)vpi_get(vpiLineNo, callh));
vpi_printf("could not close %s %s(0x%x) in %s().\n",
IS_MCD(fd_mcd) ? "MCD" : "file descriptor",
fd_mcd_name, (unsigned int)fd_mcd, name);
}
return 0;
}