wingo pushed a commit to branch wip-whippet in repository guile. commit 27caa4cb98fe174630f58f3604cff34075685b31 Author: Andy Wingo <wi...@pobox.com> AuthorDate: Fri Jun 20 15:46:57 2025 +0200
Move SCM_CARLOC, SCM_CDRLOC to pairs.h * libguile/gc.h: * libguile/pairs.h (scm_pair_car_loc, scm_pair_cdr_loc): New helpers. (SCM_CARLOC, SCM_CDRLOC): Move here from gc.h. * libguile/list.c (scm_list_1, scm_list_2, scm_list_3): Just use scm_cons. --- libguile/gc.h | 2 -- libguile/list.c | 22 ++++------------------ libguile/pairs.h | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/libguile/gc.h b/libguile/gc.h index 34717f2f6..4422d6092 100644 --- a/libguile/gc.h +++ b/libguile/gc.h @@ -77,8 +77,6 @@ typedef struct scm_t_cell #define SCM_SET_CELL_OBJECT_3(x, v) SCM_SET_CELL_OBJECT ((x), 3, (v)) #define SCM_CELL_OBJECT_LOC(x, n) (&SCM_GC_CELL_OBJECT ((x), (n))) -#define SCM_CARLOC(x) (SCM_CELL_OBJECT_LOC ((x), 0)) -#define SCM_CDRLOC(x) (SCM_CELL_OBJECT_LOC ((x), 1)) #define SCM_CELL_TYPE(x) SCM_CELL_WORD_0 (x) #define SCM_SET_CELL_TYPE(x, t) SCM_SET_CELL_WORD_0 ((x), (t)) diff --git a/libguile/list.c b/libguile/list.c index 8063a15d1..ee2590c30 100644 --- a/libguile/list.c +++ b/libguile/list.c @@ -1,4 +1,4 @@ -/* Copyright 1995-1997,2000-2001,2003-2004,2008-2011,2014,2018 +/* Copyright 1995-1997,2000-2001,2003-2004,2008-2011,2014,2018,2025 Free Software Foundation, Inc. This file is part of Guile. @@ -40,36 +40,22 @@ /* creating lists */ -#define SCM_I_CONS(cell, x, y) \ - do { \ - cell = scm_cell (SCM_UNPACK (x), SCM_UNPACK (y)); \ - } while (0) - SCM scm_list_1 (SCM e1) { - SCM c1; - SCM_I_CONS (c1, e1, SCM_EOL); - return c1; + return scm_cons (e1, SCM_EOL); } SCM scm_list_2 (SCM e1, SCM e2) { - SCM c1, c2; - SCM_I_CONS (c2, e2, SCM_EOL); - SCM_I_CONS (c1, e1, c2); - return c1; + return scm_cons (e1, scm_cons (e2, SCM_EOL)); } SCM scm_list_3 (SCM e1, SCM e2, SCM e3) { - SCM c1, c2, c3; - SCM_I_CONS (c3, e3, SCM_EOL); - SCM_I_CONS (c2, e2, c3); - SCM_I_CONS (c1, e1, c2); - return c1; + return scm_cons (e1, scm_cons (e2, scm_cons (e3, SCM_EOL))); } SCM diff --git a/libguile/pairs.h b/libguile/pairs.h index 94d433439..053a2b911 100644 --- a/libguile/pairs.h +++ b/libguile/pairs.h @@ -117,12 +117,27 @@ scm_pair_set_cdr_x (struct scm_pair *pair, SCM cdr) pair->cdr = cdr; } +static inline SCM* +scm_pair_car_loc (struct scm_pair *pair) +{ + return &pair->car; +} + +static inline SCM* +scm_pair_cdr_loc (struct scm_pair *pair) +{ + return &pair->cdr; +} + #define SCM_CAR(x) (scm_pair_car (scm_to_pair (x))) #define SCM_CDR(x) (scm_pair_cdr (scm_to_pair (x))) #define SCM_SETCAR(x, v) (scm_pair_set_car_x (scm_to_pair (x), v)) #define SCM_SETCDR(x, v) (scm_pair_set_cdr_x (scm_to_pair (x), v)) +#define SCM_CARLOC(x) (scm_pair_car_loc (scm_to_pair (x))) +#define SCM_CDRLOC(x) (scm_pair_cdr_loc (scm_to_pair (x))) + #define SCM_CAAR(OBJ) SCM_CAR (SCM_CAR (OBJ)) #define SCM_CDAR(OBJ) SCM_CDR (SCM_CAR (OBJ)) #define SCM_CADR(OBJ) SCM_CAR (SCM_CDR (OBJ))