Changeset 78
- Timestamp:
- 06/08/05 00:09:39 (4 years ago)
- Files:
-
- src/memory.c (modified) (1 diff)
- src/memory.h (modified) (1 diff)
- src/swaps.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
src/memory.c
r77 r78 85 85 return true; 86 86 } 87 87 88 88 89 struct meminfo_item src/memory.h
r77 r78 27 27 #define MEMSIZE_ERROR LLONG_MIN 28 28 29 /// Round (through truncation) a size (in bytes) to multiple of page size 30 #define TRUNC_TO_PAGE(n) (((memsize_t)n) & ~((memsize_t)PAGE_SIZE-1)) 31 32 29 33 /// Check if we can access memory status etc. Clobbers localbuf. 30 34 bool check_memory_status(void); src/swaps.c
r77 r78 61 61 62 62 /// Smallest allowed swapfile size 63 static memsize_t min_swapsize = (12*PAGE_SIZE) & PAGE_MASK;63 static memsize_t min_swapsize = TRUNC_TO_PAGE(12*PAGE_SIZE); 64 64 /// Largest allowed swapfile size 65 65 /** Don't set this too low. The program will learn if it runs into file size 66 66 * limits. 67 67 */ 68 static memsize_t max_swapsize = T ERA & PAGE_MASK;68 static memsize_t max_swapsize = TRUNC_TO_PAGE(TERA); 69 69 70 70 … … 100 100 char *set_min_swapsize(long long size) 101 101 { 102 min_swapsize = ((memsize_t)size & PAGE_MASK);102 min_swapsize = TRUNC_TO_PAGE(size); 103 103 return NULL; 104 104 } … … 106 106 char *set_max_swapsize(long long size) 107 107 { 108 max_swapsize = ((memsize_t)size) & PAGE_MASK;108 max_swapsize = TRUNC_TO_PAGE(size); 109 109 return NULL; 110 110 } … … 272 272 // File is too large. Remember how much we were allowed to write. 273 273 if (likely(bytes > 0 && max_swapsize > bytes)) 274 max_swapsize = (bytes & PAGE_MASK);274 max_swapsize = TRUNC_TO_PAGE(bytes); 275 275 break; 276 276 case ENOSPC: … … 303 303 { 304 304 assert(min_swapsize <= max_swapsize); 305 assert( !(max_swapsize & ~PAGE_MASK));306 assert( !(min_swapsize & ~PAGE_MASK));307 assert( !(size & ~PAGE_MASK));305 assert(max_swapsize == TRUNC_TO_PAGE(max_swapsize)); 306 assert(min_swapsize == TRUNC_TO_PAGE(min_swapsize)); 307 assert(size == TRUNC_TO_PAGE(size)); 308 308 309 309 memsize_t realsize; … … 616 616 * readers will notice that this relies on PAGE_SIZE being a power of two. 617 617 */ 618 size = (size & PAGE_MASK) + 2*PAGE_SIZE;618 size = TRUNC_TO_PAGE(size) + 2*PAGE_SIZE; 619 619 const int newswap = find_free(sequence_number); 620 620 if (swapfiles[newswap].size) return; // No free slot, sorry!
