This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Forcing register assignments before non-conditional blocks
- From: Simon Kagstrom <simon dot kagstrom at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Sun, 20 Apr 2008 15:23:14 +0200
- Subject: Re: Forcing register assignments before non-conditional blocks
- References: <20080419151944.5d73b455@lska2>
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