1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-07-01 07:20:20 +02:00

Switch all users of SCM_SIMPLE_VECTOR_REF to scm_c_vector_ref

* libguile/arrays.c:
* libguile/eval.c:
* libguile/filesys.c:
* libguile/hashtab.c:
* libguile/intrinsics.c:
* libguile/memoize.c:
* libguile/modules.c:
* libguile/poll.c:
* libguile/ports-internal.h:
* libguile/posix.c:
* libguile/print.c:
* libguile/scmsigs.c:
* libguile/socket.c:
* libguile/stime.c:
* libguile/strports.c:
* libguile/vectors.c: Use C function instead of macro.
This commit is contained in:
Andy Wingo 2025-06-24 10:32:14 +02:00
parent d73c675fa6
commit 4dedc48cfb
16 changed files with 66 additions and 66 deletions

View file

@ -841,7 +841,7 @@ SCM_DEFINE (scm_transpose_array, "transpose-array", 1, 0, 1,
ndim = 0;
for (k = 0; k < scm_array_dimension_count (ra); k++)
{
i = scm_to_signed_integer (SCM_SIMPLE_VECTOR_REF (vargs, k),
i = scm_to_signed_integer (scm_c_vector_ref (vargs, k),
0, scm_array_dimension_count (ra));
if (ndim < i)
ndim = i;
@ -858,7 +858,7 @@ SCM_DEFINE (scm_transpose_array, "transpose-array", 1, 0, 1,
for (k = scm_array_dimension_count (ra); k--;)
{
i = scm_to_int (SCM_SIMPLE_VECTOR_REF (vargs, k));
i = scm_to_int (scm_c_vector_ref (vargs, k));
s = &(ra->dims[k]);
r = &(res->dims[i]);
if (r->ubnd < r->lbnd)

View file

@ -79,7 +79,7 @@
#define CADDR(x) SCM_CADDR(x)
#define CDDDR(x) SCM_CDDDR(x)
#define VECTOR_REF(v, i) (SCM_SIMPLE_VECTOR_REF (v, i))
#define VECTOR_REF(v, i) (scm_c_vector_ref (v, i))
#define VECTOR_SET(v, i, x) (SCM_SIMPLE_VECTOR_SET (v, i, x))
#define VECTOR_LENGTH(v) (scm_c_vector_length (v))

View file

@ -829,7 +829,7 @@ fill_select_type (fd_set *set, SCM *ports_ready, SCM list_or_vec, int pos)
while (--i >= 0)
{
int fd = set_element (set, ports_ready,
SCM_SIMPLE_VECTOR_REF (list_or_vec, i), pos);
scm_c_vector_ref (list_or_vec, i), pos);
if (fd > max_fd)
max_fd = fd;
@ -890,7 +890,7 @@ retrieve_select_type (fd_set *set, SCM ports_ready, SCM list_or_vec)
while (--i >= 0)
{
answer_list = get_element (set,
SCM_SIMPLE_VECTOR_REF (list_or_vec, i),
scm_c_vector_ref (list_or_vec, i),
answer_list);
}
return scm_vector (answer_list);

View file

@ -515,7 +515,7 @@ hashtable_bucket_count (struct scm_t_hashtable *ht)
static inline SCM
hashtable_bucket (struct scm_t_hashtable *ht, size_t idx)
{
return SCM_SIMPLE_VECTOR_REF (hashtable_buckets (ht), idx);
return scm_c_vector_ref (hashtable_buckets (ht), idx);
}
static inline void
@ -613,7 +613,7 @@ rehash (struct scm_t_hashtable *table, scm_t_hash_fn hash_fn,
size_t old_size = SCM_SIMPLE_VECTOR_LENGTH (buckets);
for (i = 0; i < old_size; ++i)
{
SCM ls = SCM_SIMPLE_VECTOR_REF (buckets, i);
SCM ls = scm_c_vector_ref (buckets, i);
SCM_SIMPLE_VECTOR_SET (buckets, i, SCM_EOL);
while (scm_is_pair (ls))
@ -627,7 +627,7 @@ rehash (struct scm_t_hashtable *table, scm_t_hash_fn hash_fn,
h = hash_fn (SCM_CAR (handle), new_size, closure);
if (h >= new_size)
scm_out_of_range (func_name, scm_from_ulong (h));
SCM_SETCDR (cell, SCM_SIMPLE_VECTOR_REF (new_buckets, h));
SCM_SETCDR (cell, scm_c_vector_ref (new_buckets, h));
SCM_SIMPLE_VECTOR_SET (new_buckets, h, cell);
hashtable_increment (table);
}
@ -703,7 +703,7 @@ scm_hash_fn_get_handle (SCM table, SCM obj,
if (k >= scm_c_vector_length (buckets))
scm_out_of_range (FUNC_NAME, scm_from_ulong (k));
h = assoc_fn (obj, SCM_SIMPLE_VECTOR_REF (buckets, k), closure);
h = assoc_fn (obj, scm_c_vector_ref (buckets, k), closure);
return h;
}
@ -730,7 +730,7 @@ scm_hash_fn_create_handle_x (SCM table, SCM obj, SCM init,
if (k >= scm_c_vector_length (buckets))
scm_out_of_range ("hash_fn_create_handle_x", scm_from_ulong (k));
it = assoc_fn (obj, SCM_SIMPLE_VECTOR_REF (buckets, k), closure);
it = assoc_fn (obj, scm_c_vector_ref (buckets, k), closure);
if (scm_is_pair (it))
return it;
@ -750,7 +750,7 @@ scm_hash_fn_create_handle_x (SCM table, SCM obj, SCM init,
if (k >= scm_c_vector_length (buckets))
scm_out_of_range ("hash_fn_create_handle_x", scm_from_ulong (k));
}
SCM_SETCDR (new_bucket, SCM_SIMPLE_VECTOR_REF (buckets, k));
SCM_SETCDR (new_bucket, scm_c_vector_ref (buckets, k));
SCM_SIMPLE_VECTOR_SET (buckets, k, new_bucket);
hashtable_increment (ht);
@ -815,12 +815,12 @@ scm_hash_fn_remove_x (SCM table, SCM obj,
if (k >= scm_c_vector_length (buckets))
scm_out_of_range (FUNC_NAME, scm_from_ulong (k));
h = assoc_fn (obj, SCM_SIMPLE_VECTOR_REF (buckets, k), closure);
h = assoc_fn (obj, scm_c_vector_ref (buckets, k), closure);
if (scm_is_true (h))
{
SCM_SIMPLE_VECTOR_SET
(buckets, k, scm_delq_x (h, SCM_SIMPLE_VECTOR_REF (buckets, k)));
(buckets, k, scm_delq_x (h, scm_c_vector_ref (buckets, k)));
hashtable_decrement (ht);
if (hashtable_n_items (ht) < hashtable_lower (ht))
rehash (ht, hash_fn, closure, FUNC_NAME);
@ -1556,7 +1556,7 @@ scm_internal_hash_fold (scm_t_hash_fold_fn fn, void *closure,
{
SCM ls, handle;
for (ls = SCM_SIMPLE_VECTOR_REF (buckets, i); !scm_is_null (ls);
for (ls = scm_c_vector_ref (buckets, i); !scm_is_null (ls);
ls = SCM_CDR (ls))
{
handle = SCM_CAR (ls);
@ -1589,7 +1589,7 @@ scm_internal_hash_for_each_handle (scm_t_hash_handle_fn fn, void *closure,
for (i = 0; i < n; ++i)
{
SCM ls = SCM_SIMPLE_VECTOR_REF (buckets, i), handle;
SCM ls = scm_c_vector_ref (buckets, i), handle;
while (!scm_is_null (ls))
{
if (!scm_is_pair (ls))

View file

@ -404,9 +404,9 @@ throw_with_value (SCM val, SCM key_subr_and_message)
{
SCM key, subr, message, args, data;
key = SCM_SIMPLE_VECTOR_REF (key_subr_and_message, 0);
subr = SCM_SIMPLE_VECTOR_REF (key_subr_and_message, 1);
message = SCM_SIMPLE_VECTOR_REF (key_subr_and_message, 2);
key = scm_c_vector_ref (key_subr_and_message, 0);
subr = scm_c_vector_ref (key_subr_and_message, 1);
message = scm_c_vector_ref (key_subr_and_message, 2);
args = scm_list_1 (val);
data = SCM_BOOL_F;
@ -418,9 +418,9 @@ throw_with_value_and_data (SCM val, SCM key_subr_and_message)
{
SCM key, subr, message, args, data;
key = SCM_SIMPLE_VECTOR_REF (key_subr_and_message, 0);
subr = SCM_SIMPLE_VECTOR_REF (key_subr_and_message, 1);
message = SCM_SIMPLE_VECTOR_REF (key_subr_and_message, 2);
key = scm_c_vector_ref (key_subr_and_message, 0);
subr = scm_c_vector_ref (key_subr_and_message, 1);
message = scm_c_vector_ref (key_subr_and_message, 2);
args = scm_list_1 (val);
data = args;

View file

@ -63,7 +63,7 @@
#define CDDDR(x) SCM_CDDDR(x)
#define CADDDR(x) SCM_CADDDR(x)
#define VECTOR_REF(v, i) (SCM_SIMPLE_VECTOR_REF (v, i))
#define VECTOR_REF(v, i) (scm_c_vector_ref (v, i))
#define VECTOR_SET(v, i, x) (SCM_SIMPLE_VECTOR_SET (v, i, x))
#define VECTOR_LENGTH(v) (scm_c_vector_length (v))

View file

@ -850,7 +850,7 @@ SCM_DEFINE (scm_module_reverse_lookup, "module-reverse-lookup", 2, 0, 0,
n = scm_c_vector_length (buckets);
for (i = 0; i < n; ++i)
{
for (SCM ls = SCM_SIMPLE_VECTOR_REF (buckets, i);
for (SCM ls = scm_c_vector_ref (buckets, i);
!scm_is_null (ls);
ls = SCM_CDR (ls))
{

View file

@ -106,7 +106,7 @@ scm_primitive_poll (SCM pollfds, SCM nfds, SCM ports, SCM timeout)
for (i = 0; i < c_nfds; i++)
{
SCM port = SCM_SIMPLE_VECTOR_REF (ports, i);
SCM port = scm_c_vector_ref (ports, i);
short int revents = 0;
if (SCM_PORTP (port))
@ -145,7 +145,7 @@ scm_primitive_poll (SCM pollfds, SCM nfds, SCM ports, SCM timeout)
if (have_buffered_io)
for (i = 0; i < c_nfds; i++)
{
SCM port = SCM_SIMPLE_VECTOR_REF (ports, i);
SCM port = scm_c_vector_ref (ports, i);
short int revents = 0;
if (SCM_PORTP (port))

View file

@ -120,13 +120,13 @@ enum scm_port_buffer_field {
static inline SCM
scm_port_buffer_bytevector (SCM buf)
{
return SCM_SIMPLE_VECTOR_REF (buf, SCM_PORT_BUFFER_FIELD_BYTEVECTOR);
return scm_c_vector_ref (buf, SCM_PORT_BUFFER_FIELD_BYTEVECTOR);
}
static inline SCM
scm_port_buffer_cur (SCM buf)
{
return SCM_SIMPLE_VECTOR_REF (buf, SCM_PORT_BUFFER_FIELD_CUR);
return scm_c_vector_ref (buf, SCM_PORT_BUFFER_FIELD_CUR);
}
static inline void
@ -138,7 +138,7 @@ scm_port_buffer_set_cur (SCM buf, SCM cur)
static inline SCM
scm_port_buffer_end (SCM buf)
{
return SCM_SIMPLE_VECTOR_REF (buf, SCM_PORT_BUFFER_FIELD_END);
return scm_c_vector_ref (buf, SCM_PORT_BUFFER_FIELD_END);
}
static inline void
@ -150,7 +150,7 @@ scm_port_buffer_set_end (SCM buf, SCM end)
static inline SCM
scm_port_buffer_has_eof_p (SCM buf)
{
return SCM_SIMPLE_VECTOR_REF (buf, SCM_PORT_BUFFER_FIELD_HAS_EOF_P);
return scm_c_vector_ref (buf, SCM_PORT_BUFFER_FIELD_HAS_EOF_P);
}
static inline void
@ -166,7 +166,7 @@ scm_port_buffer_set_has_eof_p (SCM buf, SCM has_eof_p)
static inline SCM
scm_port_buffer_position (SCM buf)
{
return SCM_SIMPLE_VECTOR_REF (buf, SCM_PORT_BUFFER_FIELD_POSITION);
return scm_c_vector_ref (buf, SCM_PORT_BUFFER_FIELD_POSITION);
}
static inline SCM

View file

@ -352,11 +352,11 @@ SCM_DEFINE (scm_setgroups, "setgroups", 1, 0, 0,
{
unsigned long ulong_gid;
GETGROUPS_T gid;
SCM_VALIDATE_ULONG_COPY (1, SCM_SIMPLE_VECTOR_REF (group_vec, i),
SCM_VALIDATE_ULONG_COPY (1, scm_c_vector_ref (group_vec, i),
ulong_gid);
gid = ulong_gid;
if (gid != ulong_gid)
SCM_OUT_OF_RANGE (1, SCM_SIMPLE_VECTOR_REF (group_vec, i));
SCM_OUT_OF_RANGE (1, scm_c_vector_ref (group_vec, i));
}
size = ngroups * sizeof (GETGROUPS_T);
@ -364,7 +364,7 @@ SCM_DEFINE (scm_setgroups, "setgroups", 1, 0, 0,
SCM_OUT_OF_RANGE (SCM_ARG1, scm_from_int (ngroups));
groups = scm_malloc (size);
for(i = 0; i < ngroups; i++)
groups [i] = SCM_NUM2ULONG (1, SCM_SIMPLE_VECTOR_REF (group_vec, i));
groups [i] = SCM_NUM2ULONG (1, scm_c_vector_ref (group_vec, i));
result = setgroups (ngroups, groups);
save_errno = errno; /* don't let free() touch errno */

View file

@ -243,13 +243,13 @@ grow_ref_stack (scm_print_state *pstate)
unsigned long int i;
for (i = 0; i != old_size; ++i)
SCM_SIMPLE_VECTOR_SET (new_vect, i, SCM_SIMPLE_VECTOR_REF (old_vect, i));
SCM_SIMPLE_VECTOR_SET (new_vect, i, scm_c_vector_ref (old_vect, i));
pstate->ref_vect = new_vect;
pstate->ceiling = new_size;
}
#define PSTATE_STACK_REF(p,i) SCM_SIMPLE_VECTOR_REF((p)->ref_vect, (i))
#define PSTATE_STACK_REF(p,i) scm_c_vector_ref((p)->ref_vect, (i))
#define PSTATE_STACK_SET(p,i,v) SCM_SIMPLE_VECTOR_SET((p)->ref_vect, (i), (v))
static void

View file

@ -185,8 +185,8 @@ signal_delivery_thread (void *data)
{
SCM h, t;
h = SCM_SIMPLE_VECTOR_REF (signal_handler_asyncs, sig);
t = SCM_SIMPLE_VECTOR_REF (signal_handler_threads, sig);
h = scm_c_vector_ref (signal_handler_asyncs, sig);
t = scm_c_vector_ref (signal_handler_threads, sig);
if (scm_is_true (h))
scm_system_async_mark_for_thread (h, t);
}
@ -289,7 +289,7 @@ is_signal_delivery_thread (scm_i_pthread_t thread)
static void
take_signal (int signum)
{
SCM cell = SCM_SIMPLE_VECTOR_REF (signal_handler_asyncs, signum);
SCM cell = scm_c_vector_ref (signal_handler_asyncs, signum);
scm_thread *t = SCM_I_CURRENT_THREAD;
if (scm_is_false (SCM_CDR (cell)))
@ -346,8 +346,8 @@ scm_i_signals_post_fork ()
for (int sig = 0; sig < NSIG; sig++)
{
if (scm_is_true (SCM_SIMPLE_VECTOR_REF (signal_handler_threads, sig))
|| scm_is_true (SCM_SIMPLE_VECTOR_REF (signal_handler_asyncs, sig)))
if (scm_is_true (scm_c_vector_ref (signal_handler_threads, sig))
|| scm_is_true (scm_c_vector_ref (signal_handler_asyncs, sig)))
{
active = 1;
break;
@ -454,7 +454,7 @@ SCM_DEFINE (scm_sigaction_for_thread, "sigaction", 1, 3, 0,
scm_dynwind_block_asyncs ();
scm_i_dynwind_pthread_mutex_lock (&signal_handler_lock);
old_handler = SCM_SIMPLE_VECTOR_REF (*signal_handlers, csig);
old_handler = scm_c_vector_ref (*signal_handlers, csig);
if (SCM_UNBNDP (handler))
query_only = 1;
else if (scm_is_integer (handler))

View file

@ -1121,7 +1121,7 @@ scm_to_sockaddr (SCM address, size_t *address_size)
SCM_VALIDATE_VECTOR (1, address);
*address_size = 0;
family = scm_to_short (SCM_SIMPLE_VECTOR_REF (address, 0));
family = scm_to_short (scm_c_vector_ref (address, 0));
switch (family)
{
@ -1142,9 +1142,9 @@ scm_to_sockaddr (SCM address, size_t *address_size)
#endif
c_inet.sin_addr.s_addr =
htonl (scm_to_ulong (SCM_SIMPLE_VECTOR_REF (address, 1)));
htonl (scm_to_ulong (scm_c_vector_ref (address, 1)));
c_inet.sin_port =
htons (scm_to_ushort (SCM_SIMPLE_VECTOR_REF (address, 2)));
htons (scm_to_ushort (scm_c_vector_ref (address, 2)));
c_inet.sin_family = AF_INET;
*address_size = sizeof (c_inet);
@ -1166,14 +1166,14 @@ scm_to_sockaddr (SCM address, size_t *address_size)
struct sockaddr_in6 c_inet6;
scm_to_ipv6 (c_inet6.sin6_addr.s6_addr,
SCM_SIMPLE_VECTOR_REF (address, 1));
scm_c_vector_ref (address, 1));
c_inet6.sin6_port =
htons (scm_to_ushort (SCM_SIMPLE_VECTOR_REF (address, 2)));
htons (scm_to_ushort (scm_c_vector_ref (address, 2)));
c_inet6.sin6_flowinfo =
scm_to_uint32 (SCM_SIMPLE_VECTOR_REF (address, 3));
scm_to_uint32 (scm_c_vector_ref (address, 3));
#ifdef HAVE_SIN6_SCOPE_ID
c_inet6.sin6_scope_id =
scm_to_ulong (SCM_SIMPLE_VECTOR_REF (address, 4));
scm_to_ulong (scm_c_vector_ref (address, 4));
#endif
c_inet6.sin6_family = AF_INET6;
@ -1198,7 +1198,7 @@ scm_to_sockaddr (SCM address, size_t *address_size)
SCM path;
size_t path_len = 0;
path = SCM_SIMPLE_VECTOR_REF (address, 1);
path = scm_c_vector_ref (address, 1);
if (!scm_is_string (path) && !scm_is_false (path))
scm_misc_error (FUNC_NAME, "invalid unix address "
"path: ~A", scm_list_1 (path));

View file

@ -510,23 +510,23 @@ bdtime2c (SCM sbd_time, struct tm *lt, int pos, const char *subr)
&& scm_c_vector_length (sbd_time) == 11,
sbd_time, pos, subr);
lt->tm_sec = scm_to_int (SCM_SIMPLE_VECTOR_REF (sbd_time, 0));
lt->tm_min = scm_to_int (SCM_SIMPLE_VECTOR_REF (sbd_time, 1));
lt->tm_hour = scm_to_int (SCM_SIMPLE_VECTOR_REF (sbd_time, 2));
lt->tm_mday = scm_to_int (SCM_SIMPLE_VECTOR_REF (sbd_time, 3));
lt->tm_mon = scm_to_int (SCM_SIMPLE_VECTOR_REF (sbd_time, 4));
lt->tm_year = scm_to_int (SCM_SIMPLE_VECTOR_REF (sbd_time, 5));
lt->tm_wday = scm_to_int (SCM_SIMPLE_VECTOR_REF (sbd_time, 6));
lt->tm_yday = scm_to_int (SCM_SIMPLE_VECTOR_REF (sbd_time, 7));
lt->tm_isdst = scm_to_int (SCM_SIMPLE_VECTOR_REF (sbd_time, 8));
lt->tm_sec = scm_to_int (scm_c_vector_ref (sbd_time, 0));
lt->tm_min = scm_to_int (scm_c_vector_ref (sbd_time, 1));
lt->tm_hour = scm_to_int (scm_c_vector_ref (sbd_time, 2));
lt->tm_mday = scm_to_int (scm_c_vector_ref (sbd_time, 3));
lt->tm_mon = scm_to_int (scm_c_vector_ref (sbd_time, 4));
lt->tm_year = scm_to_int (scm_c_vector_ref (sbd_time, 5));
lt->tm_wday = scm_to_int (scm_c_vector_ref (sbd_time, 6));
lt->tm_yday = scm_to_int (scm_c_vector_ref (sbd_time, 7));
lt->tm_isdst = scm_to_int (scm_c_vector_ref (sbd_time, 8));
#if HAVE_STRUCT_TM_TM_GMTOFF
lt->tm_gmtoff = - scm_to_int (SCM_SIMPLE_VECTOR_REF (sbd_time, 9));
lt->tm_gmtoff = - scm_to_int (scm_c_vector_ref (sbd_time, 9));
#endif
#ifdef HAVE_STRUCT_TM_TM_ZONE
if (scm_is_false (SCM_SIMPLE_VECTOR_REF (sbd_time, 10)))
if (scm_is_false (scm_c_vector_ref (sbd_time, 10)))
lt->tm_zone = NULL;
else
lt->tm_zone = scm_to_locale_string (SCM_SIMPLE_VECTOR_REF (sbd_time, 10));
lt->tm_zone = scm_to_locale_string (scm_c_vector_ref (sbd_time, 10));
#endif
}
@ -689,7 +689,7 @@ SCM_DEFINE (scm_strftime, "strftime", 2, 0, 0,
environment. interrupts and thread switching must be deferred
until TZ is restored. */
char **oldenv = NULL;
SCM zone_spec = SCM_SIMPLE_VECTOR_REF (stime, 10);
SCM zone_spec = scm_c_vector_ref (stime, 10);
int have_zone = 0;
if (scm_is_true (zone_spec) && scm_c_string_length (zone_spec) > 0)

View file

@ -63,19 +63,19 @@ scm_t_port_type *scm_string_port_type;
static SCM
stream_bytevector (SCM stream)
{
return SCM_SIMPLE_VECTOR_REF (stream, 0);
return scm_c_vector_ref (stream, 0);
}
static SCM
stream_pos (SCM stream)
{
return SCM_SIMPLE_VECTOR_REF (stream, 1);
return scm_c_vector_ref (stream, 1);
}
static SCM
stream_len (SCM stream)
{
return SCM_SIMPLE_VECTOR_REF (stream, 2);
return scm_c_vector_ref (stream, 2);
}
static SCM

View file

@ -183,7 +183,7 @@ scm_c_vector_ref (SCM v, size_t k)
if (k >= SCM_I_VECTOR_LENGTH (v))
scm_out_of_range (NULL, scm_from_size_t (k));
return SCM_SIMPLE_VECTOR_REF (v, k);
return SCM_I_VECTOR_ELTS (v)[k];
}
#undef FUNC_NAME