2 * This software is part of the SBCL system. See the README file for
5 * This software is derived from the CMU CL system, which was
6 * written at Carnegie Mellon University and released into the
7 * public domain. The software is in the public domain and is
8 * provided with absolutely no warranty. See the COPYING and CREDITS
9 * files for more information.
20 /* Except for os_zero, these routines are only called by Lisp code.
21 * These routines may also be replaced by os-dependent versions
22 * instead. See hpux-os.c for some useful restrictions on actual
26 os_zero(os_vm_address_t addr, os_vm_size_t length)
28 os_vm_address_t block_start;
29 os_vm_size_t block_size;
32 fprintf(stderr,";;; os_zero: addr: 0x%08x, len: 0x%08x\n",addr,length);
35 block_start = os_round_up_to_page(addr);
37 length -= block_start-addr;
38 block_size = os_trunc_size_to_page(length);
40 if (block_start > addr)
41 bzero((char *)addr, block_start-addr);
42 if (block_size < length)
43 bzero((char *)block_start+block_size, length-block_size);
45 if (block_size != 0) {
46 /* Now deallocate and allocate the block so that it faults in
49 os_invalidate(block_start, block_size);
50 addr = os_validate(block_start, block_size);
52 if (addr == NULL || addr != block_start)
53 lose("os_zero: block moved! 0x%08x ==> 0x%08x",
60 os_allocate(os_vm_size_t len)
62 return os_validate((os_vm_address_t)NULL, len);
66 os_allocate_at(os_vm_address_t addr, os_vm_size_t len)
68 return os_validate(addr, len);
72 os_deallocate(os_vm_address_t addr, os_vm_size_t len)
74 os_invalidate(addr,len);
77 /* (This function once tried to grow the chunk by asking os_validate
78 * whether the space was available, but that really only works under
81 os_reallocate(os_vm_address_t addr, os_vm_size_t old_len, os_vm_size_t len)
83 addr=os_trunc_to_page(addr);
84 len=os_round_up_size_to_page(len);
85 old_len=os_round_up_size_to_page(old_len);
88 return os_allocate(len);
90 long len_diff=len-old_len;
93 os_invalidate(addr+len,-len_diff);
96 os_vm_address_t new=os_allocate(len);
99 bcopy(addr,new,old_len);
100 os_invalidate(addr,old_len);