Mercurial > hg > octave-nkf > gnulib-hg
changeset 17166:22a948de1761
count-leading-zeros: better 'inline'
* lib/count-leading-zeros.c: New file.
* lib/count-leading-zeros.h (COUNT_LEADING_ZEROS_INLINE):
New macro. Replace all uses of 'static inline' with it.
Use _GL_INLINE_HEADER_BEGIN, _GL_INLINE_HEADER_END.
* m4/count-leading-zeros.m4 (gl_COUNT_LEADING_ZEROS):
Do not require AC_C_INLINE.
* modules/count-leading-zeros (Files, lib_SOURCES):
Add lib/count-leading-zeros.c.
(Depends-on): Add extern-inline.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Tue, 20 Nov 2012 22:25:05 -0800 |
parents | 932266a7240e |
children | 7178d4d98ee5 |
files | ChangeLog lib/count-leading-zeros.c lib/count-leading-zeros.h m4/count-leading-zeros.m4 modules/count-leading-zeros |
diffstat | 5 files changed, 29 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2012-11-29 Paul Eggert <eggert@cs.ucla.edu> + count-leading-zeros: better 'inline' + * lib/count-leading-zeros.c: New file. + * lib/count-leading-zeros.h (COUNT_LEADING_ZEROS_INLINE): + New macro. Replace all uses of 'static inline' with it. + Use _GL_INLINE_HEADER_BEGIN, _GL_INLINE_HEADER_END. + * m4/count-leading-zeros.m4 (gl_COUNT_LEADING_ZEROS): + Do not require AC_C_INLINE. + * modules/count-leading-zeros (Files, lib_SOURCES): + Add lib/count-leading-zeros.c. + (Depends-on): Add extern-inline. + bitrotate: better 'inline' * lib/bitrotate.c: New file. * lib/bitrotate.h (BITROTATE_INLINE):
new file mode 100644 --- /dev/null +++ b/lib/count-leading-zeros.c @@ -0,0 +1,3 @@ +#include <config.h> +#define COUNT_LEADING_ZEROS_INLINE _GL_EXTERN_INLINE +#include "count-leading-zeros.h"
--- a/lib/count-leading-zeros.h +++ b/lib/count-leading-zeros.h @@ -23,6 +23,11 @@ #include <stdlib.h> #include "verify.h" +_GL_INLINE_HEADER_BEGIN +#ifndef COUNT_LEADING_ZEROS_INLINE +# define COUNT_LEADING_ZEROS_INLINE _GL_INLINE +#endif + /* Expand the code which computes the number of leading zeros of the local variable 'x' of type TYPE (an unsigned integer type) and returns it from the current function. */ @@ -44,7 +49,7 @@ /* Compute and return the number of leading zeros in the least significant 32 bits of X. */ -static inline int +COUNT_LEADING_ZEROS_INLINE int count_leading_zeros_32 (unsigned int x) { /* http://graphics.stanford.edu/~seander/bithacks.html */ @@ -66,14 +71,14 @@ #endif /* Compute and return the number of leading zeros in X. */ -static inline int +COUNT_LEADING_ZEROS_INLINE int count_leading_zeros (unsigned int x) { COUNT_LEADING_ZEROS (__builtin_clz, unsigned int); } /* Compute and return the number of leading zeros in X. */ -static inline int +COUNT_LEADING_ZEROS_INLINE int count_leading_zeros_l (unsigned long int x) { COUNT_LEADING_ZEROS (__builtin_clzl, unsigned long int); @@ -81,11 +86,13 @@ #if HAVE_UNSIGNED_LONG_LONG_INT /* Compute and return the number of leading zeros in X. */ -static inline int +COUNT_LEADING_ZEROS_INLINE int count_leading_zeros_ll (unsigned long long int x) { COUNT_LEADING_ZEROS (__builtin_clzll, unsigned long long int); } #endif +_GL_INLINE_HEADER_END + #endif /* COUNT_LEADING_ZEROS_H */
--- a/m4/count-leading-zeros.m4 +++ b/m4/count-leading-zeros.m4 @@ -1,4 +1,4 @@ -# count-leading-zeros.m4 serial 1 +# count-leading-zeros.m4 serial 2 dnl Copyright (C) 2012 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -9,7 +9,4 @@ dnl We don't need (and can't compile) count_leading_zeros_ll dnl unless the type 'unsigned long long int' exists. AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT]) - - dnl Prerequisites of lib/count-leading-zeros.h. - AC_REQUIRE([AC_C_INLINE]) ])
--- a/modules/count-leading-zeros +++ b/modules/count-leading-zeros @@ -2,16 +2,19 @@ Counts the number of leading 0-bits in a word. Files: +lib/count-leading-zeros.c lib/count-leading-zeros.h m4/count-leading-zeros.m4 Depends-on: +extern-inline verify configure.ac: gl_COUNT_LEADING_ZEROS Makefile.am: +lib_SOURCES += count-leading-zeros.c Include: "count-leading-zeros.h"