bug-gnulib
[Top][All Lists]
Advanced

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

[PATCH 02/11] count-leading-zeros: better 'inline'


From: Paul Eggert
Subject: [PATCH 02/11] count-leading-zeros: better 'inline'
Date: Mon, 29 Oct 2012 00:14:11 -0700
User-agent: Mozilla/5.0 (X11; Linux i686; rv:16.0) Gecko/20121011 Thunderbird/16.0.1

* 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.
---
 ChangeLog                   | 11 +++++++++++
 lib/count-leading-zeros.c   |  3 +++
 lib/count-leading-zeros.h   | 15 +++++++++++----
 m4/count-leading-zeros.m4   |  5 +----
 modules/count-leading-zeros |  3 +++
 5 files changed, 29 insertions(+), 8 deletions(-)
 create mode 100644 lib/count-leading-zeros.c

diff --git a/ChangeLog b/ChangeLog
index f336149..15914d1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2012-10-28  Paul Eggert  <address@hidden>
 
+       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):
diff --git a/lib/count-leading-zeros.c b/lib/count-leading-zeros.c
new file mode 100644
index 0000000..d0c0704
--- /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"
diff --git a/lib/count-leading-zeros.h b/lib/count-leading-zeros.h
index cbb3264..7eb0cf2 100644
--- 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 @@ count_leading_zeros_32 (unsigned int x)
 #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 @@ count_leading_zeros_l (unsigned long int x)
 
 #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 */
diff --git a/m4/count-leading-zeros.m4 b/m4/count-leading-zeros.m4
index 1efb941..5fef2da 100644
--- 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 @@ AC_DEFUN([gl_COUNT_LEADING_ZEROS],
   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])
 ])
diff --git a/modules/count-leading-zeros b/modules/count-leading-zeros
index 60ec930..f6ec283 100644
--- a/modules/count-leading-zeros
+++ b/modules/count-leading-zeros
@@ -2,16 +2,19 @@ Description:
 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"
-- 
1.7.11.7




reply via email to

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