From f418bea775af5af4ca3ef98506cd989626ea159c Mon Sep 17 00:00:00 2001 From: Cary R Date: Tue, 20 May 2008 15:07:35 -0700 Subject: [PATCH] MinGW fixes (system return and vsnprintf) The MinGW system() implementation appears to return the straight return value instead of the waitpid() like result that more normal systems return. Because of this just return the system() result without processing for MinGW compilations. Older version of the MinGW runtime (pre 3.14) just used the underlying vsnprintf(). Which has some problems. The 3.14 version has some nice improvements, but it has a sever bug when processing "%*.*f", -1, -1, . Because of this we need to use the underlying version without the enhancements for now. --- driver/main.c | 4 ++++ vvp/vpi_mcd.cc | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/driver/main.c b/driver/main.c index a8ab8066e..931b62639 100644 --- a/driver/main.c +++ b/driver/main.c @@ -329,6 +329,9 @@ static int t_default(char*cmd, unsigned ncmd) remove(source_path); if ( ! getenv("IVERILOG_ICONFIG")) remove(iconfig_path); +#ifdef __MINGW32__ /* MinGW just returns the exit status, so return it! */ + return rc; +#else if (rc != 0) { if (rc == 127) { fprintf(stderr, "Failed to execute: %s\n", cmd); @@ -343,6 +346,7 @@ static int t_default(char*cmd, unsigned ncmd) } return 0; +#endif } diff --git a/vvp/vpi_mcd.cc b/vvp/vpi_mcd.cc index 4fc328745..cbf24392b 100644 --- a/vvp/vpi_mcd.cc +++ b/vvp/vpi_mcd.cc @@ -152,7 +152,15 @@ vpi_mcd_vprintf(PLI_UINT32 mcd, const char*fmt, va_list ap) mcd, fmt); } +#ifdef __MINGW32__ + /* + * The MinGW runtime (version 3.14) fixes some things, but breaks + * %f for us, so we have to us the underlying version. + */ + rc = _vsnprintf(buffer, sizeof buffer, fmt, ap); +#else rc = vsnprintf(buffer, sizeof buffer, fmt, ap); +#endif for(int i = 0; i < 31; i++) { if((mcd>>i) & 1) {