Author: ek.kato
Date: Sun Nov 4 04:26:19 2007
New Revision: 5038
Modified:
sigscheme-trunk/src/alloc.c
sigscheme-trunk/src/sigscheme.h
sigscheme-trunk/src/storage-compact.h
Log:
* src/storage-compact.h (SCM_ISAL_SYMBOL_INIT) : Align the address
of symbol name (bug #12981).
* src/sigscheme.h : Export scm_align_str().
* src/alloc.c (scm_align_str) : Enable.
Modified: sigscheme-trunk/src/alloc.c
==============================================================================
--- sigscheme-trunk/src/alloc.c (original)
+++ sigscheme-trunk/src/alloc.c Sun Nov 4 04:26:19 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: sigscheme-trunk/src/sigscheme.h
==============================================================================
--- sigscheme-trunk/src/sigscheme.h (original)
+++ sigscheme-trunk/src/sigscheme.h Sun Nov 4 04:26:19 2007
@@ -1298,6 +1298,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: sigscheme-trunk/src/storage-compact.h
==============================================================================
--- sigscheme-trunk/src/storage-compact.h (original)
+++ sigscheme-trunk/src/storage-compact.h Sun Nov 4 04:26:19 2007
@@ -640,11 +640,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 {
\