From a4a7b0a09d2b91ab0f6dcdbe1354d87b748c9398 Mon Sep 17 00:00:00 2001 From: Cary R Date: Sat, 23 Oct 2010 15:52:56 -0700 Subject: [PATCH] Make ivl_alloc.h the last include so it doesn't effect any system includes. In ivl_alloc.h we redefine malloc(), realloc() and calloc() to have standard error checking. We don't want to do this for anything that comes from the standard headers. This specifically doesn't work if a C++ header files does std::malloc, etc. Also change to -W instead of -Wextra since that is more portable. I plan to add a check from -Wextra and use it when available since it is more descriptive. --- StringHeap.cc | 2 +- cadpli/cadpli.c | 2 +- configure.in | 2 +- driver/main.c | 11 +++++------ driver/substit.c | 2 +- ivlpp/lexor.lex | 2 +- ivlpp/main.c | 2 +- libveriuser/a_vcl.c | 2 +- libveriuser/veriusertfs.c | 2 +- libveriuser/workarea.c | 2 +- load_module.cc | 2 +- main.cc | 3 ++- net_link.cc | 2 +- pform.cc | 2 +- t-dll-analog.cc | 2 +- t-dll-api.cc | 2 +- t-dll-expr.cc | 2 +- t-dll-proc.cc | 2 +- t-dll.cc | 2 +- tgt-fpga/d-generic-edif.c | 2 +- tgt-fpga/edif.c | 2 +- tgt-fpga/mangle.c | 2 +- tgt-fpga/xilinx.c | 2 +- tgt-pal/emit_jed.c | 2 +- tgt-pal/fit_log.c | 2 +- tgt-pal/imain.c | 2 +- tgt-stub/stub.c | 2 +- tgt-vvp/draw_net_input.c | 2 +- tgt-vvp/draw_vpi.c | 2 +- tgt-vvp/eval_expr.c | 2 +- tgt-vvp/modpath.c | 2 +- tgt-vvp/vvp_scope.c | 2 +- vpi/sdf_parse.y | 2 +- vpi/stringheap.c | 2 +- vpi/sys_display.c | 2 +- vpi/sys_fileio.c | 2 +- vpi/sys_fst.c | 2 +- vpi/sys_lxt.c | 2 +- vpi/sys_lxt2.c | 2 +- vpi/sys_priv.c | 2 +- vpi/sys_random_mti.c | 2 +- vpi/sys_readmem.c | 2 +- vpi/sys_scanf.c | 2 +- vpi/sys_vcd.c | 2 +- vpi/v2005_math.c | 2 +- vpi/va_math.c | 2 +- vvp/array.cc | 2 +- vvp/compile.cc | 5 +++-- vvp/delay.cc | 4 ++-- vvp/lexor.lex | 2 +- vvp/parse.y | 2 +- vvp/parse_misc.cc | 2 +- vvp/stop.cc | 2 +- vvp/udp.cc | 8 ++++---- vvp/vpi_const.cc | 2 +- vvp/vpi_event.cc | 2 +- vvp/vpi_iter.cc | 2 +- vvp/vpi_mcd.cc | 2 +- vvp/vpi_modules.cc | 2 +- vvp/vpi_real.cc | 2 +- vvp/vpi_scope.cc | 2 +- vvp/vpi_signal.cc | 2 +- vvp/vpi_tasks.cc | 2 +- vvp/vpi_vthr_vector.cc | 2 +- vvp/vpip_to_dec.cc | 2 +- vvp/vvp_island.cc | 2 +- vvp/vvp_net.h | 14 +++++++++++--- 67 files changed, 88 insertions(+), 79 deletions(-) diff --git a/StringHeap.cc b/StringHeap.cc index a9ec03839..4ee081a07 100644 --- a/StringHeap.cc +++ b/StringHeap.cc @@ -18,10 +18,10 @@ */ # include "StringHeap.h" -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" #ifdef CHECK_WITH_VALGRIND static char **string_pool = NULL; diff --git a/cadpli/cadpli.c b/cadpli/cadpli.c index 572d73681..4b9d21e95 100644 --- a/cadpli/cadpli.c +++ b/cadpli/cadpli.c @@ -17,7 +17,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -# include "ivl_alloc.h" # include # include # include @@ -25,6 +24,7 @@ # include # include "config.h" # include "ivl_dlfcn.h" +# include "ivl_alloc.h" typedef void* (*funcvp)(void); diff --git a/configure.in b/configure.in index 5fd273e8e..84597574a 100644 --- a/configure.in +++ b/configure.in @@ -71,7 +71,7 @@ AC_SUBST(WARNING_FLAGS_CXX, [""]) else AC_SUBST(DEPENDENCY_FLAG, [-MD]) AC_SUBST(WARNING_FLAGS, ["-Wall -Wshadow"]) -AC_SUBST(WARNING_FLAGS_CXX, ["-Wextra"]) +AC_SUBST(WARNING_FLAGS_CXX, ["-W"]) fi AC_LANG(C++) diff --git a/driver/main.c b/driver/main.c index b3c472c22..569085378 100644 --- a/driver/main.c +++ b/driver/main.c @@ -50,7 +50,6 @@ const char HELP[] = #define MAXSIZE 4096 -#include "ivl_alloc.h" #include #include #include @@ -64,11 +63,13 @@ const char HELP[] = #endif #ifdef __MINGW32__ -#include +# include +# include #ifdef HAVE_LIBIBERTY_H -#include +# include #endif #endif +#include #if HAVE_GETOPT_H #include @@ -94,6 +95,7 @@ extern const char*optarg; # include "globals.h" #include "cfparse_misc.h" /* cfparse() */ +#include "ivl_alloc.h" #ifdef __MINGW32__ const char sep = '\\'; @@ -211,8 +213,6 @@ char *get_cmd_file() } #ifdef __MINGW32__ -# include -# include static FILE*fopen_safe(const char*path) { FILE*file = 0; @@ -225,7 +225,6 @@ static FILE*fopen_safe(const char*path) return file; } #else -# include static FILE*fopen_safe(const char*path) { FILE*file = 0; diff --git a/driver/substit.c b/driver/substit.c index e90c9f899..3aa0fc420 100644 --- a/driver/substit.c +++ b/driver/substit.c @@ -17,10 +17,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" char* substitutions(const char*str) diff --git a/ivlpp/lexor.lex b/ivlpp/lexor.lex index 3c1a630c2..fab69db65 100644 --- a/ivlpp/lexor.lex +++ b/ivlpp/lexor.lex @@ -20,7 +20,6 @@ # include "config.h" -# include "ivl_alloc.h" # include # include # include @@ -28,6 +27,7 @@ # include # include "globals.h" +# include "ivl_alloc.h" static void output_init(); #define YY_USER_INIT output_init() diff --git a/ivlpp/main.c b/ivlpp/main.c index 7e9a260a5..3b8d1857d 100644 --- a/ivlpp/main.c +++ b/ivlpp/main.c @@ -37,7 +37,6 @@ const char NOTICE[] = " 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n" ; -# include "ivl_alloc.h" # include # include # include @@ -47,6 +46,7 @@ const char NOTICE[] = # include #endif # include "globals.h" +# include "ivl_alloc.h" #if defined(__MINGW32__) && !defined(HAVE_GETOPT_H) extern int getopt(int argc, char*argv[], const char*fmt); diff --git a/libveriuser/a_vcl.c b/libveriuser/a_vcl.c index 855a8bc2d..aa2c96df4 100644 --- a/libveriuser/a_vcl.c +++ b/libveriuser/a_vcl.c @@ -17,12 +17,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#include "ivl_alloc.h" #include #include #include #include "priv.h" #include +#include "ivl_alloc.h" /* * This is the structure of a record that I use locally to hold the diff --git a/libveriuser/veriusertfs.c b/libveriuser/veriusertfs.c index 7f16cfe4f..740b80fd2 100644 --- a/libveriuser/veriusertfs.c +++ b/libveriuser/veriusertfs.c @@ -23,7 +23,6 @@ * via VPI. This is extremely ugly, so don't look after eating dinner. */ -# include "ivl_alloc.h" # include # include # include @@ -32,6 +31,7 @@ # include "priv.h" # include "vpi_user.h" # include "veriuser.h" +# include "ivl_alloc.h" /* * local structure used to hold the persistent veriusertfs data diff --git a/libveriuser/workarea.c b/libveriuser/workarea.c index c42125881..4be46d70a 100644 --- a/libveriuser/workarea.c +++ b/libveriuser/workarea.c @@ -17,10 +17,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" /* * Keep a list of sys handle to work area bindings. diff --git a/load_module.cc b/load_module.cc index c0c0bca8a..91d9241fb 100644 --- a/load_module.cc +++ b/load_module.cc @@ -21,7 +21,6 @@ # include "util.h" # include "parse_api.h" # include "compiler.h" -# include "ivl_alloc.h" # include # include # include @@ -31,6 +30,7 @@ # include # include # include +# include "ivl_alloc.h" /* * The module library items are maps of key names to file name within diff --git a/main.cc b/main.cc index 9654d96cf..bd1c80ab7 100644 --- a/main.cc +++ b/main.cc @@ -38,7 +38,6 @@ const char NOTICE[] = " 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n" ; -# include "ivl_alloc.h" # include # include # include @@ -89,6 +88,8 @@ static void signals_handler(int sig) } #endif +# include "ivl_alloc.h" + /* Count errors detected in flag processing. */ unsigned flag_errors = 0; diff --git a/net_link.cc b/net_link.cc index f866bdc9b..2ed0588b1 100644 --- a/net_link.cc +++ b/net_link.cc @@ -22,12 +22,12 @@ # include # include "netlist.h" -# include "ivl_alloc.h" # include # include # include # include # include +# include "ivl_alloc.h" void Nexus::connect(Link&r) { diff --git a/pform.cc b/pform.cc index a9c9890a1..0b58f1d46 100644 --- a/pform.cc +++ b/pform.cc @@ -28,7 +28,6 @@ # include "PGenerate.h" # include "PSpec.h" # include "discipline.h" -# include "ivl_alloc.h" # include # include # include @@ -39,6 +38,7 @@ # include # include "ivl_assert.h" +# include "ivl_alloc.h" map pform_modules; map pform_primitives; diff --git a/t-dll-analog.cc b/t-dll-analog.cc index f5861500b..26f21abe0 100644 --- a/t-dll-analog.cc +++ b/t-dll-analog.cc @@ -22,13 +22,13 @@ # include -# include "ivl_alloc.h" # include # include "target.h" # include "ivl_target.h" # include "compiler.h" # include "t-dll.h" # include +# include "ivl_alloc.h" bool dll_target::process(const NetAnalogTop*net) { diff --git a/t-dll-api.cc b/t-dll-api.cc index 436b1e507..c40aebf17 100644 --- a/t-dll-api.cc +++ b/t-dll-api.cc @@ -21,10 +21,10 @@ # include "StringHeap.h" # include "t-dll.h" # include "discipline.h" -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" static StringHeap api_strings; diff --git a/t-dll-expr.cc b/t-dll-expr.cc index 542738022..fa67f618b 100644 --- a/t-dll-expr.cc +++ b/t-dll-expr.cc @@ -19,7 +19,6 @@ # include "config.h" -# include "ivl_alloc.h" # include # include @@ -27,6 +26,7 @@ # include "netlist.h" # include # include +# include "ivl_alloc.h" /* * This is a little convenience function for converting a NetExpr diff --git a/t-dll-proc.cc b/t-dll-proc.cc index 32f33e767..e446f9653 100644 --- a/t-dll-proc.cc +++ b/t-dll-proc.cc @@ -22,13 +22,13 @@ # include -# include "ivl_alloc.h" # include # include "target.h" # include "ivl_target.h" # include "compiler.h" # include "t-dll.h" # include +# include "ivl_alloc.h" bool dll_target::process(const NetProcTop*net) { diff --git a/t-dll.cc b/t-dll.cc index baddd1af7..1146fc08a 100644 --- a/t-dll.cc +++ b/t-dll.cc @@ -21,7 +21,6 @@ # include -# include "ivl_alloc.h" # include # include // sprintf() # include "compiler.h" @@ -30,6 +29,7 @@ # include "discipline.h" # include # include "ivl_assert.h" +# include "ivl_alloc.h" struct dll_target dll_target_obj; diff --git a/tgt-fpga/d-generic-edif.c b/tgt-fpga/d-generic-edif.c index 71740d0c1..5831306ff 100644 --- a/tgt-fpga/d-generic-edif.c +++ b/tgt-fpga/d-generic-edif.c @@ -19,10 +19,10 @@ # include "device.h" # include "fpga_priv.h" -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" struct nexus_recall { struct nexus_recall*next; diff --git a/tgt-fpga/edif.c b/tgt-fpga/edif.c index 0739f5a61..9e8d97930 100644 --- a/tgt-fpga/edif.c +++ b/tgt-fpga/edif.c @@ -18,10 +18,10 @@ */ # include "edif.h" -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" typedef enum property_e { PRP_NONE = 0, diff --git a/tgt-fpga/mangle.c b/tgt-fpga/mangle.c index 0138f82d3..5b98e73e6 100644 --- a/tgt-fpga/mangle.c +++ b/tgt-fpga/mangle.c @@ -18,9 +18,9 @@ */ # include "fpga_priv.h" -# include "ivl_alloc.h" # include # include +# include "ivl_alloc.h" static size_t xnf_mangle_scope_name(ivl_scope_t net, char*buf, size_t nbuf) { diff --git a/tgt-fpga/xilinx.c b/tgt-fpga/xilinx.c index 9d9d9dd08..f64ab491f 100644 --- a/tgt-fpga/xilinx.c +++ b/tgt-fpga/xilinx.c @@ -21,10 +21,10 @@ # include "generic.h" # include "xilinx.h" # include "fpga_priv.h" -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" edif_cell_t xilinx_cell_buf(edif_xlibrary_t xlib) { diff --git a/tgt-pal/emit_jed.c b/tgt-pal/emit_jed.c index ae9ad5bbc..de0672b8c 100644 --- a/tgt-pal/emit_jed.c +++ b/tgt-pal/emit_jed.c @@ -20,10 +20,10 @@ # include "config.h" # include "priv.h" -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" static void draw_macrocell_modes(FILE*jfd) { diff --git a/tgt-pal/fit_log.c b/tgt-pal/fit_log.c index 469cebad6..3f5efed3e 100644 --- a/tgt-pal/fit_log.c +++ b/tgt-pal/fit_log.c @@ -20,11 +20,11 @@ # include "config.h" # include "ivl_target.h" -# include "ivl_alloc.h" # include # include # include # include "priv.h" +# include "ivl_alloc.h" /* * By the time we get here, all the flip-flops have been placed in diff --git a/tgt-pal/imain.c b/tgt-pal/imain.c index 00e2937ca..4f262753e 100644 --- a/tgt-pal/imain.c +++ b/tgt-pal/imain.c @@ -25,10 +25,10 @@ # include "priv.h" -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" extern void dump_final_design(FILE*out); diff --git a/tgt-stub/stub.c b/tgt-stub/stub.c index f6a325116..a963c228f 100644 --- a/tgt-stub/stub.c +++ b/tgt-stub/stub.c @@ -28,11 +28,11 @@ # include "version_tag.h" # include "config.h" # include "priv.h" -# include "ivl_alloc.h" # include # include # include # include +# include "ivl_alloc.h" static const char*version_string = "Icarus Verilog STUB Code Generator " VERSION " (" VERSION_TAG ")\n\n" diff --git a/tgt-vvp/draw_net_input.c b/tgt-vvp/draw_net_input.c index 4eb6ec311..ddfd4cc7f 100644 --- a/tgt-vvp/draw_net_input.c +++ b/tgt-vvp/draw_net_input.c @@ -18,12 +18,12 @@ */ # include "vvp_priv.h" -# include "ivl_alloc.h" # include # include # include # include # include +# include "ivl_alloc.h" #ifdef __MINGW32__ /* MinGW has inconsistent %p output. */ #define snprintf _snprintf diff --git a/tgt-vvp/draw_vpi.c b/tgt-vvp/draw_vpi.c index 575b570ad..c9231c392 100644 --- a/tgt-vvp/draw_vpi.c +++ b/tgt-vvp/draw_vpi.c @@ -18,10 +18,10 @@ */ # include "vvp_priv.h" -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" #ifdef __MINGW32__ /* MinGW has inconsistent %p output. */ #define snprintf _snprintf diff --git a/tgt-vvp/eval_expr.c b/tgt-vvp/eval_expr.c index cb2ff47be..90709ec6c 100644 --- a/tgt-vvp/eval_expr.c +++ b/tgt-vvp/eval_expr.c @@ -18,10 +18,10 @@ */ # include "vvp_priv.h" -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" static void draw_eval_expr_dest(ivl_expr_t expr, struct vector_info dest, int ok_flags); diff --git a/tgt-vvp/modpath.c b/tgt-vvp/modpath.c index ed97e5b99..89f316fdc 100644 --- a/tgt-vvp/modpath.c +++ b/tgt-vvp/modpath.c @@ -18,10 +18,10 @@ */ # include "vvp_priv.h" -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" #ifdef __MINGW32__ /* MinGW has inconsistent %p output. */ #define snprintf _snprintf diff --git a/tgt-vvp/vvp_scope.c b/tgt-vvp/vvp_scope.c index 106d42d4f..6f0a258eb 100644 --- a/tgt-vvp/vvp_scope.c +++ b/tgt-vvp/vvp_scope.c @@ -18,12 +18,12 @@ */ # include "vvp_priv.h" -# include "ivl_alloc.h" # include # include # include # include # include +# include "ivl_alloc.h" #ifdef __MINGW32__ /* MinGW has inconsistent %p output. */ #define snprintf _snprintf diff --git a/vpi/sdf_parse.y b/vpi/sdf_parse.y index 397b66847..f1ced30d8 100644 --- a/vpi/sdf_parse.y +++ b/vpi/sdf_parse.y @@ -24,10 +24,10 @@ static void yyerror(const char*msg); # include "vpi_user.h" # include "sdf_parse_priv.h" # include "sdf_priv.h" -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" /* This is the hierarchy separator to use. */ char sdf_use_hchar = '.'; diff --git a/vpi/stringheap.c b/vpi/stringheap.c index 819fdfac1..2b419965a 100644 --- a/vpi/stringheap.c +++ b/vpi/stringheap.c @@ -19,10 +19,10 @@ # include "sys_priv.h" # include "stringheap.h" -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" struct stringheap_cell { struct stringheap_cell*next; diff --git a/vpi/sys_display.c b/vpi/sys_display.c index 386338b7f..18729c4f1 100644 --- a/vpi/sys_display.c +++ b/vpi/sys_display.c @@ -18,7 +18,6 @@ */ # include "sys_priv.h" -# include "ivl_alloc.h" # include # include # include @@ -26,6 +25,7 @@ # include # include # include +# include "ivl_alloc.h" #define IS_MCD(mcd) !((mcd)>>31&1) diff --git a/vpi/sys_fileio.c b/vpi/sys_fileio.c index 4d0107cd7..305775390 100644 --- a/vpi/sys_fileio.c +++ b/vpi/sys_fileio.c @@ -18,13 +18,13 @@ */ # include "sys_priv.h" -# include "ivl_alloc.h" # include # include # include # include # include # include +# include "ivl_alloc.h" #define IS_MCD(mcd) !((mcd)>>31&1) diff --git a/vpi/sys_fst.c b/vpi/sys_fst.c index de02f00b8..b70eaf4c9 100644 --- a/vpi/sys_fst.c +++ b/vpi/sys_fst.c @@ -25,12 +25,12 @@ * This file contains the implementations of the FST related functions. */ -# include "ivl_alloc.h" # include # include # include # include # include +# include "ivl_alloc.h" static char *dump_path = NULL; static struct fstContext *dump_file = NULL; diff --git a/vpi/sys_lxt.c b/vpi/sys_lxt.c index de86501be..0cc02aaba 100644 --- a/vpi/sys_lxt.c +++ b/vpi/sys_lxt.c @@ -26,13 +26,13 @@ * This file contains the implementations of the LXT related functions. */ -# include "ivl_alloc.h" # include # include # include # include # include # include "stringheap.h" +# include "ivl_alloc.h" static char *dump_path = NULL; diff --git a/vpi/sys_lxt2.c b/vpi/sys_lxt2.c index e0228272e..b50011ca2 100644 --- a/vpi/sys_lxt2.c +++ b/vpi/sys_lxt2.c @@ -26,13 +26,13 @@ * This file contains the implementations of the LXT2 related functions. */ -# include "ivl_alloc.h" # include # include # include # include # include "stringheap.h" # include +# include "ivl_alloc.h" static char *dump_path = NULL; diff --git a/vpi/sys_priv.c b/vpi/sys_priv.c index 1f66d2b00..cf3713b18 100644 --- a/vpi/sys_priv.c +++ b/vpi/sys_priv.c @@ -18,11 +18,11 @@ */ #include "sys_priv.h" -#include "ivl_alloc.h" #include #include #include #include +#include "ivl_alloc.h" PLI_UINT64 timerec_to_time64(const struct t_vpi_time*timerec) { diff --git a/vpi/sys_random_mti.c b/vpi/sys_random_mti.c index d4abaceaa..14f9e1f68 100644 --- a/vpi/sys_random_mti.c +++ b/vpi/sys_random_mti.c @@ -20,11 +20,11 @@ # include "sys_priv.h" # include "sys_random.h" -# include "ivl_alloc.h" # include # include # include # include +# include "ivl_alloc.h" /* * Implement the $random system function using the ``Mersenne diff --git a/vpi/sys_readmem.c b/vpi/sys_readmem.c index 8cba60b7c..d716420dd 100644 --- a/vpi/sys_readmem.c +++ b/vpi/sys_readmem.c @@ -18,7 +18,6 @@ */ # include "sys_priv.h" -# include "ivl_alloc.h" # include # include # include @@ -26,6 +25,7 @@ # include # include "sys_readmem_lex.h" # include +# include "ivl_alloc.h" char **search_list = NULL; unsigned sl_count = 0; diff --git a/vpi/sys_scanf.c b/vpi/sys_scanf.c index e76e5e7ee..896a2af0a 100644 --- a/vpi/sys_scanf.c +++ b/vpi/sys_scanf.c @@ -22,7 +22,6 @@ # define _SVID_SOURCE 1 # include "sys_priv.h" -# include "ivl_alloc.h" # include # include # include @@ -30,6 +29,7 @@ # include # include # include +# include "ivl_alloc.h" struct byte_source { const char*str; diff --git a/vpi/sys_vcd.c b/vpi/sys_vcd.c index 9be51396a..94d863594 100644 --- a/vpi/sys_vcd.c +++ b/vpi/sys_vcd.c @@ -24,12 +24,12 @@ * This file contains the implementations of the VCD related functions. */ -# include "ivl_alloc.h" # include # include # include # include # include +# include "ivl_alloc.h" static char *dump_path = NULL; static FILE *dump_file = NULL; diff --git a/vpi/v2005_math.c b/vpi/v2005_math.c index 631bbc810..09edc03e2 100644 --- a/vpi/v2005_math.c +++ b/vpi/v2005_math.c @@ -20,12 +20,12 @@ */ #include "vpi_config.h" -#include "ivl_alloc.h" #include #include #include #include #include "vpi_user.h" +#include "ivl_alloc.h" /* Single argument functions. */ typedef struct s_single_data { diff --git a/vpi/va_math.c b/vpi/va_math.c index 7221abd6a..1b6bb0ea1 100644 --- a/vpi/va_math.c +++ b/vpi/va_math.c @@ -20,12 +20,12 @@ */ #include "vpi_config.h" -#include "ivl_alloc.h" #include #include #include #include #include "vpi_user.h" +#include "ivl_alloc.h" /* * Compile time options: (set in the Makefile.) diff --git a/vvp/array.cc b/vvp/array.cc index a5c07bdcd..0dd77eb64 100644 --- a/vvp/array.cc +++ b/vvp/array.cc @@ -26,13 +26,13 @@ #ifdef CHECK_WITH_VALGRIND #include "vvp_cleanup.h" #endif -# include "ivl_alloc.h" # include # include # include # include # include "compile.h" # include +# include "ivl_alloc.h" unsigned long count_net_arrays = 0; unsigned long count_net_array_words = 0; diff --git a/vvp/compile.cc b/vvp/compile.cc index 6adc7a1ad..c913deb33 100644 --- a/vvp/compile.cc +++ b/vvp/compile.cc @@ -28,7 +28,6 @@ # include "vpi_priv.h" # include "parse_misc.h" # include "statistics.h" -# include "ivl_alloc.h" # include # include # include @@ -39,6 +38,8 @@ #include #endif +# include "ivl_alloc.h" + unsigned compile_errors = 0; /* @@ -76,7 +77,7 @@ struct opcode_table_s { enum operand_e argt[OPERAND_MAX]; }; -const static struct opcode_table_s opcode_table[] = { +static const struct opcode_table_s opcode_table[] = { { "%abs/wr", of_ABS_WR, 2, {OA_BIT1, OA_BIT2, OA_NONE} }, { "%add", of_ADD, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, { "%add/wr", of_ADD_WR, 2, {OA_BIT1, OA_BIT2, OA_NONE} }, diff --git a/vvp/delay.cc b/vvp/delay.cc index cfb0077d8..03cd6b506 100644 --- a/vvp/delay.cc +++ b/vvp/delay.cc @@ -24,12 +24,12 @@ #ifdef CHECK_WITH_VALGRIND #include "vvp_cleanup.h" #endif -#include "ivl_alloc.h" #include #include #include #include #include +#include "ivl_alloc.h" void vvp_delay_t::calculate_min_delay_() { @@ -526,7 +526,7 @@ static vvp_time64_t delay_from_edge(vvp_bit4_t a, vvp_bit4_t b, vvp_time64_t array[12]) { typedef delay_edge_t bit4_table4[4]; - const static bit4_table4 edge_table[4] = { + static const bit4_table4 edge_table[4] = { { DELAY_EDGE_01, DELAY_EDGE_01, DELAY_EDGE_0x, DELAY_EDGE_0z }, { DELAY_EDGE_10, DELAY_EDGE_10, DELAY_EDGE_1x, DELAY_EDGE_1z }, { DELAY_EDGE_x0, DELAY_EDGE_x1, DELAY_EDGE_x0, DELAY_EDGE_xz }, diff --git a/vvp/lexor.lex b/vvp/lexor.lex index 6dfee86a1..049da6258 100644 --- a/vvp/lexor.lex +++ b/vvp/lexor.lex @@ -25,9 +25,9 @@ # include "parse_misc.h" # include "compile.h" # include "parse.h" -# include "ivl_alloc.h" # include # include +# include "ivl_alloc.h" static char* strdupnew(char const *str) { diff --git a/vvp/parse.y b/vvp/parse.y index a77ead1ee..49d3566a1 100644 --- a/vvp/parse.y +++ b/vvp/parse.y @@ -22,10 +22,10 @@ # include "parse_misc.h" # include "compile.h" # include "delay.h" -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" /* * These are bits in the lexor. diff --git a/vvp/parse_misc.cc b/vvp/parse_misc.cc index 966e74084..e811fcbca 100644 --- a/vvp/parse_misc.cc +++ b/vvp/parse_misc.cc @@ -19,9 +19,9 @@ # include "parse_misc.h" # include "compile.h" -# include "ivl_alloc.h" # include # include +# include "ivl_alloc.h" const char*yypath; unsigned yyline; diff --git a/vvp/stop.cc b/vvp/stop.cc index 140b17d85..07af64487 100644 --- a/vvp/stop.cc +++ b/vvp/stop.cc @@ -28,7 +28,6 @@ # include "vpi_priv.h" # include "vthread.h" # include "schedule.h" -# include "ivl_alloc.h" # include # include #ifdef USE_READLINE @@ -39,6 +38,7 @@ #endif # include # include +# include "ivl_alloc.h" struct __vpiScope*stop_current_scope = 0; bool stop_is_finish; /* When set, $stop acts like $finish (set in main.cc). */ diff --git a/vvp/udp.cc b/vvp/udp.cc index fc221e04b..0c45be816 100644 --- a/vvp/udp.cc +++ b/vvp/udp.cc @@ -25,15 +25,15 @@ #include "symbols.h" #include "compile.h" #include "config.h" -#ifdef CHECK_WITH_VALGRIND -#include "vvp_cleanup.h" -#include "ivl_alloc.h" -#endif #include #include #include #include #include +#ifdef CHECK_WITH_VALGRIND +#include "vvp_cleanup.h" +#include "ivl_alloc.h" +#endif // We may need these later when we build the VPI interface to // UDP definitions. diff --git a/vvp/vpi_const.cc b/vvp/vpi_const.cc index deef61863..c9947c153 100644 --- a/vvp/vpi_const.cc +++ b/vvp/vpi_const.cc @@ -23,11 +23,11 @@ #ifdef CHECK_WITH_VALGRIND # include "vvp_cleanup.h" #endif -# include "ivl_alloc.h" # include # include # include # include +# include "ivl_alloc.h" static int string_get(int code, vpiHandle ref) { diff --git a/vvp/vpi_event.cc b/vvp/vpi_event.cc index 7866df871..49c01cab0 100644 --- a/vvp/vpi_event.cc +++ b/vvp/vpi_event.cc @@ -19,11 +19,11 @@ # include "compile.h" # include "vpi_priv.h" -# include "ivl_alloc.h" # include # include # include # include +# include "ivl_alloc.h" static int named_event_get(int code, vpiHandle ref) { diff --git a/vvp/vpi_iter.cc b/vvp/vpi_iter.cc index 36434a53f..f548e796a 100644 --- a/vvp/vpi_iter.cc +++ b/vvp/vpi_iter.cc @@ -22,9 +22,9 @@ */ # include "vpi_priv.h" -# include "ivl_alloc.h" # include # include +# include "ivl_alloc.h" static int iterator_free_object(vpiHandle ref) { diff --git a/vvp/vpi_mcd.cc b/vvp/vpi_mcd.cc index 177a7efe5..079ad1abe 100644 --- a/vvp/vpi_mcd.cc +++ b/vvp/vpi_mcd.cc @@ -22,12 +22,12 @@ #ifdef CHECK_WITH_VALGRIND # include "vvp_cleanup.h" #endif -# include "ivl_alloc.h" # include # include # include # include # include +# include "ivl_alloc.h" extern FILE* vpi_trace; diff --git a/vvp/vpi_modules.cc b/vvp/vpi_modules.cc index 4a944c2d8..f45055eae 100644 --- a/vvp/vpi_modules.cc +++ b/vvp/vpi_modules.cc @@ -21,11 +21,11 @@ # include "vpi_priv.h" # include "ivl_dlfcn.h" # include "vvp_cleanup.h" -# include "ivl_alloc.h" # include # include # include # include +# include "ivl_alloc.h" static ivl_dll_t*dll_list = 0; static unsigned dll_list_cnt = 0; diff --git a/vvp/vpi_real.cc b/vvp/vpi_real.cc index 83a40d1e3..72812ecca 100644 --- a/vvp/vpi_real.cc +++ b/vvp/vpi_real.cc @@ -24,11 +24,11 @@ #ifdef CHECK_WITH_VALGRIND # include "vvp_cleanup.h" #endif -# include "ivl_alloc.h" # include # include # include # include +# include "ivl_alloc.h" struct __vpiRealVar* vpip_realvar_from_handle(vpiHandle obj) { diff --git a/vvp/vpi_scope.cc b/vvp/vpi_scope.cc index c0743647a..e3449679c 100644 --- a/vvp/vpi_scope.cc +++ b/vvp/vpi_scope.cc @@ -25,10 +25,10 @@ #ifdef CHECK_WITH_VALGRIND # include "vvp_cleanup.h" #endif -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" static vpiHandle *vpip_root_table_ptr = 0; static unsigned vpip_root_table_cnt = 0; diff --git a/vvp/vpi_signal.cc b/vvp/vpi_signal.cc index 2aaa326ca..4d07c997f 100644 --- a/vvp/vpi_signal.cc +++ b/vvp/vpi_signal.cc @@ -31,7 +31,6 @@ #ifdef CHECK_WITH_VALGRIND # include "vvp_cleanup.h" #endif -# include "ivl_alloc.h" # include # include # include @@ -42,6 +41,7 @@ #ifdef CHECK_WITH_VALGRIND # include #endif +# include "ivl_alloc.h" /* * Hex digits that represent 4-value bits of Verilog are not as diff --git a/vvp/vpi_tasks.cc b/vvp/vpi_tasks.cc index 8c4858136..e76789f7a 100644 --- a/vvp/vpi_tasks.cc +++ b/vvp/vpi_tasks.cc @@ -29,11 +29,11 @@ #ifdef CHECK_WITH_VALGRIND # include "vvp_cleanup.h" #endif -# include "ivl_alloc.h" # include # include # include # include +# include "ivl_alloc.h" static const struct __vpirt vpip_systf_def_rt = { vpiUserSystf, diff --git a/vvp/vpi_vthr_vector.cc b/vvp/vpi_vthr_vector.cc index 8f277e9ef..785ccbbe1 100644 --- a/vvp/vpi_vthr_vector.cc +++ b/vvp/vpi_vthr_vector.cc @@ -30,10 +30,10 @@ # include "vvp_cleanup.h" # include #endif -# include "ivl_alloc.h" # include # include # include +# include "ivl_alloc.h" struct __vpiVThrVec { struct __vpiHandle base; diff --git a/vvp/vpip_to_dec.cc b/vvp/vpip_to_dec.cc index 4ea73f3aa..6b2a99bf3 100644 --- a/vvp/vpip_to_dec.cc +++ b/vvp/vpip_to_dec.cc @@ -23,13 +23,13 @@ #ifdef CHECK_WITH_VALGRIND # include "vvp_cleanup.h" #endif -# include "ivl_alloc.h" # include # include # include /* for CHAR_BIT */ # include # include # include +# include "ivl_alloc.h" /* If you are allergic to malloc, you can set a stack memory allocation * here. Otherwise, malloc() is used for the temporary array, so the diff --git a/vvp/vvp_island.cc b/vvp/vvp_island.cc index 1ae39af50..49c167e75 100644 --- a/vvp/vvp_island.cc +++ b/vvp/vvp_island.cc @@ -25,12 +25,12 @@ #ifdef CHECK_WITH_VALGRIND # include "vvp_cleanup.h" #endif -# include "ivl_alloc.h" # include # include # include # include # include +# include "ivl_alloc.h" static bool at_EOS = false; diff --git a/vvp/vvp_net.h b/vvp/vvp_net.h index aa531b8af..59689b1d3 100644 --- a/vvp/vvp_net.h +++ b/vvp/vvp_net.h @@ -23,7 +23,6 @@ # include "vpi_user.h" # include "vvp_vpi_callback.h" # include "permaheap.h" -# include "ivl_alloc.h" # include # include # include @@ -36,6 +35,8 @@ class ostream; #endif +# include "ivl_alloc.h" + using namespace std; @@ -334,12 +335,12 @@ inline vvp_vector4_t::vvp_vector4_t(unsigned size__, vvp_bit4_t val) : size_(size__) { /* note: this relies on the bit encoding for the vvp_bit4_t. */ - const static unsigned long init_atable[4] = { + static const unsigned long init_atable[4] = { WORD_0_ABITS, WORD_1_ABITS, WORD_Z_ABITS, WORD_X_ABITS }; - const static unsigned long init_btable[4] = { + static const unsigned long init_btable[4] = { WORD_0_BBITS, WORD_1_BBITS, WORD_Z_BBITS, @@ -1646,4 +1647,11 @@ inline bool vvp_net_fil_t::test_force_mask_is_zero(void) const return false; } +/* + * Undefine the ivl_alloc.h definitions so they don't leak out of this file. + */ +#undef malloc +#undef realloc +#undef calloc + #endif