comparison src/buffer.c @ 44617:c54f8a37564e

(MMAP_ALLOCATED_P): New macro to be set from system configuration files. (mmap_enlarge): Enlarge mapped regions only if MMAP_ALLOCATED_P returns 0.
author Gerd Moellmann <gerd@gnu.org>
date Tue, 16 Apr 2002 07:34:36 +0000
parents 223f1f5d160d
children 8180d4f92b70
comparison
equal deleted inserted replaced
44616:fe5006134263 44617:c54f8a37564e
1 /* Buffer manipulation primitives for GNU Emacs. 1 /* Buffer manipulation primitives for GNU Emacs.
2 Copyright (C) 1985,86,87,88,89,93,94,95,97,98, 1999, 2000, 2001 2 Copyright (C) 1985,86,87,88,89,93,94,95,97,98, 1999, 2000, 2001, 2002
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5 This file is part of GNU Emacs. 5 This file is part of GNU Emacs.
6 6
7 GNU Emacs is free software; you can redistribute it and/or modify 7 GNU Emacs is free software; you can redistribute it and/or modify
4341 #define MMAP_USER_AREA(P) \ 4341 #define MMAP_USER_AREA(P) \
4342 ((POINTER_TYPE *) ((char *) (P) + MMAP_REGION_STRUCT_SIZE)) 4342 ((POINTER_TYPE *) ((char *) (P) + MMAP_REGION_STRUCT_SIZE))
4343 4343
4344 #define MEM_ALIGN sizeof (double) 4344 #define MEM_ALIGN sizeof (double)
4345 4345
4346 /* Predicate returning true if part of the address range [START ..
4347 END[ is currently mapped. Used to prevent overwriting an existing
4348 memory mapping.
4349
4350 Default is to conservativly assume the address range is occupied by
4351 something else. This can be overridden by system configuration
4352 files if system-specific means to determine this exists. */
4353
4354 #ifndef MMAP_ALLOCATED_P
4355 #define MMAP_ALLOCATED_P(start, end) 1
4356 #endif
4357
4346 /* Function prototypes. */ 4358 /* Function prototypes. */
4347 4359
4348 static int mmap_free_1 P_ ((struct mmap_region *)); 4360 static int mmap_free_1 P_ ((struct mmap_region *));
4349 static int mmap_enlarge P_ ((struct mmap_region *, int)); 4361 static int mmap_enlarge P_ ((struct mmap_region *, int));
4350 static struct mmap_region *mmap_find P_ ((POINTER_TYPE *, POINTER_TYPE *)); 4362 static struct mmap_region *mmap_find P_ ((POINTER_TYPE *, POINTER_TYPE *));
4433 success = 1; 4445 success = 1;
4434 } 4446 }
4435 } 4447 }
4436 else if (npages > 0) 4448 else if (npages > 0)
4437 { 4449 {
4438 struct mmap_region *r2;
4439
4440 nbytes = npages * mmap_page_size; 4450 nbytes = npages * mmap_page_size;
4441 4451
4442 /* Try to map additional pages at the end of the region. We 4452 /* Try to map additional pages at the end of the region. We
4443 cannot do this if the address range is already occupied by 4453 cannot do this if the address range is already occupied by
4444 something else because mmap deletes any previous mapping. 4454 something else because mmap deletes any previous mapping.
4445 I'm not sure this is worth doing, let's see. */ 4455 I'm not sure this is worth doing, let's see. */
4446 r2 = mmap_find (region_end, region_end + nbytes); 4456 if (!MMAP_ALLOCATED_P (region_end, region_end + nbytes))
4447 if (r2 == NULL)
4448 { 4457 {
4449 POINTER_TYPE *p; 4458 POINTER_TYPE *p;
4450 4459
4451 p = mmap (region_end, nbytes, PROT_READ | PROT_WRITE, 4460 p = mmap (region_end, nbytes, PROT_READ | PROT_WRITE,
4452 MAP_ANON | MAP_PRIVATE | MAP_FIXED, mmap_fd, 0); 4461 MAP_ANON | MAP_PRIVATE | MAP_FIXED, mmap_fd, 0);