X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fos-common.c;h=bb09a24d1808d7148ff7cb0791d4df33ebe913ab;hb=78fa16bf55be44cc16845be84d98023e83fb14bc;hp=842781ace248b375d22b9d155bc311dd602be611;hpb=28a6fdf5f4ef6c63e1631b27e2650d928b9ba62e;p=sbcl.git diff --git a/src/runtime/os-common.c b/src/runtime/os-common.c index 842781a..bb09a24 100644 --- a/src/runtime/os-common.c +++ b/src/runtime/os-common.c @@ -22,11 +22,38 @@ * instead. See hpux-os.c for some useful restrictions on actual * usage. */ -/* FIXME: this should be turned into a pure inline memset where it is used. */ void os_zero(os_vm_address_t addr, os_vm_size_t length) { - memset(addr, 0, length); + os_vm_address_t block_start; + os_vm_size_t block_size; + +#ifdef DEBUG + fprintf(stderr,";;; os_zero: addr: 0x%08x, len: 0x%08x\n",addr,length); +#endif + + block_start = os_round_up_to_page(addr); + + length -= block_start-addr; + block_size = os_trunc_size_to_page(length); + + if (block_start > addr) + bzero((char *)addr, block_start-addr); + if (block_size < length) + bzero((char *)block_start+block_size, length-block_size); + + if (block_size != 0) { + /* Now deallocate and allocate the block so that it faults in + * zero-filled. */ + + os_invalidate(block_start, block_size); + addr = os_validate(block_start, block_size); + + if (addr == NULL || addr != block_start) + lose("os_zero: block moved! 0x%08x ==> 0x%08x", + block_start, + addr); + } } os_vm_address_t