SCP: Add ability to descriptively name UNITs

This allows a device simulator to specifically name the units that it uses
for different purposes.  This info is visible in the output of SHOW QUEUE
and debug output.

Once specified or dynamically determined (as previously occurred with
each call to sim_uname()), that name is saved for fast delivery on subsequent
calls.  This will remove some overhead when running with debugging on.
This commit is contained in:
Mark Pizzolato 2017-02-06 10:27:01 -08:00
parent 7050a1aef5
commit 692b9abe5f
3 changed files with 18 additions and 5 deletions

21
scp.c
View file

@ -5791,17 +5791,28 @@ return (dptr ? (dptr->lname? dptr->lname: dptr->name) : "");
const char *sim_uname (UNIT *uptr)
{
DEVICE *d = find_dev_from_unit(uptr);
static AIO_TLS char uname[CBUFSIZE];
DEVICE *d;
char uname[CBUFSIZE];
if (uptr->uname)
return uptr->uname;
d = find_dev_from_unit(uptr);
if (!d)
return "";
if (d->numunits == 1)
return sim_dname (d);
sprintf (uname, "%s%d", sim_dname (d), (int)(uptr-d->units));
return uname;
sprintf (uname, "%s", sim_dname (d));
else
sprintf (uname, "%s%d", sim_dname (d), (int)(uptr-d->units));
return sim_set_uname (uptr, uname);
}
const char *sim_set_uname (UNIT *uptr, const char *uname)
{
free (uptr->uname);
uptr->uname = strcpy ((char *)malloc (1 + strlen (uname)), uname);
}
/* Save command
sa[ve] filename save state to specified file

1
scp.h
View file

@ -144,6 +144,7 @@ t_stat reset_all (uint32 start_device);
t_stat reset_all_p (uint32 start_device);
const char *sim_dname (DEVICE *dptr);
const char *sim_uname (UNIT *dptr);
const char *sim_set_uname (UNIT *uptr, const char *uname);
t_stat get_yn (const char *ques, t_stat deflt);
int sim_isspace (char c);
int sim_islower (char c);

View file

@ -547,6 +547,7 @@ struct UNIT {
void *tmxr; /* TMXR linkage */
t_bool (*cancel)(UNIT *);
double usecs_remaining; /* time balance for long delays */
char *uname; /* Unit name */
#ifdef SIM_ASYNCH_IO
void (*a_check_completion)(UNIT *);
t_bool (*a_is_active)(UNIT *);