Further fixes for const-correctness.

- allow ICARUS_VPI_CONST to be pre-defined by the user
- use it for sizetf as well as for compiletf and calltf
- fix remaining warnings when it is defined as 'const'
This commit is contained in:
Martin Whitaker 2018-09-29 08:53:32 +01:00
parent 8df2f0cadf
commit 0d494da702
7 changed files with 35 additions and 34 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2014 Michael Ruff (mruff at chiaro.com)
* Copyright (c) 2002-2018 Michael Ruff (mruff at chiaro.com)
* Michael Runyan (mrunyan at chiaro.com)
*
* This source code is free software; you can redistribute it
@ -42,8 +42,8 @@ typedef struct t_pli_data {
int paramvc; /* parameter number for misctf */
} s_pli_data, *p_pli_data;
static PLI_INT32 compiletf(char *);
static PLI_INT32 calltf(char *);
static PLI_INT32 compiletf(ICARUS_VPI_CONST PLI_BYTE8 *);
static PLI_INT32 calltf(ICARUS_VPI_CONST PLI_BYTE8 *);
static PLI_INT32 callback(p_cb_data);
/*
@ -150,7 +150,7 @@ void veriusertfs_register_table(p_tfcell vtable)
tf_data.tfname = tf->tfname;
tf_data.compiletf = compiletf;
tf_data.calltf = calltf;
tf_data.sizetf = (PLI_INT32 (*)(PLI_BYTE8 *))tf->sizetf;
tf_data.sizetf = (PLI_INT32 (*)(ICARUS_VPI_CONST PLI_BYTE8 *))tf->sizetf;
tf_data.user_data = (char *)data;
if (pli_trace) {
@ -180,7 +180,7 @@ void veriusertfs_register_table(p_tfcell vtable)
* This function calls the veriusertfs checktf and sets up all the
* callbacks misctf requires.
*/
static PLI_INT32 compiletf(char *data)
static PLI_INT32 compiletf(ICARUS_VPI_CONST PLI_BYTE8*data)
{
p_pli_data pli;
p_tfcell tf;
@ -260,7 +260,7 @@ static PLI_INT32 compiletf(char *data)
/*
* This function is the wrapper for the veriusertfs calltf routine.
*/
static PLI_INT32 calltf(char *data)
static PLI_INT32 calltf(ICARUS_VPI_CONST PLI_BYTE8*data)
{
int rc = 0;
p_pli_data pli;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003-2014 Michael Ruff (mruff at chiaro.com)
* Copyright (c) 2003-2018 Michael Ruff (mruff at chiaro.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -90,12 +90,12 @@ static void error_message(vpiHandle callh, const char* msg)
vpi_control(vpiFinish, 1);
}
static PLI_INT32 sizetf_32 (PLI_BYTE8*name)
static PLI_INT32 sizetf_32 (ICARUS_VPI_CONST PLI_BYTE8*name)
{
(void)name; /* Parameter is not used. */
return 32;
}
static PLI_INT32 sizetf_64 (PLI_BYTE8*name)
static PLI_INT32 sizetf_64 (ICARUS_VPI_CONST PLI_BYTE8*name)
{
(void)name; /* Parameter is not used. */
return 64;
@ -288,4 +288,3 @@ void sys_convert_register(void)
res = vpi_register_systf(&tf_data);
vpip_make_systf_system_defined(res);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2014 Stephen Williams (steve@icarus.com)
* Copyright (c) 2000-2018 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -924,7 +924,7 @@ static PLI_INT32 sys_dist_erlang_calltf(ICARUS_VPI_CONST PLI_BYTE8 *name)
return 0;
}
static PLI_INT32 sys_rand_func_sizetf(PLI_BYTE8 *name)
static PLI_INT32 sys_rand_func_sizetf(ICARUS_VPI_CONST PLI_BYTE8 *name)
{
(void)name; /* Parameter is not used. */
return 32;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006-2015 Stephen Williams (steve@icarus.com)
* Copyright (c) 2006-2018 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -219,7 +219,7 @@ static double get_float(struct byte_source *src, unsigned width, int *match)
*/
static int scan_format_float(vpiHandle callh, vpiHandle argv,
struct byte_source *src, unsigned width,
unsigned suppress_flag, PLI_BYTE8 *name,
unsigned suppress_flag, ICARUS_VPI_CONST PLI_BYTE8 *name,
char code)
{
vpiHandle arg;
@ -266,7 +266,7 @@ static int scan_format_float(vpiHandle callh, vpiHandle argv,
*/
static int scan_format_float_time(vpiHandle callh, vpiHandle argv,
struct byte_source*src, unsigned width,
unsigned suppress_flag, PLI_BYTE8 *name)
unsigned suppress_flag, ICARUS_VPI_CONST PLI_BYTE8 *name)
{
vpiHandle scope = vpi_handle(vpiScope, callh);
int time_units = vpi_get(vpiTimeUnit, scope);
@ -330,7 +330,7 @@ static int scan_format_float_time(vpiHandle callh, vpiHandle argv,
*/
static int scan_format_base(vpiHandle callh, vpiHandle argv,
struct byte_source *src, unsigned width,
unsigned suppress_flag, PLI_BYTE8 *name,
unsigned suppress_flag, ICARUS_VPI_CONST PLI_BYTE8 *name,
const char *match, char code,
PLI_INT32 type)
{
@ -406,7 +406,7 @@ static int scan_format_base(vpiHandle callh, vpiHandle argv,
*/
static int scan_format_binary(vpiHandle callh, vpiHandle argv,
struct byte_source *src, int width,
unsigned suppress_flag, PLI_BYTE8 *name)
unsigned suppress_flag, ICARUS_VPI_CONST PLI_BYTE8 *name)
{
return scan_format_base(callh, argv, src, width, suppress_flag, name,
"01xzXZ?_", 'b', vpiBinStrVal);
@ -420,7 +420,7 @@ static int scan_format_binary(vpiHandle callh, vpiHandle argv,
*/
static int scan_format_char(vpiHandle callh, vpiHandle argv,
struct byte_source *src, unsigned width,
unsigned suppress_flag, PLI_BYTE8 *name)
unsigned suppress_flag, ICARUS_VPI_CONST PLI_BYTE8 *name)
{
vpiHandle arg;
s_vpi_value val;
@ -466,7 +466,7 @@ static int scan_format_char(vpiHandle callh, vpiHandle argv,
*/
static int scan_format_decimal(vpiHandle callh, vpiHandle argv,
struct byte_source *src, unsigned width,
unsigned suppress_flag, PLI_BYTE8 *name)
unsigned suppress_flag, ICARUS_VPI_CONST PLI_BYTE8 *name)
{
vpiHandle arg;
char *strval = malloc(1);
@ -585,7 +585,7 @@ static int scan_format_decimal(vpiHandle callh, vpiHandle argv,
*/
static int scan_format_hex(vpiHandle callh, vpiHandle argv,
struct byte_source *src, unsigned width,
unsigned suppress_flag, PLI_BYTE8 *name)
unsigned suppress_flag, ICARUS_VPI_CONST PLI_BYTE8 *name)
{
return scan_format_base(callh, argv, src, width, suppress_flag, name,
"0123456789abcdefxzABCDEFXZ?_", 'h',
@ -597,7 +597,7 @@ static int scan_format_hex(vpiHandle callh, vpiHandle argv,
*/
static int scan_format_octal(vpiHandle callh, vpiHandle argv,
struct byte_source *src, unsigned width,
unsigned suppress_flag, PLI_BYTE8 *name)
unsigned suppress_flag, ICARUS_VPI_CONST PLI_BYTE8 *name)
{
return scan_format_base(callh, argv, src, width, suppress_flag, name,
"01234567xzXZ?_", 'o', vpiOctStrVal);
@ -608,7 +608,7 @@ static int scan_format_octal(vpiHandle callh, vpiHandle argv,
* Routine to return the current hierarchical path (implements %m).
*/
static int scan_format_module_path(vpiHandle callh, vpiHandle argv,
unsigned suppress_flag, PLI_BYTE8 *name)
unsigned suppress_flag, ICARUS_VPI_CONST PLI_BYTE8 *name)
{
vpiHandle scope, arg;
char *module_path;
@ -650,7 +650,7 @@ static int scan_format_module_path(vpiHandle callh, vpiHandle argv,
*/
static int scan_format_string(vpiHandle callh, vpiHandle argv,
struct byte_source *src, unsigned width,
unsigned suppress_flag, PLI_BYTE8 *name)
unsigned suppress_flag, ICARUS_VPI_CONST PLI_BYTE8 *name)
{
vpiHandle arg;
char *strval = malloc(1);
@ -729,7 +729,7 @@ static int scan_format_string(vpiHandle callh, vpiHandle argv,
*/
static int scan_format_two_state(vpiHandle callh, vpiHandle argv,
struct byte_source *src, unsigned width,
unsigned suppress_flag, PLI_BYTE8 *name)
unsigned suppress_flag, ICARUS_VPI_CONST PLI_BYTE8 *name)
{
vpiHandle arg;
p_vpi_vecval val_ptr;
@ -868,7 +868,7 @@ static int scan_format_two_state(vpiHandle callh, vpiHandle argv,
*/
static int scan_format_four_state(vpiHandle callh, vpiHandle argv,
struct byte_source *src, unsigned width,
unsigned suppress_flag, PLI_BYTE8 *name)
unsigned suppress_flag, ICARUS_VPI_CONST PLI_BYTE8 *name)
{
vpiHandle arg;
p_vpi_vecval val_ptr;
@ -1006,7 +1006,7 @@ static int scan_format_four_state(vpiHandle callh, vpiHandle argv,
* passed to this function, which processes the rest of the function.
*/
static int scan_format(vpiHandle callh, struct byte_source*src, vpiHandle argv,
PLI_BYTE8 *name)
ICARUS_VPI_CONST PLI_BYTE8 *name)
{
s_vpi_value val;
vpiHandle item;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 Stephen Williams (steve@icarus.com)
* Copyright (c) 2010-2018 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -226,7 +226,7 @@ static void fill_handle_with_init(vpiHandle arg, int is_two_state)
/*
* Implement the next()/prev() enumeration methods.
*/
static PLI_INT32 ivl_enum_method_next_prev_calltf(PLI_BYTE8*name)
static PLI_INT32 ivl_enum_method_next_prev_calltf(ICARUS_VPI_CONST PLI_BYTE8*name)
{
vpiHandle sys = vpi_handle(vpiSysTfCall, 0);
vpiHandle argv = vpi_iterate(vpiArgument, sys);
@ -431,7 +431,7 @@ static PLI_INT32 ivl_enum_method_name_compiletf(ICARUS_VPI_CONST PLI_BYTE8*name)
/*
* Implement the name() enumeration method.
*/
static PLI_INT32 ivl_enum_method_name_calltf(PLI_BYTE8*name)
static PLI_INT32 ivl_enum_method_name_calltf(ICARUS_VPI_CONST PLI_BYTE8*name)
{
vpiHandle sys = vpi_handle(vpiSysTfCall, 0);
vpiHandle argv = vpi_iterate(vpiArgument, sys);

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2008-2014 Cary R. (cygcary@yahoo.com)
* Copyright (C) 2008-2018 Cary R. (cygcary@yahoo.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -247,7 +247,7 @@ static PLI_INT32 simparam_str_calltf(ICARUS_VPI_CONST PLI_BYTE8 *name_ext)
return 0;
}
static PLI_INT32 simparam_str_sizetf(PLI_BYTE8 *name_ext)
static PLI_INT32 simparam_str_sizetf(ICARUS_VPI_CONST PLI_BYTE8 *name_ext)
{
(void) name_ext; /* Parameter is not used. */
return MAX_STRING_RESULT; /* 128 characters max! */

View File

@ -1,7 +1,7 @@
#ifndef VPI_USER_H
#define VPI_USER_H
/*
* Copyright (c) 1999-2014 Stephen Williams (steve@icarus.com)
* Copyright (c) 1999-2018 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -46,7 +46,9 @@ EXTERN_C_START
# include <stdarg.h>
# include "_pli_types.h"
#ifndef ICARUS_VPI_CONST
#define ICARUS_VPI_CONST
#endif
#ifdef __cplusplus
typedef class __vpiHandle *vpiHandle;
#else
@ -63,7 +65,7 @@ typedef struct t_vpi_systf_data {
const char *tfname;
PLI_INT32 (*calltf) (ICARUS_VPI_CONST PLI_BYTE8*);
PLI_INT32 (*compiletf)(ICARUS_VPI_CONST PLI_BYTE8*);
PLI_INT32 (*sizetf) (PLI_BYTE8*);
PLI_INT32 (*sizetf) (ICARUS_VPI_CONST PLI_BYTE8*);
ICARUS_VPI_CONST PLI_BYTE8 *user_data;
} s_vpi_systf_data, *p_vpi_systf_data;
@ -466,7 +468,7 @@ typedef struct t_cb_data {
p_vpi_time time;
p_vpi_value value;
PLI_INT32 index;
char *user_data;
ICARUS_VPI_CONST PLI_BYTE8 *user_data;
} s_cb_data, *p_cb_data;
#define cbValueChange 1