Craig,

Which compiler are you using?  If it's gcc then try including the following
in a header file and then calling CALLBACK_PROLOGUE at the beggining of your
function and CALLBACK_EPILOGUE at the end of it and see if that helps.

/////////////////////////////////////////////
// callback.h

#ifndef __CALLBACK_H__
#define __CALLBACK_H__

/* This is a workaround for a bug in the current version of gcc: gcc assumes
   that no one will touch %a4 after it is set up in crt0.o. This isn't true
   if a function is called as a callback by something that wasn't compiled
by
   gcc (like FrmCloseAllForms()).  It may also not be true if it is used as
a
   callback by something in a different shared library. We really want a
function
   attribute "callback" that inserts this prologue and epilogue
automatically.
- Ian */

register void *reg_a4 asm("%a4");

#define CALLBACK_PROLOGUE    void *save_a4 = reg_a4; asm("move.l %%a5,%%a4; 
sub.l #edata,%%a4" : :);
#define CALLBACK_EPILOGUE reg_a4 = save_a4;

#endif

"Craig Allan Jeffree" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> Hello all,
> I have the following function in a virtual driver:
>
> static Err responseNotification(SysNotifyParamType *notifyParamsP)
> {
>     Err err;
>     static UInt16 count = 0;
>
>     notificationBufferP data =
> (notificationBufferP)(notifyParamsP->notifyDetailsP);
>
>     if (notifyParamsP->notifyType == kDrvrCreatorType &&
> notifyParamsP->broadcaster == kDrvrCreatorType)
>     {
>         LOG_PRINTF_F((data->globals->logInfoP, "  Sending: (%u)\n",
> data->bufSize));
>         LOG_DUMPASC_DS((data->globals->logInfoP, (UInt8*) data->buf,
> data->bufSize));
>         SrmSend(data->globals->portRef, (void *)data->buf,
> (UInt32)data->bufSize, &err);
>         MemPtrFree(data->buf);
>
>         ((SysNotifyParamType *)notifyParamsP)->handled = true;
>
>         LOG_PRINTF_F((data->globals->logInfoP, "Count = %u\n", count));
>
> if (count < 3)
>     {
>     // Reprime the wake up handler
>             LOG_PRINTF_F((data->globals->logInfoP, "  repriming wakeup
> handler\n"));
>         err = SrmPrimeWakeupHandler(data->globals->portRef, 1);
>
>             count++;
>         }
>
>     }
>     return 0;
> }
>
> The function is used to respond to a notification broadcast sent by
> another part of my code.  The problem is that the function works fine
> and all the variables check out in the network connection dialog box -
> but when I go to an application that uses the serial manager the
> function crashes.  Does this occure because the code has been moved and
> the pointer has become invalid?
>
> To help me figure this out I added the count variable so that it would
> only get triggered the first time in the application (it gets triggered
> twice immediately after connection).  The problem is that the count
> variable gets logged as having strange random values in the thousands
> and the if (count < 3) never gets entered.  The only way I can see this
> happening is if the stack has been totally screwed by a mismatch in the
> amount of data pushed on compared to the amount expected to be there.
> I'm guessing that the screwy stack could cause the count variable to be
> refered to wrong - but then that would only mean the wrong place in
> memory would be set to zero and then seen as zero . . . anyway back to
> my point...
>
> What could possibly be going wrong to cause this to happen?
>
>
> Thanks in advance,
> Craig.
>
> --
> Craig Jeffree [EMAIL PROTECTED]
> dotWAP.com Inc.   http://www.dotwap.com/
> Melbourne, Australia
>
>





-- 
For information on using the ACCESS Developer Forums, or to unsubscribe, please 
see http://www.access-company.com/developers/forums/

Reply via email to