aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2011-09-30 10:44:37 -0700
committerPaul Eggert2011-09-30 10:44:37 -0700
commit535272bb73eff5a5db01301e5b60f6128d6dc788 (patch)
treeb41937c81a61bf737ef15efb434fc06338da25b4 /src
parent38532ce6ecb33efee5f697886d9fd20a3c2cda01 (diff)
parentf701dc2abbcfb64c0c4d02ac899dccb03ee2b246 (diff)
downloademacs-535272bb73eff5a5db01301e5b60f6128d6dc788.tar.gz
emacs-535272bb73eff5a5db01301e5b60f6128d6dc788.zip
Merge from trunk.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog73
-rw-r--r--src/alloc.c43
-rw-r--r--src/charset.c36
-rw-r--r--src/nsterm.m18
-rw-r--r--src/sysdep.c4
5 files changed, 122 insertions, 52 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 37f2e39848f..2cb49cace00 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,14 +1,4 @@
12011-09-29 Paul Eggert <eggert@cs.ucla.edu> 12011-09-30 Paul Eggert <eggert@cs.ucla.edu>
2
3 * alloc.c: Do not assume sizeof (size_t) is a multiple of 8
4 when debugging.
5 (alignof, XMALLOC_BASE_ALIGNMENT, XMALLOC_HEADER_ALIGNMENT)
6 (XMALLOC_OVERRUN_SIZE_SIZE): New macros.
7 (XMALLOC_OVERRUN_CHECK_OVERHEAD, xmalloc_put_size, xmalloc_get_size)
8 (overrun_check_malloc, overrun_check_realloc, overrun_check_free):
9 Replace uses of sizeof (size_t) with XMALLOC_OVERRUN_SIZE_SIZE.
10
112011-09-28 Paul Eggert <eggert@cs.ucla.edu>
12 2
13 * alloc.c (pure_bytes_used_lisp, pure_bytes_used_non_lisp): 3 * alloc.c (pure_bytes_used_lisp, pure_bytes_used_non_lisp):
14 (allocate_vectorlike, buffer_memory_full, struct sdata, SDATA_SIZE) 4 (allocate_vectorlike, buffer_memory_full, struct sdata, SDATA_SIZE)
@@ -785,6 +775,57 @@
785 rather than rolling our own approximation. 775 rather than rolling our own approximation.
786 (SCROLL_BAR_VEC_SIZE): Remove; not used. 776 (SCROLL_BAR_VEC_SIZE): Remove; not used.
787 777
7782011-09-30 Paul Eggert <eggert@cs.ucla.edu>
779
780 Remove dependency on glibc malloc internals.
781 * alloc.c (XMALLOC_OVERRUN_CHECK_OVERHEAD, XMALLOC_OVERRUN_CHECK_SIZE):
782 Move back here from lisp.h, but with their new implementations.
783 (XMALLOC_BASE_ALIGNMENT, COMMON_MULTIPLE, XMALLOC_HEADER_ALIGNMENT)
784 (XMALLOC_OVERRUN_SIZE_SIZE): Move these new lisp.h macros here.
785 * charset.c (charset_table_init): New static var.
786 (syms_of_charset): Use it instead of xmalloc. This removes a
787 dependency on glibc malloc internals. See Eli Zaretskii's comment in
788 <http://lists.gnu.org/archive/html/emacs-devel/2011-09/msg00815.html>.
789 * lisp.h (XMALLOC_OVERRUN_CHECK_OVERHEAD, XMALLOC_OVERRUN_CHECK_SIZE):
790 Move back to alloc.c.
791 (XMALLOC_BASE_ALIGNMENT, COMMON_MULTIPLE, XMALLOC_HEADER_ALIGNMENT)
792 (XMALLOC_OVERRUN_SIZE_SIZE): Move to alloc.c.
793
7942011-09-30 Jan Djärv <jan.h.d@swipnet.se>
795
796 * nsterm.m (windowDidResize): Call x_set_window_size only when
797 ns_in_resize is true. Otherwise set pixelwidth/height and
798 call change_frame_size (Bug#9628).
799
8002011-09-30 Paul Eggert <eggert@cs.ucla.edu>
801
802 Port --enable-checking=all to Fedora 14 x86-64.
803 * charset.c (syms_of_charset): Also account for glibc malloc's
804 internal overhead when calculating the initial malloc maximum.
805
806 Port --enable-checking=all to Fedora 14 x86.
807 * alloc.c (XMALLOC_OVERRUN_CHECK_OVERHEAD, XMALLOC_OVERRUN_CHECK_SIZE):
808 Move to lisp.h.
809 (xmalloc_put_size, xmalloc_get_size, overrun_check_malloc)
810 (overrun_check_realloc, overrun_check_free):
811 Use XMALLOC_OVERRUN_SIZE_SIZE, not sizeof (size_t).
812 That way, xmalloc returns a properly-aligned pointer even if
813 XMALLOC_OVERRUN_CHECK is defined. The old debugging code happened
814 to align OK on typical 64-bit hosts, but not on Fedora 14 x86.
815 * charset.c (syms_of_charset): Take XMALLOC_OVERRUN_CHECK_OVERHEAD
816 into account when calculating the initial malloc maximum.
817 * lisp.h (XMALLOC_OVERRUN_CHECK_OVERHEAD, XMALLOC_OVERRUN_CHECK_SIZE):
818 Move here from alloc.c, so that charset.c can use it too.
819 Properly align; the old code wasn't right for common 32-bit hosts
820 when configured with --enable-checking=all.
821 (XMALLOC_BASE_ALIGNMENT, COMMON_MULTIPLE, XMALLOC_HEADER_ALIGNMENT)
822 (XMALLOC_OVERRUN_SIZE_SIZE): New macros.
823
8242011-09-29 Eli Zaretskii <eliz@gnu.org>
825
826 * sysdep.c (snprintf) [!EOVERFLOW]: If EOVERFLOW is not defined,
827 use EDOM.
828
7882011-09-28 Eli Zaretskii <eliz@gnu.org> 8292011-09-28 Eli Zaretskii <eliz@gnu.org>
789 830
790 * xdisp.c (compute_display_string_end): If there's no display 831 * xdisp.c (compute_display_string_end): If there's no display
@@ -803,8 +844,8 @@
803 * xdisp.c (handle_invisible_prop): If invisible text ends on a 844 * xdisp.c (handle_invisible_prop): If invisible text ends on a
804 newline, reseat the iterator instead of bidi-iterating there one 845 newline, reseat the iterator instead of bidi-iterating there one
805 character at a time. (Bug#9610) 846 character at a time. (Bug#9610)
806 (BUFFER_POS_REACHED_P, move_it_in_display_line_to): Bail when past 847 (BUFFER_POS_REACHED_P, move_it_in_display_line_to): Bail out when
807 TO_CHARPOS if the bidi iterator is at base embedding level. 848 past TO_CHARPOS if the bidi iterator is at base embedding level.
808 849
8092011-09-27 Andreas Schwab <schwab@linux-m68k.org> 8502011-09-27 Andreas Schwab <schwab@linux-m68k.org>
810 851
@@ -841,9 +882,9 @@
841 value is now t. Doc fix. 882 value is now t. Doc fix.
842 883
843 * indent.c (Fvertical_motion): Compute and apply the overshoot 884 * indent.c (Fvertical_motion): Compute and apply the overshoot
844 logic when moving up, not only when moving down. Fix the 885 logic also when moving up, not only when moving down. Fix the
845 confusing name and values of the it_overshoot_expected variable; 886 confusing name and values of the it_overshoot_expected variable;
846 logic changes accordingly. (Bug#9254) (Bug#9549) 887 logic changed accordingly. (Bug#9254) (Bug#9549)
847 888
848 * xdisp.c (pos_visible_p): Produce correct pixel coordinates when 889 * xdisp.c (pos_visible_p): Produce correct pixel coordinates when
849 CHARPOS is covered by a display string which includes newlines. 890 CHARPOS is covered by a display string which includes newlines.
@@ -859,7 +900,7 @@
859 900
8602011-09-24 Jim Meyering <meyering@redhat.com> 9012011-09-24 Jim Meyering <meyering@redhat.com>
861 902
862 do not ignore write error for any output size 903 Do not ignore write error for any output size.
863 The previous change was incomplete. 904 The previous change was incomplete.
864 While it makes emacs --batch detect the vast majority of stdout 905 While it makes emacs --batch detect the vast majority of stdout
865 write failures, errors were still ignored whenever the output size is 906 write failures, errors were still ignored whenever the output size is
diff --git a/src/alloc.c b/src/alloc.c
index 286421ebe47..bfb40e6c09a 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -490,36 +490,45 @@ buffer_memory_full (ptrdiff_t nbytes)
490/* Check for overrun in malloc'ed buffers by wrapping a header and trailer 490/* Check for overrun in malloc'ed buffers by wrapping a header and trailer
491 around each block. 491 around each block.
492 492
493 The header consists of 16 fixed bytes followed by 493 The header consists of XMALLOC_OVERRUN_CHECK_SIZE fixed bytes
494 XMALLOC_OVERRUN_SIZE_SIZE bytes containing the original block size 494 followed by XMALLOC_OVERRUN_SIZE_SIZE bytes containing the original
495 in little-endian order. The trailer consists of 16 fixed bytes. 495 block size in little-endian order. The trailer consists of
496 XMALLOC_OVERRUN_CHECK_SIZE fixed bytes.
496 497
497 The header is used to detect whether this block has been allocated 498 The header is used to detect whether this block has been allocated
498 through these functions -- as it seems that some low-level libc 499 through these functions, as some low-level libc functions may
499 functions may bypass the malloc hooks. 500 bypass the malloc hooks. */
500*/
501
502 501
503#define XMALLOC_OVERRUN_CHECK_SIZE 16 502#define XMALLOC_OVERRUN_CHECK_SIZE 16
504#define XMALLOC_OVERRUN_CHECK_OVERHEAD \ 503#define XMALLOC_OVERRUN_CHECK_OVERHEAD \
505 (2 * XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE) 504 (2 * XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE)
506 505
507/* Define XMALLOC_OVERRUN_SIZE_SIZE so that (1) it's large enough to 506/* Define XMALLOC_OVERRUN_SIZE_SIZE so that (1) it's large enough to
508 hold a size_t value and (2) so that the header size is a multiple 507 hold a size_t value and (2) the header size is a multiple of the
509 of the alignment that Emacs needs. */ 508 alignment that Emacs needs for C types and for USE_LSB_TAG. */
510#define alignof(type) offsetof (struct { char c; type x; }, x) 509#define XMALLOC_BASE_ALIGNMENT \
511#define XMALLOC_BASE_ALIGNMENT \ 510 offsetof ( \
512 max (max (alignof (double), alignof (long double)), alignof (intmax_t)) 511 struct { \
512 union { long double d; intmax_t i; void *p; } u; \
513 char c; \
514 }, \
515 c)
513#ifdef USE_LSB_TAG 516#ifdef USE_LSB_TAG
514# define XMALLOC_HEADER_ALIGNMENT max (1 << GCTYPEBITS, XMALLOC_BASE_ALIGNMENT) 517/* A common multiple of the positive integers A and B. Ideally this
518 would be the least common multiple, but there's no way to do that
519 as a constant expression in C, so do the best that we can easily do. */
520# define COMMON_MULTIPLE(a, b) \
521 ((a) % (b) == 0 ? (a) : (b) % (a) == 0 ? (b) : (a) * (b))
522# define XMALLOC_HEADER_ALIGNMENT \
523 COMMON_MULTIPLE (1 << GCTYPEBITS, XMALLOC_BASE_ALIGNMENT)
515#else 524#else
516# define XMALLOC_HEADER_ALIGNMENT XMALLOC_BASE_ALIGNMENT 525# define XMALLOC_HEADER_ALIGNMENT XMALLOC_BASE_ALIGNMENT
517#endif 526#endif
518#define XMALLOC_OVERRUN_SIZE_SIZE \ 527#define XMALLOC_OVERRUN_SIZE_SIZE \
519 (((XMALLOC_OVERRUN_CHECK_SIZE + sizeof (size_t) \ 528 (((XMALLOC_OVERRUN_CHECK_SIZE + sizeof (size_t) \
520 + XMALLOC_HEADER_ALIGNMENT - 1) \ 529 + XMALLOC_HEADER_ALIGNMENT - 1) \
521 / XMALLOC_HEADER_ALIGNMENT * XMALLOC_HEADER_ALIGNMENT) \ 530 / XMALLOC_HEADER_ALIGNMENT * XMALLOC_HEADER_ALIGNMENT) \
522 - XMALLOC_OVERRUN_CHECK_SIZE) 531 - XMALLOC_OVERRUN_CHECK_SIZE)
523 532
524static char const xmalloc_overrun_check_header[XMALLOC_OVERRUN_CHECK_SIZE] = 533static char const xmalloc_overrun_check_header[XMALLOC_OVERRUN_CHECK_SIZE] =
525 { '\x9a', '\x9b', '\xae', '\xaf', 534 { '\x9a', '\x9b', '\xae', '\xaf',
diff --git a/src/charset.c b/src/charset.c
index 2451c55e92a..299655b2cf8 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -1154,10 +1154,10 @@ usage: (define-charset-internal ...) */)
1154 sizeof *charset_table); 1154 sizeof *charset_table);
1155 memcpy (new_table, charset_table, old_size * sizeof *new_table); 1155 memcpy (new_table, charset_table, old_size * sizeof *new_table);
1156 charset_table = new_table; 1156 charset_table = new_table;
1157 /* FIXME: Doesn't this leak memory? The old charset_table becomes 1157 /* FIXME: This leaks memory, as the old charset_table becomes
1158 unreachable. It could be that this is intentional, because the 1158 unreachable. If the old charset table is charset_table_init
1159 old charset table may be in a dumped emacs, and reallocating such 1159 then this leak is intentional; otherwise, it's unclear.
1160 a table may not work. If the memory leak is intentional, a 1160 If the latter memory leak is intentional, a
1161 comment should be added to explain this. If not, the old 1161 comment should be added to explain this. If not, the old
1162 charset_table should be freed, by passing it as the 1st argument 1162 charset_table should be freed, by passing it as the 1st argument
1163 to xpalloc and removing the memcpy. */ 1163 to xpalloc and removing the memcpy. */
@@ -2318,20 +2318,21 @@ init_charset_once (void)
2318 2318
2319#ifdef emacs 2319#ifdef emacs
2320 2320
2321/* Allocate an initial charset table that is large enough to handle
2322 Emacs while it is bootstrapping. As of September 2011, the size
2323 needs to be at least 166; make it a bit bigger to allow for future
2324 expansion.
2325
2326 Don't make the value so small that the table is reallocated during
2327 bootstrapping, as glibc malloc calls larger than just under 64 KiB
2328 during an initial bootstrap wreak havoc after dumping; see the
2329 M_MMAP_THRESHOLD value in alloc.c, plus there is a extra overhead
2330 internal to glibc malloc and perhaps to Emacs malloc debugging. */
2331static struct charset charset_table_init[180];
2332
2321void 2333void
2322syms_of_charset (void) 2334syms_of_charset (void)
2323{ 2335{
2324 /* Allocate an initial charset table that is just under 64 KiB in size.
2325 This should be large enough so that the charset table need not be
2326 reallocated during an initial bootstrap. Allocating anything larger than
2327 64 KiB in an initial run may not work, because glibc malloc might use
2328 mmap for larger allocations, and these don't work well across dumped
2329 systems. */
2330 enum {
2331 initial_malloc_max = (1 << 16) - 1,
2332 charset_table_size_init = initial_malloc_max / sizeof (struct charset)
2333 };
2334
2335 DEFSYM (Qcharsetp, "charsetp"); 2336 DEFSYM (Qcharsetp, "charsetp");
2336 2337
2337 DEFSYM (Qascii, "ascii"); 2338 DEFSYM (Qascii, "ascii");
@@ -2364,9 +2365,8 @@ syms_of_charset (void)
2364 Vcharset_hash_table = Fmake_hash_table (2, args); 2365 Vcharset_hash_table = Fmake_hash_table (2, args);
2365 } 2366 }
2366 2367
2367 charset_table = (struct charset *) xmalloc (sizeof (struct charset) 2368 charset_table = charset_table_init;
2368 * charset_table_size_init); 2369 charset_table_size = sizeof charset_table_init / sizeof *charset_table_init;
2369 charset_table_size = charset_table_size_init;
2370 charset_table_used = 0; 2370 charset_table_used = 0;
2371 2371
2372 defsubr (&Scharsetp); 2372 defsubr (&Scharsetp);
diff --git a/src/nsterm.m b/src/nsterm.m
index 827404a2974..a2ae5e69512 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -5357,7 +5357,23 @@ ns_term_shutdown (int sig)
5357 a "windowDidResize" which calls x_set_window_size). */ 5357 a "windowDidResize" which calls x_set_window_size). */
5358#ifndef NS_IMPL_GNUSTEP 5358#ifndef NS_IMPL_GNUSTEP
5359 if (cols > 0 && rows > 0) 5359 if (cols > 0 && rows > 0)
5360 x_set_window_size (emacsframe, 0, cols, rows); 5360 {
5361 if (ns_in_resize)
5362 x_set_window_size (emacsframe, 0, cols, rows);
5363 else
5364 {
5365 NSWindow *window = [self window];
5366 NSRect wr = [window frame];
5367 FRAME_PIXEL_WIDTH (emacsframe) = (int)wr.size.width
5368 - emacsframe->border_width;
5369 FRAME_PIXEL_HEIGHT (emacsframe) = (int)wr.size.height
5370 - FRAME_NS_TITLEBAR_HEIGHT (emacsframe)
5371 - FRAME_TOOLBAR_HEIGHT (emacsframe);
5372 change_frame_size (emacsframe, rows, cols, 0, 0, 1);
5373 SET_FRAME_GARBAGED (emacsframe);
5374 cancel_mouse_face (emacsframe);
5375 }
5376 }
5361#endif 5377#endif
5362 5378
5363 ns_send_appdefined (-1); 5379 ns_send_appdefined (-1);
diff --git a/src/sysdep.c b/src/sysdep.c
index ba296a2d094..d2ce5a8cc1b 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -1844,7 +1844,11 @@ snprintf (char *buf, size_t bufsize, char const *format, ...)
1844 1844
1845 if (INT_MAX < nbytes) 1845 if (INT_MAX < nbytes)
1846 { 1846 {
1847#ifdef EOVERFLOW
1847 errno = EOVERFLOW; 1848 errno = EOVERFLOW;
1849#else
1850 errno = EDOM;
1851#endif
1848 return -1; 1852 return -1;
1849 } 1853 }
1850 return nbytes; 1854 return nbytes;