diff options
Diffstat (limited to 'libguile/strings.c')
-rw-r--r-- | libguile/strings.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/libguile/strings.c b/libguile/strings.c index 6e3b0a347..1839c6ac0 100644 --- a/libguile/strings.c +++ b/libguile/strings.c @@ -65,8 +65,8 @@ * stringbuf. So we have fixstrings and bigstrings... */ -#define STRINGBUF_F_SHARED 0x100 -#define STRINGBUF_F_INLINE 0x200 +#define STRINGBUF_F_SHARED SCM_I_STRINGBUF_F_SHARED +#define STRINGBUF_F_INLINE SCM_I_STRINGBUF_F_INLINE #define STRINGBUF_TAG scm_tc7_stringbuf #define STRINGBUF_SHARED(buf) (SCM_CELL_WORD_0(buf) & STRINGBUF_F_SHARED) @@ -86,8 +86,15 @@ #define STRINGBUF_MAX_INLINE_LEN (3*sizeof(scm_t_bits)) -#define SET_STRINGBUF_SHARED(buf) \ - (SCM_SET_CELL_WORD_0 ((buf), SCM_CELL_WORD_0 (buf) | STRINGBUF_F_SHARED)) +#define SET_STRINGBUF_SHARED(buf) \ + do \ + { \ + /* Don't modify BUF if it's already marked as shared since it might be \ + a read-only, statically allocated stringbuf. */ \ + if (SCM_LIKELY (!STRINGBUF_SHARED (buf))) \ + SCM_SET_CELL_WORD_0 ((buf), SCM_CELL_WORD_0 (buf) | STRINGBUF_F_SHARED); \ + } \ + while (0) #if SCM_DEBUG static size_t lenhist[1001]; @@ -155,7 +162,7 @@ scm_i_pthread_mutex_t stringbuf_write_mutex = SCM_I_PTHREAD_MUTEX_INITIALIZER; /* Read-only strings. */ -#define RO_STRING_TAG (scm_tc7_string + 0x200) +#define RO_STRING_TAG scm_tc7_ro_string #define IS_RO_STRING(str) (SCM_CELL_TYPE(str)==RO_STRING_TAG) /* Mutation-sharing substrings |