DIRECTORY ProcessStackCheck; ProcessStackCheckImpl: CEDAR PROGRAM EXPORTS ProcessStackCheck = BEGIN << StackPushTestInline: PROC [bytes: INT] RETURNS [BOOL] = TRUSTED MACHINE CODE { "+#include \n"; "static bool StackPushTestHelper(bytes) int bytes; {\n"; " int here = 0;\n"; " XR_Thread t = XR_currThread;\n"; " XR_Pointer sp = (XR_Pointer) &here;\n"; " if (t->t_stack.stack_warmLimit < t->t_stack.stack_physInitial) {\n"; " /* stack grows down */\n"; " sp = sp - bytes;\n"; " if (sp <= t->t_stack.stack_warmLimit) return (0);\n"; " if (sp >= t->t_stack.stack_physInitial) return (0);\n"; " return (1);\n"; " };\n"; " /* stack grows up */\n"; " sp = sp + bytes;\n"; " if (sp <= t->t_stack.stack_physInitial) return (0);\n"; " if (sp >= t->t_stack.stack_warmLimit) return (0);\n"; " return (1);\n"; "}\n"; ".StackPushTestHelper"; }; >> StackPushTest: PUBLIC PROC [bytes: INT] RETURNS [BOOL] = { RETURN [XRStackPushTest[bytes]]; }; XRStackPushTest: PROC [bytes: INT] RETURNS [BOOL] = TRUSTED MACHINE CODE { ".XR_StackPushTest" }; END. f ProcessStackCheckImpl.mesa Copyright Σ 1992 by Xerox Corporation. All rights reserved. Russ Atkinson (RRA) October 9, 1992 1:28 pm PDT Michael Plass, January 29, 1993 11:31 am PST Returns TRUE if it appears to be OK to push an additional number of bytes on the stack (pop if bytes < 0). Returns FALSE if the stack is exceeded in either direction. ΚΥ•NewlineDelimiter –(cedarcode) style™code™Kšœ Οeœ1™