+int
+scm_c_frame_previous (enum scm_vm_frame_kind kind, struct scm_frame *frame)
+{
+ SCM *this_fp, *new_fp, *new_sp;
+ SCM *stack_base = frame_stack_base (kind, frame);
+
+ again:
+ this_fp = frame->fp_offset + stack_base;
+
+ if (this_fp == stack_base)
+ return 0;
+
+ new_fp = SCM_FRAME_DYNAMIC_LINK (this_fp);
+
+ if (!new_fp)
+ return 0;
+
+ new_fp = RELOC (kind, frame, new_fp);
+
+ if (new_fp < stack_base)
+ return 0;
+
+ new_sp = SCM_FRAME_PREVIOUS_SP (this_fp);
+ frame->fp_offset = new_fp - stack_base;
+ frame->sp_offset = new_sp - stack_base;
+ frame->ip = SCM_FRAME_RETURN_ADDRESS (this_fp);
+
+ {
+ SCM proc = scm_c_frame_closure (kind, frame);
+ if (SCM_PROGRAM_P (proc) && SCM_PROGRAM_IS_BOOT (proc))
+ goto again;
+ }
+
+ return 1;
+}
+