verilog-to-routing / vtr-verilog-to-routing

Verilog to Routing -- Open Source CAD Flow for FPGA Research
https://verilogtorouting.org
Other
988 stars 380 forks source link

Replace strdup with vtr::strdup and remove strnlen (non-standard) #377

Closed vaughnbetz closed 5 years ago

vaughnbetz commented 5 years ago

VTR won't compile on cygwin due to use of strdup and strnlen in two ODIN-II files: netlist_visualizer.cpp and soft_logic_parser_def.cpp.

Neither strdup nor strnlen is standard C, so we should not use them.

Expected Behaviour

Should compile on cygwin.

Current Behaviour

Compiler errors in these files, due to undefined functions.

Possible Solution

  1. Replace strdup calls with vtr::strdup. (everywhere else in VTR we call this function that we control).
  2. Replace strnlen with strlen, and min the result with 65 if necessary (that's what the current code does).
  3. (Optional, but would be good). It would be best to get rid of the hardcoded 65, and the earlier hardcoded bufsize of 64 in soft_logic_parser_def.cpp and replace them with a #define LOGIC_PARSER_BUFSIZE or some such, as these hard coded numbers are bad. Probably best to use a bigger buffer size too; using a small buffer like 64/65 characters isn't a great idea even if you don't think people will use long names as the cost of a 8192 or so entry buffer is 0 negligible anyway.

Steps to Reproduce

Compile on cygwin.

Context

Two users, David Lewis and Igor Ilyukhin, have hit those in the past two weeks.

Your Environment

Trunk VTR (recent as of July 20, 2018) Gcc Cygwin

jeanlego commented 5 years ago

fixed