aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrea Corallo2020-06-04 10:33:07 +0100
committerAndrea Corallo2020-06-04 10:33:07 +0100
commitf5ea65b43678621cb450d7afbcd46032258d4b20 (patch)
treedcc643ae66589a1690c50895a46e8004c981ead0 /src
parente4e6bb7fddaa3a4e82748c106366fe9113dc16d9 (diff)
parent4fff6502368e87b3c031589a1a96267243f868b0 (diff)
downloademacs-f5ea65b43678621cb450d7afbcd46032258d4b20.tar.gz
emacs-f5ea65b43678621cb450d7afbcd46032258d4b20.zip
Merge remote-tracking branch 'savannah/master' into HEAD
Diffstat (limited to 'src')
-rw-r--r--src/alloc.c57
-rw-r--r--src/composite.c4
-rw-r--r--src/emacs.c5
-rw-r--r--src/lread.c21
-rw-r--r--src/pdumper.c2
-rw-r--r--src/xdisp.c7
-rw-r--r--src/xfaces.c24
7 files changed, 55 insertions, 65 deletions
diff --git a/src/alloc.c b/src/alloc.c
index dc92d67f163..281525b20e5 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -67,7 +67,8 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
67# include <malloc.h> 67# include <malloc.h>
68#endif 68#endif
69 69
70#if defined HAVE_VALGRIND_VALGRIND_H && !defined USE_VALGRIND 70#if (defined ENABLE_CHECKING \
71 && defined HAVE_VALGRIND_VALGRIND_H && !defined USE_VALGRIND)
71# define USE_VALGRIND 1 72# define USE_VALGRIND 1
72#endif 73#endif
73 74
@@ -4463,7 +4464,7 @@ live_string_holding (struct mem_node *m, void *p)
4463 4464
4464 /* P must point into a Lisp_String structure, and it 4465 /* P must point into a Lisp_String structure, and it
4465 must not be on the free-list. */ 4466 must not be on the free-list. */
4466 if (0 <= offset && offset < STRING_BLOCK_SIZE * sizeof b->strings[0]) 4467 if (0 <= offset && offset < sizeof b->strings)
4467 { 4468 {
4468 cp = ptr_bounds_copy (cp, b); 4469 cp = ptr_bounds_copy (cp, b);
4469 struct Lisp_String *s = p = cp -= offset % sizeof b->strings[0]; 4470 struct Lisp_String *s = p = cp -= offset % sizeof b->strings[0];
@@ -4496,7 +4497,7 @@ live_cons_holding (struct mem_node *m, void *p)
4496 /* P must point into a Lisp_Cons, not be 4497 /* P must point into a Lisp_Cons, not be
4497 one of the unused cells in the current cons block, 4498 one of the unused cells in the current cons block,
4498 and not be on the free-list. */ 4499 and not be on the free-list. */
4499 if (0 <= offset && offset < CONS_BLOCK_SIZE * sizeof b->conses[0] 4500 if (0 <= offset && offset < sizeof b->conses
4500 && (b != cons_block 4501 && (b != cons_block
4501 || offset / sizeof b->conses[0] < cons_block_index)) 4502 || offset / sizeof b->conses[0] < cons_block_index))
4502 { 4503 {
@@ -4532,7 +4533,7 @@ live_symbol_holding (struct mem_node *m, void *p)
4532 /* P must point into the Lisp_Symbol, not be 4533 /* P must point into the Lisp_Symbol, not be
4533 one of the unused cells in the current symbol block, 4534 one of the unused cells in the current symbol block,
4534 and not be on the free-list. */ 4535 and not be on the free-list. */
4535 if (0 <= offset && offset < SYMBOL_BLOCK_SIZE * sizeof b->symbols[0] 4536 if (0 <= offset && offset < sizeof b->symbols
4536 && (b != symbol_block 4537 && (b != symbol_block
4537 || offset / sizeof b->symbols[0] < symbol_block_index)) 4538 || offset / sizeof b->symbols[0] < symbol_block_index))
4538 { 4539 {
@@ -4566,9 +4567,8 @@ live_float_p (struct mem_node *m, void *p)
4566 4567
4567 /* P must point to the start of a Lisp_Float and not be 4568 /* P must point to the start of a Lisp_Float and not be
4568 one of the unused cells in the current float block. */ 4569 one of the unused cells in the current float block. */
4569 return (offset >= 0 4570 return (0 <= offset && offset < sizeof b->floats
4570 && offset % sizeof b->floats[0] == 0 4571 && offset % sizeof b->floats[0] == 0
4571 && offset < (FLOAT_BLOCK_SIZE * sizeof b->floats[0])
4572 && (b != float_block 4572 && (b != float_block
4573 || offset / sizeof b->floats[0] < float_block_index)); 4573 || offset / sizeof b->floats[0] < float_block_index));
4574 } 4574 }
@@ -4694,35 +4694,6 @@ mark_maybe_objects (Lisp_Object const *array, ptrdiff_t nelts)
4694 mark_maybe_object (*array); 4694 mark_maybe_object (*array);
4695} 4695}
4696 4696
4697/* A lower bound on the alignment of Lisp objects that need marking.
4698 Although 1 is safe, higher values speed up mark_maybe_pointer.
4699 If USE_LSB_TAG, this value is typically GCALIGNMENT; otherwise,
4700 it's determined by the natural alignment of Lisp structs.
4701 All vectorlike objects have alignment at least that of union
4702 vectorlike_header and it's unlikely they all have alignment greater,
4703 so use the union as a safe and likely-accurate standin for
4704 vectorlike objects. */
4705
4706enum { GC_OBJECT_ALIGNMENT_MINIMUM
4707 = max (GCALIGNMENT,
4708 min (alignof (union vectorlike_header),
4709 min (min (alignof (struct Lisp_Cons),
4710 alignof (struct Lisp_Float)),
4711 min (alignof (struct Lisp_String),
4712 alignof (struct Lisp_Symbol))))) };
4713
4714/* Return true if P might point to Lisp data that can be garbage
4715 collected, and false otherwise (i.e., false if it is easy to see
4716 that P cannot point to Lisp data that can be garbage collected).
4717 Symbols are implemented via offsets not pointers, but the offsets
4718 are also multiples of GC_OBJECT_ALIGNMENT_MINIMUM. */
4719
4720static bool
4721maybe_lisp_pointer (void *p)
4722{
4723 return (uintptr_t) p % GC_OBJECT_ALIGNMENT_MINIMUM == 0;
4724}
4725
4726/* If P points to Lisp data, mark that as live if it isn't already 4697/* If P points to Lisp data, mark that as live if it isn't already
4727 marked. */ 4698 marked. */
4728 4699
@@ -4731,13 +4702,10 @@ mark_maybe_pointer (void *p)
4731{ 4702{
4732 struct mem_node *m; 4703 struct mem_node *m;
4733 4704
4734#ifdef USE_VALGRIND 4705#if USE_VALGRIND
4735 VALGRIND_MAKE_MEM_DEFINED (&p, sizeof (p)); 4706 VALGRIND_MAKE_MEM_DEFINED (&p, sizeof (p));
4736#endif 4707#endif
4737 4708
4738 if (!maybe_lisp_pointer (p))
4739 return;
4740
4741 if (pdumper_object_p (p)) 4709 if (pdumper_object_p (p))
4742 { 4710 {
4743 int type = pdumper_find_object_type (p); 4711 int type = pdumper_find_object_type (p);
@@ -4837,7 +4805,16 @@ mark_memory (void const *start, void const *end)
4837 4805
4838 for (pp = start; (void const *) pp < end; pp += GC_POINTER_ALIGNMENT) 4806 for (pp = start; (void const *) pp < end; pp += GC_POINTER_ALIGNMENT)
4839 { 4807 {
4840 mark_maybe_pointer (*(void *const *) pp); 4808 char *p = *(char *const *) pp;
4809 mark_maybe_pointer (p);
4810
4811 /* Unmask any struct Lisp_Symbol pointer that make_lisp_symbol
4812 previously disguised by adding the address of 'lispsym'.
4813 On a host with 32-bit pointers and 64-bit Lisp_Objects,
4814 a Lisp_Object might be split into registers saved into
4815 non-adjacent words and P might be the low-order word's value. */
4816 p += (intptr_t) lispsym;
4817 mark_maybe_pointer (p);
4841 4818
4842 verify (alignof (Lisp_Object) % GC_POINTER_ALIGNMENT == 0); 4819 verify (alignof (Lisp_Object) % GC_POINTER_ALIGNMENT == 0);
4843 if (alignof (Lisp_Object) == GC_POINTER_ALIGNMENT 4820 if (alignof (Lisp_Object) == GC_POINTER_ALIGNMENT
diff --git a/src/composite.c b/src/composite.c
index 518502be49f..2c589e4f3a9 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -1987,7 +1987,9 @@ preceding and/or following characters, this char-table contains
1987a function to call to compose that character. 1987a function to call to compose that character.
1988 1988
1989The element at index C in the table, if non-nil, is a list of 1989The element at index C in the table, if non-nil, is a list of
1990composition rules of this form: ([PATTERN PREV-CHARS FUNC] ...) 1990composition rules of the form ([PATTERN PREV-CHARS FUNC] ...);
1991the rules must be specified in the descending order of PREV-CHARS
1992values.
1991 1993
1992PATTERN is a regular expression which C and the surrounding 1994PATTERN is a regular expression which C and the surrounding
1993characters must match. 1995characters must match.
diff --git a/src/emacs.c b/src/emacs.c
index 8ecf9b4aeba..228ac293370 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -358,7 +358,10 @@ setlocale (int cat, char const *locale)
358static bool 358static bool
359using_utf8 (void) 359using_utf8 (void)
360{ 360{
361#ifdef HAVE_WCHAR_H 361 /* We don't want to compile in mbrtowc on WINDOWSNT because that
362 will prevent Emacs from starting on older Windows systems, while
363 the result is known in advance anyway... */
364#if defined HAVE_WCHAR_H && !defined WINDOWSNT
362 wchar_t wc; 365 wchar_t wc;
363 mbstate_t mbs = { 0 }; 366 mbstate_t mbs = { 0 };
364 return mbrtowc (&wc, "\xc4\x80", 2, &mbs) == 2 && wc == 0x100; 367 return mbrtowc (&wc, "\xc4\x80", 2, &mbs) == 2 && wc == 0x100;
diff --git a/src/lread.c b/src/lread.c
index 9f849eda423..026f3b6d98f 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -3030,17 +3030,18 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
3030 struct Lisp_Vector *vec; 3030 struct Lisp_Vector *vec;
3031 tmp = read_vector (readcharfun, 1); 3031 tmp = read_vector (readcharfun, 1);
3032 vec = XVECTOR (tmp); 3032 vec = XVECTOR (tmp);
3033 if (! (COMPILED_STACK_DEPTH < vec->header.size 3033 if (! (COMPILED_STACK_DEPTH < ASIZE (tmp)
3034 && (FIXNUMP (vec->contents[COMPILED_ARGLIST]) 3034 && (FIXNUMP (AREF (tmp, COMPILED_ARGLIST))
3035 || CONSP (vec->contents[COMPILED_ARGLIST]) 3035 || CONSP (AREF (tmp, COMPILED_ARGLIST))
3036 || NILP (vec->contents[COMPILED_ARGLIST])) 3036 || NILP (AREF (tmp, COMPILED_ARGLIST)))
3037 && ((STRINGP (vec->contents[COMPILED_BYTECODE]) 3037 && ((STRINGP (AREF (tmp, COMPILED_BYTECODE))
3038 && VECTORP (vec->contents[COMPILED_CONSTANTS])) 3038 && VECTORP (AREF (tmp, COMPILED_CONSTANTS)))
3039 || CONSP (vec->contents[COMPILED_BYTECODE])) 3039 || CONSP (AREF (tmp, COMPILED_BYTECODE)))
3040 && FIXNATP (vec->contents[COMPILED_STACK_DEPTH]))) 3040 && FIXNATP (AREF (tmp, COMPILED_STACK_DEPTH))))
3041 invalid_syntax ("Invalid byte-code object"); 3041 invalid_syntax ("Invalid byte-code object");
3042 3042
3043 if (STRING_MULTIBYTE (AREF (tmp, COMPILED_BYTECODE))) 3043 if (STRINGP (AREF (tmp, COMPILED_BYTECODE))
3044 && STRING_MULTIBYTE (AREF (tmp, COMPILED_BYTECODE)))
3044 { 3045 {
3045 /* BYTESTR must have been produced by Emacs 20.2 or earlier 3046 /* BYTESTR must have been produced by Emacs 20.2 or earlier
3046 because it produced a raw 8-bit string for byte-code and 3047 because it produced a raw 8-bit string for byte-code and
@@ -3051,7 +3052,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
3051 Fstring_as_unibyte (AREF (tmp, COMPILED_BYTECODE))); 3052 Fstring_as_unibyte (AREF (tmp, COMPILED_BYTECODE)));
3052 } 3053 }
3053 3054
3054 if (COMPILED_DOC_STRING < vec->header.size 3055 if (COMPILED_DOC_STRING < ASIZE (tmp)
3055 && EQ (AREF (tmp, COMPILED_DOC_STRING), make_fixnum (0))) 3056 && EQ (AREF (tmp, COMPILED_DOC_STRING), make_fixnum (0)))
3056 { 3057 {
3057 /* read_list found a docstring like '(#$ . 5521)' and treated it 3058 /* read_list found a docstring like '(#$ . 5521)' and treated it
diff --git a/src/pdumper.c b/src/pdumper.c
index 29e3560ee5a..ffe59fbb306 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -2256,7 +2256,7 @@ dump_bignum (struct dump_context *ctx, Lisp_Object object)
2256static dump_off 2256static dump_off
2257dump_float (struct dump_context *ctx, const struct Lisp_Float *lfloat) 2257dump_float (struct dump_context *ctx, const struct Lisp_Float *lfloat)
2258{ 2258{
2259#if CHECK_STRUCTS && !defined (HASH_Lisp_Float_50A7B216D9) 2259#if CHECK_STRUCTS && !defined (HASH_Lisp_Float_7E7D284C02)
2260# error "Lisp_Float changed. See CHECK_STRUCTS comment in config.h." 2260# error "Lisp_Float changed. See CHECK_STRUCTS comment in config.h."
2261#endif 2261#endif
2262 eassert (ctx->header.cold_start); 2262 eassert (ctx->header.cold_start);
diff --git a/src/xdisp.c b/src/xdisp.c
index ea28395cf55..327e8a183b1 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -8692,6 +8692,7 @@ handle_stop_backwards (struct it *it, ptrdiff_t charpos)
8692 ptrdiff_t where_we_are = (bufp ? IT_CHARPOS (*it) : IT_STRING_CHARPOS (*it)); 8692 ptrdiff_t where_we_are = (bufp ? IT_CHARPOS (*it) : IT_STRING_CHARPOS (*it));
8693 struct display_pos save_current = it->current; 8693 struct display_pos save_current = it->current;
8694 struct text_pos save_position = it->position; 8694 struct text_pos save_position = it->position;
8695 struct composition_it save_cmp_it = it->cmp_it;
8695 struct text_pos pos1; 8696 struct text_pos pos1;
8696 ptrdiff_t next_stop; 8697 ptrdiff_t next_stop;
8697 8698
@@ -8719,6 +8720,7 @@ handle_stop_backwards (struct it *it, ptrdiff_t charpos)
8719 it->bidi_p = true; 8720 it->bidi_p = true;
8720 it->current = save_current; 8721 it->current = save_current;
8721 it->position = save_position; 8722 it->position = save_position;
8723 it->cmp_it = save_cmp_it;
8722 next_stop = it->stop_charpos; 8724 next_stop = it->stop_charpos;
8723 it->stop_charpos = it->prev_stop; 8725 it->stop_charpos = it->prev_stop;
8724 handle_stop (it); 8726 handle_stop (it);
@@ -11575,7 +11577,9 @@ display_echo_area_1 (ptrdiff_t a1, Lisp_Object a2)
11575 /* Display. */ 11577 /* Display. */
11576 clear_glyph_matrix (w->desired_matrix); 11578 clear_glyph_matrix (w->desired_matrix);
11577 XSETWINDOW (window, w); 11579 XSETWINDOW (window, w);
11580 void *itdata = bidi_shelve_cache ();
11578 try_window (window, start, 0); 11581 try_window (window, start, 0);
11582 bidi_unshelve_cache (itdata, false);
11579 11583
11580 return window_height_changed_p; 11584 return window_height_changed_p;
11581} 11585}
@@ -19748,7 +19752,7 @@ find_last_row_displaying_text (struct glyph_matrix *matrix, struct it *it,
19748 by changes at the start of current_buffer that occurred since W's 19752 by changes at the start of current_buffer that occurred since W's
19749 current matrix was built. Value is null if no such row exists. 19753 current matrix was built. Value is null if no such row exists.
19750 19754
19751 BEG_UNCHANGED us the number of characters unchanged at the start of 19755 BEG_UNCHANGED is the number of characters unchanged at the start of
19752 current_buffer. BEG + BEG_UNCHANGED is the buffer position of the 19756 current_buffer. BEG + BEG_UNCHANGED is the buffer position of the
19753 first changed character in current_buffer. Characters at positions < 19757 first changed character in current_buffer. Characters at positions <
19754 BEG + BEG_UNCHANGED are at the same buffer positions as they were 19758 BEG + BEG_UNCHANGED are at the same buffer positions as they were
@@ -27702,6 +27706,7 @@ fill_gstring_glyph_string (struct glyph_string *s, int face_id,
27702 while (glyph < last 27706 while (glyph < last
27703 && glyph->u.cmp.automatic 27707 && glyph->u.cmp.automatic
27704 && glyph->u.cmp.id == s->cmp_id 27708 && glyph->u.cmp.id == s->cmp_id
27709 && glyph->face_id == face_id
27705 && s->cmp_to == glyph->slice.cmp.from) 27710 && s->cmp_to == glyph->slice.cmp.from)
27706 { 27711 {
27707 s->width += glyph->pixel_width; 27712 s->width += glyph->pixel_width;
diff --git a/src/xfaces.c b/src/xfaces.c
index 7d7aff95c11..cf155288bd1 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -4356,15 +4356,15 @@ color_distance (Emacs_Color *x, Emacs_Color *y)
4356 4356
4357 See <https://www.compuphase.com/cmetric.htm> for more info. */ 4357 See <https://www.compuphase.com/cmetric.htm> for more info. */
4358 4358
4359 long r = (x->red - y->red) >> 8; 4359 long long r = x->red - y->red;
4360 long g = (x->green - y->green) >> 8; 4360 long long g = x->green - y->green;
4361 long b = (x->blue - y->blue) >> 8; 4361 long long b = x->blue - y->blue;
4362 long r_mean = (x->red + y->red) >> 9; 4362 long long r_mean = (x->red + y->red) >> 1;
4363 4363
4364 return 4364 return (((((2 * 65536 + r_mean) * r * r) >> 16)
4365 (((512 + r_mean) * r * r) >> 8) 4365 + 4 * g * g
4366 + 4 * g * g 4366 + (((2 * 65536 + 65535 - r_mean) * b * b) >> 16))
4367 + (((767 - r_mean) * b * b) >> 8); 4367 >> 16);
4368} 4368}
4369 4369
4370 4370
@@ -4374,7 +4374,9 @@ COLOR1 and COLOR2 may be either strings containing the color name,
4374or lists of the form (RED GREEN BLUE), each in the range 0 to 65535 inclusive. 4374or lists of the form (RED GREEN BLUE), each in the range 0 to 65535 inclusive.
4375If FRAME is unspecified or nil, the current frame is used. 4375If FRAME is unspecified or nil, the current frame is used.
4376If METRIC is specified, it should be a function that accepts 4376If METRIC is specified, it should be a function that accepts
4377two lists of the form (RED GREEN BLUE) aforementioned. */) 4377two lists of the form (RED GREEN BLUE) aforementioned.
4378Despite the name, this is not a true distance metric as it does not satisfy
4379the triangle inequality. */)
4378 (Lisp_Object color1, Lisp_Object color2, Lisp_Object frame, 4380 (Lisp_Object color1, Lisp_Object color2, Lisp_Object frame,
4379 Lisp_Object metric) 4381 Lisp_Object metric)
4380{ 4382{
@@ -4931,7 +4933,7 @@ DEFUN ("face-attributes-as-vector", Fface_attributes_as_vector,
4931 4933
4932/* If the distance (as returned by color_distance) between two colors is 4934/* If the distance (as returned by color_distance) between two colors is
4933 less than this, then they are considered the same, for determining 4935 less than this, then they are considered the same, for determining
4934 whether a color is supported or not. The range of values is 0-65535. */ 4936 whether a color is supported or not. */
4935 4937
4936#define TTY_SAME_COLOR_THRESHOLD 10000 4938#define TTY_SAME_COLOR_THRESHOLD 10000
4937 4939