m4-patches
[Top][All Lists]
Advanced

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

[PATCH 3/7] build: mark several pure functions


From: Eric Blake
Subject: [PATCH 3/7] build: mark several pure functions
Date: Tue, 4 Sep 2012 17:10:01 -0600

Found by using gcc 4.7.0's -Wsuggest-attribute=pure.

* src/m4.h (M4_GNUC_PURE): New macro.
* src/m4.c (fault_handler): Mark pure.
* src/builtin.c (find_builtin_by_addr, find_builtin_by_name):
Likewise.
* src/symtab.c (hash): Likewise.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog     | 9 +++++++++
 src/builtin.c | 4 ++--
 src/m4.c      | 2 +-
 src/m4.h      | 1 +
 src/symtab.c  | 2 +-
 5 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1d2400a..30b444b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2012-09-04  Eric Blake  <address@hidden>
+
+       build: mark several pure functions
+       * src/m4.h (M4_GNUC_PURE): New macro.
+       * src/m4.c (fault_handler): Mark pure.
+       * src/builtin.c (find_builtin_by_addr, find_builtin_by_name):
+       Likewise.
+       * src/symtab.c (hash): Likewise.
+
 2012-09-01  Eric Blake  <address@hidden>

        build: silence gcc warning
diff --git a/src/builtin.c b/src/builtin.c
index d8c9bd5..5ff443e 100644
--- a/src/builtin.c
+++ b/src/builtin.c
@@ -173,7 +173,7 @@ static predefined const predefined_tab[] =
 | Find the builtin, which lives on ADDR.  |
 `----------------------------------------*/

-const builtin *
+const builtin * M4_GNUC_PURE
 find_builtin_by_addr (builtin_func *func)
 {
   const builtin *bp;
@@ -191,7 +191,7 @@ find_builtin_by_addr (builtin_func *func)
 | placeholder builtin.                                      |
 `----------------------------------------------------------*/

-const builtin *
+const builtin * M4_GNUC_PURE
 find_builtin_by_name (const char *name)
 {
   const builtin *bp;
diff --git a/src/m4.c b/src/m4.c
index d4c2681..3666a65 100644
--- a/src/m4.c
+++ b/src/m4.c
@@ -140,7 +140,7 @@ static const char * volatile signal_message[NSIG];
    must be aysnc-signal safe, since it is executed as a signal
    handler.  If SIGNO is zero, this represents a stack overflow; in
    that case, we return to allow c_stack_action to handle things.  */
-static void
+static void M4_GNUC_PURE
 fault_handler (int signo)
 {
   if (signo)
diff --git a/src/m4.h b/src/m4.h
index a8d96ea..c23e448 100644
--- a/src/m4.h
+++ b/src/m4.h
@@ -118,6 +118,7 @@ typedef unsigned int bool_bitfield;
 #define M4_GNUC_PRINTF(fmt, arg)                        \
   M4_GNUC_ATTRIBUTE ((__format__ (__printf__, fmt, arg)))
 #define M4_GNUC_NORETURN        M4_GNUC_ATTRIBUTE ((__noreturn__))
+#define M4_GNUC_PURE            M4_GNUC_ATTRIBUTE ((__pure__))
 
 /* File: m4.c  --- global definitions.  */

diff --git a/src/symtab.c b/src/symtab.c
index eeec2cf..ba2afe3 100644
--- a/src/symtab.c
+++ b/src/symtab.c
@@ -120,7 +120,7 @@ symtab_init (void)
 | Return a hashvalue for a string, from GNU-emacs.  |
 `--------------------------------------------------*/

-static size_t
+static size_t M4_GNUC_PURE
 hash (const char *s)
 {
   register size_t val = 0;
-- 
1.7.11.4




reply via email to

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