avoid some function pointer warnings

This commit is contained in:
rlar 2010-06-26 17:12:56 +00:00
parent b58722b18b
commit be57f10b3b
4 changed files with 26 additions and 8 deletions

View File

@ -1,3 +1,9 @@
2010-06-26 Robert Larice
* src/include/inpptree.h,
* src/spicelib/parser/ifeval.c,
* src/spicelib/parser/inpptree.c :
avoid function pointer warnings
2010-06-25 Robert Larice
* src/frontend/com_hardcopy.c,
* src/maths/sparse/spbuild.c,

View File

@ -50,10 +50,22 @@ typedef struct INPparseNode {
int valueIndex; /* If INP_VAR, index into vars array. */
char *funcname; /* If INP_FUNCTION, name of function, */
int funcnum; /* ... one of PTF_*, */
double (*function)(); /* ... and pointer to the function. */
void *function; /* ... and pointer to the function. */
void *data; /* private data for certain functions, currently PTF_PWL */
} INPparseNode;
/* FIXME, less public
* and replace with static inline functions for better type check
*/
#define PTunary(node_ptr) \
((double(*)(double)) (node_ptr))
#define PTbinary(node_ptr) \
((double(*)(double, double)) (node_ptr))
#define PTunary_with_private(node_ptr) \
((double(*)(double, void*)) (node_ptr))
/* These are the possible types of nodes we can have in the parse tree. The
* numbers for the ops 1 - 5 have to be the same as the token numbers,
* below.

View File

@ -83,7 +83,7 @@ PTeval(INPparseNode * tree, double gmin, double *res, double *vals)
err = PTeval(tree->left->right, gmin, &r2, vals);
if (err != OK)
return (err);
*res = (*tree->function) (r1, r2);
*res = PTbinary(tree -> function) (r1, r2);
if (*res == HUGE) {
fprintf(stderr, "Error: %g, %g out of range for %s\n",
r1, r2, tree->funcname);
@ -96,9 +96,9 @@ PTeval(INPparseNode * tree, double gmin, double *res, double *vals)
if (err != OK)
return (err);
if(tree->data == NULL)
*res = (*tree->function) (r1);
*res = PTunary(tree -> function) (r1);
else
*res = (*tree->function) (r1, tree->data);
*res = PTunary_with_private(tree -> function) (r1, tree->data);
if (*res == HUGE) {
fprintf(stderr, "Error: %g out of range for %s\n",
r1, tree->funcname);
@ -138,7 +138,7 @@ PTeval(INPparseNode * tree, double gmin, double *res, double *vals)
err = PTeval(tree->right, gmin, &r2, vals);
if (err != OK)
return (err);
*res = (*tree->function) (r1, r2);
*res = PTbinary(tree -> function) (r1, r2);
if (*res == HUGE) {
fprintf(stderr, "Error: %g, %g out of range for %s\n",
r1, r2, tree->funcname);

View File

@ -42,7 +42,7 @@ extern IFsimulator *ft_sim; /* XXX */
static struct op {
int number;
char *name;
double (*funcptr) ();
void *funcptr;
} ops[] = {
{
PT_COMMA, ",", NULL}, {
@ -58,7 +58,7 @@ static struct op {
static struct func {
char *name;
int number;
double (*funcptr) ();
void *funcptr;
} funcs[] = {
{ "abs", PTF_ABS, PTabs } ,
{ "acos", PTF_ACOS, PTacos } ,
@ -665,7 +665,7 @@ static INPparseNode *mkf(int type, INPparseNode * arg)
}
if (arg->type == PT_CONSTANT) {
constval = ((*funcs[i].funcptr) (arg->constant));
constval = PTunary(funcs[i].funcptr) (arg->constant);
return (mkcon(constval));
}