diff options
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 69 |
1 files changed, 6 insertions, 63 deletions
diff --git a/src/buffer.c b/src/buffer.c index 1f0bd3f0970..3cbb8153bc9 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -41,6 +41,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 41 | #include "keymap.h" | 41 | #include "keymap.h" |
| 42 | #include "frame.h" | 42 | #include "frame.h" |
| 43 | 43 | ||
| 44 | #ifdef WINDOWSNT | ||
| 45 | #include "w32heap.h" /* for mmap_* */ | ||
| 46 | #endif | ||
| 47 | |||
| 44 | struct buffer *current_buffer; /* The current buffer. */ | 48 | struct buffer *current_buffer; /* The current buffer. */ |
| 45 | 49 | ||
| 46 | /* First buffer in chain of all buffers (in reverse order of creation). | 50 | /* First buffer in chain of all buffers (in reverse order of creation). |
| @@ -4632,7 +4636,8 @@ evaporate_overlays (ptrdiff_t pos) | |||
| 4632 | Allocation with mmap | 4636 | Allocation with mmap |
| 4633 | ***********************************************************************/ | 4637 | ***********************************************************************/ |
| 4634 | 4638 | ||
| 4635 | #ifdef USE_MMAP_FOR_BUFFERS | 4639 | /* Note: WINDOWSNT implements this stuff on w32heap.c. */ |
| 4640 | #if defined USE_MMAP_FOR_BUFFERS && !defined WINDOWSNT | ||
| 4636 | 4641 | ||
| 4637 | #include <sys/mman.h> | 4642 | #include <sys/mman.h> |
| 4638 | 4643 | ||
| @@ -4774,36 +4779,6 @@ mmap_init (void) | |||
| 4774 | mmap_page_size = getpagesize (); | 4779 | mmap_page_size = getpagesize (); |
| 4775 | } | 4780 | } |
| 4776 | 4781 | ||
| 4777 | /* Return a region overlapping address range START...END, or null if | ||
| 4778 | none. END is not including, i.e. the last byte in the range | ||
| 4779 | is at END - 1. */ | ||
| 4780 | |||
| 4781 | static struct mmap_region * | ||
| 4782 | mmap_find (void *start, void *end) | ||
| 4783 | { | ||
| 4784 | struct mmap_region *r; | ||
| 4785 | char *s = start, *e = end; | ||
| 4786 | |||
| 4787 | for (r = mmap_regions; r; r = r->next) | ||
| 4788 | { | ||
| 4789 | char *rstart = (char *) r; | ||
| 4790 | char *rend = rstart + r->nbytes_mapped; | ||
| 4791 | |||
| 4792 | if (/* First byte of range, i.e. START, in this region? */ | ||
| 4793 | (s >= rstart && s < rend) | ||
| 4794 | /* Last byte of range, i.e. END - 1, in this region? */ | ||
| 4795 | || (e > rstart && e <= rend) | ||
| 4796 | /* First byte of this region in the range? */ | ||
| 4797 | || (rstart >= s && rstart < e) | ||
| 4798 | /* Last byte of this region in the range? */ | ||
| 4799 | || (rend > s && rend <= e)) | ||
| 4800 | break; | ||
| 4801 | } | ||
| 4802 | |||
| 4803 | return r; | ||
| 4804 | } | ||
| 4805 | |||
| 4806 | |||
| 4807 | /* Unmap a region. P is a pointer to the start of the user-araa of | 4782 | /* Unmap a region. P is a pointer to the start of the user-araa of |
| 4808 | the region. */ | 4783 | the region. */ |
| 4809 | 4784 | ||
| @@ -4880,38 +4855,6 @@ mmap_enlarge (struct mmap_region *r, int npages) | |||
| 4880 | } | 4855 | } |
| 4881 | 4856 | ||
| 4882 | 4857 | ||
| 4883 | /* Set or reset variables holding references to mapped regions. | ||
| 4884 | If not RESTORE_P, set all variables to null. If RESTORE_P, set all | ||
| 4885 | variables to the start of the user-areas of mapped regions. | ||
| 4886 | |||
| 4887 | This function is called from Fdump_emacs to ensure that the dumped | ||
| 4888 | Emacs doesn't contain references to memory that won't be mapped | ||
| 4889 | when Emacs starts. */ | ||
| 4890 | |||
| 4891 | void | ||
| 4892 | mmap_set_vars (bool restore_p) | ||
| 4893 | { | ||
| 4894 | struct mmap_region *r; | ||
| 4895 | |||
| 4896 | if (restore_p) | ||
| 4897 | { | ||
| 4898 | mmap_regions = mmap_regions_1; | ||
| 4899 | mmap_fd = mmap_fd_1; | ||
| 4900 | for (r = mmap_regions; r; r = r->next) | ||
| 4901 | *r->var = MMAP_USER_AREA (r); | ||
| 4902 | } | ||
| 4903 | else | ||
| 4904 | { | ||
| 4905 | for (r = mmap_regions; r; r = r->next) | ||
| 4906 | *r->var = NULL; | ||
| 4907 | mmap_regions_1 = mmap_regions; | ||
| 4908 | mmap_regions = NULL; | ||
| 4909 | mmap_fd_1 = mmap_fd; | ||
| 4910 | mmap_fd = -1; | ||
| 4911 | } | ||
| 4912 | } | ||
| 4913 | |||
| 4914 | |||
| 4915 | /* Allocate a block of storage large enough to hold NBYTES bytes of | 4858 | /* Allocate a block of storage large enough to hold NBYTES bytes of |
| 4916 | data. A pointer to the data is returned in *VAR. VAR is thus the | 4859 | data. A pointer to the data is returned in *VAR. VAR is thus the |
| 4917 | address of some variable which will use the data area. | 4860 | address of some variable which will use the data area. |