1// This file must be compiled with -fno-builtin. 2 3#include "Thread.h" 4 5namespace Auto { 6 7 // 8 // clear_stack 9 // 10 // clears stack memory from the current sp to the depth that was scanned by the last collection 11 // 12 void Thread::clear_stack() { 13 // We need to be careful about calling functions during stack clearing. 14 // We can't use bzero or the like to do the zeroing because we don't know how much stack they use. 15 // The amount to clear is typically small so just use a simple loop writing pointer sized NULL values. 16 void **sp = (void **)auto_get_sp(); 17 void **zero_addr = (void **)_stack_scan_peak; 18 _stack_scan_peak = sp; 19 while (zero_addr < sp) { 20 *zero_addr = NULL; 21 zero_addr++; 22 } 23 } 24 25}; 26