This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Forcing register assignments before non-conditional blocks


On Sat, 19 Apr 2008 15:19:44 +0200
Simon Kagstrom <simon.kagstrom@gmail.com> wrote:

> For a project of mine [1], I'm using Java exceptions in C code and
> have implemented a construct similar to Java try/catch blocks. I have
> a slight problem with GCC optimization though.

I just wanted to say that I found a solution to this problem (very
simple as well). I defined the try/catch macros as

   #define NOPH_try(callback, arg) do { \
     asm volatile("");                  \
     __NOPH_try(callback, arg);         \
   } while(0); if ( *(int*)0 != 0 ) {

   #define NOPH_catch() } do {          \
     asm volatile("");                  \
     __NOPH_catch();                    \
   } while(0)

instead, i.e., adding an if-statement that I know will always be true
and enclosing everything between try/catch in this block.

// Simon


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]