Skarmander wrote:
> Chris Dollin wrote:
>> Sensei wrote:
>>
>>
>>>On 2005-10-10 15:31:40 +0200, Chris Dollin <> said:
>>>
>>>
>>>>Sensei wrote:
>>>>
>>>>
>>>>>So why I see so often something like:
>>>>>
>>>>>#define CEXCERPT do { \
>>>>>some(); \
>>>>>C_code(); \
>>>>>here(); \
>>>>>} while(0)
>>>>>
>>>>>Is it just some person thinking he would achieve more speed?
>>>>
>>>>No, it's some person arranging that their macro can be expanded
>>>>as CEXCERPT;
>>>>
>>>>without confusion. (I would have thought, even more likely
>>>>with a parameterised macro.)
>>>
>>>
>>>I understood why he does not use a ; at the end, but why someone would
>>>have such a big macro... is beyond my knowledge, something like the
>>>xge_whatever stuff I found... 
>>
>>
>> How big is "big"?
>>
>> #define NEEDS(mill, n) \
>> do { \
>> if (vm->myHeap->available < (Size) (n)) \
>> (FREEZE(), millRegenerate( mill ), MELT()); \
>> } while (0)
>>
> #define INLINE inline
>
> INLINE void needs(? mill, Size n) {
> if (vm -> myHeap -> available < n) {
> freeze();
> millRegenerate(mill);
> melt();
> }
> }
Won't work.
FREEZE() is a macro, MELT is a macro, both of them use variables
available where NEEDS is called - such as, for example, `vm`.
And `inline` wasn't routinely available when this code was written;
furthermore, failure to inline is likely to make the code run
significantly more slowly. Since this is part of the system core,
it would matter.
--
Chris "electric hedgehog" Dollin
"I know three kinds: hot, cool, and what-time-does-the-tune-start?"