Enable use of MinGW ANSI stdio routines.
Defining __USE_MINGW_ANSI_STDIO=1 provides C99 compatible printf and scanf routines, which avoids the need for workarounds for the various failings of the Microsoft C runtime library.
This commit is contained in:
parent
e530b4e642
commit
cfbc90812b
14
config.h.in
14
config.h.in
|
|
@ -27,10 +27,6 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
# define SIZEOF_UNSIGNED_LONG_LONG 0
|
||||
|
||||
# define SIZEOF_SIZE_T 0
|
||||
|
||||
# undef NEED_LU
|
||||
# undef NEED_TU
|
||||
# undef WLU
|
||||
|
|
@ -66,14 +62,4 @@
|
|||
*/
|
||||
# undef CHECK_WITH_VALGRIND
|
||||
|
||||
#ifdef __MINGW32__
|
||||
# if SIZEOF_SIZE_T == SIZEOF_UNSIGNED_LONG_LONG
|
||||
# define SIZE_FMT_D "llu"
|
||||
# else
|
||||
# define SIZE_FMT_D "u"
|
||||
# endif
|
||||
#else
|
||||
# define SIZE_FMT_D "zu"
|
||||
#endif
|
||||
|
||||
#endif /* IVL_config_H */
|
||||
|
|
|
|||
|
|
@ -131,7 +131,6 @@ CXXFLAGS="$iverilog_temp_cxxflags"
|
|||
AC_CHECK_SIZEOF(unsigned long long)
|
||||
AC_CHECK_SIZEOF(unsigned long)
|
||||
AC_CHECK_SIZEOF(unsigned)
|
||||
AC_CHECK_SIZEOF(size_t)
|
||||
|
||||
# vvp uses these...
|
||||
AC_CHECK_LIB(termcap, tputs)
|
||||
|
|
@ -224,6 +223,10 @@ case "${host}" in
|
|||
CPPFLAGS="-mieee $CPPFLAGS"
|
||||
CFLAGS="-mieee $CFLAGS"
|
||||
;;
|
||||
*-*-mingw*)
|
||||
CXXFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $CXXFLAGS"
|
||||
CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $CFLAGS"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Do some more operating system specific setup. We put the file64_support
|
||||
|
|
|
|||
|
|
@ -1898,7 +1898,7 @@ static int load_next_input(void)
|
|||
static void do_dump_precompiled_defines(FILE* out, struct define_t* table)
|
||||
{
|
||||
if (!table->keyword)
|
||||
fprintf(out, "%s:%d:%" SIZE_FMT_D ":%s\n", table->name, table->argc, strlen(table->value), table->value);
|
||||
fprintf(out, "%s:%d:%zd:%s\n", table->name, table->argc, strlen(table->value), table->value);
|
||||
|
||||
if (table->left) do_dump_precompiled_defines(out, table->left);
|
||||
|
||||
|
|
|
|||
|
|
@ -26,10 +26,6 @@
|
|||
# include <assert.h>
|
||||
# include "ivl_alloc.h"
|
||||
|
||||
#ifdef __MINGW32__ /* MinGW has inconsistent %p output. */
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
static ivl_signal_type_t signal_type_of_nexus(ivl_nexus_t nex)
|
||||
{
|
||||
unsigned idx;
|
||||
|
|
|
|||
|
|
@ -23,10 +23,6 @@
|
|||
# include <assert.h>
|
||||
# include "ivl_alloc.h"
|
||||
|
||||
#ifdef __MINGW32__ /* MinGW has inconsistent %p output. */
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
struct args_info {
|
||||
char*text;
|
||||
/* True ('s' or 'u' if this argument is a calculated vec4. */
|
||||
|
|
|
|||
|
|
@ -23,10 +23,6 @@
|
|||
# include <assert.h>
|
||||
# include "ivl_alloc.h"
|
||||
|
||||
#ifdef __MINGW32__ /* MinGW has inconsistent %p output. */
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
static ivl_signal_t find_path_source_port(ivl_delaypath_t path)
|
||||
{
|
||||
unsigned idx;
|
||||
|
|
|
|||
|
|
@ -22,11 +22,6 @@
|
|||
# include <assert.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
#ifdef __MINGW32__ /* MinGW has inconsistent %p output. */
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* These functions handle the blocking assignment. Use the %set
|
||||
* instruction to perform the actual assignment, and calculate any
|
||||
|
|
|
|||
|
|
@ -23,11 +23,6 @@
|
|||
# include "ivl_target.h"
|
||||
# include <stdio.h>
|
||||
|
||||
#ifdef __MINGW32__ /* MinGW has inconsistent %p output. */
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
|
||||
extern int debug_draw;
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -23,10 +23,6 @@
|
|||
# include <stdlib.h>
|
||||
# include <stdbool.h>
|
||||
|
||||
#ifdef __MINGW32__ /* MinGW has inconsistent %p output. */
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
static int show_statement(ivl_statement_t net, ivl_scope_t sscope);
|
||||
|
||||
unsigned local_count = 0;
|
||||
|
|
|
|||
|
|
@ -421,10 +421,17 @@ extern PLI_UINT32 vpi_mcd_open(char *name);
|
|||
extern PLI_UINT32 vpi_mcd_close(PLI_UINT32 mcd);
|
||||
extern char *vpi_mcd_name(PLI_UINT32 mcd);
|
||||
extern PLI_INT32 vpi_mcd_printf(PLI_UINT32 mcd, const char*fmt, ...)
|
||||
#ifdef __MINGW32__
|
||||
__attribute__((format (gnu_printf,2,3)));
|
||||
#else
|
||||
__attribute__((format (printf,2,3)));
|
||||
|
||||
#endif
|
||||
extern PLI_INT32 vpi_printf(const char*fmt, ...)
|
||||
#ifdef __MINGW32__
|
||||
__attribute__((format (gnu_printf,1,2)));
|
||||
#else
|
||||
__attribute__((format (printf,1,2)));
|
||||
#endif
|
||||
|
||||
extern PLI_INT32 vpi_vprintf(const char*fmt, va_list ap);
|
||||
extern PLI_INT32 vpi_mcd_vprintf(PLI_UINT32 mcd, const char*fmt, va_list ap);
|
||||
|
|
|
|||
|
|
@ -33,8 +33,6 @@
|
|||
#endif
|
||||
# define SIZEOF_UNSIGNED 0
|
||||
|
||||
# define SIZEOF_SIZE_T 0
|
||||
|
||||
# undef NEED_LU
|
||||
# undef NEED_TU
|
||||
# undef WLU
|
||||
|
|
@ -88,15 +86,9 @@
|
|||
|
||||
typedef uint64_t vvp_time64_t;
|
||||
|
||||
#ifdef __MINGW32__
|
||||
# define TIME_FMT_O "I64o"
|
||||
# define TIME_FMT_U "I64u"
|
||||
# define TIME_FMT_X "I64x"
|
||||
#else
|
||||
# define TIME_FMT_O PRIo64
|
||||
# define TIME_FMT_U PRIu64
|
||||
# define TIME_FMT_X PRIx64
|
||||
#endif
|
||||
|
||||
# ifdef UINT64_T_AND_ULONG_SAME
|
||||
# define UL_AND_TIME64_SAME
|
||||
|
|
@ -135,16 +127,6 @@ typedef unsigned long vvp_time64_t;
|
|||
|
||||
#endif /* HAVE_INTTYPES_H */
|
||||
|
||||
#ifdef __MINGW32__
|
||||
# if SIZEOF_SIZE_T == SIZEOF_UNSIGNED_LONG_LONG
|
||||
# define SIZE_FMT_U "llu"
|
||||
# else
|
||||
# define SIZE_FMT_U "u"
|
||||
# endif
|
||||
#else
|
||||
# define SIZE_FMT_U "zu"
|
||||
#endif
|
||||
|
||||
# include <cmath>
|
||||
|
||||
/* getrusage, /proc/self/statm */
|
||||
|
|
|
|||
|
|
@ -464,18 +464,18 @@ int main(int argc, char*argv[])
|
|||
}
|
||||
|
||||
if (verbose_flag) {
|
||||
vpi_mcd_printf(1, " ... %8lu functors (net_fun pool=%" SIZE_FMT_U " bytes)\n",
|
||||
vpi_mcd_printf(1, " ... %8lu functors (net_fun pool=%zu bytes)\n",
|
||||
count_functors, vvp_net_fun_t::heap_total());
|
||||
vpi_mcd_printf(1, " %8lu logic\n", count_functors_logic);
|
||||
vpi_mcd_printf(1, " %8lu bufif\n", count_functors_bufif);
|
||||
vpi_mcd_printf(1, " %8lu resolv\n",count_functors_resolv);
|
||||
vpi_mcd_printf(1, " %8lu signals\n", count_functors_sig);
|
||||
vpi_mcd_printf(1, " ... %8lu filters (net_fil pool=%" SIZE_FMT_U " bytes)\n",
|
||||
vpi_mcd_printf(1, " ... %8lu filters (net_fil pool=%zu bytes)\n",
|
||||
count_filters, vvp_net_fil_t::heap_total());
|
||||
vpi_mcd_printf(1, " ... %8lu opcodes (%" SIZE_FMT_U " bytes)\n",
|
||||
vpi_mcd_printf(1, " ... %8lu opcodes (%zu bytes)\n",
|
||||
count_opcodes, size_opcodes);
|
||||
vpi_mcd_printf(1, " ... %8lu nets\n", count_vpi_nets);
|
||||
vpi_mcd_printf(1, " ... %8lu vvp_nets (%" SIZE_FMT_U " bytes)\n",
|
||||
vpi_mcd_printf(1, " ... %8lu vvp_nets (%zu bytes)\n",
|
||||
count_vvp_nets, size_vvp_nets);
|
||||
vpi_mcd_printf(1, " ... %8lu arrays (%lu words)\n",
|
||||
count_net_arrays, count_net_array_words);
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ void vvp_udp_comb_s::compile_table(char**tab)
|
|||
cur.maskx = 0;
|
||||
if (port_count() > 8*sizeof(cur.mask0)) {
|
||||
fprintf(stderr, "internal error: primitive port count=%u "
|
||||
" > %" SIZE_FMT_U "\n", port_count(), sizeof(cur.mask0));
|
||||
" > %zu\n", port_count(), sizeof(cur.mask0));
|
||||
assert(port_count() <= 8*sizeof(cur.mask0));
|
||||
}
|
||||
for (unsigned pp = 0 ; pp < port_count() ; pp += 1) {
|
||||
|
|
|
|||
|
|
@ -191,31 +191,6 @@ vpi_mcd_vprintf(PLI_UINT32 mcd, const char*fmt, va_list ap)
|
|||
}
|
||||
|
||||
va_copy(saved_ap, ap);
|
||||
#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);
|
||||
/*
|
||||
* Windows returns -1 to indicate the result was truncated (thanks for
|
||||
* following the standard!). Since we don't know how big to make the
|
||||
* buffer just keep doubling it until it works.
|
||||
*/
|
||||
if (rc == -1) {
|
||||
size_t buf_size = sizeof buffer;
|
||||
buf_ptr = NULL;
|
||||
need_free = true;
|
||||
while (rc == -1) {
|
||||
va_list tmp_ap;
|
||||
va_copy(tmp_ap, saved_ap);
|
||||
buf_size *= 2;
|
||||
buf_ptr = (char *)realloc(buf_ptr, buf_size);
|
||||
rc = vsnprintf(buf_ptr, buf_size, fmt, tmp_ap);
|
||||
va_end(tmp_ap);
|
||||
}
|
||||
}
|
||||
#else
|
||||
rc = vsnprintf(buffer, sizeof buffer, fmt, ap);
|
||||
assert(rc >= 0);
|
||||
/*
|
||||
|
|
@ -227,7 +202,6 @@ vpi_mcd_vprintf(PLI_UINT32 mcd, const char*fmt, va_list ap)
|
|||
need_free = true;
|
||||
rc = vsnprintf(buf_ptr, rc+1, fmt, saved_ap);
|
||||
}
|
||||
#endif
|
||||
va_end(saved_ap);
|
||||
|
||||
for(int i = 0; i < 31; i++) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue