[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/4] chdir-long, cycle-check, savewd: better 'inline'
From: |
Paul Eggert |
Subject: |
[PATCH 3/4] chdir-long, cycle-check, savewd: better 'inline' |
Date: |
Sun, 04 Nov 2012 23:18:59 -0800 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:16.0) Gecko/20121028 Thunderbird/16.0.2 |
* lib/chdir-long.c (cdb_init, cdb_fchdir, cdb_free)
(find_non_slash):
* lib/cycle-check.c (is_zero_or_power_of_two):
* lib/savewd.c (savewd_delegating):
Change 'static inline' to 'inline'.
* lib/savewd.c, lib/savewd.h (SAVEWD_INLINE): New macro.
Replace all remaining uses of 'static inline' with it.
* lib/savewd.h:
Use _GL_INLINE_HEADER_BEGIN, _GL_INLINE_HEADER_END.
* m4/chdir-long.m4 (gl_PREREQ_CHDIR_LONG):
* m4/cycle-check.m4 (gl_CYCLE_CHECK):
* m4/savewd.m4 (gl_SAVEWD):
Do not require AC_C_INLINE.
* modules/savewd (Depends-on): Add extern-inline.
---
ChangeLog | 16 ++++++++++++++++
lib/chdir-long.c | 8 ++++----
lib/cycle-check.c | 2 +-
lib/savewd.c | 4 +++-
lib/savewd.h | 11 +++++++++--
m4/chdir-long.m4 | 8 ++------
m4/cycle-check.m4 | 7 ++-----
m4/savewd.m4 | 3 +--
modules/savewd | 1 +
9 files changed, 39 insertions(+), 21 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8cc8f25..891ac34 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
2012-11-04 Paul Eggert <address@hidden>
+ chdir-long, cycle-check, savewd: better 'inline'
+ * lib/chdir-long.c (cdb_init, cdb_fchdir, cdb_free)
+ (find_non_slash):
+ * lib/cycle-check.c (is_zero_or_power_of_two):
+ * lib/savewd.c (savewd_delegating):
+ Change 'static inline' to 'inline'.
+ * lib/savewd.c, lib/savewd.h (SAVEWD_INLINE): New macro.
+ Replace all remaining uses of 'static inline' with it.
+ * lib/savewd.h:
+ Use _GL_INLINE_HEADER_BEGIN, _GL_INLINE_HEADER_END.
+ * m4/chdir-long.m4 (gl_PREREQ_CHDIR_LONG):
+ * m4/cycle-check.m4 (gl_CYCLE_CHECK):
+ * m4/savewd.m4 (gl_SAVEWD):
+ Do not require AC_C_INLINE.
+ * modules/savewd (Depends-on): Add extern-inline.
+
base32, base64: no need for 'inline'
* lib/base32.c (to_uchar, get_8, decode_8):
* lib/base64.c (to_uchar, get_4, decode_4):
diff --git a/lib/chdir-long.c b/lib/chdir-long.c
index 599d141..a597530 100644
--- a/lib/chdir-long.c
+++ b/lib/chdir-long.c
@@ -42,19 +42,19 @@ struct cd_buf
int fd;
};
-static inline void
+static void
cdb_init (struct cd_buf *cdb)
{
cdb->fd = AT_FDCWD;
}
-static inline int
+static int
cdb_fchdir (struct cd_buf const *cdb)
{
return fchdir (cdb->fd);
}
-static inline void
+static void
cdb_free (struct cd_buf const *cdb)
{
if (0 <= cdb->fd)
@@ -83,7 +83,7 @@ cdb_advance_fd (struct cd_buf *cdb, char const *dir)
}
/* Return a pointer to the first non-slash in S. */
-static inline char * _GL_ATTRIBUTE_PURE
+static char * _GL_ATTRIBUTE_PURE
find_non_slash (char const *s)
{
size_t n_slash = strspn (s, "/");
diff --git a/lib/cycle-check.c b/lib/cycle-check.c
index 011cae9..2f0869d 100644
--- a/lib/cycle-check.c
+++ b/lib/cycle-check.c
@@ -33,7 +33,7 @@
/* Return true if I is a power of 2, or is zero. */
-static inline bool
+static bool
is_zero_or_power_of_two (uintmax_t i)
{
return (i & (i - 1)) == 0;
diff --git a/lib/savewd.c b/lib/savewd.c
index c5aec36..1412765 100644
--- a/lib/savewd.c
+++ b/lib/savewd.c
@@ -19,6 +19,8 @@
#include <config.h>
+#define SAVEWD_INLINE _GL_EXTERN_INLINE
+
#include "savewd.h"
#include <assert.h>
@@ -254,7 +256,7 @@ savewd_finish (struct savewd *wd)
This is why savewd_chdir is broken out into another function;
savewd_chdir's callers _can_ inspect the file system to decide
whether to call savewd_chdir. */
-static inline bool
+static bool
savewd_delegating (struct savewd const *wd)
{
return wd->state == FORKING_STATE && 0 < wd->val.child;
diff --git a/lib/savewd.h b/lib/savewd.h
index 06cc6c1..9291e2c 100644
--- a/lib/savewd.h
+++ b/lib/savewd.h
@@ -23,6 +23,11 @@
#include <stdbool.h>
#include <sys/types.h>
+_GL_INLINE_HEADER_BEGIN
+#ifndef SAVEWD_INLINE
+# define SAVEWD_INLINE _GL_INLINE
+#endif
+
/* A saved working directory. The member names and constants defined
by this structure are private to the savewd module. */
struct savewd
@@ -67,7 +72,7 @@ struct savewd
};
/* Initialize a saved working directory object. */
-static inline void
+SAVEWD_INLINE void
savewd_init (struct savewd *wd)
{
wd->state = INITIAL_STATE;
@@ -117,7 +122,7 @@ int savewd_chdir (struct savewd *wd, char const *dir, int
options,
int savewd_restore (struct savewd *wd, int status);
/* Return WD's error number, or 0 if WD is not in an error state. */
-static inline int
+SAVEWD_INLINE int
savewd_errno (struct savewd const *wd)
{
return (wd->state == ERROR_STATE ? wd->val.errnum : 0);
@@ -145,4 +150,6 @@ int savewd_process_files (int n_files, char **file,
int (*act) (char *, struct savewd *, void *),
void *options);
+_GL_INLINE_HEADER_END
+
#endif
diff --git a/m4/chdir-long.m4 b/m4/chdir-long.m4
index 6180891..fb6ace9 100644
--- a/m4/chdir-long.m4
+++ b/m4/chdir-long.m4
@@ -1,4 +1,4 @@
-#serial 14
+#serial 15
# Use Gnulib's robust chdir function.
# It can handle arbitrarily long directory names, which means
@@ -27,8 +27,4 @@ have_arbitrary_file_name_length_limit
gl_cv_have_arbitrary_file_name_length_limit=no)])
])
-AC_DEFUN([gl_PREREQ_CHDIR_LONG],
-[
- AC_REQUIRE([AC_C_INLINE])
- :
-])
+AC_DEFUN([gl_PREREQ_CHDIR_LONG], [:])
diff --git a/m4/cycle-check.m4 b/m4/cycle-check.m4
index 34c5bcb..daa6a25 100644
--- a/m4/cycle-check.m4
+++ b/m4/cycle-check.m4
@@ -1,10 +1,7 @@
-#serial 6
+#serial 7
dnl Copyright (C) 2005-2007, 2009-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,
dnl with or without modifications, as long as this notice is preserved.
-AC_DEFUN([gl_CYCLE_CHECK],
-[
- AC_REQUIRE([AC_C_INLINE])
-])
+AC_DEFUN([gl_CYCLE_CHECK], [:])
diff --git a/m4/savewd.m4 b/m4/savewd.m4
index 5a38eaf..571e3d2 100644
--- a/m4/savewd.m4
+++ b/m4/savewd.m4
@@ -5,5 +5,4 @@ dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
-AC_DEFUN([gl_SAVEWD],
- [AC_REQUIRE([AC_C_INLINE])])
+AC_DEFUN([gl_SAVEWD], [:])
diff --git a/modules/savewd b/modules/savewd
index bb48c06..b7a9fee 100644
--- a/modules/savewd
+++ b/modules/savewd
@@ -10,6 +10,7 @@ Depends-on:
chdir
dosname
errno
+extern-inline
fchdir
fcntl-safer
fcntl-h
--
1.7.11.7
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH 3/4] chdir-long, cycle-check, savewd: better 'inline',
Paul Eggert <=