[DGD] Is Running Atomically.

Gary gary at mups.co.uk
Sat Sep 24 19:18:05 CEST 2016


I had the need to determine if a piece of code (within my logd) was
running as part of an atomic call chain so that write_file calls could
be avoided.

I've added a kfun to extra.cpp as follows

----

# ifdef FUNCDEF
FUNCDEF("running_atomically", kf_running_atomically,
pt_running_atomically, 0)
# else
char pt_running_atomically[] = { C_STATIC, 0, 0, 0, 6, T_INT };

/*
 * NAME:	kfun->running_atomically()
 * DESCRIPTION:	returns whether the caller is executing within an atomic
frame
 */
int kf_running_atomically(Frame *f, int n, kfunc *kf)
{
    UNREFERENCED_PARAMETER(n);
    UNREFERENCED_PARAMETER(kf);

    PUSH_INTVAL(f, (f->level != 0));

    return 0;
}
# endif

----

Whilst this appears to work correctly, I've a couple of questions as
I've not really looked into the dgd source all that much yet.

Is C_STATIC correct? What is this param for? I noticed there's also
C_PRIVATE, C_ATOMIC, C_MASK... which can be or'd into the mask, does
this define what the LPC prototype would be for any auto object override
of the kfun or serve another purpose?

The first 0 appears to be number of passed in arguments to the kfun, in
this case 0. What are the 2nd and 3rd 0s for? What is the 6 for?

Is there any documentation that provides any a rough overview as to the
internals of DGD? I'm guessing not and it's just a case of diving in and
tracing through, but figured it was worth asking.

Also, is this of any general use to others and would it really be better
off as an lpc extension?

Regards,

Gary



More information about the DGD mailing list