aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2011-08-16 11:48:49 -0700
committerPaul Eggert2011-08-16 11:48:49 -0700
commitbc81e2c4e885787603da3e0314d6ea45a43f7862 (patch)
treec3da7331f40c60b0ebb434d15f83ce027188d5e9 /src
parenta69fbedbd629c3e46a23095486617482fb1228c5 (diff)
parentb215eee57d8427ac896f42a9546930cd852a1637 (diff)
downloademacs-bc81e2c4e885787603da3e0314d6ea45a43f7862.tar.gz
emacs-bc81e2c4e885787603da3e0314d6ea45a43f7862.zip
Merge from trunk.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog22
-rw-r--r--src/gmalloc.c58
-rw-r--r--src/unexcw.c5
-rw-r--r--src/xdisp.c10
4 files changed, 89 insertions, 6 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 6866daf9f38..4613192187e 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -416,6 +416,28 @@
416 (gs_load): Use printmax_t to print the widest integers possible. 416 (gs_load): Use printmax_t to print the widest integers possible.
417 Check for integer overflow when computing image height and width. 417 Check for integer overflow when computing image height and width.
418 418
4192011-08-16 Eli Zaretskii <eliz@gnu.org>
420
421 * xdisp.c (set_cursor_from_row): Don't accept a previous candidate
422 if it fails the cursor_row_p test. Fixes cursor positioning at ZV.
423
4242011-08-16 Ken Brown <kbrown@cornell.edu>
425
426 Fix memory allocation problems in Cygwin build (Bug#9273).
427
428 * unexcw.c ( __malloc_initialized): Declare external variable.
429 (fixup_executable): Force the dumped emacs to reinitialize malloc.
430
431 * gmalloc.c [CYGWIN] (bss_sbrk_heapbase, bss_sbrk_heapinfo): New
432 variables.
433 (malloc_initialize_1) [CYGWIN]: Prepare for reinitializing the
434 dumped emacs.
435 (_free_internal_nolock) [CYGWIN]: Ignore requests to free storage
436 in the static heap.
437 [CYGWIN] (special_realloc): New function.
438 (_realloc_internal_nolock) [CYGWIN]: Use the new function on
439 requests to realloc storage in the static heap.
440
4192011-08-15 Paul Eggert <eggert@cs.ucla.edu> 4412011-08-15 Paul Eggert <eggert@cs.ucla.edu>
420 442
421 * bidi.c (bidi_initialize): Remove unused local. 443 * bidi.c (bidi_initialize): Remove unused local.
diff --git a/src/gmalloc.c b/src/gmalloc.c
index 916bb300fe1..61046ad9d1b 100644
--- a/src/gmalloc.c
+++ b/src/gmalloc.c
@@ -351,10 +351,17 @@ Fifth Floor, Boston, MA 02110-1301, USA.
351#endif 351#endif
352#include <errno.h> 352#include <errno.h>
353 353
354/* How to really get more memory. */ 354/* On Cygwin there are two heaps. temacs uses the static heap
355#if defined(CYGWIN) 355 (defined in sheap.c and managed with bss_sbrk), and the dumped
356 emacs uses the Cygwin heap (managed with sbrk). When emacs starts
357 on Cygwin, it reinitializes malloc, and we save the old info for
358 use by free and realloc if they're called with a pointer into the
359 static heap. */
360#ifdef CYGWIN
356extern __ptr_t bss_sbrk PP ((ptrdiff_t __size)); 361extern __ptr_t bss_sbrk PP ((ptrdiff_t __size));
357extern int bss_sbrk_did_unexec; 362extern int bss_sbrk_did_unexec;
363char *bss_sbrk_heapbase; /* _heapbase for static heap */
364malloc_info *bss_sbrk_heapinfo; /* _heapinfo for static heap */
358#endif 365#endif
359__ptr_t (*__morecore) PP ((__malloc_ptrdiff_t __size)) = __default_morecore; 366__ptr_t (*__morecore) PP ((__malloc_ptrdiff_t __size)) = __default_morecore;
360 367
@@ -584,6 +591,16 @@ malloc_initialize_1 ()
584 mcheck (NULL); 591 mcheck (NULL);
585#endif 592#endif
586 593
594#ifdef CYGWIN
595 if (bss_sbrk_did_unexec)
596 /* we're reinitializing the dumped emacs */
597 {
598 bss_sbrk_heapbase = _heapbase;
599 bss_sbrk_heapinfo = _heapinfo;
600 memset (_fraghead, 0, BLOCKLOG * sizeof (struct list));
601 }
602#endif
603
587 if (__malloc_initialize_hook) 604 if (__malloc_initialize_hook)
588 (*__malloc_initialize_hook) (); 605 (*__malloc_initialize_hook) ();
589 606
@@ -1054,6 +1071,12 @@ _free_internal_nolock (ptr)
1054 if (ptr == NULL) 1071 if (ptr == NULL)
1055 return; 1072 return;
1056 1073
1074#ifdef CYGWIN
1075 if (ptr < _heapbase)
1076 /* We're being asked to free something in the static heap. */
1077 return;
1078#endif
1079
1057 PROTECT_MALLOC_STATE (0); 1080 PROTECT_MALLOC_STATE (0);
1058 1081
1059 LOCK_ALIGNED_BLOCKS (); 1082 LOCK_ALIGNED_BLOCKS ();
@@ -1349,6 +1372,31 @@ Fifth Floor, Boston, MA 02110-1301, USA.
1349 1372
1350#define min(A, B) ((A) < (B) ? (A) : (B)) 1373#define min(A, B) ((A) < (B) ? (A) : (B))
1351 1374
1375/* On Cygwin the dumped emacs may try to realloc storage allocated in
1376 the static heap. We just malloc space in the new heap and copy the
1377 data. */
1378#ifdef CYGWIN
1379__ptr_t
1380special_realloc (ptr, size)
1381 __ptr_t ptr;
1382 __malloc_size_t size;
1383{
1384 __ptr_t result;
1385 int type;
1386 __malloc_size_t block, oldsize;
1387
1388 block = ((char *) ptr - bss_sbrk_heapbase) / BLOCKSIZE + 1;
1389 type = bss_sbrk_heapinfo[block].busy.type;
1390 oldsize =
1391 type == 0 ? bss_sbrk_heapinfo[block].busy.info.size * BLOCKSIZE
1392 : (__malloc_size_t) 1 << type;
1393 result = _malloc_internal_nolock (size);
1394 if (result != NULL)
1395 memcpy (result, ptr, min (oldsize, size));
1396 return result;
1397}
1398#endif
1399
1352/* Debugging hook for realloc. */ 1400/* Debugging hook for realloc. */
1353__ptr_t (*__realloc_hook) PP ((__ptr_t __ptr, __malloc_size_t __size)); 1401__ptr_t (*__realloc_hook) PP ((__ptr_t __ptr, __malloc_size_t __size));
1354 1402
@@ -1375,6 +1423,12 @@ _realloc_internal_nolock (ptr, size)
1375 else if (ptr == NULL) 1423 else if (ptr == NULL)
1376 return _malloc_internal_nolock (size); 1424 return _malloc_internal_nolock (size);
1377 1425
1426#ifdef CYGWIN
1427 if (ptr < _heapbase)
1428 /* ptr points into the static heap */
1429 return special_realloc (ptr, size);
1430#endif
1431
1378 block = BLOCK (ptr); 1432 block = BLOCK (ptr);
1379 1433
1380 PROTECT_MALLOC_STATE (0); 1434 PROTECT_MALLOC_STATE (0);
diff --git a/src/unexcw.c b/src/unexcw.c
index f643c196de0..62df82ec3bc 100644
--- a/src/unexcw.c
+++ b/src/unexcw.c
@@ -33,6 +33,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
33 33
34extern int bss_sbrk_did_unexec; 34extern int bss_sbrk_did_unexec;
35 35
36extern int __malloc_initialized;
37
36/* emacs symbols that indicate where bss and data end for emacs internals */ 38/* emacs symbols that indicate where bss and data end for emacs internals */
37extern char my_endbss[]; 39extern char my_endbss[];
38extern char my_edata[]; 40extern char my_edata[];
@@ -210,9 +212,12 @@ fixup_executable (int fd)
210 lseek (fd, (long) (exe_header->section_header[i].s_scnptr), 212 lseek (fd, (long) (exe_header->section_header[i].s_scnptr),
211 SEEK_SET); 213 SEEK_SET);
212 assert (ret != -1); 214 assert (ret != -1);
215 /* force the dumped emacs to reinitialize malloc */
216 __malloc_initialized = 0;
213 ret = 217 ret =
214 write (fd, (char *) start_address, 218 write (fd, (char *) start_address,
215 my_endbss - (char *) start_address); 219 my_endbss - (char *) start_address);
220 __malloc_initialized = 1;
216 assert (ret == (my_endbss - (char *) start_address)); 221 assert (ret == (my_endbss - (char *) start_address));
217 if (debug_unexcw) 222 if (debug_unexcw)
218 printf (" .bss, mem start 0x%08x mem length %d\n", 223 printf (" .bss, mem start 0x%08x mem length %d\n",
diff --git a/src/xdisp.c b/src/xdisp.c
index 5cbdee41009..ea70c916762 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -13749,11 +13749,13 @@ set_cursor_from_row (struct window *w, struct glyph_row *row,
13749 /* that candidate is not the row we are processing */ 13749 /* that candidate is not the row we are processing */
13750 && MATRIX_ROW (matrix, w->cursor.vpos) != row 13750 && MATRIX_ROW (matrix, w->cursor.vpos) != row
13751 /* Make sure cursor.vpos specifies a row whose start and end 13751 /* Make sure cursor.vpos specifies a row whose start and end
13752 charpos occlude point. This is because some callers of this 13752 charpos occlude point, and it is valid candidate for being a
13753 function leave cursor.vpos at the row where the cursor was 13753 cursor-row. This is because some callers of this function
13754 displayed during the last redisplay cycle. */ 13754 leave cursor.vpos at the row where the cursor was displayed
13755 during the last redisplay cycle. */
13755 && MATRIX_ROW_START_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos)) <= pt_old 13756 && MATRIX_ROW_START_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos)) <= pt_old
13756 && pt_old <= MATRIX_ROW_END_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos))) 13757 && pt_old <= MATRIX_ROW_END_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos))
13758 && cursor_row_p (MATRIX_ROW (matrix, w->cursor.vpos)))
13757 { 13759 {
13758 struct glyph *g1 = 13760 struct glyph *g1 =
13759 MATRIX_ROW_GLYPH_START (matrix, w->cursor.vpos) + w->cursor.hpos; 13761 MATRIX_ROW_GLYPH_START (matrix, w->cursor.vpos) + w->cursor.hpos;