guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] GNU Guile branch, master, updated. v2.1.0-70-g27583e7


From: Andy Wingo
Subject: [Guile-commits] GNU Guile branch, master, updated. v2.1.0-70-g27583e7
Date: Thu, 26 May 2011 15:22:19 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=27583e746617ebb7351a05952c52331b81ddd70d

The branch, master has been updated
       via  27583e746617ebb7351a05952c52331b81ddd70d (commit)
       via  ff670362aae35495cf0861ba3435bbabbaaa3a7b (commit)
       via  4cf77f094671559f7f120c7d14e4e3d0982148b1 (commit)
       via  ebc16e6a762748fc5939903a8b3a367d422f1371 (commit)
       via  a8952d1fb73218ad2389bb290ebbb737d4f88fce (commit)
       via  65619ebe9a9af71f6dd17736f5556e53db485f1c (commit)
       via  f567a43cf0336151fac1a51c6553431420f21397 (commit)
      from  a099c8d971c1d5b32e00f25469b36ce45fd4d8c7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 27583e746617ebb7351a05952c52331b81ddd70d
Author: Andy Wingo <address@hidden>
Date:   Thu May 26 16:49:47 2011 +0200

    scm_new_smob, scm_new_double_smob inline functions
    
    * libguile/smob.h (scm_new_smob, scm_new_double_smob): New constructors,
      which do what SCM_NEWSMOB / SCM_NEWSMOB3 had done, but with inline
      functions instead of macros.  They also bail to scm_i_new_smob /
      scm_i_new_double_smob in either the mark or the free case, so that the
      inline definition doesn't reference other internal details like libgc
      stuff.
      (SCM_SMOB_TYPE_MASK et al): Move definitions up so the new_smob see
      them as already being declared.
      (SCM_NEWSMOB, SCM_RETURN_NEWSMOB, SCM_NEWSMOB2, SCM_RETURN_NEWSMOB2):
      (SCM_NEWSMOB3, SCM_RETURN_NEWSMOB3): Reimplement in terms of the new
      inline functions.
      (scm_i_finalize_smob): Remove declaration, as it's no longer needed or
      used.
      Remove now-unneeded bdw-gc include.
    
    * libguile/smob.c (finalize_smob): Rename from scm_i_finalize_smob, and
      make static.
      (scm_i_new_smob, scm_i_new_double_smob): Slow-path allocators.
    
    * libguile/inline.c: Include smob.h, so as to reify scm_new_smob and
      scm_new_double_smob.

commit ff670362aae35495cf0861ba3435bbabbaaa3a7b
Author: Andy Wingo <address@hidden>
Date:   Thu May 26 16:08:02 2011 +0200

    scm_cell, scm_double_cell, scm_words back to gc.h
    
    * libguile/inline.h:
    * libguile/gc.h (scm_cell, scm_double_cell, scm_words): Move
      declarations and definitions back here, from inline.h.  It's more
      natural.
    
    * libguile/inline.c: Include gc.h as well.

commit 4cf77f094671559f7f120c7d14e4e3d0982148b1
Author: Andy Wingo <address@hidden>
Date:   Thu May 26 15:53:02 2011 +0200

    simplify inline function infrastructure
    
    * libguile/__scm.h (SCM_C_EXTERN_INLINE): Move this definition here,
      from inline.h.  We'd like to support inline function definitions in
      more header files: not just inline.h.
      (SCM_CAN_INLINE, SCM_INLINE, SCM_INLINE_IMPLEMENTATION): New
      definitions.
    
    * libguile/gc.h (SCM_GC_MALLOC, SCM_GC_MALLOC_POINTERLESS): Define these
      wrappers, which redirect to the GC_MALLOC macros when building Guile,
      and the scm_gc_malloc functions otherwise.  A step towards getting
      BDW-GC out of Guile's API.
    
    * libguile/inline.h: Simplify, using SCM_INLINE,
      SCM_INLINE_IMPLEMENTATION, and SCM_IMPLEMENT_INLINES.  Also use the
      new SCM_GC_MALLOC macros.

commit ebc16e6a762748fc5939903a8b3a367d422f1371
Merge: a099c8d a8952d1
Author: Andy Wingo <address@hidden>
Date:   Thu May 26 17:03:23 2011 +0200

    Merge remote-tracking branch 'local-2.0/stable-2.0'

-----------------------------------------------------------------------

Summary of changes:
 doc/ref/data-rep.texi |    4 +-
 libguile/__scm.h      |   58 ++++++++++
 libguile/deprecated.c |   22 ++++
 libguile/deprecated.h |    8 ++
 libguile/gc.c         |    5 -
 libguile/gc.h         |  108 ++++++++++++++++++
 libguile/inline.c     |    7 +-
 libguile/inline.h     |  290 ++++---------------------------------------------
 libguile/smob.c       |   93 ++++++++++++----
 libguile/smob.h       |  160 ++++++++++++---------------
 libguile/strings.c    |    4 +-
 11 files changed, 371 insertions(+), 388 deletions(-)

diff --git a/doc/ref/data-rep.texi b/doc/ref/data-rep.texi
index c16f1b1..d0a76e9 100644
--- a/doc/ref/data-rep.texi
+++ b/doc/ref/data-rep.texi
@@ -443,8 +443,8 @@ representation, for obvious reasons.
 @end deftypefn
 
 @deftypefn Macro SCM SCM_UNSPECIFIED
-The value returned by expressions which the Scheme standard says return
-an ``unspecified'' value.
+The value returned by some (but not all) expressions that the Scheme
+standard says return an ``unspecified'' value.
 
 This is sort of a weirdly literal way to take things, but the standard
 read-eval-print loop prints nothing when the expression returns this
diff --git a/libguile/__scm.h b/libguile/__scm.h
index 19fcce8..3a8b07a 100644
--- a/libguile/__scm.h
+++ b/libguile/__scm.h
@@ -161,6 +161,64 @@
 
 
 
+/* 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
+
+
+
 /* {Debugging Options}
  *
  * These compile time options determine whether to include code that is only
diff --git a/libguile/deprecated.c b/libguile/deprecated.c
index 3e2d88a..e6ef917 100644
--- a/libguile/deprecated.c
+++ b/libguile/deprecated.c
@@ -56,6 +56,28 @@ scm_internal_dynamic_wind (scm_t_guard before,
 
 
 
+SCM
+scm_immutable_cell (scm_t_bits car, scm_t_bits cdr)
+{
+  scm_c_issue_deprecation_warning
+    ("scm_immutable_cell is deprecated.  Use scm_cell instead.");
+
+  return scm_cell (car, cdr);
+}
+
+SCM
+scm_immutable_double_cell (scm_t_bits car, scm_t_bits cbr,
+                          scm_t_bits ccr, scm_t_bits cdr)
+{
+  scm_c_issue_deprecation_warning
+    ("scm_immutable_double_cell is deprecated.  Use scm_double_cell instead.");
+
+  return scm_double_cell (car, cbr, ccr, cdr);
+}
+
+
+
+
 void
 scm_i_init_deprecated ()
 {
diff --git a/libguile/deprecated.h b/libguile/deprecated.h
index ca7f141..d116671 100644
--- a/libguile/deprecated.h
+++ b/libguile/deprecated.h
@@ -137,6 +137,14 @@ typedef scm_i_t_array 
scm_i_t_array__GONE__REPLACE_WITH__scm_t_array;
 
 
 
+/* Deprecated 26-05-2011, as the GC_STUBBORN API doesn't do anything any
+   more.  */
+SCM_API SCM scm_immutable_cell (scm_t_bits car, scm_t_bits cdr);
+SCM_API SCM scm_immutable_double_cell (scm_t_bits car, scm_t_bits cbr,
+                                      scm_t_bits ccr, scm_t_bits cdr);
+
+
+
 void scm_i_init_deprecated (void);
 
 #endif
diff --git a/libguile/gc.c b/libguile/gc.c
index 0451fbb..3ae978f 100644
--- a/libguile/gc.c
+++ b/libguile/gc.c
@@ -224,11 +224,6 @@ SCM_SYMBOL (sym_protected_objects, "protected-objects");
 SCM_SYMBOL (sym_times, "gc-times");
 
 
-/* Number of calls to SCM_NEWCELL since startup.  */
-unsigned scm_newcell_count;
-unsigned scm_newcell2_count;
-
-
 /* {Scheme Interface to GC}
  */
 static SCM
diff --git a/libguile/gc.h b/libguile/gc.h
index 2e2fc1f..f062942 100644
--- a/libguile/gc.h
+++ b/libguile/gc.h
@@ -191,6 +191,114 @@ SCM_API char *scm_gc_strdup (const char *str, const char 
*what)
 SCM_API char *scm_gc_strndup (const char *str, size_t n, const char *what)
   SCM_MALLOC;
 
+
+#ifdef BUILDING_LIBGUILE
+#include "libguile/bdw-gc.h"
+#define SCM_GC_MALLOC(size) GC_MALLOC (size)
+#define SCM_GC_MALLOC_POINTERLESS(size) GC_MALLOC_ATOMIC (size)
+#else
+#define SCM_GC_MALLOC(size) scm_gc_malloc (size, NULL)
+#define SCM_GC_MALLOC_POINTERLESS(size) scm_gc_malloc_pointerless (size, NULL)
+#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_uint16 n_words);
+
+#if SCM_CAN_INLINE || defined SCM_INLINE_C_IMPLEMENTING_INLINES
+
+SCM_INLINE_IMPLEMENTATION SCM
+scm_cell (scm_t_bits car, scm_t_bits cdr)
+{
+  SCM cell = PTR2SCM (SCM_GC_MALLOC (sizeof (scm_t_cell)));
+
+  /* Initialize the type slot last so that the cell is ignored by the GC
+     until it is completely initialized.  This is only relevant when the GC
+     can actually run during this code, which it can't since the GC only runs
+     when all other threads are stopped.  */
+  SCM_GC_SET_CELL_WORD (cell, 1, cdr);
+  SCM_GC_SET_CELL_WORD (cell, 0, car);
+
+  return cell;
+}
+
+SCM_INLINE_IMPLEMENTATION SCM
+scm_double_cell (scm_t_bits car, scm_t_bits cbr,
+                scm_t_bits ccr, scm_t_bits cdr)
+{
+  SCM z;
+
+  z = PTR2SCM (SCM_GC_MALLOC (2 * sizeof (scm_t_cell)));
+  /* Initialize the type slot last so that the cell is ignored by the
+     GC until it is completely initialized.  This is only relevant
+     when the GC can actually run during this code, which it can't
+     since the GC only runs when all other threads are stopped.
+  */
+  SCM_GC_SET_CELL_WORD (z, 1, cbr);
+  SCM_GC_SET_CELL_WORD (z, 2, ccr);
+  SCM_GC_SET_CELL_WORD (z, 3, cdr);
+  SCM_GC_SET_CELL_WORD (z, 0, car);
+
+  /* When this function is inlined, it's possible that the last
+     SCM_GC_SET_CELL_WORD above will be adjacent to a following
+     initialization of z.  E.g., it occurred in scm_make_real.  GCC
+     from around version 3 (e.g., certainly 3.2) began taking
+     advantage of strict C aliasing rules which say that it's OK to
+     interchange the initialization above and the one below when the
+     pointer types appear to differ sufficiently.  We don't want that,
+     of course.  GCC allows this behaviour to be disabled with the
+     -fno-strict-aliasing option, but would also need to be supplied
+     by Guile users.  Instead, the following statements prevent the
+     reordering.
+   */
+#ifdef __GNUC__
+  __asm__ volatile ("" : : : "memory");
+#else
+  /* portable version, just in case any other compiler does the same
+     thing.  */
+  scm_remember_upto_here_1 (z);
+#endif
+
+  return z;
+}
+
+SCM_INLINE_IMPLEMENTATION SCM
+scm_words (scm_t_bits car, scm_t_uint16 n_words)
+{
+  SCM z;
+
+  z = PTR2SCM (SCM_GC_MALLOC (sizeof (scm_t_bits) * n_words));
+  SCM_GC_SET_CELL_WORD (z, 0, car);
+
+  /* FIXME: is the following concern even relevant with BDW-GC? */
+
+  /* When this function is inlined, it's possible that the last
+     SCM_GC_SET_CELL_WORD above will be adjacent to a following
+     initialization of z.  E.g., it occurred in scm_make_real.  GCC
+     from around version 3 (e.g., certainly 3.2) began taking
+     advantage of strict C aliasing rules which say that it's OK to
+     interchange the initialization above and the one below when the
+     pointer types appear to differ sufficiently.  We don't want that,
+     of course.  GCC allows this behaviour to be disabled with the
+     -fno-strict-aliasing option, but would also need to be supplied
+     by Guile users.  Instead, the following statements prevent the
+     reordering.
+   */
+#ifdef __GNUC__
+  __asm__ volatile ("" : : : "memory");
+#else
+  /* portable version, just in case any other compiler does the same
+     thing.  */
+  scm_remember_upto_here_1 (z);
+#endif
+
+  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
index 79728ff..be7670a 100644
--- a/libguile/inline.c
+++ b/libguile/inline.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2006, 2008 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2006, 2008, 2011 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
@@ -20,5 +20,8 @@
 # include <config.h>
 #endif
 
-#define SCM_INLINE_C_INCLUDING_INLINE_H 1
+#define SCM_IMPLEMENT_INLINES 1
+#define SCM_INLINE_C_IMPLEMENTING_INLINES 1
 #include "libguile/inline.h"
+#include "libguile/gc.h"
+#include "libguile/smob.h"
diff --git a/libguile/inline.h b/libguile/inline.h
index 835edcc..6b1cf5e 100644
--- a/libguile/inline.h
+++ b/libguile/inline.h
@@ -23,9 +23,9 @@
  */
 
 /* This file is for inline functions.  On platforms that don't support
-   inlining functions, they are turned into ordinary functions.  See
-   "inline.c".
-*/
+   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 <stdio.h>
 #include <string.h>
@@ -41,248 +41,27 @@
 #include "libguile/error.h"
 
 
-#ifndef SCM_INLINE_C_INCLUDING_INLINE_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);
 
-/* GCC has `__inline__' in all modes, including strict ansi.  GCC 4.3 and
-   above with `-std=c99' or `-std=gnu99' implements ISO C99 inline semantics,
-   unless `-fgnu89-inline' is used.  Here we want GNU "extern inline"
-   semantics, hence the `__gnu_inline__' attribute, in accordance with:
-   http://gcc.gnu.org/gcc-4.3/porting_to.html .
+SCM_INLINE int scm_is_pair (SCM x);
+SCM_INLINE int scm_is_string (SCM x);
 
-   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.
+SCM_INLINE int scm_get_byte_or_eof (SCM port);
+SCM_INLINE int scm_peek_byte_or_eof (SCM port);
+SCM_INLINE void scm_putc (char c, SCM port);
+SCM_INLINE void scm_puts (const char *str_data, SCM port);
 
-   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))
-#  define SCM_C_USE_EXTERN_INLINE 1
-#  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
-# elif (defined SCM_C_INLINE)
-#  define SCM_C_EXTERN_INLINE static SCM_C_INLINE
-# endif
-
-#endif /* SCM_INLINE_C_INCLUDING_INLINE_H */
-
-
-#if (!defined SCM_C_INLINE) || (defined SCM_INLINE_C_INCLUDING_INLINE_H) \
-    || (defined SCM_C_USE_EXTERN_INLINE)
-
-/* The `extern' declarations.  They should only appear when used from
-   "inline.c", when `inline' is not supported at all or when "extern inline"
-   is used.  */
-
-#include "libguile/bdw-gc.h"
-
-
-SCM_API SCM scm_cell (scm_t_bits car, scm_t_bits cdr);
-SCM_API SCM scm_immutable_cell (scm_t_bits car, scm_t_bits cdr);
-SCM_API SCM scm_double_cell (scm_t_bits car, scm_t_bits cbr,
+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_API SCM scm_immutable_double_cell (scm_t_bits car, scm_t_bits cbr,
-                                      scm_t_bits ccr, scm_t_bits cdr);
-SCM_API SCM scm_words (scm_t_bits car, scm_t_uint16 n_words);
-/* no immutable words for now, would require initialization at the same time as
-   allocation */
-
-SCM_API SCM scm_array_handle_ref (scm_t_array_handle *h, ssize_t pos);
-SCM_API void scm_array_handle_set (scm_t_array_handle *h, ssize_t pos, SCM 
val);
-
-SCM_API int scm_is_pair (SCM x);
-SCM_API int scm_is_string (SCM x);
-
-SCM_API int scm_get_byte_or_eof (SCM port);
-SCM_API int scm_peek_byte_or_eof (SCM port);
-SCM_API void scm_putc (char c, SCM port);
-SCM_API void scm_puts (const char *str_data, SCM port);
-
-#endif
-
-
-#if defined SCM_C_EXTERN_INLINE || defined SCM_INLINE_C_INCLUDING_INLINE_H
-/* either inlining, or being included from inline.c.  We use (and
-   repeat) this long #if test here and below so that we don't have to
-   introduce any extraneous symbols into the public namespace.  We
-   only need SCM_C_INLINE to be seen publically . */
+SCM_INLINE SCM scm_words (scm_t_bits car, scm_t_uint16 n_words);
 
-extern unsigned scm_newcell2_count;
-extern unsigned scm_newcell_count;
+#if SCM_CAN_INLINE || defined SCM_INLINE_C_IMPLEMENTING_INLINES
+/* Either inlining, or being included from inline.c.  */
 
-
-#ifndef SCM_INLINE_C_INCLUDING_INLINE_H
-SCM_C_EXTERN_INLINE
-#endif
-
-SCM
-scm_cell (scm_t_bits car, scm_t_bits cdr)
-{
-  SCM cell = PTR2SCM (GC_MALLOC (sizeof (scm_t_cell)));
-
-  /* Initialize the type slot last so that the cell is ignored by the GC
-     until it is completely initialized.  This is only relevant when the GC
-     can actually run during this code, which it can't since the GC only runs
-     when all other threads are stopped.  */
-  SCM_GC_SET_CELL_WORD (cell, 1, cdr);
-  SCM_GC_SET_CELL_WORD (cell, 0, car);
-
-  return cell;
-}
-
-#ifndef SCM_INLINE_C_INCLUDING_INLINE_H
-SCM_C_EXTERN_INLINE
-#endif
-SCM
-scm_immutable_cell (scm_t_bits car, scm_t_bits cdr)
-{
-  SCM cell = PTR2SCM (GC_MALLOC_STUBBORN (sizeof (scm_t_cell)));
-
-  /* Initialize the type slot last so that the cell is ignored by the GC
-     until it is completely initialized.  This is only relevant when the GC
-     can actually run during this code, which it can't since the GC only runs
-     when all other threads are stopped.  */
-  SCM_GC_SET_CELL_WORD (cell, 1, cdr);
-  SCM_GC_SET_CELL_WORD (cell, 0, car);
-
-  GC_END_STUBBORN_CHANGE (SCM2PTR (cell));
-
-  return cell;
-}
-
-#ifndef SCM_INLINE_C_INCLUDING_INLINE_H
-SCM_C_EXTERN_INLINE
-#endif
-SCM
-scm_double_cell (scm_t_bits car, scm_t_bits cbr,
-                scm_t_bits ccr, scm_t_bits cdr)
-{
-  SCM z;
-
-  z = PTR2SCM (GC_MALLOC (2 * sizeof (scm_t_cell)));
-  /* Initialize the type slot last so that the cell is ignored by the
-     GC until it is completely initialized.  This is only relevant
-     when the GC can actually run during this code, which it can't
-     since the GC only runs when all other threads are stopped.
-  */
-  SCM_GC_SET_CELL_WORD (z, 1, cbr);
-  SCM_GC_SET_CELL_WORD (z, 2, ccr);
-  SCM_GC_SET_CELL_WORD (z, 3, cdr);
-  SCM_GC_SET_CELL_WORD (z, 0, car);
-
-  /* When this function is inlined, it's possible that the last
-     SCM_GC_SET_CELL_WORD above will be adjacent to a following
-     initialization of z.  E.g., it occurred in scm_make_real.  GCC
-     from around version 3 (e.g., certainly 3.2) began taking
-     advantage of strict C aliasing rules which say that it's OK to
-     interchange the initialization above and the one below when the
-     pointer types appear to differ sufficiently.  We don't want that,
-     of course.  GCC allows this behaviour to be disabled with the
-     -fno-strict-aliasing option, but would also need to be supplied
-     by Guile users.  Instead, the following statements prevent the
-     reordering.
-   */
-#ifdef __GNUC__
-  __asm__ volatile ("" : : : "memory");
-#else
-  /* portable version, just in case any other compiler does the same
-     thing.  */
-  scm_remember_upto_here_1 (z);
-#endif
-
-  return z;
-}
-
-#ifndef SCM_INLINE_C_INCLUDING_INLINE_H
-SCM_C_EXTERN_INLINE
-#endif
-SCM
-scm_immutable_double_cell (scm_t_bits car, scm_t_bits cbr,
-                          scm_t_bits ccr, scm_t_bits cdr)
-{
-  SCM z;
-
-  z = PTR2SCM (GC_MALLOC_STUBBORN (2 * sizeof (scm_t_cell)));
-  /* Initialize the type slot last so that the cell is ignored by the
-     GC until it is completely initialized.  This is only relevant
-     when the GC can actually run during this code, which it can't
-     since the GC only runs when all other threads are stopped.
-  */
-  SCM_GC_SET_CELL_WORD (z, 1, cbr);
-  SCM_GC_SET_CELL_WORD (z, 2, ccr);
-  SCM_GC_SET_CELL_WORD (z, 3, cdr);
-  SCM_GC_SET_CELL_WORD (z, 0, car);
-
-  GC_END_STUBBORN_CHANGE (SCM2PTR (z));
-
-  /* When this function is inlined, it's possible that the last
-     SCM_GC_SET_CELL_WORD above will be adjacent to a following
-     initialization of z.  E.g., it occurred in scm_make_real.  GCC
-     from around version 3 (e.g., certainly 3.2) began taking
-     advantage of strict C aliasing rules which say that it's OK to
-     interchange the initialization above and the one below when the
-     pointer types appear to differ sufficiently.  We don't want that,
-     of course.  GCC allows this behaviour to be disabled with the
-     -fno-strict-aliasing option, but would also need to be supplied
-     by Guile users.  Instead, the following statements prevent the
-     reordering.
-   */
-#ifdef __GNUC__
-  __asm__ volatile ("" : : : "memory");
-#else
-  /* portable version, just in case any other compiler does the same
-     thing.  */
-  scm_remember_upto_here_1 (z);
-#endif
-
-  return z;
-}
-
-#ifndef SCM_INLINE_C_INCLUDING_INLINE_H
-SCM_C_EXTERN_INLINE
-#endif
-SCM
-scm_words (scm_t_bits car, scm_t_uint16 n_words)
-{
-  SCM z;
-
-  z = PTR2SCM (GC_MALLOC (sizeof (scm_t_bits) * n_words));
-  SCM_GC_SET_CELL_WORD (z, 0, car);
-
-  /* FIXME: is the following concern even relevant with BDW-GC? */
-
-  /* When this function is inlined, it's possible that the last
-     SCM_GC_SET_CELL_WORD above will be adjacent to a following
-     initialization of z.  E.g., it occurred in scm_make_real.  GCC
-     from around version 3 (e.g., certainly 3.2) began taking
-     advantage of strict C aliasing rules which say that it's OK to
-     interchange the initialization above and the one below when the
-     pointer types appear to differ sufficiently.  We don't want that,
-     of course.  GCC allows this behaviour to be disabled with the
-     -fno-strict-aliasing option, but would also need to be supplied
-     by Guile users.  Instead, the following statements prevent the
-     reordering.
-   */
-#ifdef __GNUC__
-  __asm__ volatile ("" : : : "memory");
-#else
-  /* portable version, just in case any other compiler does the same
-     thing.  */
-  scm_remember_upto_here_1 (z);
-#endif
-
-  return z;
-}
-
-#ifndef SCM_INLINE_C_INCLUDING_INLINE_H
-SCM_C_EXTERN_INLINE
-#endif
-SCM
+SCM_INLINE_IMPLEMENTATION SCM
 scm_array_handle_ref (scm_t_array_handle *h, ssize_t p)
 {
   if (SCM_UNLIKELY (p < 0 && ((size_t)-p) > h->base))
@@ -292,10 +71,7 @@ scm_array_handle_ref (scm_t_array_handle *h, ssize_t p)
   return h->impl->vref (h, h->base + p);
 }
 
-#ifndef SCM_INLINE_C_INCLUDING_INLINE_H
-SCM_C_EXTERN_INLINE
-#endif
-void
+SCM_INLINE_IMPLEMENTATION 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))
@@ -305,10 +81,7 @@ scm_array_handle_set (scm_t_array_handle *h, ssize_t p, SCM 
v)
   h->impl->vset (h, h->base + p, v);
 }
 
-#ifndef SCM_INLINE_C_INCLUDING_INLINE_H
-SCM_C_EXTERN_INLINE
-#endif
-int
+SCM_INLINE_IMPLEMENTATION int
 scm_is_pair (SCM x)
 {
   /* The following "workaround_for_gcc_295" avoids bad code generated by
@@ -335,10 +108,7 @@ scm_is_pair (SCM x)
   return SCM_I_CONSP (x);
 }
 
-#ifndef SCM_INLINE_C_INCLUDING_INLINE_H
-SCM_C_EXTERN_INLINE
-#endif
-int
+SCM_INLINE_IMPLEMENTATION int
 scm_is_string (SCM x)
 {
   return SCM_NIMP (x) && (SCM_TYP7 (x) == scm_tc7_string);
@@ -346,10 +116,7 @@ scm_is_string (SCM x)
 
 /* Port I/O.  */
 
-#ifndef SCM_INLINE_C_INCLUDING_INLINE_H
-SCM_C_EXTERN_INLINE
-#endif
-int
+SCM_INLINE_IMPLEMENTATION int
 scm_get_byte_or_eof (SCM port)
 {
   int c;
@@ -374,10 +141,7 @@ scm_get_byte_or_eof (SCM port)
 }
 
 /* Like `scm_get_byte_or_eof' but does not change PORT's `read_pos'.  */
-#ifndef SCM_INLINE_C_INCLUDING_INLINE_H
-SCM_C_EXTERN_INLINE
-#endif
-int
+SCM_INLINE_IMPLEMENTATION int
 scm_peek_byte_or_eof (SCM port)
 {
   int c;
@@ -401,20 +165,14 @@ scm_peek_byte_or_eof (SCM port)
   return c;
 }
 
-#ifndef SCM_INLINE_C_INCLUDING_INLINE_H
-SCM_C_EXTERN_INLINE
-#endif
-void
+SCM_INLINE_IMPLEMENTATION void
 scm_putc (char c, SCM port)
 {
   SCM_ASSERT_TYPE (SCM_OPOUTPORTP (port), port, 0, NULL, "output port");
   scm_lfwrite (&c, 1, port);
 }
 
-#ifndef SCM_INLINE_C_INCLUDING_INLINE_H
-SCM_C_EXTERN_INLINE
-#endif
-void
+SCM_INLINE_IMPLEMENTATION void
 scm_puts (const char *s, SCM port)
 {
   SCM_ASSERT_TYPE (SCM_OPOUTPORTP (port), port, 0, NULL, "output port");
diff --git a/libguile/smob.c b/libguile/smob.c
index c414913..ef3f564 100644
--- a/libguile/smob.c
+++ b/libguile/smob.c
@@ -475,8 +475,8 @@ scm_make_smob (scm_t_bits tc)
 static int smob_gc_kind;
 
 
-/* The generic SMOB mark procedure that gets called for SMOBs allocated with
-   `scm_i_new_smob_with_mark_proc ()'.  */
+/* The generic SMOB mark procedure that gets called for SMOBs allocated
+   with smob_gc_kind.  */
 static struct GC_ms_entry *
 smob_mark (GC_word *addr, struct GC_ms_entry *mark_stack_ptr,
           struct GC_ms_entry *mark_stack_limit, GC_word env)
@@ -565,28 +565,10 @@ scm_gc_mark (SCM o)
 #undef CURRENT_MARK_LIMIT
 }
 
-/* Return a SMOB with typecode TC.  The SMOB type corresponding to TC may
-   provide a custom mark procedure and it will be honored.  */
-SCM
-scm_i_new_smob_with_mark_proc (scm_t_bits tc, scm_t_bits data1,
-                              scm_t_bits data2, scm_t_bits data3)
-{
-  /* Return a double cell.  */
-  SCM cell = SCM_PACK (GC_generic_malloc (2 * sizeof (scm_t_cell),
-                                         smob_gc_kind));
-
-  SCM_SET_CELL_WORD_3 (cell, data3);
-  SCM_SET_CELL_WORD_2 (cell, data2);
-  SCM_SET_CELL_WORD_1 (cell, data1);
-  SCM_SET_CELL_WORD_0 (cell, tc);
-
-  return cell;
-}
-
 
 /* Finalize SMOB by calling its SMOB type's free function, if any.  */
-void
-scm_i_finalize_smob (GC_PTR ptr, GC_PTR data)
+static void
+finalize_smob (GC_PTR ptr, GC_PTR data)
 {
   SCM smob;
   size_t (* free_smob) (SCM);
@@ -602,6 +584,73 @@ scm_i_finalize_smob (GC_PTR ptr, GC_PTR data)
     free_smob (smob);
 }
 
+/* Return a SMOB with typecode TC.  The SMOB type corresponding to TC may
+   provide a custom mark procedure and it will be honored.  */
+SCM
+scm_i_new_smob (scm_t_bits tc, scm_t_bits data)
+{
+  scm_t_bits smobnum = SCM_TC2SMOBNUM (tc);
+  SCM ret;
+
+  /* Use the smob_gc_kind if needed to allow the mark procedure to
+     run.  Since the marker only deals with double cells, that case
+     allocates a double cell.  We leave words 2 and 3 to there initial
+     values, which is 0.  */
+  if (scm_smobs [smobnum].mark)
+    ret = PTR2SCM (GC_generic_malloc (2 * sizeof (scm_t_cell), smob_gc_kind));
+  else
+    ret = PTR2SCM (GC_MALLOC (sizeof (scm_t_cell)));
+  
+  SCM_SET_CELL_WORD_1 (ret, data);
+  SCM_SET_CELL_WORD_0 (ret, tc);
+
+  if (scm_smobs[smobnum].free)
+    {
+      GC_finalization_proc prev_finalizer;
+      GC_PTR prev_finalizer_data;
+
+      GC_REGISTER_FINALIZER_NO_ORDER (SCM2PTR (ret),
+                                      finalize_smob, NULL,
+                                      &prev_finalizer, &prev_finalizer_data);
+    }
+
+  return ret;
+}
+
+/* Return a SMOB with typecode TC.  The SMOB type corresponding to TC may
+   provide a custom mark procedure and it will be honored.  */
+SCM
+scm_i_new_double_smob (scm_t_bits tc, scm_t_bits data1,
+                       scm_t_bits data2, scm_t_bits data3)
+{
+  scm_t_bits smobnum = SCM_TC2SMOBNUM (tc);
+  SCM ret;
+
+  /* Use the smob_gc_kind if needed to allow the mark procedure to
+     run.  */
+  if (scm_smobs [smobnum].mark)
+    ret = PTR2SCM (GC_generic_malloc (2 * sizeof (scm_t_cell), smob_gc_kind));
+  else
+    ret = PTR2SCM (GC_MALLOC (2 * sizeof (scm_t_cell)));
+  
+  SCM_SET_CELL_WORD_3 (ret, data3);
+  SCM_SET_CELL_WORD_2 (ret, data2);
+  SCM_SET_CELL_WORD_1 (ret, data1);
+  SCM_SET_CELL_WORD_0 (ret, tc);
+
+  if (scm_smobs[smobnum].free)
+    {
+      GC_finalization_proc prev_finalizer;
+      GC_PTR prev_finalizer_data;
+
+      GC_REGISTER_FINALIZER_NO_ORDER (SCM2PTR (ret),
+                                      finalize_smob, NULL,
+                                      &prev_finalizer, &prev_finalizer_data);
+    }
+
+  return ret;
+}
+
 
 void
 scm_smob_prehistory ()
diff --git a/libguile/smob.h b/libguile/smob.h
index 6a7ceea..1bcece6 100644
--- a/libguile/smob.h
+++ b/libguile/smob.h
@@ -27,8 +27,6 @@
 #include "libguile/__scm.h"
 #include "libguile/print.h"
 
-#include "libguile/bdw-gc.h"
-
 
 
 /* This is the internal representation of a smob type */
@@ -46,78 +44,79 @@ typedef struct scm_smob_descriptor
 } scm_smob_descriptor;
 
 
+#define SCM_SMOB_TYPE_MASK             0xffff
+#define SCM_SMOB_TYPE_BITS(tc)         (tc)
+#define SCM_TC2SMOBNUM(x)              (0x0ff & ((x) >> 8))
+#define SCM_SMOBNUM(x)                 (SCM_TC2SMOBNUM (SCM_CELL_TYPE (x)))
+/* SCM_SMOBNAME can be 0 if name is missing */
+#define SCM_SMOBNAME(smobnum)          (scm_smobs[smobnum].name)
+#define SCM_SMOB_PREDICATE(tag, obj)   SCM_TYP16_PREDICATE (tag, obj)
+#define SCM_SMOB_DESCRIPTOR(x)         (scm_smobs[SCM_SMOBNUM (x)])
+#define SCM_SMOB_APPLICABLE_P(x)       (SCM_SMOB_DESCRIPTOR (x).apply)
+
+/* Maximum number of SMOB types.  */
+#define SCM_I_MAX_SMOB_TYPE_COUNT  256
+
+SCM_API long scm_numsmob;
+SCM_API scm_smob_descriptor scm_smobs[];
+
+
 
-SCM_API SCM scm_i_new_smob_with_mark_proc (scm_t_bits tc,
-                                          scm_t_bits, scm_t_bits, scm_t_bits);
-
-
-
-#define SCM_NEWSMOB(z, tc, data)                                         \
-do                                                                       \
-  {                                                                      \
-    register scm_t_bits _smobnum = SCM_TC2SMOBNUM (tc);                        
  \
-    z = (scm_smobs[_smobnum].mark                                        \
-        ? scm_i_new_smob_with_mark_proc ((tc), (scm_t_bits)(data),       \
-                                         0, 0)                           \
-        : scm_cell (tc, (scm_t_bits)(data)));                            \
-    if (scm_smobs[_smobnum].free)                                        \
-      {                                                                        
  \
-       GC_finalization_proc _prev_finalizer;                             \
-       GC_PTR _prev_finalizer_data;                                      \
-                                                                         \
-       GC_REGISTER_FINALIZER_NO_ORDER (SCM2PTR (z), scm_i_finalize_smob, \
-                                       NULL,                             \
-                                       &_prev_finalizer,                 \
-                                       &_prev_finalizer_data);           \
-      }                                                                        
  \
-  }                                                                      \
-while (0)
-
-#define SCM_RETURN_NEWSMOB(tc, data)                   \
-  do { SCM __SCM_smob_answer;                          \
-       SCM_NEWSMOB (__SCM_smob_answer, (tc), (data));  \
-       return __SCM_smob_answer;                       \
-  } while (0)
-
-#define SCM_NEWSMOB2(z, tc, data1, data2)      \
-  SCM_NEWSMOB3 (z, tc, data1, data2, 0)
-
-#define SCM_RETURN_NEWSMOB2(tc, data1, data2)                          \
-  do { SCM __SCM_smob_answer;                                          \
-       SCM_NEWSMOB2 (__SCM_smob_answer, (tc), (data1), (data2));       \
-       return __SCM_smob_answer;                                       \
-  } while (0)
-
-#define SCM_NEWSMOB3(z, tc, data1, data2, data3)                         \
-do                                                                       \
-  {                                                                      \
-    register scm_t_bits _smobnum = SCM_TC2SMOBNUM (tc);                        
  \
-    z = (scm_smobs[_smobnum].mark                                        \
-        ? scm_i_new_smob_with_mark_proc (tc, (scm_t_bits)(data1),        \
-                                         (scm_t_bits)(data2),            \
-                                         (scm_t_bits)(data3))            \
-        : scm_double_cell ((tc), (scm_t_bits)(data1),                    \
-                           (scm_t_bits)(data2),                          \
-                           (scm_t_bits)(data3)));                        \
-    if (scm_smobs[_smobnum].free)                                        \
-      {                                                                        
  \
-       GC_finalization_proc _prev_finalizer;                             \
-       GC_PTR _prev_finalizer_data;                                      \
-                                                                         \
-       GC_REGISTER_FINALIZER_NO_ORDER (SCM2PTR (z), scm_i_finalize_smob, \
-                                       NULL,                             \
-                                       &_prev_finalizer,                 \
-                                       &_prev_finalizer_data);           \
-      }                                                                        
  \
-  }                                                                      \
-while (0)
-
-#define SCM_RETURN_NEWSMOB3(tc, data1, data2, data3)                       \
-  do { SCM __SCM_smob_answer;                                              \
-       SCM_NEWSMOB3 (__SCM_smob_answer, (tc), (data1), (data2), (data3));   \
-       return __SCM_smob_answer;                                           \
-  } while (0)
 
+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
+scm_new_smob (scm_t_bits tc, scm_t_bits data)
+{
+  scm_t_bits smobnum = SCM_TC2SMOBNUM (tc);
+
+  if (SCM_UNLIKELY (scm_smobs[smobnum].mark || scm_smobs[smobnum].free))
+    return scm_i_new_smob (tc, data);
+  else
+    return scm_cell (tc, data);
+}
+
+SCM_INLINE_IMPLEMENTATION SCM
+scm_new_double_smob (scm_t_bits tc, scm_t_bits data1,
+                     scm_t_bits data2, scm_t_bits data3)
+{
+  scm_t_bits smobnum = SCM_TC2SMOBNUM (tc);
+
+  if (SCM_UNLIKELY (scm_smobs[smobnum].mark || scm_smobs[smobnum].free))
+    return scm_i_new_double_smob (tc, data1, data2, data3);
+  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))
+#define SCM_RETURN_NEWSMOB(tc, data)            \
+  return scm_new_smob ((tc), (scm_t_bits)(data))
+
+#define SCM_NEWSMOB2(z, tc, data1, data2)               \
+  z = scm_new_double_smob ((tc), (scm_t_bits)(data1),   \
+                           (scm_t_bits)(data2), 0)
+#define SCM_RETURN_NEWSMOB2(tc, data1, data2)                   \
+  return scm_new_double_smob ((tc), (scm_t_bits)(data1),        \
+                              (scm_t_bits)(data2), 0)
+
+#define SCM_NEWSMOB3(z, tc, data1, data2, data3)                        \
+  z = scm_new_double_smob ((tc), (scm_t_bits)(data1),                   \
+                           (scm_t_bits)(data2), (scm_t_bits)(data3))
+#define SCM_RETURN_NEWSMOB3(tc, data1, data2, data3)                    \
+  return scm_new_double_smob ((tc), (scm_t_bits)(data1),                \
+                              (scm_t_bits)(data2), (scm_t_bits)(data3))
+
+
 
 #define SCM_SMOB_DATA_N(x, n)          (SCM_CELL_WORD ((x), (n)))
 #define SCM_SET_SMOB_DATA_N(x, n, data)        (SCM_SET_CELL_WORD ((x), (n), 
(data)))
@@ -158,28 +157,11 @@ while (0)
 #define SCM_SMOB_OBJECT_LOC(x)         (SCM_SMOB_OBJECT_1_LOC (x)))
 
 
-#define SCM_SMOB_TYPE_MASK             0xffff
-#define SCM_SMOB_TYPE_BITS(tc)         (tc)
-#define SCM_TC2SMOBNUM(x)              (0x0ff & ((x) >> 8))
-#define SCM_SMOBNUM(x)                 (SCM_TC2SMOBNUM (SCM_CELL_TYPE (x)))
-/* SCM_SMOBNAME can be 0 if name is missing */
-#define SCM_SMOBNAME(smobnum)          (scm_smobs[smobnum].name)
-#define SCM_SMOB_PREDICATE(tag, obj)   SCM_TYP16_PREDICATE (tag, obj)
-#define SCM_SMOB_DESCRIPTOR(x)         (scm_smobs[SCM_SMOBNUM (x)])
-#define SCM_SMOB_APPLICABLE_P(x)       (SCM_SMOB_DESCRIPTOR (x).apply)
 #define SCM_SMOB_APPLY_0(x)            (scm_call_0 (x))
 #define SCM_SMOB_APPLY_1(x, a1)                (scm_call_1 (x, a1))
 #define SCM_SMOB_APPLY_2(x, a1, a2)    (scm_call_2 (x, a1, a2))
 #define SCM_SMOB_APPLY_3(x, a1, a2, rst) (scm_call_3 (x, a1, a2, a3))
 
-/* Maximum number of SMOB types.  */
-#define SCM_I_MAX_SMOB_TYPE_COUNT  256
-
-SCM_API long scm_numsmob;
-SCM_API scm_smob_descriptor scm_smobs[];
-
-SCM_API void scm_i_finalize_smob (GC_PTR obj, GC_PTR data);
-
 
 
 SCM_API SCM scm_mark0 (SCM ptr);
diff --git a/libguile/strings.c b/libguile/strings.c
index 8e7ad8d..e54c27d 100644
--- a/libguile/strings.c
+++ b/libguile/strings.c
@@ -741,8 +741,8 @@ scm_i_c_make_symbol (const char *name, size_t len,
   SCM buf = make_stringbuf (len);
   memcpy (STRINGBUF_CHARS (buf), name, len);
 
-  return scm_immutable_double_cell (scm_tc7_symbol | flags, SCM_UNPACK (buf),
-                                   (scm_t_bits) hash, SCM_UNPACK (props));
+  return scm_double_cell (scm_tc7_symbol | flags, SCM_UNPACK (buf),
+                          (scm_t_bits) hash, SCM_UNPACK (props));
 }
 
 /* Returns the number of characters in SYM.  This may be different


hooks/post-receive
-- 
GNU Guile



reply via email to

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