Kevin O'Connor wrote:
> On Thu, Jul 05, 2007 at 01:46:30AM +0100, Pedro Alves wrote:
>> This is the part I was trying to get right with the macros:
>>
>>> __asm__(
>>>     // Data to be placed at start of .text section
>>>     "\t.section .init\n"
>>>     "\t.word eh_handler\n"
>>>     "\t.word 0\n"
>>>     "start_eh_text:\n"
>>>
>> This is documented to having to be placed immediately before the function it
>> corresponds to ...
                   ^^^
LOL this was supposed to be be a sentence finished below ...


> The trick here is that the default linker script will put sections
> labeled with ".init" into the very first part of .text.
> 

... where I would comment that this is a nice hack. :)

> $ /opt/mingw32ce/bin/arm-wince-mingw32ce-objdump -Dr out/haret-debug
> 
> Disassembly of section .text:
> 
> 00011000 <___crt_xc_end__>:
>    11000:       000183b8        streqh  r8, [r1], -r8
>    11004:       00000000        andeq   r0, r0, r0
> 
> 00011008 <WinMainCRTStartup>:
>    11008:       e92d40f0        stmdb   sp!, {r4, r5, r6, r7, lr}
>    1100c:       e1a04000        mov     r4, r0
>    11010:       e1a05001        mov     r5, r1
> [...]
> 
> Disassembly of section .pdata:
> 
> 00035000 <.pdata>:
>    35000:       00011008        andeq   r1, r1, r8
>    35004:       cfffff02        svcgt   0x00ffff02
> 
>> Anyway,
>> Looks nice and simple,  I'll give it a try tomorrow too.  Thanks.
> 
> Thanks.  And thanks Danny for your code and comments as well.
> 
> BTW, I've attached a newer version.  I think I'll check this into
> haret's cvs if testing continues to look good.
> 
> Sample usage:
> 
>   TRY_EXCEPTION_HANDLER
>   {
>     while (wcount--)
>       *vaddr++ = value;
>   }
>   CATCH_EXCEPTION_HANDLER
>   {
>     Output(C_ERROR "EXCEPTION while writing %08x to address %p",
>       value, vaddr);
>   }
> 
> I still don't know why I can't leave the exception handler with
> EXCEPTION_CONTINUE_EXECUTION..
> 

I'll give that a shot tomorrow.

#define TRY_EXCEPTION_HANDLER                   \
     struct eh_data __ehd;                       \
     int __ret = setjmp(__ehd.env);              \
     if (!__ret) {                               \
         start_ehandling(&__ehd);

#define CATCH_EXCEPTION_HANDLER                 \
         end_ehandling(&__ehd);                  \
     } else

Very nice.  Hiding the __ehd would be great.  If not possible
then I suggest at least adding ##__LINE__ to it.

#define TRY_EXCEPTION_HANDLER                   \
     struct eh_data __ehd ## __LINE__ ;          \
(...)

( TRY_SEH, CATCH_SEH seems shorter to type :) )

Cheers,
Pedro Alves


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Cegcc-devel mailing list
Cegcc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cegcc-devel

Reply via email to