Mercurial > hg > octave-kai > gnulib-hg
changeset 17101:99fa3b05f1c8
pipe-filter-gi, pipe-filter-ii: better use of 'inline'
* lib/pipe-filter-aux.c: New file.
* lib/pipe-filter-aux.h (PIPE_FILTER_AUX_INLINE): New macro.
Replace all uses of 'static inline' with it.
Use _GL_INLINE_HEADER_BEGIN, _GL_INLINE_HEADER_END.
* lib/pipe-filter-gi.c (filter_init, filter_cleanup)
(filter_retcode): No real need for inline here.
* modules/pipe-filter-gi, modules/pipe-filter-ii:
(Files): Add lib/pipe-filter-aux.c.
(Depends-on): Add extern-inline.
(configure.ac): Do not require AC_C_INLINE.
(lib_SOURCES): Add pipe-filter-aux.c.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Wed, 29 Aug 2012 22:17:49 -0700 |
parents | 1783fdc5730c |
children | 9e72d3927af1 |
files | ChangeLog lib/pipe-filter-aux.c lib/pipe-filter-aux.h lib/pipe-filter-gi.c modules/pipe-filter-gi modules/pipe-filter-ii |
diffstat | 6 files changed, 79 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ 2012-09-22 Paul Eggert <eggert@cs.ucla.edu> + pipe-filter-gi, pipe-filter-ii: better use of 'inline' + * lib/pipe-filter-aux.c: New file. + * lib/pipe-filter-aux.h (PIPE_FILTER_AUX_INLINE): New macro. + Replace all uses of 'static inline' with it. + Use _GL_INLINE_HEADER_BEGIN, _GL_INLINE_HEADER_END. + * lib/pipe-filter-gi.c (filter_init, filter_cleanup) + (filter_retcode): No real need for inline here. + * modules/pipe-filter-gi, modules/pipe-filter-ii: + (Files): Add lib/pipe-filter-aux.c. + (Depends-on): Add extern-inline. + (configure.ac): Do not require AC_C_INLINE. + (lib_SOURCES): Add pipe-filter-aux.c. + fdutimensat: omit unnecessary AC_C_INLINE * modules/fdutimensat (configure.ac): Remove AC_C_INLINE.
new file mode 100644 --- /dev/null +++ b/lib/pipe-filter-aux.c @@ -0,0 +1,43 @@ +/* Auxiliary code for filtering of data through a subprocess. + Copyright (C) 2012 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include <config.h> + +#define PIPE_FILTER_AUX_INLINE _GL_EXTERN_INLINE + +#include "pipe-filter.h" + +#include <errno.h> +#include <fcntl.h> +#include <stdbool.h> +#include <stdint.h> +#include <stdlib.h> +#include <unistd.h> +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# include <windows.h> +#else +# include <signal.h> +# include <sys/select.h> +#endif + +#include "error.h" +#include "spawn-pipe.h" +#include "wait-process.h" +#include "gettext.h" + +#define _(str) gettext (str) + +#include "pipe-filter-aux.h"
--- a/lib/pipe-filter-aux.h +++ b/lib/pipe-filter-aux.h @@ -15,6 +15,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ +_GL_INLINE_HEADER_BEGIN +#ifndef PIPE_FILTER_AUX_INLINE +# define PIPE_FILTER_AUX_INLINE _GL_INLINE +#endif #ifndef SSIZE_MAX # define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2)) @@ -39,7 +43,7 @@ These functions can return -1/EINTR even though we don't have any signal handlers set up, namely when we get interrupted via SIGSTOP. */ -static inline int +PIPE_FILTER_AUX_INLINE int nonintr_close (int fd) { int retval; @@ -53,7 +57,7 @@ #undef close /* avoid warning related to gnulib module unistd */ #define close nonintr_close -static inline ssize_t +PIPE_FILTER_AUX_INLINE ssize_t nonintr_read (int fd, void *buf, size_t count) { ssize_t retval; @@ -66,7 +70,7 @@ } #define read nonintr_read -static inline ssize_t +PIPE_FILTER_AUX_INLINE ssize_t nonintr_write (int fd, const void *buf, size_t count) { ssize_t retval; @@ -82,7 +86,7 @@ # if HAVE_SELECT -static inline int +PIPE_FILTER_AUX_INLINE int nonintr_select (int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) { @@ -111,3 +115,5 @@ # define IS_EAGAIN(errcode) ((errcode) == EAGAIN) # endif #endif + +_GL_INLINE_HEADER_END
--- a/lib/pipe-filter-gi.c +++ b/lib/pipe-filter-gi.c @@ -81,7 +81,7 @@ /* Perform additional initializations. Return 0 if successful, -1 upon failure. */ -static inline int filter_init (struct pipe_filter_gi *filter); +static int filter_init (struct pipe_filter_gi *filter); /* Write count bytes starting at buf, while at the same time invoking the read iterator (the functions prepare_read/done_read) when needed. */ @@ -91,8 +91,8 @@ /* Perform cleanup actions at the end. finish_reading is true if there was no error, or false if some error occurred already. */ -static inline void filter_cleanup (struct pipe_filter_gi *filter, - bool finish_reading); +static void filter_cleanup (struct pipe_filter_gi *filter, + bool finish_reading); #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ @@ -136,7 +136,7 @@ abort (); } -static inline int +static int filter_init (struct pipe_filter_gi *filter) { InitializeCriticalSection (&filter->lock); @@ -200,7 +200,7 @@ } } -static inline void +static void filter_cleanup (struct pipe_filter_gi *filter, bool finish_reading) { if (finish_reading) @@ -218,7 +218,7 @@ #else /* Unix API. */ -static inline int +static int filter_init (struct pipe_filter_gi *filter) { #if !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) @@ -459,7 +459,7 @@ Return 0 upon success, or (only if exit_on_error is false): - -1 with errno set upon failure, - the positive exit code of the subprocess if that failed. */ -static inline int +static int filter_retcode (struct pipe_filter_gi *filter) { if (filter->writer_errno != 0)
--- a/modules/pipe-filter-gi +++ b/modules/pipe-filter-gi @@ -5,11 +5,13 @@ lib/pipe-filter.h lib/pipe-filter-gi.c lib/pipe-filter-aux.h +lib/pipe-filter-aux.c Depends-on: spawn-pipe wait-process error +extern-inline fcntl-h gettext-h stdbool @@ -19,11 +21,10 @@ unistd configure.ac: -AC_REQUIRE([AC_C_INLINE]) AC_CHECK_FUNCS_ONCE([select]) Makefile.am: -lib_SOURCES += pipe-filter-gi.c +lib_SOURCES += pipe-filter-gi.c pipe-filter-aux.c Include: "pipe-filter.h"
--- a/modules/pipe-filter-ii +++ b/modules/pipe-filter-ii @@ -5,11 +5,13 @@ lib/pipe-filter.h lib/pipe-filter-ii.c lib/pipe-filter-aux.h +lib/pipe-filter-aux.c Depends-on: spawn-pipe wait-process error +extern-inline fcntl-h gettext-h stdbool @@ -19,11 +21,10 @@ unistd configure.ac: -AC_REQUIRE([AC_C_INLINE]) AC_CHECK_FUNCS_ONCE([select]) Makefile.am: -lib_SOURCES += pipe-filter-ii.c +lib_SOURCES += pipe-filter-ii.c pipe-filter-aux.c Include: "pipe-filter.h"