mirror of
https://github.com/urbit/shrub.git
synced 2024-11-28 13:54:20 +03:00
u3: control presence of guard page using macro
This commit is contained in:
parent
53af044d18
commit
b7cd97664d
@ -68,6 +68,7 @@ in stdenv.mkDerivation {
|
||||
|
||||
CFLAGS = oFlags ++ lib.optionals (!enableDebug) [ "-Werror" ];
|
||||
|
||||
GUARD_PAGE = true;
|
||||
MEMORY_DEBUG = enableDebug;
|
||||
CPU_DEBUG = enableDebug;
|
||||
EVENT_TIME_DEBUG = false;
|
||||
|
1
pkg/urbit/configure
vendored
1
pkg/urbit/configure
vendored
@ -64,6 +64,7 @@ do
|
||||
shift
|
||||
done
|
||||
|
||||
[ -n "${GUARD_PAGE-}" ] && defmacro U3_GUARD_PAGE 1
|
||||
[ -n "${MEMORY_DEBUG-}" ] && defmacro U3_MEMORY_DEBUG 1
|
||||
[ -n "${MEMORY_LOG-}" ] && defmacro U3_MEMORY_LOG 1
|
||||
[ -n "${CPU_DEBUG-}" ] && defmacro U3_CPU_DEBUG 1
|
||||
|
@ -398,28 +398,26 @@
|
||||
{
|
||||
u3R->cap_p += pil_u->mov_ws;
|
||||
|
||||
// XX define symbol to control guard page
|
||||
//
|
||||
#if 0
|
||||
#ifndef U3_GUARD_PAGE
|
||||
// !off means we're on a north road
|
||||
//
|
||||
if ( !pil_u->off_ws ) {
|
||||
if( !(u3R->cap_p > u3R->hat_p) ) {
|
||||
u3m_bail(c3__meme);
|
||||
}
|
||||
#ifdef U3_MEMORY_DEBUG
|
||||
# ifdef U3_MEMORY_DEBUG
|
||||
c3_assert( pil_u->top_p >= u3R->cap_p );
|
||||
#endif
|
||||
# endif
|
||||
}
|
||||
else {
|
||||
if( !(u3R->cap_p < u3R->hat_p) ) {
|
||||
u3m_bail(c3__meme);
|
||||
}
|
||||
#ifdef U3_MEMORY_DEBUG
|
||||
# ifdef U3_MEMORY_DEBUG
|
||||
c3_assert( pil_u->top_p <= u3R->cap_p );
|
||||
#endif
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
#endif /* ifndef U3_GUARD_PAGE */
|
||||
|
||||
#ifdef U3_MEMORY_DEBUG
|
||||
c3_assert( pil_u->rod_u == u3R );
|
||||
|
@ -186,6 +186,7 @@ _ce_mapfree(void* map_v)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef U3_GUARD_PAGE
|
||||
//! Place a guard page at the (approximate) middle of the free space between
|
||||
//! the heap and stack of the current road, bailing if memory has been
|
||||
//! exhausted.
|
||||
@ -237,6 +238,7 @@ _ce_center_guard_page(void)
|
||||
fail:
|
||||
u3m_signal(c3__meme);
|
||||
}
|
||||
#endif /* ifdef U3_GUARD_PAGE */
|
||||
|
||||
/* u3e_fault(): handle a memory event with libsigsegv protocol.
|
||||
*/
|
||||
@ -265,11 +267,14 @@ u3e_fault(void* adr_v, c3_i ser_i)
|
||||
c3_w blk_w = (pag_w >> 5);
|
||||
c3_w bit_w = (pag_w & 31);
|
||||
|
||||
#ifdef U3_GUARD_PAGE
|
||||
// The fault happened in the guard page.
|
||||
if ( gar_pag_p <= adr_p && adr_p < gar_pag_p + pag_wiz_i ) {
|
||||
_ce_center_guard_page();
|
||||
}
|
||||
else if ( 0 != (u3P.dit_w[blk_w] & (1 << bit_w)) ) {
|
||||
else
|
||||
#endif /* ifdef U3_GUARD_PAGE */
|
||||
if ( 0 != (u3P.dit_w[blk_w] & (1 << bit_w)) ) {
|
||||
fprintf(stderr, "strange page: %d, at %p, off %x\r\n", pag_w, adr_w, adr_p);
|
||||
c3_assert(0);
|
||||
return 0;
|
||||
@ -1093,5 +1098,7 @@ u3e_foul(void)
|
||||
void
|
||||
u3e_init(void)
|
||||
{
|
||||
#ifdef U3_GUARD_PAGE
|
||||
_ce_center_guard_page();
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user