Add preliminary support for vpiUserSystf, vpi_get_systf_info(), etc.

This patch changes system tasks and functions to use the vpiUserSystf
property and returns this information when vpi_register_systf() is
called. It also adds the vpiUserDefn property for system tasks and
functions which for now always returns 1 (true). System task and
functions can now get a handle to this information using the
vpiUserSystf property. vpi_systf_info() returns pointers to the
real data so the user will need to be careful when using the pointer
fields (e.g. tfname, user_data, etc.). This is a shallow copy. A deep
copy would require the user to free the various fields and I'm not
certain it is even possible or desirable to copy the user_data for
all cases.

A stub for vpi_compare_objects() was also added since I will need
that when testing the second half of the patch (add iteration over
all the vpiUserSystf objects and add a method to control vpiUserDefn).
This commit is contained in:
Cary R
2010-04-13 20:54:43 -07:00
committed by Stephen Williams
parent 7a0e23179b
commit aa1cd1646c
4 changed files with 69 additions and 19 deletions
+20 -17
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001-2009 Stephen Williams ([email protected])
* Copyright (c) 2001-2010 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -37,18 +37,8 @@
# include <string.h>
# include <assert.h>
static const struct __vpirt vpip_systask_def_rt = {
vpiSysTask,
0,
0,
0,
0,
0,
0
};
static const struct __vpirt vpip_sysfunc_def_rt = {
vpiSysFunc,
static const struct __vpirt vpip_systf_def_rt = {
vpiUserSystf,
0,
0,
0,
@@ -67,6 +57,11 @@ static vpiHandle systask_handle(int type, vpiHandle ref)
case vpiScope:
return &rfp->scope->base;
case vpiUserSystf:
/* Assert that vpiUserDefn is true! */
assert(1);
return &rfp->defn->base;
default:
return 0;
};
@@ -91,6 +86,10 @@ static int systask_get(int type, vpiHandle ref)
case vpiLineNo:
return rfp->lineno;
/* For now we always have this information. */
case vpiUserDefn:
return 1;
default:
return vpiUndefined;
}
@@ -110,6 +109,10 @@ static int sysfunc_get(int type, vpiHandle ref)
case vpiLineNo:
return rfp->lineno;
/* For now we always have this information. */
case vpiUserDefn:
return 1;
default:
return vpiUndefined;
}
@@ -723,16 +726,14 @@ void vpip_execute_vpi_call(vthread_t thr, vpiHandle ref)
* __vpi_userSystf to represent the definition for the calls that come
* to pass later.
*/
void vpi_register_systf(const struct t_vpi_systf_data*ss)
vpiHandle vpi_register_systf(const struct t_vpi_systf_data*ss)
{
struct __vpiUserSystf*cur = allocate_def();
assert(ss);
switch (ss->type) {
case vpiSysTask:
cur->base.vpi_type = &vpip_systask_def_rt;
break;
case vpiSysFunc:
cur->base.vpi_type = &vpip_sysfunc_def_rt;
cur->base.vpi_type = &vpip_systf_def_rt;
break;
default:
fprintf(stderr, "Unsupported type %d.\n", (int)ss->type);
@@ -741,6 +742,8 @@ void vpi_register_systf(const struct t_vpi_systf_data*ss)
cur->info = *ss;
cur->info.tfname = strdup(ss->tfname);
return &cur->base;
}
PLI_INT32 vpi_put_userdata(vpiHandle ref, void*data)