[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gnugo-devel] attribute noreturn for abortgo()

From: Paul Pogonyshev
Subject: Re: [gnugo-devel] attribute noreturn for abortgo()
Date: Mon, 19 Apr 2004 14:47:47 +0300
User-agent: KMail/1.6.51

Arend wrote:
> This patch gives about 1% speedup. If GCC knows that abortgo() will never
> return it can avoid to save registers before calling it (making code size
> smaller), and reduce number of branch mispredictions by marking the assertions
> (which trigger the call to abortgo() ) as unlikely.
> If someone has suggestions how to make this more portable (Does this exist
> in other compilers at all?), they are welcome. The #ifdef is a little ugly
> but I think it is worth the speedup.

I certainly agree it's worth it.  The more common way of coding such things
is like having

#ifdef __GNUC__
#define GNUGO_NO_RETURN         __attribute__ ((noreturn))

in a header file.  However, in this case your way is probably better since
there are not many functions in GNU Go that don't return.

Another, more generic, option is to add

#ifndef __GNUC__
#define __attribute__

to a header file.  Then we can add whatever attributes without more need
to bother with portability.

BTW, about old idea of having portable `inline'.  Autoconf provides an
easy way of doing this.  We just need to make sure that `config.h' is
included in every file that uses `inline' and find out what to use for
MSVC compiler.  Regarding `', the following one-liner should
do it:

--- /home/paul/gnugo/       2004-04-17 00:35:01.000000000 +0300
+++ /tmp/buffer-content-794is7  2004-04-19 14:42:26.000000000 +0300
@@ -155,6 +155,7 @@ AC_HEADER_MAJOR
 AC_CHECK_HEADERS(unistd.h sys/time.h sys/times.h)
 AC_CHECK_HEADERS(curses.h term.h ncurses/curses.h ncurses/term.h)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]