1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

Use ptrdiff_t instead of scm_t_ptrdiff

* libguile/continuations.h:
* libguile/control.c:
* libguile/control.h:
* libguile/dynstack.c:
* libguile/dynstack.h:
* libguile/eval.c:
* libguile/foreign.c:
* libguile/frames.h:
* libguile/gen-scmconfig.c:
* libguile/gsubr.c:
* libguile/gsubr.h:
* libguile/loader.c:
* libguile/numbers.h:
* libguile/stacks.c:
* libguile/throw.c:
* libguile/vm-engine.c:
* libguile/vm.c:
* libguile/vm.h: Use ptrdiff_t from stddef.h.
This commit is contained in:
Andy Wingo 2018-06-21 08:43:47 +02:00
parent 16879cabed
commit 6ad1fc9ce0
18 changed files with 49 additions and 49 deletions

View file

@ -59,7 +59,7 @@ typedef struct
into the live stack, you need to add OFFSET so that it points
into the copy.
*/
scm_t_ptrdiff offset;
ptrdiff_t offset;
SCM_STACKITEM stack[1]; /* copied stack of size num_stack_items. */
} scm_t_contregs;

View file

@ -47,10 +47,10 @@
/* Only to be called if the setjmp returns 1 */
SCM
scm_i_prompt_pop_abort_args_x (struct scm_vm *vp,
scm_t_ptrdiff saved_stack_depth)
ptrdiff_t saved_stack_depth)
{
size_t i, n;
scm_t_ptrdiff stack_depth;
ptrdiff_t stack_depth;
SCM vals = SCM_EOL;
stack_depth = vp->stack_top - vp->sp;
@ -137,7 +137,7 @@ scm_c_abort (struct scm_vm *vp, SCM tag, size_t n, SCM *argv,
scm_t_dynstack *dynstack = &SCM_I_CURRENT_THREAD->dynstack;
scm_t_bits *prompt;
scm_t_dynstack_prompt_flags flags;
scm_t_ptrdiff fp_offset, sp_offset;
ptrdiff_t fp_offset, sp_offset;
union scm_vm_stack_element *fp, *sp;
uint32_t *ip;
jmp_buf *registers;

View file

@ -26,7 +26,7 @@
SCM_INTERNAL SCM scm_i_prompt_pop_abort_args_x (struct scm_vm *vp,
scm_t_ptrdiff saved_stack_depth);
ptrdiff_t saved_stack_depth);
SCM_INTERNAL void scm_c_abort (struct scm_vm *vp, SCM tag, size_t n, SCM *argv,
jmp_buf *registers) SCM_NORETURN;

View file

@ -39,9 +39,9 @@
#define PROMPT_WORDS 5
#define PROMPT_KEY(top) (SCM_PACK ((top)[0]))
#define PROMPT_FP(top) ((scm_t_ptrdiff) ((top)[1]))
#define PROMPT_FP(top) ((ptrdiff_t) ((top)[1]))
#define SET_PROMPT_FP(top, fp) do { top[1] = (scm_t_bits)(fp); } while (0)
#define PROMPT_SP(top) ((scm_t_ptrdiff) ((top)[2]))
#define PROMPT_SP(top) ((ptrdiff_t) ((top)[2]))
#define SET_PROMPT_SP(top, sp) do { top[2] = (scm_t_bits)(sp); } while (0)
#define PROMPT_IP(top) ((uint32_t *) ((top)[3]))
#define PROMPT_JMPBUF(top) ((jmp_buf *) ((top)[4]))
@ -195,7 +195,7 @@ void
scm_dynstack_push_prompt (scm_t_dynstack *dynstack,
scm_t_dynstack_prompt_flags flags,
SCM key,
scm_t_ptrdiff fp_offset, scm_t_ptrdiff sp_offset,
ptrdiff_t fp_offset, ptrdiff_t sp_offset,
uint32_t *ip, jmp_buf *registers)
{
scm_t_bits *words;
@ -293,7 +293,7 @@ scm_dynstack_capture (scm_t_dynstack *dynstack, scm_t_bits *item)
}
void
scm_dynstack_relocate_prompts (scm_t_dynstack *dynstack, scm_t_ptrdiff base)
scm_dynstack_relocate_prompts (scm_t_dynstack *dynstack, ptrdiff_t base)
{
scm_t_bits *walk;
@ -498,7 +498,7 @@ scm_dynstack_unwind_fork (scm_t_dynstack *dynstack, scm_t_dynstack *branch)
scm_t_bits*
scm_dynstack_find_prompt (scm_t_dynstack *dynstack, SCM key,
scm_t_dynstack_prompt_flags *flags,
scm_t_ptrdiff *fp_offset, scm_t_ptrdiff *sp_offset,
ptrdiff_t *fp_offset, ptrdiff_t *sp_offset,
uint32_t **ip, jmp_buf **registers)
{
scm_t_bits *walk;
@ -579,7 +579,7 @@ scm_dynstack_find_old_fluid_value (scm_t_dynstack *dynstack, SCM fluid,
void
scm_dynstack_wind_prompt (scm_t_dynstack *dynstack, scm_t_bits *item,
scm_t_ptrdiff base_fp_offset,
ptrdiff_t base_fp_offset,
jmp_buf *registers)
{
scm_t_bits tag = SCM_DYNSTACK_TAG (item);

View file

@ -158,8 +158,8 @@ SCM_INTERNAL void scm_dynstack_push_dynamic_state (scm_t_dynstack *, SCM,
SCM_INTERNAL void scm_dynstack_push_prompt (scm_t_dynstack *,
scm_t_dynstack_prompt_flags,
SCM key,
scm_t_ptrdiff fp_offset,
scm_t_ptrdiff sp_offset,
ptrdiff_t fp_offset,
ptrdiff_t sp_offset,
uint32_t *ip,
jmp_buf *registers);
SCM_INTERNAL void scm_dynstack_push_dynwind (scm_t_dynstack *,
@ -198,8 +198,8 @@ SCM_INTERNAL void scm_dynstack_unwind_dynamic_state
SCM_INTERNAL scm_t_bits* scm_dynstack_find_prompt (scm_t_dynstack *, SCM,
scm_t_dynstack_prompt_flags *,
scm_t_ptrdiff *,
scm_t_ptrdiff *,
ptrdiff_t *,
ptrdiff_t *,
uint32_t **,
jmp_buf **);
@ -207,10 +207,10 @@ SCM_INTERNAL SCM scm_dynstack_find_old_fluid_value (scm_t_dynstack *,
SCM, size_t, SCM);
SCM_INTERNAL void scm_dynstack_relocate_prompts (scm_t_dynstack *,
scm_t_ptrdiff);
ptrdiff_t);
SCM_INTERNAL void scm_dynstack_wind_prompt (scm_t_dynstack *, scm_t_bits *,
scm_t_ptrdiff, jmp_buf *);
ptrdiff_t, jmp_buf *);
#endif /* SCM_DYNSTACK_H */

View file

@ -435,7 +435,7 @@ eval (SCM x, SCM env)
SCM k, handler, res;
jmp_buf registers;
const void *prev_cookie;
scm_t_ptrdiff saved_stack_depth;
ptrdiff_t saved_stack_depth;
k = EVAL1 (CAR (mx), env);
handler = EVAL1 (CDDR (mx), env);

View file

@ -1029,7 +1029,7 @@ scm_i_foreign_call (SCM cif_scm, SCM pointer_scm, int *errno_ret,
void **args;
unsigned i;
size_t arg_size;
scm_t_ptrdiff off;
ptrdiff_t off;
cif = SCM_POINTER_VALUE (cif_scm);
func = SCM_POINTER_VALUE (pointer_scm);
@ -1270,7 +1270,7 @@ scm_init_foreign (void)
#elif SCM_SIZEOF_SCM_T_PTRDIFF == 4
scm_from_uint8 (SCM_FOREIGN_TYPE_INT32)
#else
# error unsupported sizeof (scm_t_ptrdiff)
# error unsupported sizeof (ptrdiff_t)
#endif
);

View file

@ -120,8 +120,8 @@ union scm_vm_stack_element
struct scm_frame
{
void *stack_holder;
scm_t_ptrdiff fp_offset;
scm_t_ptrdiff sp_offset;
ptrdiff_t fp_offset;
ptrdiff_t sp_offset;
uint32_t *ip;
};

View file

@ -88,7 +88,7 @@
- make sure that anything that we explicitly typedef publically is
prefixed with scm_t_. i.e. we used to typedef long to ptrdiff_t
if we didn't detect ptrdiff_t, but this has been changed so that
we typedef scm_t_ptrdiff instead so that we won't conflict with
we typedef ptrdiff_t instead so that we won't conflict with
any non-guile header definitions of the same type. For types
like intptr_t and uintptr_t which we just try to detect and don't
actually define, it's fine not to have a corresponding scm_t_

View file

@ -298,7 +298,7 @@ scm_i_primitive_call_ip (SCM subr)
}
SCM
scm_apply_subr (union scm_vm_stack_element *sp, scm_t_ptrdiff nslots)
scm_apply_subr (union scm_vm_stack_element *sp, ptrdiff_t nslots)
{
SCM (*subr)() = SCM_SUBRF (sp[nslots - 1].as_scm);

View file

@ -57,7 +57,7 @@ SCM_INTERNAL uintptr_t scm_i_primitive_call_ip (SCM subr);
union scm_vm_stack_element;
SCM_INTERNAL SCM scm_apply_subr (union scm_vm_stack_element *sp,
scm_t_ptrdiff nargs);
ptrdiff_t nargs);
SCM_API SCM scm_c_make_gsubr (const char *name,
int req, int opt, int rst, scm_t_subr fcn);

View file

@ -264,7 +264,7 @@ process_dynamic_segment (char *base, Elf_Phdr *dyn_phdr,
Elf_Dyn *dyn = (Elf_Dyn *) dyn_addr;
size_t i, dyn_size = dyn_phdr->p_memsz / sizeof (Elf_Dyn);
char *init = 0, *gc_root = 0, *entry = 0, *frame_maps = 0;
scm_t_ptrdiff gc_root_size = 0;
ptrdiff_t gc_root_size = 0;
enum bytecode_kind bytecode_kind = BYTECODE_KIND_NONE;
for (i = 0; i < dyn_size; i++)

View file

@ -534,7 +534,7 @@ SCM_API SCM scm_from_mpz (mpz_t rop);
#define scm_to_ptrdiff_t scm_to_int64
#define scm_from_ptrdiff_t scm_from_int64
#else
#error sizeof(scm_t_ptrdiff) is not 4 or 8.
#error sizeof(ptrdiff_t) is not 4 or 8.
#endif
#endif

View file

@ -101,10 +101,10 @@ stack_depth (enum scm_vm_frame_kind kind, const struct scm_frame *frame)
* encountered.
*/
static scm_t_ptrdiff
static ptrdiff_t
find_prompt (SCM key)
{
scm_t_ptrdiff fp_offset;
ptrdiff_t fp_offset;
if (!scm_dynstack_find_prompt (&SCM_I_CURRENT_THREAD->dynstack, key,
NULL, &fp_offset, NULL, NULL, NULL))
@ -180,7 +180,7 @@ narrow_stack (long len, enum scm_vm_frame_kind kind, struct scm_frame *frame,
else
{
/* Cut until the given prompt tag is seen. */
scm_t_ptrdiff fp_offset = find_prompt (inner_cut);
ptrdiff_t fp_offset = find_prompt (inner_cut);
for (; len; len--, scm_c_frame_previous (kind, frame))
if (fp_offset == frame->fp_offset)
break;
@ -240,7 +240,7 @@ narrow_stack (long len, enum scm_vm_frame_kind kind, struct scm_frame *frame,
/* Cut until the given prompt tag is seen. */
long i;
struct scm_frame tmp;
scm_t_ptrdiff fp_offset = find_prompt (outer_cut);
ptrdiff_t fp_offset = find_prompt (outer_cut);
memcpy (&tmp, frame, sizeof tmp);

View file

@ -87,7 +87,7 @@ catch (SCM tag, SCM thunk, SCM handler, SCM pre_unwind_handler)
scm_t_dynamic_state *dynamic_state = SCM_I_CURRENT_THREAD->dynamic_state;
jmp_buf registers;
const void *prev_cookie;
scm_t_ptrdiff saved_stack_depth;
ptrdiff_t saved_stack_depth;
if (!scm_is_eq (tag, SCM_BOOL_T) && !scm_is_symbol (tag))
scm_wrong_type_arg ("catch", 1, tag);

View file

@ -2685,14 +2685,14 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
{
uint8_t compare_result;
uint32_t expected;
scm_t_ptrdiff nargs;
ptrdiff_t nargs;
UNPACK_24 (op, expected);
nargs = FRAME_LOCALS_COUNT ();
if (nargs < (scm_t_ptrdiff) expected)
if (nargs < (ptrdiff_t) expected)
compare_result = SCM_F_COMPARE_LESS_THAN;
else if (nargs == (scm_t_ptrdiff) expected)
else if (nargs == (ptrdiff_t) expected)
compare_result = SCM_F_COMPARE_EQUAL;
else
compare_result = SCM_F_COMPARE_NONE;
@ -2706,7 +2706,7 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
{
uint8_t compare_result;
uint32_t nreq, expected;
scm_t_ptrdiff nargs, npos;
ptrdiff_t nargs, npos;
UNPACK_24 (op, nreq);
UNPACK_24 (ip[1], expected);
@ -2717,9 +2717,9 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
if (scm_is_keyword (FP_REF (npos)))
break;
if (npos < (scm_t_ptrdiff) expected)
if (npos < (ptrdiff_t) expected)
compare_result = SCM_F_COMPARE_LESS_THAN;
else if (npos == (scm_t_ptrdiff) expected)
else if (npos == (ptrdiff_t) expected)
compare_result = SCM_F_COMPARE_EQUAL;
else
compare_result = SCM_F_COMPARE_NONE;

View file

@ -411,7 +411,7 @@ vm_reinstate_partial_continuation (struct scm_vm *vp, SCM cont, size_t nargs,
struct vm_reinstate_partial_continuation_data data;
struct scm_vm_cont *cp;
union scm_vm_stack_element *args;
scm_t_ptrdiff old_fp_offset;
ptrdiff_t old_fp_offset;
args = alloca (nargs * sizeof (*args));
memcpy (args, vp->sp, nargs * sizeof (*args));
@ -952,7 +952,7 @@ scm_i_vm_mark_stack (struct scm_vm *vp, struct GC_ms_entry *mark_stack_ptr,
fp < vp->stack_top;
fp = SCM_FRAME_DYNAMIC_LINK (fp))
{
scm_t_ptrdiff nlocals = SCM_FRAME_NUM_LOCALS (fp, sp);
ptrdiff_t nlocals = SCM_FRAME_NUM_LOCALS (fp, sp);
size_t slot = nlocals - 1;
for (slot = nlocals - 1; sp < fp; sp++, slot--)
{
@ -1018,7 +1018,7 @@ vm_expand_stack_inner (void *data_ptr)
struct scm_vm *vp = data->vp;
union scm_vm_stack_element *old_top, *new_bottom;
size_t new_size;
scm_t_ptrdiff reloc;
ptrdiff_t reloc;
old_top = vp->stack_top;
new_size = vp->stack_size;
@ -1042,7 +1042,7 @@ vm_expand_stack_inner (void *data_ptr)
return new_bottom;
}
static scm_t_ptrdiff
static ptrdiff_t
current_overflow_size (struct scm_vm *vp)
{
if (scm_is_pair (vp->overflow_handler_stack))
@ -1051,9 +1051,9 @@ current_overflow_size (struct scm_vm *vp)
}
static int
should_handle_stack_overflow (struct scm_vm *vp, scm_t_ptrdiff stack_size)
should_handle_stack_overflow (struct scm_vm *vp, ptrdiff_t stack_size)
{
scm_t_ptrdiff overflow_size = current_overflow_size (vp);
ptrdiff_t overflow_size = current_overflow_size (vp);
return overflow_size >= 0 && stack_size >= overflow_size;
}
@ -1095,7 +1095,7 @@ unwind_overflow_handler (void *ptr)
static void
vm_expand_stack (struct scm_vm *vp, union scm_vm_stack_element *new_sp)
{
scm_t_ptrdiff stack_size = vp->stack_top - new_sp;
ptrdiff_t stack_size = vp->stack_top - new_sp;
if (stack_size > vp->stack_size)
{
@ -1181,7 +1181,7 @@ scm_call_n (SCM proc, SCM *argv, size_t nargs)
greater than INTMAX/2 and therefore we don't have to check for
overflow here or below. */
size_t return_nlocals = 1, call_nlocals = nargs + 1, frame_size = 2;
scm_t_ptrdiff stack_reserve_words;
ptrdiff_t stack_reserve_words;
size_t i;
thread = SCM_I_CURRENT_THREAD;
@ -1424,7 +1424,7 @@ SCM_DEFINE (scm_call_with_stack_overflow_handler,
#define FUNC_NAME s_scm_call_with_stack_overflow_handler
{
struct scm_vm *vp;
scm_t_ptrdiff c_limit, stack_size;
ptrdiff_t c_limit, stack_size;
struct overflow_handler_data data;
SCM new_limit, ret;

View file

@ -93,10 +93,10 @@ struct scm_vm_cont {
/* IP of newest frame. */
uint32_t *ra;
/* Offset of FP of newest frame, relative to stack top. */
scm_t_ptrdiff fp_offset;
ptrdiff_t fp_offset;
/* Besides being the stack size, this is also the offset of the SP of
the newest frame. */
scm_t_ptrdiff stack_size;
ptrdiff_t stack_size;
/* Stack bottom, which also keeps saved stack alive for GC. */
union scm_vm_stack_element *stack_bottom;
/* Saved dynamic stack, with prompts relocated to record saved SP/FP