Mercurial > hg > xemacs-beta
comparison src/ralloc.c @ 70:131b0175ea99 r20-0b30
Import from CVS: tag r20-0b30
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:02:59 +0200 |
parents | 8d2a9b52c682 |
children | 54cc21c15cbb |
comparison
equal
deleted
inserted
replaced
69:804d1389bcd6 | 70:131b0175ea99 |
---|---|
755 | 755 |
756 /* Compute the hash value for an address. */ | 756 /* Compute the hash value for an address. */ |
757 static int | 757 static int |
758 MHASH (VM_ADDR addr) | 758 MHASH (VM_ADDR addr) |
759 { | 759 { |
760 #if (LONGBITS == 64) | |
761 unsigned long int addr_shift = (unsigned long int)(addr) >> USELESS_LOWER_ADDRESS_BITS; | |
762 #else | |
763 unsigned int addr_shift = (unsigned int)(addr) >> USELESS_LOWER_ADDRESS_BITS; | 760 unsigned int addr_shift = (unsigned int)(addr) >> USELESS_LOWER_ADDRESS_BITS; |
764 #endif | |
765 int hval = addr_shift % MHASH_PRIME; /* We could have addresses which are -ve | 761 int hval = addr_shift % MHASH_PRIME; /* We could have addresses which are -ve |
766 when converted to signed ints */ | 762 when converted to signed ints */ |
767 return ((hval >= 0) ? hval : MHASH_PRIME + hval); | 763 return ((hval >= 0) ? hval : MHASH_PRIME + hval); |
768 } | 764 } |
769 | 765 |
916 purpose. [ACP Vol I]. We can't use the workaround of using a | 912 purpose. [ACP Vol I]. We can't use the workaround of using a |
917 randomized first fit because we don't want to presume too much | 913 randomized first fit because we don't want to presume too much |
918 about the memory map. Instead, we try to coalesce empty or | 914 about the memory map. Instead, we try to coalesce empty or |
919 unavailable blocks at any available opportunity. */ | 915 unavailable blocks at any available opportunity. */ |
920 | 916 |
921 /* Initialization procedure for address picking scheme */ | 917 static void Addr_Block_initialize(); /* Initialization procedure for address picking scheme */ |
922 static void Addr_Block_initialize(void); | 918 static VM_ADDR New_Addr_Block( SIZE sz ); /* Get a suitable VM_ADDR via mmap */ |
923 | 919 static void Free_Addr_Block( VM_ADDR addr, SIZE sz ); /* Free a VM_ADDR allocated via New_Addr_Block */ |
924 /* Get a suitable VM_ADDR via mmap */ | |
925 static VM_ADDR New_Addr_Block( SIZE sz ); | |
926 | |
927 /* Free a VM_ADDR allocated via New_Addr_Block */ | |
928 static void Free_Addr_Block( VM_ADDR addr, SIZE sz ); | |
929 | 920 |
930 #ifdef MMAP_GENERATE_ADDRESSES | 921 #ifdef MMAP_GENERATE_ADDRESSES |
931 /* Implementation of the three calls for address picking when XEmacs is incharge */ | 922 /* Implementation of the three calls for address picking when XEmacs is incharge */ |
932 | 923 |
933 /* The enum denotes the status of the following block. */ | 924 /* The enum denotes the status of the following block. */ |
1042 } | 1033 } |
1043 #else /* !MMAP_GENERATE_ADDRESSES */ | 1034 #else /* !MMAP_GENERATE_ADDRESSES */ |
1044 /* This is an alternate (simpler) implementation in cases where the | 1035 /* This is an alternate (simpler) implementation in cases where the |
1045 address is picked by the kernel. */ | 1036 address is picked by the kernel. */ |
1046 | 1037 |
1047 static void Addr_Block_initialize(void) | 1038 static void Addr_Block_initialize() |
1048 { | 1039 {} /* Nothing. */ |
1049 /* Nothing. */ | |
1050 } | |
1051 | 1040 |
1052 static VM_ADDR New_Addr_Block( SIZE sz ) | 1041 static VM_ADDR New_Addr_Block( SIZE sz ) |
1053 { | 1042 { |
1054 return mmap( 0, sz, PROT_READ|PROT_WRITE, MAP_FLAGS, | 1043 return mmap( 0, sz, PROT_READ|PROT_WRITE, MAP_FLAGS, |
1055 DEV_ZERO_FD, 0 ); | 1044 DEV_ZERO_FD, 0 ); |
1268 | 1257 |
1269 void | 1258 void |
1270 syms_of_ralloc (void) | 1259 syms_of_ralloc (void) |
1271 { | 1260 { |
1272 #ifdef MMAP_METERING | 1261 #ifdef MMAP_METERING |
1273 defsymbol (&Qmm_times_mapped, "mmap-times-mapped"); | 1262 defsymbol (&Qmm_times_mapped, "mmap-times-mapped" ); |
1274 defsymbol (&Qmm_pages_mapped, "mmap-pages-mapped"); | 1263 defsymbol (&Qmm_pages_mapped, "mmap-pages-mapped" ); |
1275 defsymbol (&Qmm_times_unmapped, "mmap-times-unmapped"); | 1264 defsymbol (&Qmm_times_unmapped, "mmap-times-unmapped" ); |
1276 defsymbol (&Qmm_times_remapped, "mmap-times-remapped"); | 1265 defsymbol (&Qmm_times_remapped, "mmap-times-remapped" ); |
1277 defsymbol (&Qmm_didnt_copy, "mmap-didnt-copy"); | 1266 defsymbol (&Qmm_didnt_copy, "mmap-didnt-copy" ); |
1278 defsymbol (&Qmm_pages_copied, "mmap-pages-copied"); | 1267 defsymbol (&Qmm_pages_copied, "mmap-pages-copied" ); |
1279 defsymbol (&Qmm_average_bumpval, "mmap-average-bumpval"); | 1268 defsymbol (&Qmm_average_bumpval, "mmap-average-bumpval" ); |
1280 defsymbol (&Qmm_wastage, "mmap-wastage"); | 1269 defsymbol (&Qmm_wastage, "mmap-wastage" ); |
1281 defsymbol (&Qmm_live_pages, "mmap-live-pages"); | 1270 defsymbol (&Qmm_live_pages, "mmap-live-pages" ); |
1282 defsymbol (&Qmm_addr_looked_up, "mmap-had-to-look-up-address"); | 1271 defsymbol (&Qmm_addr_looked_up, "mmap-had-to-look-up-address" ); |
1283 defsymbol (&Qmm_hash_worked, "mmap-hash-table-worked"); | 1272 defsymbol (&Qmm_hash_worked, "mmap-hash-table-worked" ); |
1284 defsymbol (&Qmm_addrlist_size, "mmap-addrlist-size"); | 1273 defsymbol (&Qmm_addrlist_size, "mmap-addrlist-size" ); |
1285 DEFSUBR (Fmmap_allocator_status); | 1274 DEFSUBR (Fmmap_allocator_status); |
1286 #endif /* MMAP_METERING */ | 1275 #endif /* MMAP_METERING */ |
1287 } | 1276 } |
1288 | 1277 |
1289 void | 1278 void |