Alan Carvalho de Assis wrote:
> Hi Borut,
>
> 2007/11/6, Borut Razem <[EMAIL PROTECTED]>:
>   
>> #define SAVE_TASK_CTX(stack_low, stack_high)                           \
>> do {                                                                   \
>>     /* Disable global interrupt. */                                    \
>>         _asm                                                           \
>>         bcf     INTCON, 6, 0                                           \
>>         _endasm;                                                       \
>>         _asm                                                           \
>>         movff   STATUS, PREINC1                                        \
>>         _endasm;                                                       \
>>         _asm                                                           \
>>         movff   WREG, PREINC1                                          \
>>         _endasm;                                                       \
>>     /* Store the necessary registers to the stack. */                  \
>>         ...
>> } while (0)
>>
>>
>> so that the following cases work correctly:
>>
>> if (...)
>>   SAVE_TASK_CTX(stack_low, stack_high);
>>
>>
>> if (...)
>>   SAVE_TASK_CTX(stack_low, stack_high);
>> else
>>   ...
>>
>>     
>
> Yes. I saw this tips at kernelnewbies.org some years ago. I'm
> wondering because the original code works, see the pro_man.c from
> PICos18:
>
>   if (kernelState & USER)
>     SAVE_TASK_CTX(stack_low, stack_high);
>   SCHEDULE;
>
> Very strange!
>
> Cheers,
>
>   
Your original code wouldn't work in the second example:

if (...)
  SAVE_TASK_CTX(stack_low, stack_high);
else
  ...

because there is a semicolon (an additional null statement) before else.

Borut



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to