summaryrefslogtreecommitdiff
path: root/libguile/inline.h
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2010-01-05 15:20:47 +0100
committerAndy Wingo <wingo@pobox.com>2010-01-05 15:33:46 +0100
commite809758a7e0f3f63162a0a9064b95bd1c1d10628 (patch)
tree4090a48ef3c228e2609b2bee7a6946172d4a91a1 /libguile/inline.h
parentbab980466108c6c22d2c820213d07b3d1b18c48e (diff)
downloadguile-e809758a7e0f3f63162a0a9064b95bd1c1d10628.tar.gz
clean up macros.[ch]
There are some incompatible changes here, but only to interfaces that were introduced earlier in 1.9, or interfaces which have been broken since early in 1.9. * libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump, as the macro changes affect the interface that is called by psyntax-generated macro definitions. * libguile/inline.h (scm_words): New function, allocates a variable number of contiguous scm_t_bits locations, with a given value in the 0th word, and 0 in the rest of the words. * libguile/macros.h: Rework interface to correspond more closely, and minimally, to the needs of memoize.c and psyntax. (SCM_ASSYNT, SCM_MACRO_TYPE_BITS, SCM_MACRO_TYPE_MASK) (SCM_F_MACRO_EXTENDED, SCM_MACROP, SCM_MACRO_TYPE) (SCM_MACRO_IS_EXTENDED, SCM_BUILTIN_MACRO_P, SCM_SYNCASE_MACRO_P) (SCM_MACRO_CODE, scm_tc16_macro): Remove CPP macros related to the representation of Scheme macros. (scm_i_make_primitive_macro): Renamed from scm_i_makbimacro. (scm_i_macro_primitive): New accessor so that memoize.c can get to the primitive syntax transformer. (scm_make_syncase_macro, scm_make_extended_syncase_macro) (scm_syncase_macro_type, scm_syncase_macro_binding): Removed these functions, replaced by make-syntax-transformer and its accessors. (scm_macro_binding): New accessor, the same as what scm_syncase_macro_binding was. * libguile/macros.c: All representation details of syntax transformers are private to this file now. (macro_print): Print macros as #<syntax-transformer ...>, or #<primitive-syntax-transformer ...> if psyntax has not attached a transformer of its own. (scm_i_make_primitive_macro): Represent macros as 5-word smobs. (scm_make_syntax_transformer): New constructor for syntax transformers (macros), exported to scheme. Takes a name, and looks it up in the current module to determine the previous primitive transformer, if any. (scm_macro_type): Instead of returning 'builtin-macro!, etc, return the type as set by psyntax, or #f if it's a primitive. (scm_macro_name): Return the stored macro name. (scm_macro_transformer): Return the psyntax-set syntax transformer. Hacky, but should help introspection somewhat. * libguile/memoize.c (memoize_env_ref_transformer): Use the new scm_i_macro_primitive, and adapt to other macro API changes. * module/ice-9/psyntax.scm (put-global-definition-hook) (get-global-definition-hook, chi-install-global): Call (and generate calls to) the new macro constructors and accessors. * module/ice-9/psyntax-pp.scm: Doubly regenerated. * module/ice-9/debugging/traps.scm (trap-here): Comment out this definition and export, while it's not working.
Diffstat (limited to 'libguile/inline.h')
-rw-r--r--libguile/inline.h41
1 files changed, 40 insertions, 1 deletions
diff --git a/libguile/inline.h b/libguile/inline.h
index 09a1b5a35..018e6c636 100644
--- a/libguile/inline.h
+++ b/libguile/inline.h
@@ -3,7 +3,7 @@
#ifndef SCM_INLINE_H
#define SCM_INLINE_H
-/* Copyright (C) 2001, 2002, 2003, 2004, 2006, 2008, 2009 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2002, 2003, 2004, 2006, 2008, 2009, 2010 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
@@ -87,6 +87,9 @@ SCM_API 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);
@@ -241,6 +244,42 @@ scm_immutable_double_cell (scm_t_bits car, scm_t_bits cbr,
SCM_C_EXTERN_INLINE
#endif
SCM
+scm_words (scm_t_bits car, scm_t_uint16 n_words)
+{
+ SCM z;
+
+ z = SCM_PACK ((scm_t_bits) (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_array_handle_ref (scm_t_array_handle *h, ssize_t p)
{
if (SCM_UNLIKELY (p < 0 && ((size_t)-p) > h->base))