* [PATCH] [wip] c99 inline
@ 2016-08-31 11:34 daniel.llorens
0 siblings, 0 replies; only message in thread
From: daniel.llorens @ 2016-08-31 11:34 UTC (permalink / raw)
To: guile-devel; +Cc: Daniel Llorens
From: Daniel Llorens <daniel.llorens@bluewin.ch>
---
libguile.h | 1 -
libguile/Makefile.am | 2 --
libguile/__scm.h | 69 -------------------------------------------------
libguile/_scm.h | 1 -
libguile/array-handle.c | 3 +++
libguile/array-handle.h | 12 ++-------
libguile/gc.c | 6 +++++
libguile/gc.h | 15 +++--------
libguile/inline.c | 30 ---------------------
libguile/inline.h | 57 ----------------------------------------
libguile/numbers.c | 2 +-
libguile/pairs.c | 5 ++++
libguile/pairs.h | 15 +++--------
libguile/smob.c | 4 +++
libguile/smob.h | 11 ++------
libguile/socket.c | 2 +-
libguile/strings.c | 2 ++
libguile/strings.h | 6 +++++
libguile/strorder.c | 2 +-
19 files changed, 40 insertions(+), 205 deletions(-)
delete mode 100644 libguile/inline.c
delete mode 100644 libguile/inline.h
diff --git a/libguile.h b/libguile.h
index d2030eb..57e0e66 100644
--- a/libguile.h
+++ b/libguile.h
@@ -124,7 +124,6 @@ extern "C" {
#include "libguile/debug.h"
#include "libguile/stacks.h"
#include "libguile/threads.h"
-#include "libguile/inline.h"
#include "libguile/deprecated.h"
diff --git a/libguile/Makefile.am b/libguile/Makefile.am
index 8161ade..7fc6998 100644
--- a/libguile/Makefile.am
+++ b/libguile/Makefile.am
@@ -165,7 +165,6 @@ libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES = \
hooks.c \
i18n.c \
init.c \
- inline.c \
instructions.c \
ioext.c \
keywords.c \
@@ -611,7 +610,6 @@ modinclude_HEADERS = \
hooks.h \
i18n.h \
init.h \
- inline.h \
instructions.h \
ioext.h \
iselect.h \
diff --git a/libguile/__scm.h b/libguile/__scm.h
index 31e3952..8e56fb8 100644
--- a/libguile/__scm.h
+++ b/libguile/__scm.h
@@ -162,64 +162,6 @@
\f
-/* We would like gnu89 extern inline semantics, not C99 extern inline
- semantics, so that we can be sure to avoid reifying definitions of
- inline functions in all compilation units, which is a possibility at
- low optimization levels, or if a user takes the address of an inline
- function.
-
- Hence the `__gnu_inline__' attribute, in accordance with:
- http://gcc.gnu.org/gcc-4.3/porting_to.html .
-
- With GCC 4.2, `__GNUC_STDC_INLINE__' is never defined (because C99 inline
- semantics are not supported), but a warning is issued in C99 mode if
- `__gnu_inline__' is not used.
-
- Apple's GCC build >5400 (since Xcode 3.0) doesn't support GNU inline in
- C99 mode and doesn't define `__GNUC_STDC_INLINE__'. Fall back to "static
- inline" in that case. */
-
-# if (defined __GNUC__) && (!(((defined __APPLE_CC__) && (__APPLE_CC__ > 5400)) && __STDC_VERSION__ >= 199901L))
-# if (defined __GNUC_STDC_INLINE__) || (__GNUC__ == 4 && __GNUC_MINOR__ == 2)
-# define SCM_C_EXTERN_INLINE \
- extern __inline__ __attribute__ ((__gnu_inline__))
-# else
-# define SCM_C_EXTERN_INLINE extern __inline__
-# endif
-# endif
-
-/* SCM_INLINE is a macro prepended to all public inline function
- declarations. Implementations of those functions should also be in
- the header file, prefixed by SCM_INLINE_IMPLEMENTATION, and protected
- by SCM_CAN_INLINE and a CPP define for the C file in question, like
- SCM_INLINE_C_INCLUDING_INLINE_H. See inline.h for an example
- usage. */
-
-#if defined SCM_IMPLEMENT_INLINES
-/* Reifying functions to a file, whether or not inlining is available. */
-# define SCM_CAN_INLINE 0
-# define SCM_INLINE SCM_API
-# define SCM_INLINE_IMPLEMENTATION
-#elif defined SCM_C_INLINE
-/* Declarations when inlining is available. */
-# define SCM_CAN_INLINE 1
-# ifdef SCM_C_EXTERN_INLINE
-# define SCM_INLINE SCM_C_EXTERN_INLINE
-# else
-/* Fall back to static inline if GNU "extern inline" is unavailable. */
-# define SCM_INLINE static SCM_C_INLINE
-# endif
-# define SCM_INLINE_IMPLEMENTATION SCM_INLINE
-#else
-/* Declarations when inlining is not available. */
-# define SCM_CAN_INLINE 0
-# define SCM_INLINE SCM_API
-/* Don't define SCM_INLINE_IMPLEMENTATION; it should never be seen in
- this case. */
-#endif
-
-\f
-
/* {Debugging Options}
*
* These compile time options determine whether to include code that is only
@@ -504,17 +446,6 @@ typedef long SCM_STACKITEM;
\f
-/* Define SCM_C_INLINE_KEYWORD so that it can be used as a replacement
- for the "inline" keyword, expanding to nothing when "inline" is not
- available.
-*/
-
-#ifdef SCM_C_INLINE
-#define SCM_C_INLINE_KEYWORD SCM_C_INLINE
-#else
-#define SCM_C_INLINE_KEYWORD
-#endif
-
/* Handling thread-local storage (TLS). */
#ifdef SCM_HAVE_THREAD_STORAGE_CLASS
diff --git a/libguile/_scm.h b/libguile/_scm.h
index 60ad082..363f299 100644
--- a/libguile/_scm.h
+++ b/libguile/_scm.h
@@ -85,7 +85,6 @@
#include "libguile/programs.h" /* ... and program.h. */
#include "libguile/variable.h"
#include "libguile/modules.h"
-#include "libguile/inline.h"
#include "libguile/strings.h"
/* ASYNC_TICK after finding EINTR in order to handle pending signals, if
diff --git a/libguile/array-handle.c b/libguile/array-handle.c
index 89277d9..ade01f2 100644
--- a/libguile/array-handle.c
+++ b/libguile/array-handle.c
@@ -261,6 +261,9 @@ scm_array_handle_pos (scm_t_array_handle *h, SCM indices)
return pos;
}
+extern inline SCM scm_array_handle_ref (scm_t_array_handle *h, ssize_t pos);
+extern inline void scm_array_handle_set (scm_t_array_handle *h, ssize_t pos, SCM val);
+
static void
check_array_index_bounds (scm_t_array_dim *dim, ssize_t idx)
{
diff --git a/libguile/array-handle.h b/libguile/array-handle.h
index a623b4e..6835c47 100644
--- a/libguile/array-handle.h
+++ b/libguile/array-handle.h
@@ -100,13 +100,7 @@ SCM_API const SCM* scm_array_handle_elements (scm_t_array_handle *h);
SCM_API SCM* scm_array_handle_writable_elements (scm_t_array_handle *h);
-SCM_INLINE SCM scm_array_handle_ref (scm_t_array_handle *h, ssize_t pos);
-SCM_INLINE void scm_array_handle_set (scm_t_array_handle *h, ssize_t pos, SCM val);
-
-#if SCM_CAN_INLINE || defined SCM_INLINE_C_IMPLEMENTING_INLINES
-/* Either inlining, or being included from inline.c. */
-
-SCM_INLINE_IMPLEMENTATION SCM
+inline SCM
scm_array_handle_ref (scm_t_array_handle *h, ssize_t p)
{
if (SCM_UNLIKELY (p < 0 && ((size_t)-p) > h->base))
@@ -116,7 +110,7 @@ scm_array_handle_ref (scm_t_array_handle *h, ssize_t p)
return h->vref (h->vector, h->base + p);
}
-SCM_INLINE_IMPLEMENTATION void
+inline void
scm_array_handle_set (scm_t_array_handle *h, ssize_t p, SCM v)
{
if (SCM_UNLIKELY (p < 0 && ((size_t)-p) > h->base))
@@ -126,8 +120,6 @@ scm_array_handle_set (scm_t_array_handle *h, ssize_t p, SCM v)
h->vset (h->vector, h->base + p, v);
}
-#endif
-
SCM_INTERNAL void scm_init_array_handle (void);
diff --git a/libguile/gc.c b/libguile/gc.c
index b75a688..8274678 100644
--- a/libguile/gc.c
+++ b/libguile/gc.c
@@ -89,6 +89,12 @@ int scm_debug_cells_gc_interval = 0;
static SCM scm_protects;
+extern inline SCM scm_cell (scm_t_bits car, scm_t_bits cdr);
+extern inline SCM scm_double_cell (scm_t_bits car, scm_t_bits cbr,
+ scm_t_bits ccr, scm_t_bits cdr);
+extern inline SCM scm_words (scm_t_bits car, scm_t_uint32 n_words);
+
+
#if (SCM_DEBUG_CELL_ACCESSES == 1)
diff --git a/libguile/gc.h b/libguile/gc.h
index 8b3ae79..a31a8fd 100644
--- a/libguile/gc.h
+++ b/libguile/gc.h
@@ -192,14 +192,7 @@ SCM_API char *scm_gc_strndup (const char *str, size_t n, const char *what)
#endif
-SCM_INLINE SCM scm_cell (scm_t_bits car, scm_t_bits cdr);
-SCM_INLINE SCM scm_double_cell (scm_t_bits car, scm_t_bits cbr,
- scm_t_bits ccr, scm_t_bits cdr);
-SCM_INLINE SCM scm_words (scm_t_bits car, scm_t_uint32 n_words);
-
-#if SCM_CAN_INLINE || defined SCM_INLINE_C_IMPLEMENTING_INLINES
-
-SCM_INLINE_IMPLEMENTATION SCM
+inline SCM
scm_cell (scm_t_bits car, scm_t_bits cdr)
{
SCM cell = SCM_PACK_POINTER (SCM_GC_MALLOC (sizeof (scm_t_cell)));
@@ -214,7 +207,7 @@ scm_cell (scm_t_bits car, scm_t_bits cdr)
return cell;
}
-SCM_INLINE_IMPLEMENTATION SCM
+inline SCM
scm_double_cell (scm_t_bits car, scm_t_bits cbr,
scm_t_bits ccr, scm_t_bits cdr)
{
@@ -254,7 +247,7 @@ scm_double_cell (scm_t_bits car, scm_t_bits cbr,
return z;
}
-SCM_INLINE_IMPLEMENTATION SCM
+inline SCM
scm_words (scm_t_bits car, scm_t_uint32 n_words)
{
SCM z;
@@ -287,8 +280,6 @@ scm_words (scm_t_bits car, scm_t_uint32 n_words)
return z;
}
-#endif /* SCM_CAN_INLINE || defined SCM_INLINE_C_IMPLEMENTING_INLINES */
-
SCM_API void scm_remember_upto_here_1 (SCM obj);
SCM_API void scm_remember_upto_here_2 (SCM obj1, SCM obj2);
SCM_API void scm_remember_upto_here (SCM obj1, ...);
diff --git a/libguile/inline.c b/libguile/inline.c
deleted file mode 100644
index 6e7688c..0000000
--- a/libguile/inline.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Copyright (C) 2001, 2006, 2008, 2011, 2012, 2013 Free Software Foundation, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of
- * the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#define SCM_IMPLEMENT_INLINES 1
-#define SCM_INLINE_C_IMPLEMENTING_INLINES 1
-#include "libguile/inline.h"
-#include "libguile/array-handle.h"
-#include "libguile/gc.h"
-#include "libguile/smob.h"
-#include "libguile/pairs.h"
-#include "libguile/ports.h"
diff --git a/libguile/inline.h b/libguile/inline.h
deleted file mode 100644
index 3c9b09b..0000000
--- a/libguile/inline.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* classes: h_files */
-
-#ifndef SCM_INLINE_H
-#define SCM_INLINE_H
-
-/* Copyright (C) 2001, 2002, 2003, 2004, 2006, 2008, 2009, 2010,
- * 2011, 2012, 2013 Free Software Foundation, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of
- * the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA
- */
-
-/* This file is for inline functions. On platforms that don't support
- inlining functions, they are turned into ordinary functions. On
- platforms that do support inline functions, the definitions are still
- compiled into the library, once, in inline.c. */
-
-#include "libguile/__scm.h"
-
-#include "libguile/gc.h"
-#include "libguile/threads.h"
-#include "libguile/array-handle.h"
-#include "libguile/ports.h"
-#include "libguile/numbers.h"
-#include "libguile/error.h"
-
-
-SCM_INLINE int scm_is_string (SCM x);
-
-SCM_INLINE SCM scm_cell (scm_t_bits car, scm_t_bits cdr);
-SCM_INLINE SCM scm_double_cell (scm_t_bits car, scm_t_bits cbr,
- scm_t_bits ccr, scm_t_bits cdr);
-SCM_INLINE SCM scm_words (scm_t_bits car, scm_t_uint32 n_words);
-
-#if SCM_CAN_INLINE || defined SCM_INLINE_C_IMPLEMENTING_INLINES
-/* Either inlining, or being included from inline.c. */
-
-SCM_INLINE_IMPLEMENTATION int
-scm_is_string (SCM x)
-{
- return SCM_HAS_TYP7 (x, scm_tc7_string);
-}
-
-#endif
-#endif
diff --git a/libguile/numbers.c b/libguile/numbers.c
index d0f6e62..dfc247c 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -418,7 +418,7 @@ scm_i_normbig (SCM b)
return b;
}
-static SCM_C_INLINE_KEYWORD SCM
+static inline SCM
scm_i_mpz2num (mpz_t b)
{
/* convert a mpz number to a SCM number. */
diff --git a/libguile/pairs.c b/libguile/pairs.c
index 764458e..46a27c0 100644
--- a/libguile/pairs.c
+++ b/libguile/pairs.c
@@ -68,6 +68,11 @@ void scm_error_pair_access (SCM non_pair)
#endif
+extern inline int scm_is_pair (SCM x);
+extern inline SCM scm_cons (SCM x, SCM y);
+extern inline SCM scm_car (SCM x);
+extern inline SCM scm_cdr (SCM x);
+
SCM
scm_cons2 (SCM w, SCM x, SCM y)
{
diff --git a/libguile/pairs.h b/libguile/pairs.h
index 130bf28..113e59b 100644
--- a/libguile/pairs.h
+++ b/libguile/pairs.h
@@ -117,22 +117,16 @@
SCM_API void scm_error_pair_access (SCM);
#endif
-SCM_INLINE int scm_is_pair (SCM x);
-SCM_INLINE SCM scm_cons (SCM x, SCM y);
-SCM_INLINE SCM scm_car (SCM x);
-SCM_INLINE SCM scm_cdr (SCM x);
-
-#if SCM_CAN_INLINE || defined SCM_INLINE_C_IMPLEMENTING_INLINES
/* Return a newly allocated pair whose car is @var{x} and whose cdr is
@var{y}. The pair is guaranteed to be different (in the sense of
@code{eq?}) from every previously existing object. */
-SCM_INLINE_IMPLEMENTATION SCM
+inline SCM
scm_cons (SCM x, SCM y)
{
return scm_cell (SCM_UNPACK (x), SCM_UNPACK (y));
}
-SCM_INLINE_IMPLEMENTATION int
+inline int
scm_is_pair (SCM x)
{
/* The following "workaround_for_gcc_295" avoids bad code generated by
@@ -159,7 +153,7 @@ scm_is_pair (SCM x)
return SCM_I_CONSP (x);
}
-SCM_INLINE_IMPLEMENTATION SCM
+inline SCM
scm_car (SCM x)
{
if (SCM_UNLIKELY (!scm_is_pair (x)))
@@ -167,14 +161,13 @@ scm_car (SCM x)
return SCM_CAR (x);
}
-SCM_INLINE_IMPLEMENTATION SCM
+inline SCM
scm_cdr (SCM x)
{
if (SCM_UNLIKELY (!scm_is_pair (x)))
scm_wrong_type_arg_msg ("cdr", 0, x, "pair");
return SCM_CDR (x);
}
-#endif
SCM_API SCM scm_cons2 (SCM w, SCM x, SCM y);
SCM_API SCM scm_pair_p (SCM x);
diff --git a/libguile/smob.c b/libguile/smob.c
index 43ea613..5723242 100644
--- a/libguile/smob.c
+++ b/libguile/smob.c
@@ -42,6 +42,10 @@
\f
+extern inline SCM scm_new_smob (scm_t_bits tc, scm_t_bits);
+extern inline SCM scm_new_double_smob (scm_t_bits tc, scm_t_bits,
+ scm_t_bits, scm_t_bits);
+
/* scm_smobs scm_numsmob
* implement a fixed sized array of smob records.
* Indexes into this table are used when generating type
diff --git a/libguile/smob.h b/libguile/smob.h
index 561a6d1..ea7b3dc 100644
--- a/libguile/smob.h
+++ b/libguile/smob.h
@@ -67,13 +67,7 @@ SCM_API SCM scm_i_new_smob (scm_t_bits tc, scm_t_bits);
SCM_API SCM scm_i_new_double_smob (scm_t_bits tc, scm_t_bits,
scm_t_bits, scm_t_bits);
-
-SCM_INLINE SCM scm_new_smob (scm_t_bits tc, scm_t_bits);
-SCM_INLINE SCM scm_new_double_smob (scm_t_bits tc, scm_t_bits,
- scm_t_bits, scm_t_bits);
-
-#if SCM_CAN_INLINE || defined SCM_INLINE_C_IMPLEMENTING_INLINES
-SCM_INLINE_IMPLEMENTATION SCM
+inline SCM
scm_new_smob (scm_t_bits tc, scm_t_bits data)
{
scm_t_bits smobnum = SCM_TC2SMOBNUM (tc);
@@ -84,7 +78,7 @@ scm_new_smob (scm_t_bits tc, scm_t_bits data)
return scm_cell (tc, data);
}
-SCM_INLINE_IMPLEMENTATION SCM
+inline SCM
scm_new_double_smob (scm_t_bits tc, scm_t_bits data1,
scm_t_bits data2, scm_t_bits data3)
{
@@ -95,7 +89,6 @@ scm_new_double_smob (scm_t_bits tc, scm_t_bits data1,
else
return scm_double_cell (tc, data1, data2, data3);
}
-#endif
#define SCM_NEWSMOB(z, tc, data) \
z = scm_new_smob ((tc), (scm_t_bits)(data))
diff --git a/libguile/socket.c b/libguile/socket.c
index 37e9f52..aff4113 100644
--- a/libguile/socket.c
+++ b/libguile/socket.c
@@ -961,7 +961,7 @@ SCM_DEFINE (scm_listen, "listen", 2, 0, 0,
#undef FUNC_NAME
/* Put the components of a sockaddr into a new SCM vector. */
-static SCM_C_INLINE_KEYWORD SCM
+static inline SCM
_scm_from_sockaddr (const scm_t_max_sockaddr *address, unsigned addr_size,
const char *proc)
{
diff --git a/libguile/strings.c b/libguile/strings.c
index 232ddf9..f5f5b18 100644
--- a/libguile/strings.c
+++ b/libguile/strings.c
@@ -78,6 +78,8 @@ SCM_SYMBOL (sym_error, "error");
* strings.
*/
+inline int scm_is_string (SCM x);
+
/* The size in words of the stringbuf header (type tag + size). */
#define STRINGBUF_HEADER_SIZE 2U
diff --git a/libguile/strings.h b/libguile/strings.h
index 882e7ce..4128807 100644
--- a/libguile/strings.h
+++ b/libguile/strings.h
@@ -90,6 +90,12 @@
no wide version of this interface.
*/
+inline int
+scm_is_string (SCM x)
+{
+ return SCM_HAS_TYP7 (x, scm_tc7_string);
+}
+
/* A type indicating what strategy to take when string locale
conversion is unsuccessful. */
typedef enum
diff --git a/libguile/strorder.c b/libguile/strorder.c
index a51ce17..2695eb0 100644
--- a/libguile/strorder.c
+++ b/libguile/strorder.c
@@ -31,7 +31,7 @@
#include "libguile/srfi-13.h"
\f
-SCM_C_INLINE_KEYWORD static SCM
+static inline SCM
srfi13_cmp (SCM s1, SCM s2, SCM (*cmp) (SCM, SCM, SCM, SCM, SCM, SCM))
{
if (scm_is_true (cmp (s1, s2,
--
2.9.3
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2016-08-31 11:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-31 11:34 [PATCH] [wip] c99 inline daniel.llorens
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).