While I'm digging about in hal_lib.c....
I mentioned earlier that unlinking a pin can also
result in a sudden and unexpected change in its
value, because the pointer now aims at the
dummy, and its value is unlikely to be the same
as the value of the signal the pin was previously
linked to. I said we should copy the signal
value to the dummy on an unlink. That would
look something like this:
3111 static void unlink_pin(hal_pin_t * pin)
3112 {
3113 hal_sig_t *sig;
3114 hal_comp_t *comp;
3115 void *dummy_addr, **data_ptr_addr;
new hal_data_u oldval, *sig_data_addr;
3116
3117 /* is this pin linked to a signal? */
3118 if (pin->signal != 0) {
3119 /* yes, need to unlink it */
3120 sig = SHMPTR(pin->signal);
3121 /* make pin's 'data_ptr' point to its dummy signal */
3122 data_ptr_addr = SHMPTR(pin->data_ptr_addr);
3123 comp = SHMPTR(pin->owner_ptr);
3124 dummy_addr = comp->shmem_base + SHMOFF(&(pin->dummysig));
3125 *data_ptr_addr = dummy_addr;
new /* copy current signal value to dummy */
new sig_data_addr = comp->shmem_base + sig->data_ptr;
new memcpy(dummy_addr, sig_data_addr, sizeof(hal_data_u));
3126 /* update the signal's reader/writer counts */
3127 if ((pin->dir & HAL_IN) != 0) {
3128 sig->readers--;
3129 }
3130 if (pin->dir == HAL_OUT) {
3131 sig->writers--;
3132 }
3133 if (pin->dir == HAL_IO) {
3134 sig->bidirs--;
3135 }
3136 /* mark pin as unlinked */
3137 pin->signal = 0;
3138 }
I'm not 100% sure about the details of the pointer stuff, I'm
rusty.
--
John Kasunich
[email protected]
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers