Author: ek.kato
Date: Sun Nov  4 04:30:10 2007
New Revision: 5039

Modified:
  branches/sigscheme-0.7/src/alloc.c
  branches/sigscheme-0.7/src/sigscheme.h
  branches/sigscheme-0.7/src/storage-compact.h

Log:
* src/storage-compact.h
* src/sigscheme.h
* src/alloc.c
 - Port r4963:5038 from sigscheme-trunk (bug #12981).


Modified: branches/sigscheme-0.7/src/alloc.c
==============================================================================
--- branches/sigscheme-0.7/src/alloc.c  (original)
+++ branches/sigscheme-0.7/src/alloc.c  Sun Nov  4 04:30:10 2007
@@ -181,10 +181,12 @@
    return copied;
}

-#if 0
/* For 'name' slot of symbol object on storage-compact. If your malloc(3) does
 * not ensure 8-bytes alignment, Complete this function and hook this into
- * symbol object creation and modification.  -- YamaKen 2006-05-30 */
+ * symbol object creation and modification.  -- YamaKen 2006-05-30
+ *
+ * At least strdup(3) with short string in FreeBSD Release 7.0 BETA1.5
+ * and 8.0-CURRENT x86 returns unaligned address -- ekato 2007-11-04 */
SCM_EXPORT char *
scm_align_str(char *str)
{
@@ -192,17 +194,16 @@
    size_t size;

    /* Use ScmCell-alignment to ensure at least 8-bytes aligned. */
-    if ((uintptr_t)ptr % sizeof(ScmCell)) {
+    if ((uintptr_t)str % sizeof(ScmCell)) {
        size = strlen(str) + sizeof("");
-        copied = scm_malloc_aligned8(size);
+        copied = scm_malloc_aligned(size);
        strcpy(copied, str);
        free(str);
        return copied;
    } else {
-        return ptr;
+        return str;
    }
}
-#endif

/*=======================================
   Extendable Local Buffer

Modified: branches/sigscheme-0.7/src/sigscheme.h
==============================================================================
--- branches/sigscheme-0.7/src/sigscheme.h      (original)
+++ branches/sigscheme-0.7/src/sigscheme.h      Sun Nov  4 04:30:10 2007
@@ -1242,6 +1242,7 @@
SCM_EXPORT void *scm_calloc(size_t number, size_t size);
SCM_EXPORT void *scm_realloc(void *ptr, size_t size);
SCM_EXPORT char *scm_strdup(const char *str);
+SCM_EXPORT char *scm_align_str(char *str);

/* storage-gc.c */
SCM_EXPORT void scm_gc_protect(ScmObj *var);

Modified: branches/sigscheme-0.7/src/storage-compact.h
==============================================================================
--- branches/sigscheme-0.7/src/storage-compact.h        (original)
+++ branches/sigscheme-0.7/src/storage-compact.h        Sun Nov  4 04:30:10 2007
@@ -639,11 +639,14 @@
(SCM_ASSERT(SCM_ALIGNED_SYMBOL_NAME(n)), \
     SCM_SET_Y(SCM_SYMBOL_PTR(o), (scm_uintobj_t)(n) | SCM_MTAG_SYMBOL))
#define SCM_ISAL_SYMBOL_INIT(o, n, c) \ - (SCM_ASSERT(SCM_ALIGNED_SYMBOL_NAME(n)), \ - SCM_INIT((o), \ - (c), \ - (scm_uintobj_t)(n) | SCM_MTAG_SYMBOL, \
-              SCM_PTAG_MISC))
+ do { \ + char *_s = scm_align_str(n); \ + (SCM_ASSERT(SCM_ALIGNED_SYMBOL_NAME(_s)), \ + SCM_INIT((o), \ + (c), \ + (scm_uintobj_t)(_s) | SCM_MTAG_SYMBOL, \ + SCM_PTAG_MISC)); \
+    } while (0)
#define SCM_CELL_SYMBOLP(c)            SCM_MISC_CELL_TYPEP((c), SYMBOL)
#define SCM_CELL_SYMBOL_FIN(c) \ do { \

Reply via email to