wingo pushed a commit to branch wip-whippet
in repository guile.

commit d73c675fa610947d562dc8f4b6ff0c828bd2537c
Author: Andy Wingo <wi...@pobox.com>
AuthorDate: Tue Jun 24 09:59:24 2025 +0200

    Switch all users of SCM_SIMPLE_VECTOR_LENGTH to scm_c_vector_length
    
    * libguile/arrays.c:
    * libguile/eval.c:
    * libguile/filesys.c:
    * libguile/hash.c:
    * libguile/hashtab.c:
    * libguile/memoize.c:
    * libguile/modules.c:
    * libguile/poll.c:
    * libguile/posix.c:
    * libguile/print.c:
    * libguile/socket.c:
    * libguile/stime.c: Use C function instead of macro.
---
 libguile/arrays.c  |  2 +-
 libguile/eval.c    |  2 +-
 libguile/filesys.c |  8 ++++----
 libguile/hash.c    |  2 +-
 libguile/hashtab.c | 28 ++++++++++++++--------------
 libguile/memoize.c |  2 +-
 libguile/modules.c |  2 +-
 libguile/poll.c    |  4 ++--
 libguile/posix.c   |  2 +-
 libguile/print.c   |  6 +++---
 libguile/socket.c  |  6 +++---
 libguile/stime.c   |  4 ++--
 12 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/libguile/arrays.c b/libguile/arrays.c
index 6eb692c4e..48d9aab46 100644
--- a/libguile/arrays.c
+++ b/libguile/arrays.c
@@ -836,7 +836,7 @@ SCM_DEFINE (scm_transpose_array, "transpose-array", 1, 0, 1,
 
   SCM vargs = scm_vector (args);
   struct scm_array *ra = scm_to_array (array);
-  if (SCM_SIMPLE_VECTOR_LENGTH (vargs) != scm_array_dimension_count (ra))
+  if (scm_c_vector_length (vargs) != scm_array_dimension_count (ra))
     SCM_WRONG_NUM_ARGS ();
   ndim = 0;
   for (k = 0; k < scm_array_dimension_count (ra); k++)
diff --git a/libguile/eval.c b/libguile/eval.c
index a93c5a41f..850a88d78 100644
--- a/libguile/eval.c
+++ b/libguile/eval.c
@@ -81,7 +81,7 @@
 
 #define VECTOR_REF(v, i) (SCM_SIMPLE_VECTOR_REF (v, i))
 #define VECTOR_SET(v, i, x) (SCM_SIMPLE_VECTOR_SET (v, i, x))
-#define VECTOR_LENGTH(v) (SCM_SIMPLE_VECTOR_LENGTH (v))
+#define VECTOR_LENGTH(v) (scm_c_vector_length (v))
 
 
 
diff --git a/libguile/filesys.c b/libguile/filesys.c
index ef5526cfb..f062fd25f 100644
--- a/libguile/filesys.c
+++ b/libguile/filesys.c
@@ -824,7 +824,7 @@ fill_select_type (fd_set *set, SCM *ports_ready, SCM 
list_or_vec, int pos)
 
   if (scm_is_vector (list_or_vec))
     {
-      int i = SCM_SIMPLE_VECTOR_LENGTH (list_or_vec);
+      int i = scm_c_vector_length (list_or_vec);
       
       while (--i >= 0)
        {
@@ -958,7 +958,7 @@ SCM_DEFINE (scm_select, "select", 3, 2, 0,
 
   if (scm_is_vector (reads))
     {
-      read_count = SCM_SIMPLE_VECTOR_LENGTH (reads);
+      read_count = scm_c_vector_length (reads);
     }
   else
     {
@@ -967,7 +967,7 @@ SCM_DEFINE (scm_select, "select", 3, 2, 0,
     }
   if (scm_is_vector (writes))
     {
-      write_count = SCM_SIMPLE_VECTOR_LENGTH (writes);
+      write_count = scm_c_vector_length (writes);
     }
   else
     {
@@ -976,7 +976,7 @@ SCM_DEFINE (scm_select, "select", 3, 2, 0,
     }
   if (scm_is_vector (excepts))
     {
-      except_count = SCM_SIMPLE_VECTOR_LENGTH (excepts);
+      except_count = scm_c_vector_length (excepts);
     }
   else
     {
diff --git a/libguile/hash.c b/libguile/hash.c
index 27260c285..7799c039d 100644
--- a/libguile/hash.c
+++ b/libguile/hash.c
@@ -319,7 +319,7 @@ scm_raw_ihash (SCM obj, size_t depth)
       return scm_raw_ihashq ((uintptr_t) SCM_POINTER_VALUE (obj));
     case scm_tc7_vector:
       {
-       size_t len = SCM_SIMPLE_VECTOR_LENGTH (obj);
+       size_t len = scm_c_vector_length (obj);
         size_t i = depth / 2;
         unsigned long h = scm_raw_ihashq (SCM_CELL_WORD_0 (obj));
         if (len)
diff --git a/libguile/hashtab.c b/libguile/hashtab.c
index e11c54de9..9f90fe93b 100644
--- a/libguile/hashtab.c
+++ b/libguile/hashtab.c
@@ -509,7 +509,7 @@ hashtable_lower (struct scm_t_hashtable *ht)
 static inline size_t
 hashtable_bucket_count (struct scm_t_hashtable *ht)
 {
-  return SCM_SIMPLE_VECTOR_LENGTH (hashtable_buckets (ht));
+  return scm_c_vector_length (hashtable_buckets (ht));
 }
 
 static inline SCM
@@ -697,10 +697,10 @@ scm_hash_fn_get_handle (SCM table, SCM obj,
   struct scm_t_hashtable *ht = scm_to_hashtable (table);
   buckets = hashtable_buckets (ht);
 
-  if (SCM_SIMPLE_VECTOR_LENGTH (buckets) == 0)
+  if (scm_c_vector_length (buckets) == 0)
     return SCM_BOOL_F;
-  k = hash_fn (obj, SCM_SIMPLE_VECTOR_LENGTH (buckets), closure);
-  if (k >= SCM_SIMPLE_VECTOR_LENGTH (buckets))
+  k = hash_fn (obj, scm_c_vector_length (buckets), closure);
+  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);
@@ -723,11 +723,11 @@ scm_hash_fn_create_handle_x (SCM table, SCM obj, SCM init,
   struct scm_t_hashtable *ht = scm_to_hashtable (table);
   buckets = hashtable_buckets (ht);
 
-  if (SCM_SIMPLE_VECTOR_LENGTH (buckets) == 0)
+  if (scm_c_vector_length (buckets) == 0)
     SCM_MISC_ERROR ("void hashtable", SCM_EOL);
 
-  k = hash_fn (obj, SCM_SIMPLE_VECTOR_LENGTH (buckets), closure);
-  if (k >= SCM_SIMPLE_VECTOR_LENGTH (buckets))
+  k = hash_fn (obj, scm_c_vector_length (buckets), closure);
+  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);
@@ -746,8 +746,8 @@ scm_hash_fn_create_handle_x (SCM table, SCM obj, SCM init,
       if (!scm_is_eq (hashtable_buckets (ht), buckets))
        {
          buckets = hashtable_buckets (ht);
-         k = hash_fn (obj, SCM_SIMPLE_VECTOR_LENGTH (buckets), closure);
-         if (k >= SCM_SIMPLE_VECTOR_LENGTH (buckets))
+         k = hash_fn (obj, scm_c_vector_length (buckets), closure);
+         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));
@@ -808,11 +808,11 @@ scm_hash_fn_remove_x (SCM table, SCM obj,
   struct scm_t_hashtable *ht = scm_to_hashtable (table);
   buckets = hashtable_buckets (ht);
 
-  if (SCM_SIMPLE_VECTOR_LENGTH (buckets) == 0)
+  if (scm_c_vector_length (buckets) == 0)
     return SCM_EOL;
 
-  k = hash_fn (obj, SCM_SIMPLE_VECTOR_LENGTH (buckets), closure);
-  if (k >= SCM_SIMPLE_VECTOR_LENGTH (buckets))
+  k = hash_fn (obj, scm_c_vector_length (buckets), closure);
+  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);
@@ -1551,7 +1551,7 @@ scm_internal_hash_fold (scm_t_hash_fold_fn fn, void 
*closure,
   struct scm_t_hashtable *ht = scm_to_hashtable (table);
   buckets = hashtable_buckets (ht);
   
-  n = SCM_SIMPLE_VECTOR_LENGTH (buckets);
+  n = scm_c_vector_length (buckets);
   for (i = 0; i < n; ++i)
     {
       SCM ls, handle;
@@ -1585,7 +1585,7 @@ scm_internal_hash_for_each_handle (scm_t_hash_handle_fn 
fn, void *closure,
   SCM_VALIDATE_HASHTABLE (0, table);
   struct scm_t_hashtable *ht = scm_to_hashtable (table);
   buckets = hashtable_buckets (ht);
-  n = SCM_SIMPLE_VECTOR_LENGTH (buckets);
+  n = scm_c_vector_length (buckets);
 
   for (i = 0; i < n; ++i)
     {
diff --git a/libguile/memoize.c b/libguile/memoize.c
index 8c4043355..d10d7a6ed 100644
--- a/libguile/memoize.c
+++ b/libguile/memoize.c
@@ -65,7 +65,7 @@
 
 #define VECTOR_REF(v, i) (SCM_SIMPLE_VECTOR_REF (v, i))
 #define VECTOR_SET(v, i, x) (SCM_SIMPLE_VECTOR_SET (v, i, x))
-#define VECTOR_LENGTH(v) (SCM_SIMPLE_VECTOR_LENGTH (v))
+#define VECTOR_LENGTH(v) (scm_c_vector_length (v))
 
 SCM_SYMBOL (sym_case_lambda_star, "case-lambda*");
 
diff --git a/libguile/modules.c b/libguile/modules.c
index f9c827b67..12d4664e8 100644
--- a/libguile/modules.c
+++ b/libguile/modules.c
@@ -847,7 +847,7 @@ SCM_DEFINE (scm_module_reverse_lookup, 
"module-reverse-lookup", 2, 0, 0,
 
   struct scm_t_hashtable *ht = scm_to_hashtable (obarray);
   SCM buckets = ht->buckets;
-  n = SCM_SIMPLE_VECTOR_LENGTH (buckets);
+  n = scm_c_vector_length (buckets);
   for (i = 0; i < n; ++i)
     {
       for (SCM ls = SCM_SIMPLE_VECTOR_REF (buckets, i);
diff --git a/libguile/poll.c b/libguile/poll.c
index 82281fff0..dafb3c1d9 100644
--- a/libguile/poll.c
+++ b/libguile/poll.c
@@ -1,4 +1,4 @@
-/* Copyright 2010,2013,2018
+/* Copyright 2010,2013,2018,2025
      Free Software Foundation, Inc.
 
    This file is part of Guile.
@@ -99,7 +99,7 @@ scm_primitive_poll (SCM pollfds, SCM nfds, SCM ports, SCM 
timeout)
     SCM_OUT_OF_RANGE (SCM_ARG2, nfds);
   
   SCM_VALIDATE_VECTOR (SCM_ARG3, ports);
-  if (SCM_UNLIKELY (SCM_SIMPLE_VECTOR_LENGTH (ports) < c_nfds))
+  if (SCM_UNLIKELY (scm_c_vector_length (ports) < c_nfds))
     SCM_OUT_OF_RANGE (SCM_ARG3, ports);
     
   fds = (struct pollfd*)SCM_BYTEVECTOR_CONTENTS (pollfds);
diff --git a/libguile/posix.c b/libguile/posix.c
index fe349f4f4..682ff532c 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -345,7 +345,7 @@ SCM_DEFINE (scm_setgroups, "setgroups", 1, 0, 0,
 
   SCM_VALIDATE_VECTOR (SCM_ARG1, group_vec);
 
-  ngroups = SCM_SIMPLE_VECTOR_LENGTH (group_vec);
+  ngroups = scm_c_vector_length (group_vec);
 
   /* validate before allocating, so we don't have to worry about leaks */
   for (i = 0; i < ngroups; i++)
diff --git a/libguile/print.c b/libguile/print.c
index 3dc63a176..45692644f 100644
--- a/libguile/print.c
+++ b/libguile/print.c
@@ -212,7 +212,7 @@ push_print_state (SCM port, struct scm_print_state *state,
   state->prev = prev;
   state->port = port;
   state->ref_vect = scm_c_make_vector (PSTATE_SIZE, SCM_UNDEFINED);
-  state->ceiling = SCM_SIMPLE_VECTOR_LENGTH (state->ref_vect);
+  state->ceiling = scm_c_vector_length (state->ref_vect);
   scm_i_pthread_setspecific (print_state_key, state);
 }
 
@@ -237,7 +237,7 @@ static void
 grow_ref_stack (scm_print_state *pstate)
 {
   SCM old_vect = pstate->ref_vect;
-  size_t old_size = SCM_SIMPLE_VECTOR_LENGTH (old_vect);
+  size_t old_size = scm_c_vector_length (old_vect);
   size_t new_size = 2 * pstate->ceiling;
   SCM new_vect = scm_c_make_vector (new_size, SCM_UNDEFINED);
   unsigned long int i;
@@ -806,7 +806,7 @@ iprin1 (SCM exp, SCM port, scm_print_state *pstate)
        case scm_tc7_vector:
          ENTER_NESTED_DATA (pstate, exp, circref);
          scm_puts ("#(", port);
-          print_vector (exp, SCM_SIMPLE_VECTOR_LENGTH (exp), scm_c_vector_ref,
+          print_vector (exp, scm_c_vector_length (exp), scm_c_vector_ref,
                         port, pstate);
          EXIT_NESTED_DATA (pstate);
          break;
diff --git a/libguile/socket.c b/libguile/socket.c
index 1e6b42970..31c36f055 100644
--- a/libguile/socket.c
+++ b/libguile/socket.c
@@ -1127,7 +1127,7 @@ scm_to_sockaddr (SCM address, size_t *address_size)
     {
     case AF_INET:
       {
-       if (SCM_SIMPLE_VECTOR_LENGTH (address) != 3)
+       if (scm_c_vector_length (address) != 3)
          scm_misc_error (FUNC_NAME,
                          "invalid inet address representation: ~A",
                          scm_list_1 (address));
@@ -1158,7 +1158,7 @@ scm_to_sockaddr (SCM address, size_t *address_size)
 #ifdef HAVE_IPV6
     case AF_INET6:
       {
-       if (SCM_SIMPLE_VECTOR_LENGTH (address) != 5)
+       if (scm_c_vector_length (address) != 5)
          scm_misc_error (FUNC_NAME, "invalid inet6 address representation: ~A",
                          scm_list_1 (address));
        else
@@ -1190,7 +1190,7 @@ scm_to_sockaddr (SCM address, size_t *address_size)
 #ifdef HAVE_UNIX_DOMAIN_SOCKETS
     case AF_UNIX:
       {
-       if (SCM_SIMPLE_VECTOR_LENGTH (address) != 2)
+       if (scm_c_vector_length (address) != 2)
          scm_misc_error (FUNC_NAME, "invalid unix address representation: ~A",
                          scm_list_1 (address));
        else
diff --git a/libguile/stime.c b/libguile/stime.c
index 18af71350..8061204d9 100644
--- a/libguile/stime.c
+++ b/libguile/stime.c
@@ -1,4 +1,4 @@
-/* Copyright 1995-2001,2003-2009,2011,2013-2014,2016-2020
+/* Copyright 1995-2001,2003-2009,2011,2013-2014,2016-2020,2025
      Free Software Foundation, Inc.
 
    This file is part of Guile.
@@ -507,7 +507,7 @@ static void
 bdtime2c (SCM sbd_time, struct tm *lt, int pos, const char *subr)
 {
   SCM_ASSERT (scm_is_vector (sbd_time)
-             && SCM_SIMPLE_VECTOR_LENGTH (sbd_time) == 11,
+             && scm_c_vector_length (sbd_time) == 11,
              sbd_time, pos, subr);
 
   lt->tm_sec = scm_to_int (SCM_SIMPLE_VECTOR_REF (sbd_time, 0));

Reply via email to