From f2d3008d3ce90e30e347f184d6394f96f04dae3c Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 19 Apr 2011 12:10:31 -0700 Subject: [PATCH] * alloc.c (SDATA_SIZE) [!GC_CHECK_STRING_BYTES]: Avoid runtime check in the common case where SDATA_DATA_OFFSET is a multiple of Emacs word size. --- src/ChangeLog | 4 ++++ src/alloc.c | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 7a97a066f12..480d163d18d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2011-04-19 Paul Eggert + * alloc.c (SDATA_SIZE) [!GC_CHECK_STRING_BYTES]: Avoid runtime check + in the common case where SDATA_DATA_OFFSET is a multiple of Emacs + word size. + * gnutls.c: Fix problems found by GCC 4.6.0 on Ubuntu 10.10. (gnutls_make_error): Rename local to avoid shadowing. (gnutls_emacs_global_deinit): ifdef out; not used. diff --git a/src/alloc.c b/src/alloc.c index 82be8a903b4..8be6371d247 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -1643,10 +1643,18 @@ static char const string_overrun_cookie[GC_STRING_OVERRUN_COOKIE_SIZE] = #else /* not GC_CHECK_STRING_BYTES */ -#define SDATA_SIZE(NBYTES) \ - ((SDATA_DATA_OFFSET \ - + max (NBYTES, sizeof (EMACS_INT) - 1) + 1 \ - + sizeof (EMACS_INT) - 1) \ +/* The 'max' reserves space for the nbytes union member even when NBYTES + 1 is + less than the size of that member. The 'max' is not needed when + SDATA_DATA_OFFSET is a multiple of sizeof (EMACS_INT), because then the + alignment code reserves enough space. */ + +#define SDATA_SIZE(NBYTES) \ + ((SDATA_DATA_OFFSET \ + + (SDATA_DATA_OFFSET % sizeof (EMACS_INT) == 0 \ + ? NBYTES \ + : max (NBYTES, sizeof (EMACS_INT) - 1)) \ + + 1 \ + + sizeof (EMACS_INT) - 1) \ & ~(sizeof (EMACS_INT) - 1)) #endif /* not GC_CHECK_STRING_BYTES */ -- 2.39.2