Write mark PCF types for thread PVT
This commit is contained in:
parent
ea79c90c89
commit
b4d445b378
@ -23,6 +23,7 @@ struct mark_label {
|
|||||||
|
|
||||||
struct mark_type {
|
struct mark_type {
|
||||||
long type;
|
long type;
|
||||||
|
long prvtype;
|
||||||
long index; /* From 0 to ntypes - 1 */
|
long index; /* From 0 to ntypes - 1 */
|
||||||
enum chan_type ctype;
|
enum chan_type ctype;
|
||||||
struct mark_label *labels; /* Hash table of labels */
|
struct mark_label *labels; /* Hash table of labels */
|
||||||
@ -155,6 +156,7 @@ create_mark_type(struct ovni_mark_emu *m, long type, const char *chan_type, cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
t->type = type;
|
t->type = type;
|
||||||
|
t->prvtype = type + PRV_OVNI_MARK;
|
||||||
t->index = m->ntypes;
|
t->index = m->ntypes;
|
||||||
|
|
||||||
int len = snprintf(t->title, MAX_PCF_LABEL, "%s", title);
|
int len = snprintf(t->title, MAX_PCF_LABEL, "%s", title);
|
||||||
@ -352,7 +354,7 @@ connect_thread_prv(struct emu *emu, struct thread *sth, struct prv *prv)
|
|||||||
struct chan *ch = &mth->channels[i];
|
struct chan *ch = &mth->channels[i];
|
||||||
long row = sth->gindex;
|
long row = sth->gindex;
|
||||||
long flags = 0;
|
long flags = 0;
|
||||||
long prvtype = type->type + PRV_OVNI_MARK;
|
long prvtype = type->prvtype;
|
||||||
if (prv_register(prv, row, prvtype, &emu->bay, ch, flags)) {
|
if (prv_register(prv, row, prvtype, &emu->bay, ch, flags)) {
|
||||||
err("prv_register failed");
|
err("prv_register failed");
|
||||||
return -1;
|
return -1;
|
||||||
@ -362,6 +364,41 @@ connect_thread_prv(struct emu *emu, struct thread *sth, struct prv *prv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
create_type(struct pcf *pcf, struct mark_type *type)
|
||||||
|
{
|
||||||
|
struct pcf_type *pcftype = pcf_add_type(pcf, type->prvtype, type->title);
|
||||||
|
if (pcftype == NULL) {
|
||||||
|
err("pcf_add_type failed");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (struct mark_label *l = type->labels; l; l = l->hh.next) {
|
||||||
|
if (pcf_add_value(pcftype, l->value, l->label) == NULL) {
|
||||||
|
err("pcf_add_value failed");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
init_pcf(struct emu *emu, struct pcf *pcf)
|
||||||
|
{
|
||||||
|
struct ovni_emu *oemu = EXT(emu, 'O');
|
||||||
|
struct ovni_mark_emu *m = &oemu->mark;
|
||||||
|
|
||||||
|
for (struct mark_type *type = m->types; type; type = type->hh.next) {
|
||||||
|
if (create_type(pcf, type) != 0) {
|
||||||
|
err("create_type failed");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
connect_thread(struct emu *emu)
|
connect_thread(struct emu *emu)
|
||||||
{
|
{
|
||||||
@ -381,7 +418,13 @@ connect_thread(struct emu *emu)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: Init thread PCF */
|
/* Init thread PCF */
|
||||||
|
struct pcf *pcf = pvt_get_pcf(pvt);
|
||||||
|
if (init_pcf(emu, pcf) != 0) {
|
||||||
|
err("init_pcf failed");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,4 +29,4 @@ test_emu(dummy.c NAME "ovniver" DRIVER "ovniver.driver.sh")
|
|||||||
test_emu(dummy.c NAME "match-doc-events" DRIVER "match-doc-events.sh")
|
test_emu(dummy.c NAME "match-doc-events" DRIVER "match-doc-events.sh")
|
||||||
test_emu(dummy.c NAME "match-doc-version" DRIVER "match-doc-version.sh")
|
test_emu(dummy.c NAME "match-doc-version" DRIVER "match-doc-version.sh")
|
||||||
test_emu(libovni-attr.c)
|
test_emu(libovni-attr.c)
|
||||||
test_emu(libovni-mark.c)
|
test_emu(libovni-mark.c MP)
|
||||||
|
@ -7,32 +7,34 @@
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
MARK_COLORS = 1,
|
MARK_COLORS = 1,
|
||||||
COL_RED = 1,
|
COL_BLUE = 1,
|
||||||
COL_BLUE = 2,
|
COL_GRAY = 2,
|
||||||
COL_GREEN = 3,
|
COL_RED = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Check ovni_mark_* API. */
|
/* Check ovni_mark_* API. */
|
||||||
int
|
int
|
||||||
main(void)
|
main(void)
|
||||||
{
|
{
|
||||||
instr_start(0, 1);
|
int rank = atoi(getenv("OVNI_RANK"));
|
||||||
|
int nranks = atoi(getenv("OVNI_NRANKS"));
|
||||||
|
instr_start(rank, nranks);
|
||||||
|
|
||||||
ovni_mark_type(MARK_COLORS, OVNI_MARK_STACK, "Colors");
|
ovni_mark_type(MARK_COLORS, OVNI_MARK_STACK, "Colors");
|
||||||
|
|
||||||
if(!ovni_attr_has("ovni.mark.1.title"))
|
if(!ovni_attr_has("ovni.mark.1.title"))
|
||||||
die("missing mark title");
|
die("missing mark title");
|
||||||
|
|
||||||
ovni_mark_label(MARK_COLORS, 1, "Blue");
|
ovni_mark_label(MARK_COLORS, COL_BLUE, "Blue");
|
||||||
ovni_mark_label(MARK_COLORS, 2, "Gray");
|
ovni_mark_label(MARK_COLORS, COL_GRAY, "Gray");
|
||||||
ovni_mark_label(MARK_COLORS, 3, "Red");
|
ovni_mark_label(MARK_COLORS, COL_RED, "Red");
|
||||||
|
|
||||||
sleep_us(10); ovni_mark_push(MARK_COLORS, COL_RED);
|
|
||||||
sleep_us(10); ovni_mark_push(MARK_COLORS, COL_BLUE);
|
sleep_us(10); ovni_mark_push(MARK_COLORS, COL_BLUE);
|
||||||
sleep_us(10); ovni_mark_push(MARK_COLORS, COL_GREEN);
|
sleep_us(10); ovni_mark_push(MARK_COLORS, COL_GRAY);
|
||||||
sleep_us(10); ovni_mark_pop(MARK_COLORS, COL_GREEN);
|
sleep_us(10); ovni_mark_push(MARK_COLORS, COL_RED);
|
||||||
|
sleep_us(50); ovni_mark_pop(MARK_COLORS, COL_RED);
|
||||||
|
sleep_us(10); ovni_mark_pop(MARK_COLORS, COL_GRAY);
|
||||||
sleep_us(10); ovni_mark_pop(MARK_COLORS, COL_BLUE);
|
sleep_us(10); ovni_mark_pop(MARK_COLORS, COL_BLUE);
|
||||||
sleep_us(10); ovni_mark_pop(MARK_COLORS, COL_RED);
|
|
||||||
|
|
||||||
instr_end();
|
instr_end();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user