- char *sp = (char *) signature_page;
-
- strncpy(sp + pagesize - 10, sig, 10);
-}
-
-#define V0_MAX_PAGES (8 * (pagesize - 10))
-/* Before 2.2.0pre9 */
-#define V1_OLD_MAX_PAGES ((0x7fffffff / pagesize) - 1)
-/* Since 2.2.0pre9:
- error if nr of pages >= SWP_OFFSET(SWP_ENTRY(0,~0UL))
- with variations on
- #define SWP_ENTRY(type,offset) (((type) << 1) | ((offset) << 8))
- #define SWP_OFFSET(entry) ((entry) >> 8)
- on the various architectures. Below the result - yuk.
-
- Machine pagesize SWP_ENTRY SWP_OFFSET bound+1 oldbound+2
- i386 2^12 o<<8 e>>8 1<<24 1<<19
- mips 2^12 o<<15 e>>15 1<<17 1<<19
- alpha 2^13 o<<40 e>>40 1<<24 1<<18
- m68k 2^12 o<<12 e>>12 1<<20 1<<19
- sparc 2^{12,13} (o&0x3ffff)<<9 (e>>9)&0x3ffff 1<<18 1<<{19,18}
- sparc64 2^13 o<<13 e>>13 1<<51 1<<18
- ppc 2^12 o<<8 e>>8 1<<24 1<<19
- armo 2^{13,14,15} o<<8 e>>8 1<<24 1<<{18,17,16}
- armv 2^12 o<<9 e>>9 1<<23 1<<19
-
- assuming that longs have 64 bits on alpha and sparc64 and 32 bits elsewhere.
-
- The bad part is that we need to know this since the kernel will
- refuse a swap space if it is too large.
-*/
-/* patch from jj - why does this differ from the above? */
-#if defined(__alpha__)
-#define V1_MAX_PAGES ((1 << 24) - 1)
-#elif defined(__mips__)
-#define V1_MAX_PAGES ((1 << 17) - 1)
-#elif defined(__sparc_v9__)
-#define V1_MAX_PAGES ((3 << 29) - 1)
-#elif defined(__sparc__)
-#define V1_MAX_PAGES (pagesize == 8192 ? ((3 << 29) - 1) : ((1 << 18) - 1))
-#else
-#define V1_MAX_PAGES V1_OLD_MAX_PAGES
-#endif
-/* man page now says:
-The maximum useful size of a swap area now depends on the architecture.
-It is roughly 2GB on i386, PPC, m68k, ARM, 1GB on sparc, 512MB on mips,
-128GB on alpha and 3TB on sparc64.
-*/
-
-#define MAX_BADPAGES ((pagesize-1024-128*sizeof(int)-10)/sizeof(int))
-
-static void bit_set(unsigned int *addr, unsigned int nr)
-{
- unsigned int r, m;
-
- addr += nr / (8 * sizeof(int));
-
- r = *addr;
- m = 1 << (nr & (8 * sizeof(int) - 1));
-
- *addr = r | m;
-}
-
-static int bit_test_and_clear(unsigned int *addr, unsigned int nr)
-{
- unsigned int r, m;
-
- addr += nr / (8 * sizeof(int));
-
- r = *addr;
- m = 1 << (nr & (8 * sizeof(int) - 1));
-
- *addr = r & ~m;
- return (r & m) != 0;
-}
-
-
-void die(const char *str)
-{
- error_msg("%s\n", str);
- exit(EXIT_FAILURE);
-}
-
-void page_ok(int page)
-{
- if (version == 0)
- bit_set(signature_page, page);
-}
-
-void page_bad(int page)
-{
- if (version == 0)
- bit_test_and_clear(signature_page, page);
- else {
- if (badpages == MAX_BADPAGES)
- die("too many bad pages");
- p->badpages[badpages] = page;
- }
- badpages++;
-}
-
-void check_blocks(void)
-{
- unsigned int current_page;
- int do_seek = 1;
- char *buffer;
-
- buffer = xmalloc(pagesize);
- current_page = 0;
- while (current_page < PAGES) {
- if (!check) {
- page_ok(current_page++);
- continue;