1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-07-04 08:40:21 +02:00

frames, values: BUILDING_LIBGUILE-guarded defs to internal headers

I was writing the trace function, which is included by Whippet, which
doesn't have the BUILDING_LIBGUILE define.  It is just as fine to put
these in private headers; better, even.

* libguile/frames-internal.h:
* libguile/values-internal.h: New files.
* libguile/Makefile.am (noinst_HEADERS): Add new files.
* libguile/backtrace.c:
* libguile/continuations.c:
* libguile/control.c:
* libguile/eval.c:
* libguile/frames.c:
* libguile/frames.h:
* libguile/gsubr.c:
* libguile/init.c:
* libguile/intrinsics.c:
* libguile/numbers.c:
* libguile/print.c:
* libguile/smob.c:
* libguile/smob.h:
* libguile/stacks.c:
* libguile/stacks.h:
* libguile/values.c:
* libguile/values.h:
* libguile/vm.c: Include new files.
This commit is contained in:
Andy Wingo 2025-07-01 10:43:14 +02:00
parent 65a265adea
commit 6a32628e18
21 changed files with 213 additions and 148 deletions

111
libguile/frames-internal.h Normal file
View file

@ -0,0 +1,111 @@
/* Copyright 2001,2009-2015,2018,2025
Free Software Foundation, Inc.
This file is part of Guile.
Guile is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Guile is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
License along with Guile. If not, see
<https://www.gnu.org/licenses/>. */
#ifndef _SCM_FRAMES_INTERNAL_H_
#define _SCM_FRAMES_INTERNAL_H_
#include <libguile/frames.h>
struct scm_frame
{
void *stack_holder;
ptrdiff_t fp_offset;
ptrdiff_t sp_offset;
uint32_t *ip;
};
struct scm_vm_frame
{
scm_t_bits tag_and_flags;
struct scm_frame frame;
};
enum scm_vm_frame_kind
{
SCM_VM_FRAME_KIND_VM,
SCM_VM_FRAME_KIND_CONT
};
static inline int
scm_is_vm_frame (SCM x)
{
return SCM_HAS_TYP7 (x, scm_tc7_frame);
}
#define SCM_VM_FRAME_P(x) (scm_is_vm_frame (x))
#define SCM_VALIDATE_VM_FRAME(p,x) SCM_MAKE_VALIDATE (p, x, VM_FRAME_P)
static inline struct scm_vm_frame*
scm_vm_frame (SCM x)
{
if (!scm_is_vm_frame (x))
abort ();
return (struct scm_vm_frame *) SCM_UNPACK_POINTER (x);
}
static inline enum scm_vm_frame_kind
scm_vm_frame_kind (struct scm_vm_frame *frame)
{
return (enum scm_vm_frame_kind) (frame->tag_and_flags >> 8);
}
SCM_INTERNAL union scm_vm_stack_element*
scm_vm_frame_stack_top (struct scm_vm_frame *frame);
static inline union scm_vm_stack_element*
scm_vm_frame_fp (struct scm_vm_frame *frame)
{
return scm_vm_frame_stack_top (frame) - frame->frame.fp_offset;
}
static inline union scm_vm_stack_element*
scm_vm_frame_sp (struct scm_vm_frame *frame)
{
return scm_vm_frame_stack_top (frame) - frame->frame.sp_offset;
}
static inline uint32_t*
scm_vm_frame_ip (struct scm_vm_frame *frame)
{
return frame->frame.ip;
}
/* See notes in frames.c before using this. */
SCM_INTERNAL SCM scm_c_frame_closure (enum scm_vm_frame_kind kind,
const struct scm_frame *frame);
SCM_INTERNAL SCM scm_c_make_frame (enum scm_vm_frame_kind kind,
const struct scm_frame *frame);
SCM_INTERNAL int scm_c_frame_previous (enum scm_vm_frame_kind kind,
struct scm_frame *frame);
static inline void
scm_frame_init_from_vm_frame (struct scm_frame *frame,
const struct scm_vm_frame *vm_frame)
{
memcpy (frame, &vm_frame->frame, sizeof (*frame));
}
SCM_INTERNAL void scm_i_frame_print (SCM frame, SCM port,
scm_print_state *pstate);
SCM_INTERNAL void scm_init_frames (void);
#endif /* _SCM_FRAMES_INTERNAL_H_ */