Commit Graph

38 Commits

Author SHA1 Message Date
Cary R 27cb140cb4 Fix space issues.
This patch removes space before EOL, etc.
2011-11-03 19:18:30 -07:00
Cary R 7d588d699b Use UINT_MAX instead of -1 to set unsigned to maximum value.
The Sun C compiler warns when -1 is used to initialize an unsigned.
2011-10-31 17:20:55 -07:00
Cary R 5fbffe24cc Remove old comment. 2011-10-31 10:38:40 -07:00
Cary R edc67fce40 Major rework of the $sscanf()/$fscanf() code.
Add support for %m, suppression '*' and a maximum field width along with
a number of other fixes/enhancements. There is still no support for
%u, %v or %z.
2011-10-31 10:38:14 -07:00
Cary R 507621ef30 Update $scanf, $printtimescale and the general is_numeric check for 2-state
This patch updates the $scanf and $printtimescale routines to work with
two-state variables. It also updates the general is_numeric check to
recognize two-state variables as numeric.
2011-09-11 11:58:16 -07:00
Cary R a4a7b0a09d 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.
2010-11-02 10:51:57 -07:00
Cary R cb86fb15bf Add error checking definitions for malloc(), realloc() and calloc()
This patch adds defines that translate all malloc(), realloc() and calloc()
calls into ones with error checking when ivl_alloc.h is included.
2010-10-14 17:39:23 -07:00
Larry Doolittle eaccf4d64f Add possibility of const-correctness
Follow-up to "Brainless start to const-correct changes"
Still actually does nothing, but now if the #define ICARUS_VPI_CONST
in vpi_user.h is changed to const, Icarus is almost const-correct,
as checked with gcc flags -Wcast-qual -Wwrite-strings.

Choosing when to #define ICARUS_VPI_CONST const is left as an
exercise for the reader.

With these two patches applied, and the const define, there are
still about a dozen const problems left.
2010-10-06 15:12:28 -07:00
Larry Doolittle 5d977cac73 Brainless start to const-correct changes
Results of running
cd vpi
for f in *.c *.h; do sed -i \
  -e "s/_calltf(PLI_BYTE8/_calltf(ICARUS_VPI_CONST PLI_BYTE8/" \
  -e "s/_compiletf(PLI_BYTE8/_compiletf(ICARUS_VPI_CONST PLI_BYTE8/" $f; done
and a trivial patch to vpi_user.h to, among other things, make
ICARUS_VPI_CONST blank.

Thus, this patch does absolutely nothing.  Will be followed by a
(much shorter) patch that makes it do something.  :-)
2010-10-06 15:08:54 -07:00
Cary R d508960a9e Fix space issues in VPI directory 2010-05-23 17:19:59 -07:00
Cary R ecacd7bae9 Make sure to call vpi_config.h first.
vpi_config.h defines _FILE_OFFSET_BITS. This must be defined before
any system includes files are processed, so vpi_config.h must be
called first. This patch puts vpi_config.h first. It also removes
direct calls for both vpi_config.h and vpi_user.h when sys_priv.h
is included since it already includes these two files.

It also updates the code to always include vpi_user.h using double
quotes.
2010-05-17 20:51:59 -07:00
Cary R f2d5acabd5 Add support for vpiUserSystf iteration, etc.
This patch adds support for iterating over the list of vpiUserSystf
tasks/functions that have vpiUserDefn set. The vpiUserDefn property
is true by default, but you can call vpip_make_systf_system_defined()
to set this property false (will hide the vpiUserSystf object). All
the normal system tasks/functions have been modified to call this
procedure to remove them from the list of vpiUserSystf objects. Only
user defined system tasks or functions should appear in the list.

vpi_compare_objects() is just a simple are the two pointers the
same. This works correctly for the vpiUserSystf objects, but the
other handle objects have not been checked.
2010-04-13 20:54:59 -07:00
Cary R 7a0e23179b Remove some gcc-4.3.4 warnings (Cygwin)
The latest gcc with the latest Cygwin complains when passing a char to
the toupper, tolower, isspace, isalnum, isprint, isdigit or isalpha
functions/macros. These functions are defined to take an integer. This
patch adds cast to int as needed to remove the warnings. After this
there are still two warnings related to signed/unsigned comparison in
yy_get_next_buffer() (part of flex).
2010-04-13 20:51:21 -07:00
Cary R 6eb5f593f0 realloc() to the correct string.
Someone had mistyped the destination of the realloc. It should
have been the original string not the input buffer.
2010-01-12 10:34:49 -08:00
Cary R f31a4e6d20 Add some casts in vpi to remove warnings.
The Cygwin compiler is a bit picky. This patch adds some casts
to remove compilation warnings. In the past I have had warnings
off because of problems with the STL, but for C directories
like this it makes sense to enable the warnings. It also does
not recognize that an assert(0) or assert(false) ends a routine
so it complains about no return at end of function or variables
not being defined.
2009-12-11 21:44:53 -08:00
Cary R 35f3d7f60e Fix a few more minor memory leaks.
This patch fixes a few more memory leaks that can happen under
error conditions.
2009-08-18 14:15:36 -07:00
Cary R ce89a68735 Add full $ferror() support, bug fixes, etc.
This patch adds $ferror() support. This is enhanced over what the standard
says needs to be supported. All file I/O routines set/clear the errno flag,
This allows $ferror() to check when an invalid fd/MCD is passed to a
system task. The $ferror() fd is only checked if errno is not set since
all the other routines will set EBADF when they are called. This allows us
to test the output from $fopen() which sets the fd to zero (an invalid fd)
when it has a problem.

The following bugs (changes) are also fixed:

Fix $fdisplay*, $fwrite*, $fstrobe*, $fflush, $fclose to not accept 0 as
a valid MCD.

For the $fdisplay*, $fwrite* and $fstrobe tasks an invalid fd/MCD is now
a warning instead of an error like the other file I/O routines.

Modify $fputc() to be a function and return a value like $ungetc().

Modify $ungetc() to return a value like the standard dictates (-1 on
error else 0) and pass the value as a full int to get EOF as an error.

Remove some extra checks that could not happen in $fseek() and to
be safe convert the numeric codes to the system symbolic values.

Skip $fstrobe callback when the fd/MCD is closed. The standard says
we need to cancel the callback, but we currently do not have the
ability to do that so just skipping this will work for now.

Free the argument handle when $fscanf() is called with an invalid fd
(memory leak).
2009-08-02 10:53:29 -07:00
Cary R c5ee1fdbf5 The scanf functions must return EOF if source starts at the end of input.
The $fscanf() and $sscanf() functions are defined to return EOF when
the end of input is reached before any matches or match failures have
occurred.
2009-07-28 19:40:46 -07:00
Cary R e987162cb9 Skip leading space for some codes in scanf routines.
Most conversion codes in the scanf routines are supposed to
skip leading space. This patch adds that functionality.
2009-04-03 17:46:29 -07:00
Cary R 82805b9351 Add compiletf routines for the scanf functions.
This patch adds compiletf routines for the $sscanf/$fscanf
functions. It does not enhance the conversion routines it
only adds better error/warning messages.

It also removed the redundant IS_MCD in some of the fileio
calltf routines. This is already checked in vpi_get_file().

I also added the vpiNetArray type to allow us to distinguish
arrays of nets from other arrays (memories). Much more is
needed here, but this solved the problem of the day. The
problem was that we needed to make sure we could assign to
the word of a variable array, but not the word of a net array.
It's actually probably not needed since Icarus converts the
net array word reference to just the net, but I thought it
prudent to make sure things didn't slip by.
2009-02-27 18:00:59 -08:00
Stephen Williams 3aaea46144 Content-free portability fixes.
These are patches from ITOH Yasufumi and Larry Doolittle of pr2120948.
They change nothing, but make the code compile with older compilers.
2008-09-29 18:06:47 -07:00
Holger Wächtler c71e930ffa $fscanf("%s"): accept '-' and '_' chars. 2008-08-05 15:26:16 -07:00
Holger Wächtler 15584a4f81 fix $fscan("%d") for values > 32 bit
The old code returns a vpiIntVal for $fscanf("%d") format strings. This
limits the maximum input range arbitrarily to 32 bit.

This patch implements %d parsing similiar to %b and %x.

'?' and 'X' chars are not accepted for %d format.
2008-08-05 15:26:09 -07:00
Larry Doolittle eed4ff7e2d Spelling fixes
Mostly comments, but includes quite a few
user-visible error, debug, and help messages.
2008-06-13 08:51:28 -07:00
Cary R 538d3d1f4d Print an error message if $fscanf() is called with a NULL fd.
If $fscanf() is called with a NULL file descriptor an appropriate
error message is printed and the program exits.
2008-02-20 17:16:52 -08:00
Cary R 528af27769 Fix a realloc size error and initialize enable_ in the dff.
The buffer reallocation in scan_format_string() was one character
too small. The enable_ pin to the dff primitive was not given an
initial value.
2008-02-19 10:06:44 -08:00
Larry Doolittle 39dd22ace4 Adjust unusual spacing
minimal changes, nearly eliminates oddball/inconsistent
source code use of whitespace
2008-02-19 09:15:03 -08:00
Stephen Williams 3ea72109f8 Read and include sign of scanned decimal.
Fix simple bug where negative values read from the source file were
not getting their sign. The fix was proposed in pr1876738.
2008-01-21 18:11:28 -08:00
Stephen Williams 26aee6cbae Clean up warnings for round() function declaration. 2007-11-30 21:11:27 -08:00
Cary R 965374acf9 Implement $feof() from 1364-2005.
This patch implements the $feof() function from 1364-2005. It also
comments out a debugging line in the scanf code.
2007-11-02 20:27:48 -07:00
steve 253fdc6232 Fix scanf to abort on failed matches. 2007-04-16 00:09:58 +00:00
steve 611d2c81b3 Spelling fixes from Larry 2007-03-22 16:08:14 +00:00
steve 72ec3a2c09 VPI tasks take PLI_BYTE* by the standard. 2007-03-14 04:05:51 +00:00
steve ae88f5cc68 Lint fixes. 2007-03-07 00:38:15 +00:00
steve 841378426f Updates for Cygwin portability (pr1585922) 2006-10-30 22:45:36 +00:00
steve 6f34dfc8e5 Scanf formats for character and string. 2006-08-12 04:16:07 +00:00
steve 2c7e96caec scanf support for real values. 2006-08-12 03:38:12 +00:00
steve 382c4d74fd Add the scanf functions. 2006-08-03 05:06:04 +00:00