aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c52
1 files changed, 25 insertions, 27 deletions
diff --git a/src/buffer.c b/src/buffer.c
index d3d5bd268a2..dbaa9f0cc82 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -392,7 +392,6 @@ even if it is dead. The return value is never nil. */)
392 392
393 BVAR (b, mark) = Fmake_marker (); 393 BVAR (b, mark) = Fmake_marker ();
394 BUF_MARKERS (b) = NULL; 394 BUF_MARKERS (b) = NULL;
395 BVAR (b, name) = name;
396 395
397 /* Put this in the alist of all live buffers. */ 396 /* Put this in the alist of all live buffers. */
398 XSETBUFFER (buffer, b); 397 XSETBUFFER (buffer, b);
@@ -612,7 +611,6 @@ CLONE nil means the indirect buffer's state is reset to default values. */)
612 Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buf), Qnil)); 611 Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buf), Qnil));
613 612
614 BVAR (b, mark) = Fmake_marker (); 613 BVAR (b, mark) = Fmake_marker ();
615 BVAR (b, name) = name;
616 614
617 /* The multibyte status belongs to the base buffer. */ 615 /* The multibyte status belongs to the base buffer. */
618 BVAR (b, enable_multibyte_characters) = BVAR (b->base_buffer, enable_multibyte_characters); 616 BVAR (b, enable_multibyte_characters) = BVAR (b->base_buffer, enable_multibyte_characters);
@@ -2052,10 +2050,10 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text,
2052 eassert (current_buffer->text == &current_buffer->own_text); 2050 eassert (current_buffer->text == &current_buffer->own_text);
2053 eassert (other_buffer->text == &other_buffer->own_text); 2051 eassert (other_buffer->text == &other_buffer->own_text);
2054#ifdef REL_ALLOC 2052#ifdef REL_ALLOC
2055 r_alloc_reset_variable ((POINTER_TYPE **) &current_buffer->own_text.beg, 2053 r_alloc_reset_variable ((void **) &current_buffer->own_text.beg,
2056 (POINTER_TYPE **) &other_buffer->own_text.beg); 2054 (void **) &other_buffer->own_text.beg);
2057 r_alloc_reset_variable ((POINTER_TYPE **) &other_buffer->own_text.beg, 2055 r_alloc_reset_variable ((void **) &other_buffer->own_text.beg,
2058 (POINTER_TYPE **) &current_buffer->own_text.beg); 2056 (void **) &current_buffer->own_text.beg);
2059#endif /* REL_ALLOC */ 2057#endif /* REL_ALLOC */
2060 2058
2061 swapfield (pt, ptrdiff_t); 2059 swapfield (pt, ptrdiff_t);
@@ -4384,7 +4382,7 @@ struct mmap_region
4384 /* Pointer to the location holding the address of the memory 4382 /* Pointer to the location holding the address of the memory
4385 allocated with the mmap'd block. The variable actually points 4383 allocated with the mmap'd block. The variable actually points
4386 after this structure. */ 4384 after this structure. */
4387 POINTER_TYPE **var; 4385 void **var;
4388 4386
4389 /* Next and previous in list of all mmap'd regions. */ 4387 /* Next and previous in list of all mmap'd regions. */
4390 struct mmap_region *next, *prev; 4388 struct mmap_region *next, *prev;
@@ -4431,7 +4429,7 @@ static int mmap_initialized_p;
4431 to the start of the user-visible part of the region. */ 4429 to the start of the user-visible part of the region. */
4432 4430
4433#define MMAP_USER_AREA(P) \ 4431#define MMAP_USER_AREA(P) \
4434 ((POINTER_TYPE *) ((char *) (P) + MMAP_REGION_STRUCT_SIZE)) 4432 ((void *) ((char *) (P) + MMAP_REGION_STRUCT_SIZE))
4435 4433
4436#define MEM_ALIGN sizeof (double) 4434#define MEM_ALIGN sizeof (double)
4437 4435
@@ -4480,7 +4478,7 @@ mmap_init (void)
4480 is at END - 1. */ 4478 is at END - 1. */
4481 4479
4482static struct mmap_region * 4480static struct mmap_region *
4483mmap_find (POINTER_TYPE *start, POINTER_TYPE *end) 4481mmap_find (void *start, void *end)
4484{ 4482{
4485 struct mmap_region *r; 4483 struct mmap_region *r;
4486 char *s = (char *) start, *e = (char *) end; 4484 char *s = (char *) start, *e = (char *) end;
@@ -4518,7 +4516,7 @@ mmap_free_1 (struct mmap_region *r)
4518 else 4516 else
4519 mmap_regions = r->next; 4517 mmap_regions = r->next;
4520 4518
4521 if (munmap ((POINTER_TYPE *) r, r->nbytes_mapped) == -1) 4519 if (munmap (r, r->nbytes_mapped) == -1)
4522 { 4520 {
4523 fprintf (stderr, "munmap: %s\n", emacs_strerror (errno)); 4521 fprintf (stderr, "munmap: %s\n", emacs_strerror (errno));
4524 return 0; 4522 return 0;
@@ -4560,13 +4558,13 @@ mmap_enlarge (struct mmap_region *r, int npages)
4560 I'm not sure this is worth doing, let's see. */ 4558 I'm not sure this is worth doing, let's see. */
4561 if (!MMAP_ALLOCATED_P (region_end, region_end + nbytes)) 4559 if (!MMAP_ALLOCATED_P (region_end, region_end + nbytes))
4562 { 4560 {
4563 POINTER_TYPE *p; 4561 void *p;
4564 4562
4565 p = mmap (region_end, nbytes, PROT_READ | PROT_WRITE, 4563 p = mmap (region_end, nbytes, PROT_READ | PROT_WRITE,
4566 MAP_ANON | MAP_PRIVATE | MAP_FIXED, mmap_fd, 0); 4564 MAP_ANON | MAP_PRIVATE | MAP_FIXED, mmap_fd, 0);
4567 if (p == MAP_FAILED) 4565 if (p == MAP_FAILED)
4568 ; /* fprintf (stderr, "mmap: %s\n", emacs_strerror (errno)); */ 4566 ; /* fprintf (stderr, "mmap: %s\n", emacs_strerror (errno)); */
4569 else if (p != (POINTER_TYPE *) region_end) 4567 else if (p != region_end)
4570 { 4568 {
4571 /* Kernels are free to choose a different address. In 4569 /* Kernels are free to choose a different address. In
4572 that case, unmap what we've mapped above; we have 4570 that case, unmap what we've mapped above; we have
@@ -4628,8 +4626,8 @@ mmap_set_vars (int restore_p)
4628 If we can't allocate the necessary memory, set *VAR to null, and 4626 If we can't allocate the necessary memory, set *VAR to null, and
4629 return null. */ 4627 return null. */
4630 4628
4631static POINTER_TYPE * 4629static void *
4632mmap_alloc (POINTER_TYPE **var, size_t nbytes) 4630mmap_alloc (void **var, size_t nbytes)
4633{ 4631{
4634 void *p; 4632 void *p;
4635 size_t map; 4633 size_t map;
@@ -4670,7 +4668,7 @@ mmap_alloc (POINTER_TYPE **var, size_t nbytes)
4670 PTR. Store 0 in *PTR to show there's no block allocated. */ 4668 PTR. Store 0 in *PTR to show there's no block allocated. */
4671 4669
4672static void 4670static void
4673mmap_free (POINTER_TYPE **var) 4671mmap_free (void **var)
4674{ 4672{
4675 mmap_init (); 4673 mmap_init ();
4676 4674
@@ -4687,10 +4685,10 @@ mmap_free (POINTER_TYPE **var)
4687 and return this value. If more memory cannot be allocated, then 4685 and return this value. If more memory cannot be allocated, then
4688 leave *VAR unchanged, and return null. */ 4686 leave *VAR unchanged, and return null. */
4689 4687
4690static POINTER_TYPE * 4688static void *
4691mmap_realloc (POINTER_TYPE **var, size_t nbytes) 4689mmap_realloc (void **var, size_t nbytes)
4692{ 4690{
4693 POINTER_TYPE *result; 4691 void *result;
4694 4692
4695 mmap_init (); 4693 mmap_init ();
4696 4694
@@ -4709,7 +4707,7 @@ mmap_realloc (POINTER_TYPE **var, size_t nbytes)
4709 if (room < nbytes) 4707 if (room < nbytes)
4710 { 4708 {
4711 /* Must enlarge. */ 4709 /* Must enlarge. */
4712 POINTER_TYPE *old_ptr = *var; 4710 void *old_ptr = *var;
4713 4711
4714 /* Try to map additional pages at the end of the region. 4712 /* Try to map additional pages at the end of the region.
4715 If that fails, allocate a new region, copy data 4713 If that fails, allocate a new region, copy data
@@ -4771,13 +4769,13 @@ mmap_realloc (POINTER_TYPE **var, size_t nbytes)
4771static void 4769static void
4772alloc_buffer_text (struct buffer *b, ptrdiff_t nbytes) 4770alloc_buffer_text (struct buffer *b, ptrdiff_t nbytes)
4773{ 4771{
4774 POINTER_TYPE *p; 4772 void *p;
4775 4773
4776 BLOCK_INPUT; 4774 BLOCK_INPUT;
4777#if defined USE_MMAP_FOR_BUFFERS 4775#if defined USE_MMAP_FOR_BUFFERS
4778 p = mmap_alloc ((POINTER_TYPE **) &b->text->beg, nbytes); 4776 p = mmap_alloc ((void **) &b->text->beg, nbytes);
4779#elif defined REL_ALLOC 4777#elif defined REL_ALLOC
4780 p = r_alloc ((POINTER_TYPE **) &b->text->beg, nbytes); 4778 p = r_alloc ((void **) &b->text->beg, nbytes);
4781#else 4779#else
4782 p = xmalloc (nbytes); 4780 p = xmalloc (nbytes);
4783#endif 4781#endif
@@ -4798,14 +4796,14 @@ alloc_buffer_text (struct buffer *b, ptrdiff_t nbytes)
4798void 4796void
4799enlarge_buffer_text (struct buffer *b, ptrdiff_t delta) 4797enlarge_buffer_text (struct buffer *b, ptrdiff_t delta)
4800{ 4798{
4801 POINTER_TYPE *p; 4799 void *p;
4802 ptrdiff_t nbytes = (BUF_Z_BYTE (b) - BUF_BEG_BYTE (b) + BUF_GAP_SIZE (b) + 1 4800 ptrdiff_t nbytes = (BUF_Z_BYTE (b) - BUF_BEG_BYTE (b) + BUF_GAP_SIZE (b) + 1
4803 + delta); 4801 + delta);
4804 BLOCK_INPUT; 4802 BLOCK_INPUT;
4805#if defined USE_MMAP_FOR_BUFFERS 4803#if defined USE_MMAP_FOR_BUFFERS
4806 p = mmap_realloc ((POINTER_TYPE **) &b->text->beg, nbytes); 4804 p = mmap_realloc ((void **) &b->text->beg, nbytes);
4807#elif defined REL_ALLOC 4805#elif defined REL_ALLOC
4808 p = r_re_alloc ((POINTER_TYPE **) &b->text->beg, nbytes); 4806 p = r_re_alloc ((void **) &b->text->beg, nbytes);
4809#else 4807#else
4810 p = xrealloc (b->text->beg, nbytes); 4808 p = xrealloc (b->text->beg, nbytes);
4811#endif 4809#endif
@@ -4829,9 +4827,9 @@ free_buffer_text (struct buffer *b)
4829 BLOCK_INPUT; 4827 BLOCK_INPUT;
4830 4828
4831#if defined USE_MMAP_FOR_BUFFERS 4829#if defined USE_MMAP_FOR_BUFFERS
4832 mmap_free ((POINTER_TYPE **) &b->text->beg); 4830 mmap_free ((void **) &b->text->beg);
4833#elif defined REL_ALLOC 4831#elif defined REL_ALLOC
4834 r_alloc_free ((POINTER_TYPE **) &b->text->beg); 4832 r_alloc_free ((void **) &b->text->beg);
4835#else 4833#else
4836 xfree (b->text->beg); 4834 xfree (b->text->beg);
4837#endif 4835#endif