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. release_1-9-11-206-g4


From: Andy Wingo
Subject: [Guile-commits] GNU Guile branch, master, updated. release_1-9-11-206-g442eaa6
Date: Mon, 19 Jul 2010 20:49:24 +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=442eaa681b0c2db4254d4903f8a0996b4ffc83d0

The branch, master has been updated
       via  442eaa681b0c2db4254d4903f8a0996b4ffc83d0 (commit)
       via  d68a81e038597ba3d47f39b4cd8a5864953dc1d5 (commit)
       via  1c05a2a16d845a261bcb0804e7162f31533d674f (commit)
       via  6f8d7b12bbcc5be470bb6421bcd70d5806bce04b (commit)
      from  0f3a70cfa897530cdc50aa768d73d41419a5b360 (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 442eaa681b0c2db4254d4903f8a0996b4ffc83d0
Author: Andreas Rottmann <address@hidden>
Date:   Mon Jul 19 22:40:56 2010 +0200

    Fix random number generator on 64-bit platforms
    
    * libguile/random.c (scm_c_random): On platforms where `unsigned long' has 
64
      bit, generate up to 64 bit of randomness. This is expected by
      scm_c_random_bignum(), and hence was a serious distortion of the random 
value
      distribution for values exceeding 2^32. This change also fixes a crash 
when
      the `m' argument is a value above 2^32.

commit d68a81e038597ba3d47f39b4cd8a5864953dc1d5
Author: Andy Wingo <address@hidden>
Date:   Sat Jul 17 13:30:50 2010 +0200

    recommend #:replace
    
    * doc/ref/api-modules.texi (Creating Guile Modules): Update text to
      recommend #:replace.
    * module/srfi/srfi-19.scm (current-time): #:replace.

commit 1c05a2a16d845a261bcb0804e7162f31533d674f
Author: Andy Wingo <address@hidden>
Date:   Sat Jul 17 12:22:17 2010 +0200

    use scm_malloc_pointerless to alloc aligned blocks in fallback
    
    * libguile/continuations.c (SCM_DECLARE_STATIC_ALIGNED_ARRAY)
      (SCM_STATIC_ALIGNED_ARRAY)
    * libguile/control.c (SCM_DECLARE_STATIC_ALIGNED_ARRAY)
      (SCM_STATIC_ALIGNED_ARRAY): Tweak backslashes. Use
      scm_malloc_pointerless to ensure alignment.

commit 6f8d7b12bbcc5be470bb6421bcd70d5806bce04b
Author: Andy Wingo <address@hidden>
Date:   Sat Jul 17 12:10:52 2010 +0200

    SCM_I_FLUID_P -> SCM_FLUID_P
    
    * libguile/fluids.h (SCM_FLUID_P): Change from SCM_I_FLUID_P.
      (SCM_I_FLUID_NUM, SCM_I_DYNAMIC_STATE_P, SCM_I_DYNAMIC_STATE_FLUIDS):
      Wrap in BUILDING_LIBGUILE ifdef.

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

Summary of changes:
 doc/ref/api-modules.texi |   39 ++++++++++++++++-----------------------
 libguile/continuations.c |    9 ++++-----
 libguile/control.c       |    9 ++++-----
 libguile/fluids.c        |    2 +-
 libguile/fluids.h        |    6 +++++-
 libguile/random.c        |   28 +++++++++++++++++++++++++++-
 libguile/vm-i-system.c   |    4 ++--
 module/srfi/srfi-19.scm  |    2 +-
 8 files changed, 60 insertions(+), 39 deletions(-)

diff --git a/doc/ref/api-modules.texi b/doc/ref/api-modules.texi
index a1aff34..b412dbe 100644
--- a/doc/ref/api-modules.texi
+++ b/doc/ref/api-modules.texi
@@ -383,29 +383,22 @@ with the same name that is not also ``replacing''.  
Normally a
 replacement results in an ``override'' warning message, 
 @code{#:replace} avoids that.
 
-This is useful for modules that export bindings that have the same
-name as core bindings.  @code{#:replace}, in a sense, lets Guile know
-that the module @emph{purposefully} replaces a core binding.  It is
-important to note, however, that this binding replacement is confined
-to the name space of the module user.  In other words, the value of the
-core binding in question remains unchanged for other modules.
-
-For instance, SRFI-39 exports a binding named
address@hidden (@pxref{SRFI-39}) that is a function which
-is upwardly compatible with the core @code{current-input-port}
-function.  Therefore, SRFI-39 exports its version with
address@hidden:replace}.
-
-SRFI-19, on the other hand, exports its own version of
address@hidden (@pxref{SRFI-19 Time}) which is not compatible
-with the core @code{current-time} function (@pxref{Time}).  Therefore,
-SRFI-19 does not use @code{#:replace}.
-
-The @code{#:replace} option can also be used by a module which is
-intentionally producing a new special kind of environment and should
-override any core or other bindings already in scope.  For example
-perhaps a logic processing environment where @code{<=} is an inference
-instead of a comparison.
+In general, a module that exports a binding for which the @code{(guile)}
+module already has a definition should use @code{#:replace} instead of
address@hidden:export}.  @code{#:replace}, in a sense, lets Guile know that the
+module @emph{purposefully} replaces a core binding.  It is important to
+note, however, that this binding replacement is confined to the name
+space of the module user.  In other words, the value of the core binding
+in question remains unchanged for other modules.
+
+Note that although it is often a good idea for the replaced binding to
+remain compatible with a binding in @code{(guile)}, to avoid surprising
+the user, sometimes the bindings will be incompatible.  For example,
+SRFI-19 exports its own version of @code{current-time} (@pxref{SRFI-19
+Time}) which is not compatible with the core @code{current-time}
+function (@pxref{Time}).  Guile assumes that a user importing a module
+knows what she is doing, and uses @code{#:replace} for this binding
+rather than @code{#:export}.
 
 The @code{#:duplicates} (see below) provides fine-grain control about
 duplicate binding handling on the module-user side.
diff --git a/libguile/continuations.c b/libguile/continuations.c
index dc504f0..b478963 100644
--- a/libguile/continuations.c
+++ b/libguile/continuations.c
@@ -74,16 +74,15 @@ static scm_t_bits tc16_continuation;
 #define ALIGN_PTR(type,p,align) (type*)(ROUND_UP (((scm_t_bits)p), align))
 
 #ifdef SCM_ALIGNED
-#define SCM_DECLARE_STATIC_ALIGNED_ARRAY(type, sym)\
+#define SCM_DECLARE_STATIC_ALIGNED_ARRAY(type, sym)     \
 static const type sym[]
-#define SCM_STATIC_ALIGNED_ARRAY(alignment, type, sym)\
+#define SCM_STATIC_ALIGNED_ARRAY(alignment, type, sym)  \
 static SCM_ALIGNED (alignment) const type sym[]
 #else
-#define SCM_DECLARE_STATIC_ALIGNED_ARRAY(type, sym)\
+#define SCM_DECLARE_STATIC_ALIGNED_ARRAY(type, sym)     \
 static type *sym
 #define SCM_STATIC_ALIGNED_ARRAY(alignment, type, sym)                  \
-SCM_SNARF_INIT(sym = scm_malloc (sizeof(sym##__unaligned) + alignment - 1); \
-               sym = ALIGN_PTR (type, sym, alignment);                  \
+SCM_SNARF_INIT(sym = scm_malloc_pointerless (sizeof(sym##__unaligned)); \
                memcpy (sym, sym##__unaligned, sizeof(sym##__unaligned));) \
 static type *sym = NULL;                                                \
 static const type sym##__unaligned[]
diff --git a/libguile/control.c b/libguile/control.c
index 6c20675..99bc846 100644
--- a/libguile/control.c
+++ b/libguile/control.c
@@ -82,16 +82,15 @@ scm_i_prompt_pop_abort_args_x (SCM prompt)
 #define ALIGN_PTR(type,p,align) (type*)(ROUND_UP (((scm_t_bits)p), align))
 
 #ifdef SCM_ALIGNED
-#define SCM_DECLARE_STATIC_ALIGNED_ARRAY(type, sym)\
+#define SCM_DECLARE_STATIC_ALIGNED_ARRAY(type, sym)     \
 static const type sym[]
-#define SCM_STATIC_ALIGNED_ARRAY(alignment, type, sym)\
+#define SCM_STATIC_ALIGNED_ARRAY(alignment, type, sym)  \
 static SCM_ALIGNED (alignment) const type sym[]
 #else
-#define SCM_DECLARE_STATIC_ALIGNED_ARRAY(type, sym)\
+#define SCM_DECLARE_STATIC_ALIGNED_ARRAY(type, sym)     \
 static type *sym
 #define SCM_STATIC_ALIGNED_ARRAY(alignment, type, sym)                  \
-SCM_SNARF_INIT(sym = scm_malloc (sizeof(sym##__unaligned) + alignment - 1); \
-               sym = ALIGN_PTR (type, sym, alignment);                  \
+SCM_SNARF_INIT(sym = scm_malloc_pointerless (sizeof(sym##__unaligned); \
                memcpy (sym, sym##__unaligned, sizeof(sym##__unaligned));) \
 static type *sym = NULL;                                                \
 static const type sym##__unaligned[]
diff --git a/libguile/fluids.c b/libguile/fluids.c
index 9aa1eb2..636c78d 100644
--- a/libguile/fluids.c
+++ b/libguile/fluids.c
@@ -44,7 +44,7 @@ static size_t allocated_fluids_len = 0;
 
 static scm_i_pthread_mutex_t fluid_admin_mutex = 
SCM_I_PTHREAD_MUTEX_INITIALIZER;
 
-#define IS_FLUID(x)         SCM_I_FLUID_P (x)
+#define IS_FLUID(x)         SCM_FLUID_P (x)
 #define FLUID_NUM(x)        SCM_I_FLUID_NUM (x)
 
 #define IS_DYNAMIC_STATE(x) SCM_I_DYNAMIC_STATE_P (x)
diff --git a/libguile/fluids.h b/libguile/fluids.h
index aa01f24..d837414 100644
--- a/libguile/fluids.h
+++ b/libguile/fluids.h
@@ -54,8 +54,10 @@
    grow.
  */
 
-#define SCM_I_FLUID_P(x)          (!SCM_IMP (x) && SCM_TYP7 (x) == 
scm_tc7_fluid)
+#define SCM_FLUID_P(x)          (!SCM_IMP (x) && SCM_TYP7 (x) == scm_tc7_fluid)
+#ifdef BUILDING_LIBGUILE
 #define SCM_I_FLUID_NUM(x)        ((size_t)SCM_CELL_WORD_1(x))
+#endif
 
 SCM_API SCM scm_make_fluid (void);
 SCM_API int scm_is_fluid (SCM obj);
@@ -75,8 +77,10 @@ SCM_API SCM scm_with_fluid (SCM fluid, SCM val, SCM thunk);
 
 SCM_API void scm_dynwind_fluid (SCM fluid, SCM value);
 
+#ifdef BUILDING_LIBGUILE
 #define SCM_I_DYNAMIC_STATE_P(x) (!SCM_IMP (x) && SCM_TYP7 (x) == 
scm_tc7_dynamic_state)
 #define SCM_I_DYNAMIC_STATE_FLUIDS(x)        SCM_PACK (SCM_CELL_WORD_1 (x))
+#endif
 
 SCM_API SCM scm_make_dynamic_state (SCM parent);
 SCM_API SCM scm_dynamic_state_p (SCM obj);
diff --git a/libguile/random.c b/libguile/random.c
index 281d43a..1a9fd59 100644
--- a/libguile/random.c
+++ b/libguile/random.c
@@ -223,7 +223,8 @@ unsigned char scm_masktab[256];
 unsigned long
 scm_c_random (scm_t_rstate *state, unsigned long m)
 {
-  unsigned int r, mask;
+  unsigned long r, mask;
+#if SCM_SIZEOF_UNSIGNED_LONG == 4
   mask = (m < 0x100
          ? scm_masktab[m]
          : (m < 0x10000
@@ -232,6 +233,31 @@ scm_c_random (scm_t_rstate *state, unsigned long m)
                ? scm_masktab[m >> 16] << 16 | 0xffff
                : scm_masktab[m >> 24] << 24 | 0xffffff)));
   while ((r = scm_the_rng.random_bits (state) & mask) >= m);
+#elif SCM_SIZEOF_UNSIGNED_LONG == 8
+  mask = (m < 0x100
+         ? scm_masktab[m]
+         : (m < 0x10000
+            ? scm_masktab[m >> 8] << 8 | 0xff
+            : (m < 0x1000000
+               ? scm_masktab[m >> 16] << 16 | 0xffff
+                : (m < (1UL << 32)
+                   ? scm_masktab[m >> 24] << 24 | 0xffffff
+                   : (m < (1UL << 40)
+                      ? ((unsigned long) scm_masktab[m >> 32] << 32
+                         | 0xffffffffUL)
+                      : (m < (1UL << 48)
+                         ? ((unsigned long) scm_masktab[m >> 40] << 40
+                            | 0xffffffffffUL)
+                         : (m < (1UL << 56)
+                            ? ((unsigned long) scm_masktab[m >> 48] << 48
+                               | 0xffffffffffffUL)
+                            : ((unsigned long) scm_masktab[m >> 56] << 56
+                               | 0xffffffffffffffUL))))))));
+  while ((r = ((scm_the_rng.random_bits (state) << 32
+                | scm_the_rng.random_bits (state))) & mask) >= m);
+#else
+#error "Cannot deal with this platform's unsigned long size"
+#endif
   return r;
 }
 
diff --git a/libguile/vm-i-system.c b/libguile/vm-i-system.c
index 11f8ae0..3af6308 100644
--- a/libguile/vm-i-system.c
+++ b/libguile/vm-i-system.c
@@ -1594,7 +1594,7 @@ VM_DEFINE_INSTRUCTION (92, fluid_ref, "fluid-ref", 0, 1, 
1)
   
   CHECK_UNDERFLOW ();
   fluids = SCM_I_DYNAMIC_STATE_FLUIDS (dynstate);
-  if (SCM_UNLIKELY (!SCM_I_FLUID_P (*sp))
+  if (SCM_UNLIKELY (!SCM_FLUID_P (*sp))
       || ((num = SCM_I_FLUID_NUM (*sp)) >= SCM_SIMPLE_VECTOR_LENGTH (fluids)))
     {
       /* Punt dynstate expansion and error handling to the C proc. */
@@ -1615,7 +1615,7 @@ VM_DEFINE_INSTRUCTION (93, fluid_set, "fluid-set", 0, 2, 
0)
   POP (val);
   POP (fluid);
   fluids = SCM_I_DYNAMIC_STATE_FLUIDS (dynstate);
-  if (SCM_UNLIKELY (!SCM_I_FLUID_P (fluid))
+  if (SCM_UNLIKELY (!SCM_FLUID_P (fluid))
       || ((num = SCM_I_FLUID_NUM (fluid)) >= SCM_SIMPLE_VECTOR_LENGTH 
(fluids)))
     {
       /* Punt dynstate expansion and error handling to the C proc. */
diff --git a/module/srfi/srfi-19.scm b/module/srfi/srfi-19.scm
index e73e4d6..dcc2533 100644
--- a/module/srfi/srfi-19.scm
+++ b/module/srfi/srfi-19.scm
@@ -44,6 +44,7 @@
   :use-module (srfi srfi-9)
   :autoload   (ice-9 rdelim) (read-line)
   :use-module (ice-9 i18n)
+  :replace (current-time)
   :export (;; Constants
            time-duration
            time-monotonic
@@ -55,7 +56,6 @@
            current-date
            current-julian-day
            current-modified-julian-day
-           current-time
            time-resolution
            ;; Time object and accessors
            make-time


hooks/post-receive
-- 
GNU Guile



reply via email to

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