Mercurial > emacs
comparison src/alloc.c @ 90364:494bf720eaf0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-42
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 144-147)
- Update from CVS
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 56)
- Update from CVS
| author | Miles Bader <miles@gnu.org> |
|---|---|
| date | Fri, 10 Mar 2006 23:46:54 +0000 |
| parents | d1c5430c5bff a685fca1ccb6 |
| children | 65ca8fb66a0d |
comparison
equal
deleted
inserted
replaced
| 90363:ec0a46fadd7e | 90364:494bf720eaf0 |
|---|---|
| 881 | 881 |
| 882 /* Allocation of aligned blocks of memory to store Lisp data. */ | 882 /* Allocation of aligned blocks of memory to store Lisp data. */ |
| 883 /* The entry point is lisp_align_malloc which returns blocks of at most */ | 883 /* The entry point is lisp_align_malloc which returns blocks of at most */ |
| 884 /* BLOCK_BYTES and guarantees they are aligned on a BLOCK_ALIGN boundary. */ | 884 /* BLOCK_BYTES and guarantees they are aligned on a BLOCK_ALIGN boundary. */ |
| 885 | 885 |
| 886 /* Use posix_memalloc if the system has it and we're using the system's | |
| 887 malloc (because our gmalloc.c routines don't have posix_memalign although | |
| 888 its memalloc could be used). */ | |
| 889 #if defined (HAVE_POSIX_MEMALIGN) && defined (SYSTEM_MALLOC) | |
| 890 #define USE_POSIX_MEMALIGN 1 | |
| 891 #endif | |
| 886 | 892 |
| 887 /* BLOCK_ALIGN has to be a power of 2. */ | 893 /* BLOCK_ALIGN has to be a power of 2. */ |
| 888 #define BLOCK_ALIGN (1 << 10) | 894 #define BLOCK_ALIGN (1 << 10) |
| 889 | 895 |
| 890 /* Padding to leave at the end of a malloc'd block. This is to give | 896 /* Padding to leave at the end of a malloc'd block. This is to give |
| 946 | 952 |
| 947 /* Virtual `busy' field. */ | 953 /* Virtual `busy' field. */ |
| 948 #define ABLOCKS_BUSY(abase) ((abase)->blocks[0].abase) | 954 #define ABLOCKS_BUSY(abase) ((abase)->blocks[0].abase) |
| 949 | 955 |
| 950 /* Pointer to the (not necessarily aligned) malloc block. */ | 956 /* Pointer to the (not necessarily aligned) malloc block. */ |
| 951 #ifdef HAVE_POSIX_MEMALIGN | 957 #ifdef USE_POSIX_MEMALIGN |
| 952 #define ABLOCKS_BASE(abase) (abase) | 958 #define ABLOCKS_BASE(abase) (abase) |
| 953 #else | 959 #else |
| 954 #define ABLOCKS_BASE(abase) \ | 960 #define ABLOCKS_BASE(abase) \ |
| 955 (1 & (long) ABLOCKS_BUSY (abase) ? abase : ((void**)abase)[-1]) | 961 (1 & (long) ABLOCKS_BUSY (abase) ? abase : ((void**)abase)[-1]) |
| 956 #endif | 962 #endif |
| 987 because mapped region contents are not preserved in | 993 because mapped region contents are not preserved in |
| 988 a dumped Emacs. */ | 994 a dumped Emacs. */ |
| 989 mallopt (M_MMAP_MAX, 0); | 995 mallopt (M_MMAP_MAX, 0); |
| 990 #endif | 996 #endif |
| 991 | 997 |
| 992 #ifdef HAVE_POSIX_MEMALIGN | 998 #ifdef USE_POSIX_MEMALIGN |
| 993 { | 999 { |
| 994 int err = posix_memalign (&base, BLOCK_ALIGN, ABLOCKS_BYTES); | 1000 int err = posix_memalign (&base, BLOCK_ALIGN, ABLOCKS_BYTES); |
| 995 if (err) | 1001 if (err) |
| 996 base = NULL; | 1002 base = NULL; |
| 997 abase = base; | 1003 abase = base; |
| 1103 else | 1109 else |
| 1104 tem = &(*tem)->x.next_free; | 1110 tem = &(*tem)->x.next_free; |
| 1105 } | 1111 } |
| 1106 eassert ((aligned & 1) == aligned); | 1112 eassert ((aligned & 1) == aligned); |
| 1107 eassert (i == (aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1)); | 1113 eassert (i == (aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1)); |
| 1108 #ifdef HAVE_POSIX_MEMALIGN | 1114 #ifdef USE_POSIX_MEMALIGN |
| 1109 eassert ((unsigned long)ABLOCKS_BASE (abase) % BLOCK_ALIGN == 0); | 1115 eassert ((unsigned long)ABLOCKS_BASE (abase) % BLOCK_ALIGN == 0); |
| 1110 #endif | 1116 #endif |
| 1111 free (ABLOCKS_BASE (abase)); | 1117 free (ABLOCKS_BASE (abase)); |
| 1112 } | 1118 } |
| 1113 UNBLOCK_INPUT; | 1119 UNBLOCK_INPUT; |
