Mercurial > hg > octave-lyh > gnulib-hg
changeset 15946:d0eb709725f5
ffsl, ffsll: Optimize for GCC.
* lib/ffsl.h (FUNC): Use GCC_BUILTIN if defined.
* lib/ffsl.c (GCC_BUILTIN): New macro.
* lib/ffsll.c (GCC_BUILTIN): Likewise.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Fri, 14 Oct 2011 00:48:29 +0200 |
parents | f914ec364e88 |
children | d1ff4390df13 |
files | ChangeLog lib/ffsl.c lib/ffsl.h lib/ffsll.c |
diffstat | 4 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-10-13 Bruno Haible <bruno@clisp.org> + + ffsl, ffsll: Optimize for GCC. + * lib/ffsl.h (FUNC): Use GCC_BUILTIN if defined. + * lib/ffsl.c (GCC_BUILTIN): New macro. + * lib/ffsll.c (GCC_BUILTIN): Likewise. + 2011-10-13 Bruno Haible <bruno@clisp.org> ffs, bcopy, memset: Support symbol renaming via config.h.
--- a/lib/ffsl.c +++ b/lib/ffsl.c @@ -1,3 +1,4 @@ #define FUNC ffsl #define TYPE long int +#define GCC_BUILTIN __builtin_ffsl #include "ffsl.h"
--- a/lib/ffsl.h +++ b/lib/ffsl.h @@ -31,6 +31,9 @@ int FUNC (TYPE i) { +#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) && defined GCC_BUILTIN + return GCC_BUILTIN (i); +#else int result = 0; unsigned TYPE j = i; @@ -44,4 +47,5 @@ j >>= CHAR_BIT * sizeof (unsigned int); result += CHAR_BIT * sizeof (unsigned int); } +#endif }