Missing "unique()" function for batch
Ken Lalonde
kwlalonde at watmath.UUCP
Mon Jun 17 16:10:55 AEST 1985
The batch package I posted to net.sources a while back
made use of unique(), a local system call that returns
a unique number. If you don't want to change your kernel,
you can use
long
unique()
{
long time();
return time(0);
}
There is a remote possibility that the same value may
be returned to two processes. We added this to sys/kern_xxx.c:
/*
* Return a unique number.
* Usually the time of day, but
* with no chance of duplication.
*/
unique()
{
static long lastuniq = 0;
register long uniq;
if (lastuniq == 0)
lastuniq = time.tv_sec;
uniq = time.tv_sec;
if (uniq <= lastuniq)
uniq = lastuniq + 1;
u.u_r.r_val1 = uniq;
lastuniq = uniq;
}
More information about the Comp.sources.unix
mailing list