summaryrefslogtreecommitdiff
path: root/libguile/strings.c
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2009-11-01 18:17:31 +0100
committerLudovic Courtès <ludo@gnu.org>2009-11-01 18:17:31 +0100
commit731dd0ce191bf4f3ba8fedfe0e08c0e67a966ce4 (patch)
treedd1ad47fdceebb013c42dc9b87c03c2fa5d79c0a /libguile/strings.c
parentb4246e5b2235bd01a24a5069ed683fc3c0f6f18c (diff)
parent5f236208d0d864546e59afa0f5a11c9b3ba14b10 (diff)
downloadguile-731dd0ce191bf4f3ba8fedfe0e08c0e67a966ce4.tar.gz
Merge branch 'bdw-gc-static-alloc'
Conflicts: acinclude.m4 libguile/__scm.h libguile/bdw-gc.h libguile/eval.c
Diffstat (limited to 'libguile/strings.c')
-rw-r--r--libguile/strings.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/libguile/strings.c b/libguile/strings.c
index c7f09db21..21295addf 100644
--- a/libguile/strings.c
+++ b/libguile/strings.c
@@ -72,10 +72,8 @@
#define STRINGBUF_HEADER_BYTES (STRINGBUF_HEADER_SIZE * sizeof (SCM))
-#define STRINGBUF_F_SHARED 0x100
-#define STRINGBUF_F_WIDE 0x400 /* If true, strings have UCS-4
- encoding. Otherwise, strings
- are Latin-1. */
+#define STRINGBUF_F_SHARED SCM_I_STRINGBUF_F_SHARED
+#define STRINGBUF_F_WIDE SCM_I_STRINGBUF_F_WIDE
#define STRINGBUF_TAG scm_tc7_stringbuf
#define STRINGBUF_SHARED(buf) (SCM_CELL_WORD_0(buf) & STRINGBUF_F_SHARED)
@@ -88,8 +86,15 @@
#define STRINGBUF_WIDE_CHARS(buf) ((scm_t_wchar *) STRINGBUF_CHARS (buf))
-#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_STRING_LENGTH_HISTOGRAM
static size_t lenhist[1001];
@@ -235,7 +240,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