/* libsizzle/uvector.c - uniform vector functions
 
  Copyright (C) 2000 Martin Grabmueller <mgrabmue@cs.tu-berlin.de>
 
  This is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2, or (at your option)
  any later version.
  
  This software 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 General Public License for more details.
  
  You should have received a copy of the GNU General Public License
  along with this package; see the file COPYING.  If not, write to
  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  Boston, MA 02111-1307, USA.  */

#if HAVE_CONFIG_H
# include <config.h>
#endif 

#if ENABLE_UVECTOR

#include <stdio.h>

#if ENABLE_NLS
# include <libintl.h>
# define _(String) gettext(String)
#else
# define _(String) (String)
#endif

#include "alloc.h"
#include "node.h"
#include "eval.h"
#include "validate.h"
#include "capi.h"
#include "port.h"
#include "list.h"
#include "uvector.h"
#include "uvector64.h"

/* This holds the tag used for vector objects.  */
zzz_object_t zzz_tagged_type_s8vector;
zzz_object_t zzz_tagged_type_u8vector;
zzz_object_t zzz_tagged_type_s16vector;
zzz_object_t zzz_tagged_type_u16vector;
zzz_object_t zzz_tagged_type_s32vector;
zzz_object_t zzz_tagged_type_u32vector;
zzz_object_t zzz_tagged_type_f32vector;
zzz_object_t zzz_tagged_type_f64vector;

/*:doc
  s8vector?
  (s8vector? obj) => boolean
  Return @code{#t}, if @var{obj} is a homogenous signed 8-bit vector, 
  @code{#f} otherwise.
  doc:*/
#define FUNC_NAME "s8vector?"
static result_t
s8vector_p_func (zzz_scm_t env, zzz_scm_t obj, zzz_scm_t * result)
{
  if (s8vector_p (obj))
    *result = zzz_true_value;
  else
    *result = zzz_false_value;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  make-s8vector
  (make-s8vector len [fill]) => vector
  Create a homogenous signed 8-bit vector capable of holding @var{len}
  elements and initializes the vector fields to @var{fill}.  If @var{fill} is
  omitted, the contents of the vector is undefined.
  doc:*/
#define FUNC_NAME "make-s8vector"
static result_t
make_s8vector_func (zzz_scm_t env, zzz_scm_t k, zzz_scm_t fill,
		    zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  int len;
  signed char f;

  CHECK_TYPE (1, integer_p (k), zzz_integer_type_name);
  CHECK_RANGE (1, integer_val (k) >= 0, 
	       _("value greater than or equal to zero"));
  if (fill == zzz_undefined)
    f = 0;
  else
    {
      CHECK_TYPE (2, integer_p (fill), zzz_integer_type_name);
      f = (signed char) integer_val (fill);
      CHECK_RANGE (2, f == integer_val (fill), _("signed 8-bit value"));
    }
  len = integer_val (k);
  *result = zzz_make_s8vector (len);
  while (--len >= 0)
    s8vector_val (*result)[len] = f;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  s8vector
  (s8vector num ...) => vector
  Create a homogenous signed 8-bit vector holding all the signed 8-bit
  values @var{num}s passed as arguments.
  doc:*/
#define FUNC_NAME "s8vector"
static result_t
s8vector_func (zzz_scm_t env, zzz_scm_t param, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  zzz_scm_t temp;
  zzz_scm_t res = NULL;
  int len;
  signed char f;

  /* Param is guaranteed to be a proper list when we get here.  */
  len = zzz_list_length (param);
  res = zzz_make_s8vector (len);
  len = 0;
  temp = param;
  while (cons_p (temp))
    {
      CHECK_TYPE (len + 1, integer_p (car (temp)), zzz_integer_type_name);
      f = (signed char) integer_val (car (temp));
      CHECK_RANGE (len + 1, f == integer_val (car (temp)),
		   _("signed 8-bit value"));
      s8vector_val (res)[len] = f;
      temp = cdr (temp);
      len++;
    }
  *result = res;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  s8vector-length
  (s8vector-length vec) => integer
  Return the number of elements the homogenous signed 8-bit vector @var{vec}
  can hold.
  doc:*/
#define FUNC_NAME "s8vector-length"
static result_t
s8vector_length_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;

  CHECK_TYPE (1, s8vector_p (vec), zzz_s8vector_type_name);
  *result = zzz_make_integer (s8vector_len (vec));
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  s8vector-ref
  (s8vector-ref vec n) => object
  Return the signed 8-bit value stored at index @var{n} in the vector
  homogenous signed 8-bit @var{vec}.  The index @var{n} is zero-based.
  doc:*/
#define FUNC_NAME "s8vector-ref"
static result_t
s8vector_ref_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t k,
  zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  unsigned long index;

  CHECK_TYPE (1, s8vector_p (vec), zzz_s8vector_type_name);
  CHECK_TYPE (2, integer_p (k), zzz_integer_type_name);
  index = integer_val (k);
  CHECK_RANGE (2, index < s8vector_len (vec), _("valid vector index"));
  *result = zzz_make_integer (s8vector_val (vec)[index]);
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  s8vector-set!
  (s8vector-set! vec n num) => *undefined*
  Store the signed 8-bit value at index @var{n} into the signed 8-bit vector
  @var{vec}.  The index @var{n} is zero-based.
  doc:*/
#define FUNC_NAME "s8vector-set!"
static result_t
s8vector_set_x_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t k, zzz_scm_t obj,
		     zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  unsigned long index;
  signed char f;

  CHECK_TYPE (1, s8vector_p (vec), zzz_s8vector_type_name);
  CHECK_TYPE (1, !ro_s8vector_p (vec), _("mutable vector"));
  CHECK_TYPE (2, integer_p (k), zzz_integer_type_name);
  CHECK_TYPE (3, integer_p (obj), zzz_integer_type_name);
  f = (signed char) integer_val (obj);
  CHECK_RANGE (3, f == integer_val (obj), _("signed 8-bit value"));
  index = integer_val (k);
  CHECK_RANGE (2, index < s8vector_len (vec), _("valid vector index"));
  s8vector_val (vec)[index] = f;
  *result = zzz_unspecified;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  s8vector->list
  (s8vector->list vec) => list
  Return a list containing the elements of the signed 8-bit vector @var{vec}.
  doc:*/
#define FUNC_NAME "s8vector->list"
static result_t
s8vector_to_list_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  zzz_scm_t res;
  unsigned len;

  CHECK_TYPE (1, s8vector_p (vec), zzz_s8vector_type_name);
  len = s8vector_len (vec);
  res = NULL;
  while (len-- > 0)
    res = zzz_cons (zzz_make_integer (s8vector_val (vec)[len]), res);
  *result = res;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  list->s8vector
  (list->s8vector list) => vector
  Return a signed 8-bit vector containing the elements of the list @var{list}.
  doc:*/
#define FUNC_NAME "list->s8vector"
static result_t
list_to_s8vector_func (zzz_scm_t env, zzz_scm_t list, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  zzz_scm_t vec = NULL;
  int len = 0;
  signed char f;

  CHECK_TYPE (1, zzz_list_length (list) >= 0, zzz_proper_list_type_name);
  /* Param is guaranteed to be a proper list when we get here.  */
  len = zzz_list_length (list);
  vec = zzz_make_s8vector (len);
  len = 0;
  while (cons_p (list))
    {
      CHECK_TYPE (len + 1, integer_p (car (list)), zzz_integer_type_name);
      f = (signed char) integer_val (car (list));
      CHECK_RANGE (len + 1, f == integer_val (car (list)),
		   _("signed 8-bit value"));
      s8vector_val (vec)[len] = f;
      len++;
      list = cdr (list);
    }
  *result = vec;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  s8vector-fill!
  (s8vector-fill! vec num) => *undefined*
  Store signed 8-bit value @var{num} in all elements of the signed 8-bit
  vector @var{vec}, overwriting the old contents of @var{vec}.
  doc:*/
#define FUNC_NAME "s8vector-fill!"
static result_t
s8vector_fill_x_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t fill,
		    zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  unsigned len;
  signed char f;

  CHECK_TYPE (1, s8vector_p (vec), zzz_s8vector_type_name);
  CHECK_TYPE (1, !ro_s8vector_p (vec), _("mutable vector"));
  CHECK_TYPE (2, integer_p (fill), zzz_integer_type_name);
  f = (signed char) integer_val (fill);
  CHECK_RANGE (2, f == integer_val (fill), _("signed 8-bit value"));
  len = s8vector_len (vec);
  while (len-- > 0)
    s8vector_val (vec)[len] = f;
  *result = zzz_unspecified;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/* Constructor function for vector objects.  Expects the desired
   vector len as a long value in @var{data0}.  Returns @var{tagged}.  */
static void *
s8vector_constructor (zzz_tagged_t tagged, void * data0,
		    void * data1, void * data2)
{
  unsigned long len = (long) data0;
  signed char * vec;
  unsigned long x;

  vec = zzz_malloc (sizeof (signed char) * len);
  for (x = 0; x < len; x++)
    vec[x] = 0;
  tagged->fill[1] = (zzz_object_t) vec;
  tagged->fill[2] = (zzz_object_t) len;
  return tagged;
}

static void
s8vector_print (zzz_scm_t port, zzz_tagged_t tagged, zzz_print_state_t state)
{
  zzz_scm_t result;
  signed char * vec = s8vector_val (tagged);
  unsigned long len = s8vector_len (tagged);
  unsigned long x;
  char buf[64];
  int l;

  zzz_port_puts (port, "#s8(", 4, &result);
  for (x = 0; x < len; x++)
    {
      l = sprintf (buf, "%d", vec[x]);
      zzz_port_puts (port, buf, l, &result);
      if (x < len - 1)
	zzz_port_putc (' ', port, &result);
    }
  zzz_port_putc (')', port, &result);
}

static void
s8vector_free (zzz_tagged_t tagged)
{
  zzz_free (s8vector_val (tagged),
	    sizeof (signed char) * s8vector_len (tagged));
}

static int
s8vector_equal (zzz_tagged_t tagged0, zzz_tagged_t tagged1)
{
  signed char * vec1 = s8vector_val (tagged0);
  unsigned long len1 = s8vector_len (tagged0);
  signed char * vec2 = s8vector_val (tagged1);
  unsigned long len2 = s8vector_len (tagged1);
  unsigned long x;

  if (len1 != len2)
    return 0;
  for (x = 0; x < len1; x++)
    {
      if (vec1[x] != vec2[x])
	return 0;
    }
  return 1;
}

/*:doc
  u8vector?
  (u8vector? obj) => boolean
  Return @code{#t}, if @var{obj} is a homogenous unsigned 8-bit vector, 
  @code{#f} otherwise.
  doc:*/
#define FUNC_NAME "u8vector?"
static result_t
u8vector_p_func (zzz_scm_t env, zzz_scm_t obj, zzz_scm_t * result)
{
  if (u8vector_p (obj))
    *result = zzz_true_value;
  else
    *result = zzz_false_value;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  make-u8vector
  (make-u8vector len [fill]) => vector
  Create a homogenous unsigned 8-bit vector capable of holding @var{len}
  elements and initializes the vector fields to @var{fill}.  If @var{fill} is
  omitted, the contents of the vector is undefined.
  doc:*/
#define FUNC_NAME "make-u8vector"
static result_t
make_u8vector_func (zzz_scm_t env, zzz_scm_t k, zzz_scm_t fill,
		    zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  int len;
  unsigned char f;

  CHECK_TYPE (1, integer_p (k), zzz_integer_type_name);
  CHECK_RANGE (1, integer_val (k) >= 0, 
	       _("value greater than or equal to zero"));
  if (fill == zzz_undefined)
    f = 0;
  else
    {
      CHECK_TYPE (2, integer_p (fill), zzz_integer_type_name);
      f = (unsigned char) integer_val (fill);
      CHECK_RANGE (2, f == integer_val (fill), _("unsigned 8-bit value"));
    }
  len = integer_val (k);
  *result = zzz_make_u8vector (len);
  while (--len >= 0)
    u8vector_val (*result)[len] = f;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  u8vector
  (u8vector num ...) => vector
  Create a homogenous unsigned 8-bit vector holding all the unsigned 8-bit
  values @var{num}s passed as arguments.
  doc:*/
#define FUNC_NAME "u8vector"
static result_t
u8vector_func (zzz_scm_t env, zzz_scm_t param, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  zzz_scm_t temp;
  zzz_scm_t res = NULL;
  unsigned char f;
  int len;

  /* Param is guaranteed to be a proper list when we get here.  */
  len = zzz_list_length (param);
  res = zzz_make_u8vector (len);
  len = 0;
  temp = param;
  while (cons_p (temp))
    {
      CHECK_TYPE (len + 1, integer_p (car (temp)), zzz_integer_type_name);
      f = (unsigned char) integer_val (car (temp));
      CHECK_RANGE (len + 1, f == integer_val (car (temp)),
		   _("unsigned 8-bit value"));
      u8vector_val (res)[len] = f;
      temp = cdr (temp);
      len++;
    }
  *result = res;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  u8vector-length
  (u8vector-length vec) => integer
  Return the number of elements the homogenous unsigned 8-bit vector @var{vec}
  can hold.
  doc:*/
#define FUNC_NAME "u8vector-length"
static result_t
u8vector_length_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;

  CHECK_TYPE (1, u8vector_p (vec), zzz_u8vector_type_name);
  *result = zzz_make_integer (u8vector_len (vec));
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  u8vector-ref
  (u8vector-ref vec n) => object
  Return the unsigned 8-bit value stored at index @var{n} in the vector
  homogenous unsigned 8-bit @var{vec}.  The index @var{n} is zero-based.
  doc:*/
#define FUNC_NAME "u8vector-ref"
static result_t
u8vector_ref_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t k,
  zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  unsigned long index;

  CHECK_TYPE (1, u8vector_p (vec), zzz_u8vector_type_name);
  CHECK_TYPE (2, integer_p (k), zzz_integer_type_name);
  index = integer_val (k);
  CHECK_RANGE (2, index < u8vector_len (vec), _("valid vector index"));
  *result = zzz_make_integer (u8vector_val (vec)[index]);
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  u8vector-set!
  (u8vector-set! vec n num) => *undefined*
  Store the unsigned 8-bit value at index @var{n} into the unsigned 8-bit
  vector @var{vec}.  The index @var{n} is zero-based.
  doc:*/
#define FUNC_NAME "u8vector-set!"
static result_t
u8vector_set_x_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t k, zzz_scm_t obj,
		     zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  unsigned char f;
  unsigned long index;

  CHECK_TYPE (1, u8vector_p (vec), zzz_u8vector_type_name);
  CHECK_TYPE (1, !ro_u8vector_p (vec), _("mutable vector"));
  CHECK_TYPE (2, integer_p (k), zzz_integer_type_name);
  CHECK_TYPE (3, integer_p (obj), zzz_integer_type_name);
  f = (unsigned char) integer_val (obj);
  CHECK_RANGE (3, f == integer_val (obj), _("unsigned 8-bit value"));
  index = integer_val (k);
  CHECK_RANGE (2, index < u8vector_len (vec), _("valid vector index"));
  u8vector_val (vec)[index] = f;
  *result = zzz_unspecified;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  u8vector->list
  (u8vector->list vec) => list
  Return a list containing the elements of the unsigned 8-bit vector @var{vec}.
  doc:*/
#define FUNC_NAME "u8vector->list"
static result_t
u8vector_to_list_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  zzz_scm_t res;
  unsigned len;

  CHECK_TYPE (1, u8vector_p (vec), zzz_u8vector_type_name);
  len = u8vector_len (vec);
  res = NULL;
  while (len-- > 0)
    res = zzz_cons (zzz_make_integer (u8vector_val (vec)[len]), res);
  *result = res;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  list->u8vector
  (list->u8vector list) => vector
  Return a unsigned 8-bit vector containing the elements of the list 
  @var{list}.
  doc:*/
#define FUNC_NAME "list->u8vector"
static result_t
list_to_u8vector_func (zzz_scm_t env, zzz_scm_t list, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  zzz_scm_t vec = NULL;
  unsigned char f;
  int len = 0;

  CHECK_TYPE (1, zzz_list_length (list) >= 0, zzz_proper_list_type_name);
  /* Param is guaranteed to be a proper list when we get here.  */
  len = zzz_list_length (list);
  vec = zzz_make_u8vector (len);
  len = 0;
  while (cons_p (list))
    {
      CHECK_TYPE (len + 1, integer_p (car (list)), zzz_integer_type_name);
      f = (unsigned char) integer_val (car (list));
      CHECK_RANGE (len + 1, f == integer_val (car (list)),
		   _("unsigned 8-bit value"));
      u8vector_val (vec)[len] = f;
      len++;
      list = cdr (list);
    }
  *result = vec;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  u8vector-fill!
  (u8vector-fill! vec num) => *undefined*
  Store unsigned 8-bit value @var{num} in all elements of the unsigned 8-bit
  vector @var{vec}, overwriting the old contents of @var{vec}.
  doc:*/
#define FUNC_NAME "u8vector-fill!"
static result_t
u8vector_fill_x_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t fill,
		    zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  unsigned len;
  unsigned char f;

  CHECK_TYPE (1, u8vector_p (vec), zzz_u8vector_type_name);
  CHECK_TYPE (1, !ro_u8vector_p (vec), _("mutable vector"));
  CHECK_TYPE (2, integer_p (fill), zzz_integer_type_name);
  f = (unsigned char) integer_val (fill);
  CHECK_RANGE (2, f == integer_val (fill), _("unsigned 8-bit value"));
  len = u8vector_len (vec);
  while (len-- > 0)
    u8vector_val (vec)[len] = f;
  *result = zzz_unspecified;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/* Constructor function for vector objects.  Expects the desired
   vector len as a long value in @var{data0}.  Returns @var{tagged}.  */
static void *
u8vector_constructor (zzz_tagged_t tagged, void * data0,
		    void * data1, void * data2)
{
  unsigned long len = (long) data0;
  unsigned char * vec;
  unsigned long x;

  vec = zzz_malloc (sizeof (unsigned char) * len);
  for (x = 0; x < len; x++)
    vec[x] = 0;
  tagged->fill[1] = (zzz_object_t) vec;
  tagged->fill[2] = (zzz_object_t) len;
  return tagged;
}

static void
u8vector_print (zzz_scm_t port, zzz_tagged_t tagged, zzz_print_state_t state)
{
  zzz_scm_t result;
  unsigned char * vec = u8vector_val (tagged);
  unsigned long len = u8vector_len (tagged);
  unsigned long x;
  char buf[64];
  int l;

  zzz_port_puts (port, "#u8(", 4, &result);
  for (x = 0; x < len; x++)
    {
      l = sprintf (buf, "%d", vec[x]);
      zzz_port_puts (port, buf, l, &result);
      if (x < len - 1)
	zzz_port_putc (' ', port, &result);
    }
  zzz_port_putc (')', port, &result);
}

static void
u8vector_free (zzz_tagged_t tagged)
{
  zzz_free (u8vector_val (tagged),
	    sizeof (unsigned char) * u8vector_len (tagged));
}

static int
u8vector_equal (zzz_tagged_t tagged0, zzz_tagged_t tagged1)
{
  unsigned char * vec1 = u8vector_val (tagged0);
  unsigned long len1 = u8vector_len (tagged0);
  unsigned char * vec2 = u8vector_val (tagged1);
  unsigned long len2 = u8vector_len (tagged1);
  unsigned long x;

  if (len1 != len2)
    return 0;
  for (x = 0; x < len1; x++)
    {
      if (vec1[x] != vec2[x])
	return 0;
    }
  return 1;
}

/*:doc
  s16vector?
  (s16vector? obj) => boolean
  Return @code{#t}, if @var{obj} is a homogenous signed 16-bit vector, 
  @code{#f} otherwise.
  doc:*/
#define FUNC_NAME "s16vector?"
static result_t
s16vector_p_func (zzz_scm_t env, zzz_scm_t obj, zzz_scm_t * result)
{
  if (s16vector_p (obj))
    *result = zzz_true_value;
  else
    *result = zzz_false_value;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  make-s16vector
  (make-s16vector len [fill]) => vector
  Create a homogenous signed 16-bit vector capable of holding @var{len}
  elements and initializes the vector fields to @var{fill}.  If @var{fill} is
  omitted, the contents of the vector is undefined.
  doc:*/
#define FUNC_NAME "make-s16vector"
static result_t
make_s16vector_func (zzz_scm_t env, zzz_scm_t k, zzz_scm_t fill,
		    zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  int len;
  signed short f;

  CHECK_TYPE (1, integer_p (k), zzz_integer_type_name);
  CHECK_RANGE (1, integer_val (k) >= 0, 
	       _("value greater than or equal to zero"));
  if (fill == zzz_undefined)
    f = 0;
  else
    {
      CHECK_TYPE (2, integer_p (fill), zzz_integer_type_name);
      f = (signed short) integer_val (fill);
      CHECK_RANGE (2, f == integer_val (fill), _("signed 16-bit value"));
    }
  len = integer_val (k);
  *result = zzz_make_s16vector (len);
  while (--len >= 0)
    s16vector_val (*result)[len] = f;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  s16vector
  (s16vector num ...) => vector
  Create a homogenous signed 16-bit vector holding all the signed 16-bit
  values @var{num}s passed as arguments.
  doc:*/
#define FUNC_NAME "s16vector"
static result_t
s16vector_func (zzz_scm_t env, zzz_scm_t param, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  zzz_scm_t temp;
  zzz_scm_t res = NULL;
  signed short f;
  int len;

  /* Param is guaranteed to be a proper list when we get here.  */
  len = zzz_list_length (param);
  res = zzz_make_s16vector (len);
  len = 0;
  temp = param;
  while (cons_p (temp))
    {
      CHECK_TYPE (len + 1, integer_p (car (temp)), zzz_integer_type_name);
      f = (signed short) integer_val (car (temp));
      CHECK_RANGE (len + 1, f == integer_val (car (temp)),
		   _("signed 16-bit value"));
      s16vector_val (res)[len] = f;
      temp = cdr (temp);
      len++;
    }
  *result = res;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  s16vector-length
  (s16vector-length vec) => integer
  Return the number of elements the homogenous signed 16-bit vector @var{vec}
  can hold.
  doc:*/
#define FUNC_NAME "s16vector-length"
static result_t
s16vector_length_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;

  CHECK_TYPE (1, s16vector_p (vec), zzz_s16vector_type_name);
  *result = zzz_make_integer (s16vector_len (vec));
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  s16vector-ref
  (s16vector-ref vec n) => object
  Return the signed 16-bit value stored at index @var{n} in the vector
  homogenous signed 16-bit @var{vec}.  The index @var{n} is zero-based.
  doc:*/
#define FUNC_NAME "s16vector-ref"
static result_t
s16vector_ref_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t k,
  zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  unsigned long index;

  CHECK_TYPE (1, s16vector_p (vec), zzz_s16vector_type_name);
  CHECK_TYPE (2, integer_p (k), zzz_integer_type_name);
  index = integer_val (k);
  CHECK_RANGE (2, index < s16vector_len (vec), _("valid vector index"));
  *result = zzz_make_integer (s16vector_val (vec)[index]);
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  s16vector-set!
  (s16vector-set! vec n num) => *undefined*
  Store the signed 16-bit value at index @var{n} into the signed 16-bit vector
  @var{vec}.  The index @var{n} is zero-based.
  doc:*/
#define FUNC_NAME "s16vector-set!"
static result_t
s16vector_set_x_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t k, zzz_scm_t obj,
		     zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  unsigned long index;
  signed short f;

  CHECK_TYPE (1, s16vector_p (vec), zzz_s16vector_type_name);
  CHECK_TYPE (1, !ro_s16vector_p (vec), _("mutable vector"));
  CHECK_TYPE (2, integer_p (k), zzz_integer_type_name);
  CHECK_TYPE (3, integer_p (obj), zzz_integer_type_name);
  f = (signed short) integer_val (obj);
  CHECK_RANGE (3, f == integer_val (obj), _("signed 16-bit value"));
  index = integer_val (k);
  CHECK_RANGE (2, index < s16vector_len (vec), _("valid vector index"));
  s16vector_val (vec)[index] = f;
  *result = zzz_unspecified;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  s16vector->list
  (s16vector->list vec) => list
  Return a list containing the elements of the signed 16-bit vector @var{vec}.
  doc:*/
#define FUNC_NAME "s16vector->list"
static result_t
s16vector_to_list_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  zzz_scm_t res;
  unsigned len;

  CHECK_TYPE (1, s16vector_p (vec), zzz_s16vector_type_name);
  len = s16vector_len (vec);
  res = NULL;
  while (len-- > 0)
    res = zzz_cons (zzz_make_integer (s16vector_val (vec)[len]), res);
  *result = res;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  list->s16vector
  (list->s16vector list) => vector
  Return a signed 16-bit vector containing the elements of the list @var{list}.
  doc:*/
#define FUNC_NAME "list->s16vector"
static result_t
list_to_s16vector_func (zzz_scm_t env, zzz_scm_t list, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  zzz_scm_t vec = NULL;
  int len = 0;
  signed short f;

  CHECK_TYPE (1, zzz_list_length (list) >= 0, zzz_proper_list_type_name);
  /* Param is guaranteed to be a proper list when we get here.  */
  len = zzz_list_length (list);
  vec = zzz_make_s16vector (len);
  len = 0;
  while (cons_p (list))
    {
      CHECK_TYPE (len + 1, integer_p (car (list)), zzz_integer_type_name);
      f = (signed short) integer_val (car (list));
      CHECK_RANGE (len + 1, f == integer_val (car (list)),
		   _("signed 16-bit value"));
      s16vector_val (vec)[len] = f;
      len++;
      list = cdr (list);
    }
  *result = vec;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  s16vector-fill!
  (s16vector-fill! vec num) => *undefined*
  Store signed 16-bit value @var{num} in all elements of the signed 16-bit
  vector @var{vec}, overwriting the old contents of @var{vec}.
  doc:*/
#define FUNC_NAME "s16vector-fill!"
static result_t
s16vector_fill_x_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t fill,
		    zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  unsigned len;
  signed short f;

  CHECK_TYPE (1, s16vector_p (vec), zzz_s16vector_type_name);
  CHECK_TYPE (1, !ro_s16vector_p (vec), _("mutable vector"));
  CHECK_TYPE (2, integer_p (fill), zzz_integer_type_name);
  f = (signed short) integer_val (fill);
  CHECK_RANGE (2, f == integer_val (fill), _("signed 16-bit value"));
  len = s16vector_len (vec);
  while (len-- > 0)
    s16vector_val (vec)[len] = f;
  *result = zzz_unspecified;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/* Constructor function for vector objects.  Expects the desired
   vector len as a long value in @var{data0}.  Returns @var{tagged}.  */
static void *
s16vector_constructor (zzz_tagged_t tagged, void * data0,
		    void * data1, void * data2)
{
  unsigned long len = (long) data0;
  signed short * vec;
  unsigned long x;

  vec = zzz_malloc (sizeof (signed short) * len);
  for (x = 0; x < len; x++)
    vec[x] = 0;
  tagged->fill[1] = (zzz_object_t) vec;
  tagged->fill[2] = (zzz_object_t) len;
  return tagged;
}

static void
s16vector_print (zzz_scm_t port, zzz_tagged_t tagged, zzz_print_state_t state)
{
  zzz_scm_t result;
  signed short * vec = s16vector_val (tagged);
  unsigned long len = s16vector_len (tagged);
  unsigned long x;
  char buf[64];
  int l;

  zzz_port_puts (port, "#s16(", 5, &result);
  for (x = 0; x < len; x++)
    {
      l = sprintf (buf, "%d", vec[x]);
      zzz_port_puts (port, buf, l, &result);
      if (x < len - 1)
	zzz_port_putc (' ', port, &result);
    }
  zzz_port_putc (')', port, &result);
}

static void
s16vector_free (zzz_tagged_t tagged)
{
  zzz_free (s16vector_val (tagged),
	    sizeof (signed short) * s16vector_len (tagged));
}

static int
s16vector_equal (zzz_tagged_t tagged0, zzz_tagged_t tagged1)
{
  signed short * vec1 = s16vector_val (tagged0);
  unsigned long len1 = s16vector_len (tagged0);
  signed short * vec2 = s16vector_val (tagged1);
  unsigned long len2 = s16vector_len (tagged1);
  unsigned long x;

  if (len1 != len2)
    return 0;
  for (x = 0; x < len1; x++)
    {
      if (vec1[x] != vec2[x])
	return 0;
    }
  return 1;
}

/*:doc
  u16vector?
  (u16vector? obj) => boolean
  Return @code{#t}, if @var{obj} is a homogenous unsigned 16-bit vector, 
  @code{#f} otherwise.
  doc:*/
#define FUNC_NAME "u16vector?"
static result_t
u16vector_p_func (zzz_scm_t env, zzz_scm_t obj, zzz_scm_t * result)
{
  if (u16vector_p (obj))
    *result = zzz_true_value;
  else
    *result = zzz_false_value;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  make-u16vector
  (make-u16vector len [fill]) => vector
  Create a homogenous unsigned 16-bit vector capable of holding @var{len}
  elements and initializes the vector fields to @var{fill}.  If @var{fill} is
  omitted, the contents of the vector is undefined.
  doc:*/
#define FUNC_NAME "make-u16vector"
static result_t
make_u16vector_func (zzz_scm_t env, zzz_scm_t k, zzz_scm_t fill,
		     zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  int len;
  unsigned short f;

  CHECK_TYPE (1, integer_p (k), zzz_integer_type_name);
  CHECK_RANGE (1, integer_val (k) >= 0, 
	       _("value greater than or equal to zero"));
  if (fill == zzz_undefined)
    f = 0;
  else
    {
      CHECK_TYPE (2, integer_p (fill), zzz_integer_type_name);
      f = (unsigned short) integer_val (fill);
      CHECK_RANGE (2, f == integer_val (fill), _("unsigned 16-bit value"));
    }
  len = integer_val (k);
  *result = zzz_make_u16vector (len);
  while (--len >= 0)
    u16vector_val (*result)[len] = f;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  u16vector
  (u16vector num ...) => vector
  Create a homogenous unsigned 16-bit vector holding all the unsigned 16-bit
  values @var{num}s passed as arguments.
  doc:*/
#define FUNC_NAME "u16vector"
static result_t
u16vector_func (zzz_scm_t env, zzz_scm_t param, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  zzz_scm_t temp;
  zzz_scm_t res = NULL;
  unsigned short f;
  int len;

  /* Param is guaranteed to be a proper list when we get here.  */
  len = zzz_list_length (param);
  res = zzz_make_u16vector (len);
  len = 0;
  temp = param;
  while (cons_p (temp))
    {
      CHECK_TYPE (len + 1, integer_p (car (temp)), zzz_integer_type_name);
      f = (unsigned short) integer_val (car (temp));
      CHECK_RANGE (len + 1, f == integer_val (car (temp)),
		   _("unsigned 16-bit value"));
      u16vector_val (res)[len] = f;
      temp = cdr (temp);
      len++;
    }
  *result = res;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  u16vector-length
  (u16vector-length vec) => integer
  Return the number of elements the homogenous unsigned 16-bit vector @var{vec}
  can hold.
  doc:*/
#define FUNC_NAME "u16vector-length"
static result_t
u16vector_length_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;

  CHECK_TYPE (1, u16vector_p (vec), zzz_u16vector_type_name);
  *result = zzz_make_integer (u16vector_len (vec));
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  u16vector-ref
  (u16vector-ref vec n) => object
  Return the unsigned 16-bit value stored at index @var{n} in the vector
  homogenous unsigned 16-bit @var{vec}.  The index @var{n} is zero-based.
  doc:*/
#define FUNC_NAME "u16vector-ref"
static result_t
u16vector_ref_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t k,
  zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  unsigned long index;

  CHECK_TYPE (1, u16vector_p (vec), zzz_u16vector_type_name);
  CHECK_TYPE (2, integer_p (k), zzz_integer_type_name);
  index = integer_val (k);
  CHECK_RANGE (2, index < u16vector_len (vec), _("valid vector index"));
  *result = zzz_make_integer (u16vector_val (vec)[index]);
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  u16vector-set!
  (u16vector-set! vec n num) => *undefined*
  Store the unsigned 16-bit value at index @var{n} into the unsigned 16-bit 
  vector @var{vec}.  The index @var{n} is zero-based.
  doc:*/
#define FUNC_NAME "u16vector-set!"
static result_t
u16vector_set_x_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t k, zzz_scm_t obj,
		     zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  unsigned long index;
  unsigned short f;

  CHECK_TYPE (1, u16vector_p (vec), zzz_u16vector_type_name);
  CHECK_TYPE (1, !ro_u16vector_p (vec), _("mutable vector"));
  CHECK_TYPE (2, integer_p (k), zzz_integer_type_name);
  CHECK_TYPE (3, integer_p (obj), zzz_integer_type_name);
  f = (unsigned short) integer_val (obj);
  CHECK_RANGE (3, f == integer_val (obj), _("unsigned 16-bit value"));
  index = integer_val (k);
  CHECK_RANGE (2, index < u16vector_len (vec), _("valid vector index"));
  u16vector_val (vec)[index] = f;
  *result = zzz_unspecified;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  u16vector->list
  (u16vector->list vec) => list
  Return a list containing the elements of the unsigned 16-bit vector 
  @var{vec}.
  doc:*/
#define FUNC_NAME "u16vector->list"
static result_t
u16vector_to_list_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  zzz_scm_t res;
  unsigned len;

  CHECK_TYPE (1, u16vector_p (vec), zzz_u16vector_type_name);
  len = u16vector_len (vec);
  res = NULL;
  while (len-- > 0)
    res = zzz_cons (zzz_make_integer (u16vector_val (vec)[len]), res);
  *result = res;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  list->u16vector
  (list->u16vector list) => vector
  Return a unsigned 16-bit vector containing the elements of the list
  @var{list}.
  doc:*/
#define FUNC_NAME "list->u16vector"
static result_t
list_to_u16vector_func (zzz_scm_t env, zzz_scm_t list, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  zzz_scm_t vec = NULL;
  int len = 0;
  unsigned short f;

  CHECK_TYPE (1, zzz_list_length (list) >= 0, zzz_proper_list_type_name);
  /* Param is guaranteed to be a proper list when we get here.  */
  len = zzz_list_length (list);
  vec = zzz_make_u16vector (len);
  len = 0;
  while (cons_p (list))
    {
      CHECK_TYPE (len + 1, integer_p (car (list)), zzz_integer_type_name);
      f = (unsigned short) integer_val (car (list));
      CHECK_RANGE (len + 1, f == integer_val (car (list)),
		   _("unsigned 16-bit value"));
      u16vector_val (vec)[len] = f;
      len++;
      list = cdr (list);
    }
  *result = vec;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  u16vector-fill!
  (u16vector-fill! vec num) => *undefined*
  Store unsigned 16-bit value @var{num} in all elements of the unsigned 16-bit
  vector @var{vec}, overwriting the old contents of @var{vec}.
  doc:*/
#define FUNC_NAME "u16vector-fill!"
static result_t
u16vector_fill_x_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t fill,
		    zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  unsigned len;
  unsigned short f;

  CHECK_TYPE (1, u16vector_p (vec), zzz_u16vector_type_name);
  CHECK_TYPE (1, !ro_u16vector_p (vec), _("mutable vector"));
  CHECK_TYPE (2, integer_p (fill), zzz_integer_type_name);
  f = (unsigned short) integer_val (fill);
  CHECK_RANGE (2, f == integer_val (fill), _("unsigned 16-bit value"));
  len = u16vector_len (vec);
  while (len-- > 0)
    u16vector_val (vec)[len] = f;
  *result = zzz_unspecified;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/* Constructor function for vector objects.  Expects the desired
   vector len as a long value in @var{data0}.  Returns @var{tagged}.  */
static void *
u16vector_constructor (zzz_tagged_t tagged, void * data0,
		    void * data1, void * data2)
{
  unsigned long len = (long) data0;
  unsigned short * vec;
  unsigned long x;

  vec = zzz_malloc (sizeof (unsigned short) * len);
  for (x = 0; x < len; x++)
    vec[x] = 0;
  tagged->fill[1] = (zzz_object_t) vec;
  tagged->fill[2] = (zzz_object_t) len;
  return tagged;
}

static void
u16vector_print (zzz_scm_t port, zzz_tagged_t tagged, zzz_print_state_t state)
{
  zzz_scm_t result;
  unsigned short * vec = u16vector_val (tagged);
  unsigned long len = u16vector_len (tagged);
  unsigned long x;
  char buf[64];
  int l;

  zzz_port_puts (port, "#u16(", 5, &result);
  for (x = 0; x < len; x++)
    {
      l = sprintf (buf, "%d", vec[x]);
      zzz_port_puts (port, buf, l, &result);
      if (x < len - 1)
	zzz_port_putc (' ', port, &result);
    }
  zzz_port_putc (')', port, &result);
}

static void
u16vector_free (zzz_tagged_t tagged)
{
  zzz_free (u16vector_val (tagged),
	    sizeof (unsigned short) * u16vector_len (tagged));
}

static int
u16vector_equal (zzz_tagged_t tagged0, zzz_tagged_t tagged1)
{
  unsigned short * vec1 = u16vector_val (tagged0);
  unsigned long len1 = u16vector_len (tagged0);
  unsigned short * vec2 = u16vector_val (tagged1);
  unsigned long len2 = u16vector_len (tagged1);
  unsigned long x;

  if (len1 != len2)
    return 0;
  for (x = 0; x < len1; x++)
    {
      if (vec1[x] != vec2[x])
	return 0;
    }
  return 1;
}

/*:doc
  s32vector?
  (s32vector? obj) => boolean
  Return @code{#t}, if @var{obj} is a homogenous signed 32-bit vector, 
  @code{#f} otherwise.
  doc:*/
#define FUNC_NAME "s32vector?"
static result_t
s32vector_p_func (zzz_scm_t env, zzz_scm_t obj, zzz_scm_t * result)
{
  if (s32vector_p (obj))
    *result = zzz_true_value;
  else
    *result = zzz_false_value;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  make-s32vector
  (make-s32vector len [fill]) => vector
  Create a homogenous signed 32-bit vector capable of holding @var{len}
  elements and initializes the vector fields to @var{fill}.  If @var{fill} is
  omitted, the contents of the vector is undefined.
  doc:*/
#define FUNC_NAME "make-s32vector"
static result_t
make_s32vector_func (zzz_scm_t env, zzz_scm_t k, zzz_scm_t fill,
		    zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  int len;
  signed int f;

  CHECK_TYPE (1, integer_p (k), zzz_integer_type_name);
  CHECK_RANGE (1, integer_val (k) >= 0, 
	       _("value greater than or equal to zero"));
  if (fill == zzz_undefined)
    f = 0;
  else
    {
      CHECK_TYPE (2, integer_p (fill), zzz_integer_type_name);
      f = integer_val (fill);
    }
  len = integer_val (k);
  *result = zzz_make_s32vector (len);
  while (--len >= 0)
    s32vector_val (*result)[len] = f;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  s32vector
  (s32vector num ...) => vector
  Create a homogenous signed 32-bit vector holding all the signed 32-bit
  values @var{num}s passed as arguments.
  doc:*/
#define FUNC_NAME "s32vector"
static result_t
s32vector_func (zzz_scm_t env, zzz_scm_t param, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  zzz_scm_t temp;
  zzz_scm_t res = NULL;
  int len;

  /* Param is guaranteed to be a proper list when we get here.  */
  len = zzz_list_length (param);
  res = zzz_make_s32vector (len);
  len = 0;
  temp = param;
  while (cons_p (temp))
    {
      CHECK_TYPE (len + 1, integer_p (car (temp)), zzz_integer_type_name);
      s32vector_val (res)[len] = integer_val (car (temp));
      temp = cdr (temp);
      len++;
    }
  *result = res;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  s32vector-length
  (s32vector-length vec) => integer
  Return the number of elements the homogenous signed 32-bit vector @var{vec}
  can hold.
  doc:*/
#define FUNC_NAME "s32vector-length"
static result_t
s32vector_length_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;

  CHECK_TYPE (1, s32vector_p (vec), zzz_s32vector_type_name);
  *result = zzz_make_integer (s32vector_len (vec));
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  s32vector-ref
  (s32vector-ref vec n) => object
  Return the signed 32-bit value stored at index @var{n} in the vector
  homogenous signed 32-bit @var{vec}.  The index @var{n} is zero-based.
  doc:*/
#define FUNC_NAME "s32vector-ref"
static result_t
s32vector_ref_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t k,
  zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  unsigned long index;

  CHECK_TYPE (1, s32vector_p (vec), zzz_s32vector_type_name);
  CHECK_TYPE (2, integer_p (k), zzz_integer_type_name);
  index = integer_val (k);
  CHECK_RANGE (2, index < s32vector_len (vec), _("valid vector index"));
  *result = zzz_make_integer (s32vector_val (vec)[index]);
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  s32vector-set!
  (s32vector-set! vec n num) => *undefined*
  Store the signed 32-bit value at index @var{n} into the signed 32-bit vector
  @var{vec}.  The index @var{n} is zero-based.
  doc:*/
#define FUNC_NAME "s32vector-set!"
static result_t
s32vector_set_x_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t k, zzz_scm_t obj,
		     zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  unsigned long index;

  CHECK_TYPE (1, s32vector_p (vec), zzz_s32vector_type_name);
  CHECK_TYPE (1, !ro_s32vector_p (vec), _("mutable vector"));
  CHECK_TYPE (2, integer_p (k), zzz_integer_type_name);
  CHECK_TYPE (3, integer_p (obj), zzz_integer_type_name);
  index = integer_val (k);
  CHECK_RANGE (2, index < s32vector_len (vec), _("valid vector index"));
  s32vector_val (vec)[index] = integer_val (obj);
  *result = zzz_unspecified;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  s32vector->list
  (s32vector->list vec) => list
  Return a list containing the elements of the signed 32-bit vector @var{vec}.
  doc:*/
#define FUNC_NAME "s32vector->list"
static result_t
s32vector_to_list_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  zzz_scm_t res;
  unsigned len;

  CHECK_TYPE (1, s32vector_p (vec), zzz_s32vector_type_name);
  len = s32vector_len (vec);
  res = NULL;
  while (len-- > 0)
    res = zzz_cons (zzz_make_integer (s32vector_val (vec)[len]), res);
  *result = res;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  list->s32vector
  (list->s32vector list) => vector
  Return a signed 32-bit vector containing the elements of the list @var{list}.
  doc:*/
#define FUNC_NAME "list->s32vector"
static result_t
list_to_s32vector_func (zzz_scm_t env, zzz_scm_t list, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  zzz_scm_t vec = NULL;
  int len = 0;

  CHECK_TYPE (1, zzz_list_length (list) >= 0, zzz_proper_list_type_name);
  /* Param is guaranteed to be a proper list when we get here.  */
  len = zzz_list_length (list);
  vec = zzz_make_s32vector (len);
  len = 0;
  while (cons_p (list))
    {
      CHECK_TYPE (len + 1, integer_p (car (list)), zzz_integer_type_name);
      s32vector_val (vec)[len] = integer_val (car (list));
      len++;
      list = cdr (list);
    }
  *result = vec;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  s32vector-fill!
  (s32vector-fill! vec num) => *undefined*
  Store signed 32-bit value @var{num} in all elements of the signed 32-bit
  vector @var{vec}, overwriting the old contents of @var{vec}.
  doc:*/
#define FUNC_NAME "s32vector-fill!"
static result_t
s32vector_fill_x_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t fill,
		    zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  unsigned len;

  CHECK_TYPE (1, s32vector_p (vec), zzz_s32vector_type_name);
  CHECK_TYPE (1, !ro_s32vector_p (vec), _("mutable vector"));
  CHECK_TYPE (2, integer_p (fill), zzz_integer_type_name);
  len = s32vector_len (vec);
  while (len-- > 0)
    s32vector_val (vec)[len] = integer_val (fill);
  *result = zzz_unspecified;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/* Constructor function for vector objects.  Expects the desired
   vector len as a long value in @var{data0}.  Returns @var{tagged}.  */
static void *
s32vector_constructor (zzz_tagged_t tagged, void * data0,
		    void * data1, void * data2)
{
  unsigned long len = (long) data0;
  signed int * vec;
  unsigned long x;

  vec = zzz_malloc (sizeof (signed int) * len);
  for (x = 0; x < len; x++)
    vec[x] = 0;
  tagged->fill[1] = (zzz_object_t) vec;
  tagged->fill[2] = (zzz_object_t) len;
  return tagged;
}

static void
s32vector_print (zzz_scm_t port, zzz_tagged_t tagged, zzz_print_state_t state)
{
  zzz_scm_t result;
  signed int * vec = s32vector_val (tagged);
  unsigned long len = s32vector_len (tagged);
  unsigned long x;
  char buf[64];
  int l;

  zzz_port_puts (port, "#s32(", 5, &result);
  for (x = 0; x < len; x++)
    {
      l = sprintf (buf, "%d", vec[x]);
      zzz_port_puts (port, buf, l, &result);
      if (x < len - 1)
	zzz_port_putc (' ', port, &result);
    }
  zzz_port_putc (')', port, &result);
}

static void
s32vector_free (zzz_tagged_t tagged)
{
  zzz_free (s32vector_val (tagged),
	    sizeof (signed int) * s32vector_len (tagged));
}

static int
s32vector_equal (zzz_tagged_t tagged0, zzz_tagged_t tagged1)
{
  signed int * vec1 = s32vector_val (tagged0);
  unsigned long len1 = s32vector_len (tagged0);
  signed int * vec2 = s32vector_val (tagged1);
  unsigned long len2 = s32vector_len (tagged1);
  unsigned long x;

  if (len1 != len2)
    return 0;
  for (x = 0; x < len1; x++)
    {
      if (vec1[x] != vec2[x])
	return 0;
    }
  return 1;
}

/*:doc
  u32vector?
  (u32vector? obj) => boolean
  Return @code{#t}, if @var{obj} is a homogenous unsigned 32-bit vector,
  @code{#f} otherwise.
  doc:*/
#define FUNC_NAME "u32vector?"
static result_t
u32vector_p_func (zzz_scm_t env, zzz_scm_t obj, zzz_scm_t * result)
{
  if (u32vector_p (obj))
    *result = zzz_true_value;
  else
    *result = zzz_false_value;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  make-u32vector
  (make-u32vector len [fill]) => vector
  Create a homogenous unsigned 32-bit vector capable of holding @var{len}
  elements and initializes the vector fields to @var{fill}.  If @var{fill} is
  omitted, the contents of the vector is undefined.
  doc:*/
#define FUNC_NAME "make-u32vector"
static result_t
make_u32vector_func (zzz_scm_t env, zzz_scm_t k, zzz_scm_t fill,
		    zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  int len;
  unsigned int f;

  CHECK_TYPE (1, integer_p (k), zzz_integer_type_name);
  CHECK_RANGE (1, integer_val (k) >= 0, 
	       _("value greater than or equal to zero"));
  if (fill == zzz_undefined)
    f = 0;
  else
    {
      CHECK_TYPE (2, integer_p (fill), zzz_integer_type_name);
      f = integer_val (fill);
    }
  len = integer_val (k);
  *result = zzz_make_u32vector (len);
  while (--len >= 0)
    u32vector_val (*result)[len] = f;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  u32vector
  (u32vector num ...) => vector
  Create a homogenous unsigned 32-bit vector holding all the unsigned 32-bit
  values @var{num}s passed as arguments.
  doc:*/
#define FUNC_NAME "u32vector"
static result_t
u32vector_func (zzz_scm_t env, zzz_scm_t param, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  zzz_scm_t temp;
  zzz_scm_t res = NULL;
  int len;

  /* Param is guaranteed to be a proper list when we get here.  */
  len = zzz_list_length (param);
  res = zzz_make_u32vector (len);
  len = 0;
  temp = param;
  while (cons_p (temp))
    {
      CHECK_TYPE (len + 1, integer_p (car (temp)), zzz_integer_type_name);
      u32vector_val (res)[len] = integer_val (car (temp));
      temp = cdr (temp);
      len++;
    }
  *result = res;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  u32vector-length
  (u32vector-length vec) => integer
  Return the number of elements the homogenous unsigned 32-bit vector @var{vec}
  can hold.
  doc:*/
#define FUNC_NAME "u32vector-length"
static result_t
u32vector_length_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;

  CHECK_TYPE (1, u32vector_p (vec), zzz_u32vector_type_name);
  *result = zzz_make_integer (u32vector_len (vec));
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  u32vector-ref
  (u32vector-ref vec n) => object
  Return the unsigned 32-bit value stored at index @var{n} in the vector
  homogenous unsigned 32-bit @var{vec}.  The index @var{n} is zero-based.
  doc:*/
#define FUNC_NAME "u32vector-ref"
static result_t
u32vector_ref_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t k,
  zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  unsigned long index;

  CHECK_TYPE (1, u32vector_p (vec), zzz_u32vector_type_name);
  CHECK_TYPE (2, integer_p (k), zzz_integer_type_name);
  index = integer_val (k);
  CHECK_RANGE (2, index < u32vector_len (vec), _("valid vector index"));
  *result = zzz_make_integer (u32vector_val (vec)[index]);
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  u32vector-set!
  (u32vector-set! vec n num) => *undefined*
  Store the unsigned 32-bit value at index @var{n} into the unsigned 32-bit 
  vector @var{vec}.  The index @var{n} is zero-based.
  doc:*/
#define FUNC_NAME "u32vector-set!"
static result_t
u32vector_set_x_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t k, zzz_scm_t obj,
		     zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  unsigned long index;

  CHECK_TYPE (1, u32vector_p (vec), zzz_u32vector_type_name);
  CHECK_TYPE (1, !ro_u32vector_p (vec), _("mutable vector"));
  CHECK_TYPE (2, integer_p (k), zzz_integer_type_name);
  CHECK_TYPE (3, integer_p (obj), zzz_integer_type_name);
  index = integer_val (k);
  CHECK_RANGE (2, index < u32vector_len (vec), _("valid vector index"));
  u32vector_val (vec)[index] = integer_val (obj);
  *result = zzz_unspecified;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  u32vector->list
  (u32vector->list vec) => list
  Return a list containing the elements of the unsigned 32-bit vector
  @var{vec}.
  doc:*/
#define FUNC_NAME "u32vector->list"
static result_t
u32vector_to_list_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  zzz_scm_t res;
  unsigned len;

  CHECK_TYPE (1, u32vector_p (vec), zzz_u32vector_type_name);
  len = u32vector_len (vec);
  res = NULL;
  while (len-- > 0)
    res = zzz_cons (zzz_make_integer (u32vector_val (vec)[len]), res);
  *result = res;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  list->u32vector
  (list->u32vector list) => vector
  Return a unsigned 32-bit vector containing the elements of the list 
  @var{list}.
  doc:*/
#define FUNC_NAME "list->u32vector"
static result_t
list_to_u32vector_func (zzz_scm_t env, zzz_scm_t list, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  zzz_scm_t vec = NULL;
  int len = 0;

  CHECK_TYPE (1, zzz_list_length (list) >= 0, zzz_proper_list_type_name);
  /* Param is guaranteed to be a proper list when we get here.  */
  len = zzz_list_length (list);
  vec = zzz_make_u32vector (len);
  len = 0;
  while (cons_p (list))
    {
      CHECK_TYPE (len + 1, integer_p (car (list)), zzz_integer_type_name);
      u32vector_val (vec)[len] = integer_val (car (list));
      len++;
      list = cdr (list);
    }
  *result = vec;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  u32vector-fill!
  (u32vector-fill! vec num) => *undefined*
  Store unsigned 32-bit value @var{num} in all elements of the unsigned 32-bit
  vector @var{vec}, overwriting the old contents of @var{vec}.
  doc:*/
#define FUNC_NAME "u32vector-fill!"
static result_t
u32vector_fill_x_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t fill,
		    zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  unsigned len;

  CHECK_TYPE (1, u32vector_p (vec), zzz_u32vector_type_name);
  CHECK_TYPE (1, !ro_u32vector_p (vec), _("mutable vector"));
  CHECK_TYPE (2, integer_p (fill), zzz_integer_type_name);
  len = u32vector_len (vec);
  while (len-- > 0)
    u32vector_val (vec)[len] = integer_val (fill);
  *result = zzz_unspecified;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/* Constructor function for vector objects.  Expects the desired
   vector len as a long value in @var{data0}.  Returns @var{tagged}.  */
static void *
u32vector_constructor (zzz_tagged_t tagged, void * data0,
		    void * data1, void * data2)
{
  unsigned long len = (long) data0;
  unsigned int * vec;
  unsigned long x;

  vec = zzz_malloc (sizeof (unsigned int) * len);
  for (x = 0; x < len; x++)
    vec[x] = 0;
  tagged->fill[1] = (zzz_object_t) vec;
  tagged->fill[2] = (zzz_object_t) len;
  return tagged;
}

static void
u32vector_print (zzz_scm_t port, zzz_tagged_t tagged, zzz_print_state_t state)
{
  zzz_scm_t result;
  unsigned int * vec = u32vector_val (tagged);
  unsigned long len = u32vector_len (tagged);
  unsigned long x;
  char buf[64];
  int l;

  zzz_port_puts (port, "#u32(", 5, &result);
  for (x = 0; x < len; x++)
    {
      l = sprintf (buf, "%d", vec[x]);
      zzz_port_puts (port, buf, l, &result);
      if (x < len - 1)
	zzz_port_putc (' ', port, &result);
    }
  zzz_port_putc (')', port, &result);
}

static void
u32vector_free (zzz_tagged_t tagged)
{
  zzz_free (u32vector_val (tagged),
	    sizeof (unsigned int) * u32vector_len (tagged));
}

static int
u32vector_equal (zzz_tagged_t tagged0, zzz_tagged_t tagged1)
{
  unsigned int * vec1 = u32vector_val (tagged0);
  unsigned long len1 = u32vector_len (tagged0);
  unsigned int * vec2 = u32vector_val (tagged1);
  unsigned long len2 = u32vector_len (tagged1);
  unsigned long x;

  if (len1 != len2)
    return 0;
  for (x = 0; x < len1; x++)
    {
      if (vec1[x] != vec2[x])
	return 0;
    }
  return 1;
}

/*:doc
  f32vector?
  (f32vector? obj) => boolean
  Return @code{#t}, if @var{obj} is a homogenous 32-bit floating point vector,
  @code{#f} otherwise.
  doc:*/
#define FUNC_NAME "f32vector?"
static result_t
f32vector_p_func (zzz_scm_t env, zzz_scm_t obj, zzz_scm_t * result)
{
  if (f32vector_p (obj))
    *result = zzz_true_value;
  else
    *result = zzz_false_value;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  make-f32vector
  (make-f32vector len [fill]) => vector
  Create a homogenous 32-bit floating point vector capable of
  holding @var{len} elements and initializes the vector fields to @var{fill}. 
  If @var{fill} is omitted, the contents of the vector is undefined.
  doc:*/
#define FUNC_NAME "make-f32vector"
static result_t
make_f32vector_func (zzz_scm_t env, zzz_scm_t k, zzz_scm_t fill,
		    zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  int len;
  float f;

  CHECK_TYPE (1, integer_p (k), zzz_integer_type_name);
  CHECK_RANGE (1, integer_val (k) >= 0, 
	       _("value greater than or equal to zero"));
  if (fill == zzz_undefined)
    f = 0;
  else
    {
      CHECK_TYPE (2, number_p (fill), zzz_integer_type_name);
      if (integer_p (fill))
	f = (float) integer_val (fill);
      else if (float_p (fill))
	f = (float) float_val (fill);
      else
	abort();
    }
  len = integer_val (k);
  *result = zzz_make_f32vector (len);
  while (--len >= 0)
    f32vector_val (*result)[len] = f;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  f32vector
  (f32vector num ...) => vector
  Create a homogenous 32-bit floating point vector holding all
  the 32-bit values @var{num}s passed as arguments.
  doc:*/
#define FUNC_NAME "f32vector"
static result_t
f32vector_func (zzz_scm_t env, zzz_scm_t param, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  zzz_scm_t temp;
  zzz_scm_t res = NULL;
  int len;
  float f;

  /* Param is guaranteed to be a proper list when we get here.  */
  len = zzz_list_length (param);
  res = zzz_make_f32vector (len);
  len = 0;
  temp = param;
  while (cons_p (temp))
    {
      CHECK_TYPE (len + 1, number_p (car (temp)), zzz_number_type_name);
      if (integer_p (car (temp)))
	f = (float) integer_val (car (temp));
      else if (float_p (car (temp)))
	f = (float) float_val (car (temp));
      else
	abort ();
      f32vector_val (res)[len] = f;
      temp = cdr (temp);
      len++;
    }
  *result = res;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  f32vector-length
  (f32vector-length vec) => integer
  Return the number of elements the homogenous 32-bit floating
  point vector @var{vec} can hold.
  doc:*/
#define FUNC_NAME "f32vector-length"
static result_t
f32vector_length_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;

  CHECK_TYPE (1, f32vector_p (vec), zzz_f32vector_type_name);
  *result = zzz_make_integer (f32vector_len (vec));
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  f32vector-ref
  (f32vector-ref vec n) => object
  Return the 32-bit value stored at index @var{n} in the homogenous
  32-bit floating point vector @var{vec}.  The index @var{n} is zero-based.
  doc:*/
#define FUNC_NAME "f32vector-ref"
static result_t
f32vector_ref_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t k,
  zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  unsigned long index;

  CHECK_TYPE (1, f32vector_p (vec), zzz_f32vector_type_name);
  CHECK_TYPE (2, integer_p (k), zzz_integer_type_name);
  index = integer_val (k);
  CHECK_RANGE (2, index < f32vector_len (vec), _("valid vector index"));
  *result = zzz_make_float ((double) (f32vector_val (vec)[index]));
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  f32vector-set!
  (f32vector-set! vec n num) => *undefined*
  Store the 32-bit value at index @var{n} into the 32-bit floating
  point vector @var{vec}.  The index @var{n} is zero-based.
  doc:*/
#define FUNC_NAME "f32vector-set!"
static result_t
f32vector_set_x_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t k, zzz_scm_t obj,
		     zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  unsigned long index;
  float f;

  CHECK_TYPE (1, f32vector_p (vec), zzz_f32vector_type_name);
  CHECK_TYPE (1, !ro_f32vector_p (vec), _("mutable vector"));
  CHECK_TYPE (2, integer_p (k), zzz_integer_type_name);
  CHECK_TYPE (3, number_p (obj), zzz_number_type_name);
  if (integer_p (obj))
    f = (float) integer_val (obj);
  else if (float_p (obj))
    f = (float) float_val (obj);
  else
    abort ();
  index = integer_val (k);
  CHECK_RANGE (2, index < f32vector_len (vec), _("valid vector index"));
  f32vector_val (vec)[index] = f;
  *result = zzz_unspecified;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  f32vector->list
  (f32vector->list vec) => list
  Return a list containing the elements of the 32-bit floating point
  vector @var{vec}.
  doc:*/
#define FUNC_NAME "f32vector->list"
static result_t
f32vector_to_list_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  zzz_scm_t res;
  unsigned len;

  CHECK_TYPE (1, f32vector_p (vec), zzz_f32vector_type_name);
  len = f32vector_len (vec);
  res = NULL;
  while (len-- > 0)
    res = zzz_cons (zzz_make_float ((double) (f32vector_val (vec)[len])), res);
  *result = res;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  list->f32vector
  (list->f32vector list) => vector
  Return a 32-bit floating point vector containing the elements of the
  list @var{list}.
  doc:*/
#define FUNC_NAME "list->f32vector"
static result_t
list_to_f32vector_func (zzz_scm_t env, zzz_scm_t list, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  zzz_scm_t vec = NULL;
  int len = 0;
  float f;

  CHECK_TYPE (1, zzz_list_length (list) >= 0, zzz_proper_list_type_name);
  /* Param is guaranteed to be a proper list when we get here.  */
  len = zzz_list_length (list);
  vec = zzz_make_f32vector (len);
  len = 0;
  while (cons_p (list))
    {
      CHECK_TYPE (len + 1, number_p (car (list)), zzz_number_type_name);
      if (integer_p (car (list)))
	f = (float) integer_val (car (list));
      else if (float_p (car (list)))
	f = (float) float_val (car (list));
      else
	abort ();
      f32vector_val (vec)[len] = f;
      len++;
      list = cdr (list);
    }
  *result = vec;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  f32vector-fill!
  (f32vector-fill! vec num) => *undefined*
  Store the 32-bit floating point value @var{num} in all elements of the
  32-bit floating point vector @var{vec}, overwriting the old contents of
  @var{vec}.
  doc:*/
#define FUNC_NAME "f32vector-fill!"
static result_t
f32vector_fill_x_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t fill,
		    zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  unsigned len;
  float f;
  
  CHECK_TYPE (1, f32vector_p (vec), zzz_f32vector_type_name);
  CHECK_TYPE (1, !ro_f32vector_p (vec), _("mutable vector"));
  CHECK_TYPE (2, number_p (fill), zzz_number_type_name);
  if (integer_p (fill))
    f = (float) integer_val (fill);
  else if (float_p (fill))
    f = (float) float_val (fill);
  else
    abort ();
  len = f32vector_len (vec);
  while (len-- > 0)
    f32vector_val (vec)[len] = f;
  *result = zzz_unspecified;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/* Constructor function for vector objects.  Expects the desired
   vector len as a long value in @var{data0}.  Returns @var{tagged}.  */
static void *
f32vector_constructor (zzz_tagged_t tagged, void * data0,
		    void * data1, void * data2)
{
  unsigned long len = (long) data0;
  float * vec;
  unsigned long x;

  vec = zzz_malloc (sizeof (float) * len);
  for (x = 0; x < len; x++)
    vec[x] = 0;
  tagged->fill[1] = (zzz_object_t) vec;
  tagged->fill[2] = (zzz_object_t) len;
  return tagged;
}

static void
f32vector_print (zzz_scm_t port, zzz_tagged_t tagged, zzz_print_state_t state)
{
  zzz_scm_t result;
  float * vec = f32vector_val (tagged);
  unsigned long len = f32vector_len (tagged);
  unsigned long x;
  char buf[64];
  int l;

  zzz_port_puts (port, "#f32(", 5, &result);
  for (x = 0; x < len; x++)
    {
      l = sprintf (buf, "%f", (double) vec[x]);
      zzz_port_puts (port, buf, l, &result);
      if (x < len - 1)
	zzz_port_putc (' ', port, &result);
    }
  zzz_port_putc (')', port, &result);
}

static void
f32vector_free (zzz_tagged_t tagged)
{
  zzz_free (f32vector_val (tagged),
	    sizeof (float) * f32vector_len (tagged));
}

static int
f32vector_equal (zzz_tagged_t tagged0, zzz_tagged_t tagged1)
{
  float * vec1 = f32vector_val (tagged0);
  unsigned long len1 = f32vector_len (tagged0);
  float * vec2 = f32vector_val (tagged1);
  unsigned long len2 = f32vector_len (tagged1);
  unsigned long x;

  if (len1 != len2)
    return 0;
  for (x = 0; x < len1; x++)
    {
      if (vec1[x] != vec2[x])
	return 0;
    }
  return 1;
}

/*:doc
  f64vector?
  (f64vector? obj) => boolean
  Return @code{#t}, if @var{obj} is a homogenous 64-bit floating point vector,
  @code{#f} otherwise.
  doc:*/
#define FUNC_NAME "f64vector?"
static result_t
f64vector_p_func (zzz_scm_t env, zzz_scm_t obj, zzz_scm_t * result)
{
  if (f64vector_p (obj))
    *result = zzz_true_value;
  else
    *result = zzz_false_value;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  make-f64vector
  (make-f64vector len [fill]) => vector
  Create a homogenous 64-bit floating point vector capable of
  holding @var{len} elements and initializes the vector fields to @var{fill}. 
  If @var{fill} is omitted, the contents of the vector is undefined.
  doc:*/
#define FUNC_NAME "make-f64vector"
static result_t
make_f64vector_func (zzz_scm_t env, zzz_scm_t k, zzz_scm_t fill,
		    zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  int len;
  double f;

  CHECK_TYPE (1, integer_p (k), zzz_integer_type_name);
  CHECK_RANGE (1, integer_val (k) >= 0, 
	       _("value greater than or equal to zero"));
  if (fill == zzz_undefined)
    f = 0;
  else
    {
      CHECK_TYPE (2, number_p (fill), zzz_number_type_name);
      if (integer_p (fill))
	f = (double) integer_val (fill);
      else if (float_p (fill))
	f = float_val (fill);
      else
	abort ();
    }
  len = integer_val (k);
  *result = zzz_make_f64vector (len);
  while (--len >= 0)
    f64vector_val (*result)[len] = f;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  f64vector
  (f64vector num ...) => vector
  Create a homogenous 64-bit floating point vector holding all
  the 64-bit values @var{num}s passed as arguments.
  doc:*/
#define FUNC_NAME "f64vector"
static result_t
f64vector_func (zzz_scm_t env, zzz_scm_t param, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  zzz_scm_t temp;
  zzz_scm_t res = NULL;
  int len;
  double f;

  /* Param is guaranteed to be a proper list when we get here.  */
  len = zzz_list_length (param);
  res = zzz_make_f64vector (len);
  len = 0;
  temp = param;
  while (cons_p (temp))
    {
      CHECK_TYPE (len + 1, number_p (car (temp)), zzz_number_type_name);
      if (integer_p (car (temp)))
	f = (double) integer_val (car (temp));
      else if (float_p (car (temp)))
	f = (double) float_val (car (temp));
      else
	abort ();       
      f64vector_val (res)[len] = f;
      temp = cdr (temp);
      len++;
    }
  *result = res;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  f64vector-length
  (f64vector-length vec) => integer
  Return the number of elements the homogenous 64-bit floating
  point vector @var{vec} can hold.
  doc:*/
#define FUNC_NAME "f64vector-length"
static result_t
f64vector_length_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;

  CHECK_TYPE (1, f64vector_p (vec), zzz_f64vector_type_name);
  *result = zzz_make_integer (f64vector_len (vec));
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  f64vector-ref
  (f64vector-ref vec n) => object
  Return the 64-bit value stored at index @var{n} in the homogenous
  64-bit floating point vector @var{vec}.  The index @var{n} is zero-based.
  doc:*/
#define FUNC_NAME "f64vector-ref"
static result_t
f64vector_ref_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t k,
  zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  unsigned long index;

  CHECK_TYPE (1, f64vector_p (vec), zzz_f64vector_type_name);
  CHECK_TYPE (2, integer_p (k), zzz_integer_type_name);
  index = integer_val (k);
  CHECK_RANGE (2, index < f64vector_len (vec), _("valid vector index"));
  *result = zzz_make_float (f64vector_val (vec)[index]);
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  f64vector-set!
  (f64vector-set! vec n num) => *undefined*
  Store the 64-bit value at index @var{n} into the 64-bit floating
  point vector @var{vec}.  The index @var{n} is zero-based.
  doc:*/
#define FUNC_NAME "f64vector-set!"
static result_t
f64vector_set_x_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t k, zzz_scm_t obj,
		     zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  unsigned long index;
  double f;

  CHECK_TYPE (1, f64vector_p (vec), zzz_f64vector_type_name);
  CHECK_TYPE (1, !ro_f64vector_p (vec), _("mutable vector"));
  CHECK_TYPE (2, integer_p (k), zzz_integer_type_name);
  CHECK_TYPE (3, number_p (obj), zzz_number_type_name);
  if (integer_p (obj))
    f = (double) integer_val (obj);
  else if (float_p (obj))
    f = (double) float_val (obj);
  else
    abort ();
  index = integer_val (k);
  CHECK_RANGE (2, index < f64vector_len (vec), _("valid vector index"));
  f64vector_val (vec)[index] = f;
  *result = zzz_unspecified;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  f64vector->list
  (f64vector->list vec) => list
  Return a list containing the elements of the 64-bit floating point
  vector @var{vec}.
  doc:*/
#define FUNC_NAME "f64vector->list"
static result_t
f64vector_to_list_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  zzz_scm_t res;
  unsigned len;

  CHECK_TYPE (1, f64vector_p (vec), zzz_f64vector_type_name);
  len = f64vector_len (vec);
  res = NULL;
  while (len-- > 0)
    res = zzz_cons (zzz_make_float (f64vector_val (vec)[len]), res);
  *result = res;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  list->f64vector
  (list->f64vector list) => vector
  Return a 64-bit floating point vector containing the elements of the
  list @var{list}.
  doc:*/
#define FUNC_NAME "list->f64vector"
static result_t
list_to_f64vector_func (zzz_scm_t env, zzz_scm_t list, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  zzz_scm_t vec = NULL;
  int len = 0;
  double f;

  CHECK_TYPE (1, zzz_list_length (list) >= 0, zzz_proper_list_type_name);
  /* Param is guaranteed to be a proper list when we get here.  */
  len = zzz_list_length (list);
  vec = zzz_make_f64vector (len);
  len = 0;
  while (cons_p (list))
    {
      CHECK_TYPE (len + 1, number_p (car (list)), zzz_number_type_name);
      if (integer_p (car (list)))
	f = (double) integer_val (car (list));
      else if (float_p (car (list)))
	f = (double) float_val (car (list));
      else
	abort ();
      f64vector_val (vec)[len] = f;
      len++;
      list = cdr (list);
    }
  *result = vec;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  f64vector-fill!
  (f64vector-fill! vec num) => *undefined*
  Store the 64-bit floating point value @var{num} in all elements of the
  64-bit floating point vector @var{vec}, overwriting the old contents of 
  @var{vec}.
  doc:*/
#define FUNC_NAME "f64vector-fill!"
static result_t
f64vector_fill_x_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t fill,
		    zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  unsigned len;
  double f;

  CHECK_TYPE (1, f64vector_p (vec), zzz_f64vector_type_name);
  CHECK_TYPE (1, !ro_f64vector_p (vec), _("mutable vector"));
  CHECK_TYPE (2, number_p (fill), zzz_number_type_name);
  if (integer_p (fill))
    f = (double) integer_val (fill);
  else if (float_p (fill))
    f = (double) float_val (fill);
  else
    abort ();
  len = f64vector_len (vec);
  while (len-- > 0)
    f64vector_val (vec)[len] = f;
  *result = zzz_unspecified;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/* Constructor function for vector objects.  Expects the desired
   vector len as a long value in @var{data0}.  Returns @var{tagged}.  */
static void *
f64vector_constructor (zzz_tagged_t tagged, void * data0,
		    void * data1, void * data2)
{
  unsigned long len = (long) data0;
  double * vec;
  unsigned long x;

  vec = zzz_malloc (sizeof (double) * len);
  for (x = 0; x < len; x++)
    vec[x] = 0.0;
  tagged->fill[1] = (zzz_object_t) vec;
  tagged->fill[2] = (zzz_object_t) len;
  return tagged;
}

static void
f64vector_print (zzz_scm_t port, zzz_tagged_t tagged, zzz_print_state_t state)
{
  zzz_scm_t result;
  double * vec = f64vector_val (tagged);
  unsigned long len = f64vector_len (tagged);
  unsigned long x;
  char buf[64];
  int l;

  zzz_port_puts (port, "#f64(", 5, &result);
  for (x = 0; x < len; x++)
    {
      l = sprintf (buf, "%f", vec[x]);
      zzz_port_puts (port, buf, l, &result);
      if (x < len - 1)
	zzz_port_putc (' ', port, &result);
    }
  zzz_port_putc (')', port, &result);
}

static void
f64vector_free (zzz_tagged_t tagged)
{
  zzz_free (f64vector_val (tagged),
	    sizeof (double) * f64vector_len (tagged));
}

static int
f64vector_equal (zzz_tagged_t tagged0, zzz_tagged_t tagged1)
{
  double * vec1 = f64vector_val (tagged0);
  unsigned long len1 = f64vector_len (tagged0);
  double * vec2 = f64vector_val (tagged1);
  unsigned long len2 = f64vector_len (tagged1);
  unsigned long x;

  if (len1 != len2)
    return 0;
  for (x = 0; x < len1; x++)
    {
      if (vec1[x] != vec2[x])
	return 0;
    }
  return 1;
}

zzz_scm_t
zzz_make_s8vector (int len)
{
  return zzz_create_tagged_cell (zzz_tagged_type_s8vector,
				 (void *) ((zzz_object_t) len), NULL, NULL);
}

zzz_scm_t
zzz_make_ro_s8vector (int len)
{
  return zzz_create_tagged_cell (zzz_tagged_type_s8vector | tagged_info_ro,
				 (void *) ((zzz_object_t) len), NULL, NULL);
}

zzz_scm_t
zzz_make_u8vector (int len)
{
  return zzz_create_tagged_cell (zzz_tagged_type_u8vector,
				 (void *) ((zzz_object_t) len), NULL, NULL);
}

zzz_scm_t
zzz_make_ro_u8vector (int len)
{
  return zzz_create_tagged_cell (zzz_tagged_type_u8vector | tagged_info_ro,
				 (void *) ((zzz_object_t) len), NULL, NULL);
}

zzz_scm_t
zzz_make_s16vector (int len)
{
  return zzz_create_tagged_cell (zzz_tagged_type_s16vector,
				 (void *) ((zzz_object_t) len), NULL, NULL);
}

zzz_scm_t
zzz_make_ro_s16vector (int len)
{
  return zzz_create_tagged_cell (zzz_tagged_type_s16vector | tagged_info_ro,
				 (void *) ((zzz_object_t) len), NULL, NULL);
}

zzz_scm_t
zzz_make_u16vector (int len)
{
  return zzz_create_tagged_cell (zzz_tagged_type_u16vector,
				 (void *) ((zzz_object_t) len), NULL, NULL);
}

zzz_scm_t
zzz_make_ro_u16vector (int len)
{
  return zzz_create_tagged_cell (zzz_tagged_type_u16vector | tagged_info_ro,
				 (void *) ((zzz_object_t) len), NULL, NULL);
}

zzz_scm_t
zzz_make_s32vector (int len)
{
  return zzz_create_tagged_cell (zzz_tagged_type_s32vector,
				 (void *) ((zzz_object_t) len), NULL, NULL);
}

zzz_scm_t
zzz_make_ro_s32vector (int len)
{
  return zzz_create_tagged_cell (zzz_tagged_type_s32vector | tagged_info_ro,
				 (void *) ((zzz_object_t) len), NULL, NULL);
}

zzz_scm_t
zzz_make_u32vector (int len)
{
  return zzz_create_tagged_cell (zzz_tagged_type_u32vector,
				 (void *) ((zzz_object_t) len), NULL, NULL);
}

zzz_scm_t
zzz_make_ro_u32vector (int len)
{
  return zzz_create_tagged_cell (zzz_tagged_type_u32vector | tagged_info_ro,
				 (void *) ((zzz_object_t) len), NULL, NULL);
}

zzz_scm_t
zzz_make_f32vector (int len)
{
  return zzz_create_tagged_cell (zzz_tagged_type_f32vector,
				 (void *) ((zzz_object_t) len), NULL, NULL);
}

zzz_scm_t
zzz_make_ro_f32vector (int len)
{
  return zzz_create_tagged_cell (zzz_tagged_type_f32vector | tagged_info_ro,
				 (void *) ((zzz_object_t) len), NULL, NULL);
}

zzz_scm_t
zzz_make_f64vector (int len)
{
  return zzz_create_tagged_cell (zzz_tagged_type_f64vector,
				 (void *) ((zzz_object_t) len), NULL, NULL);
}

zzz_scm_t
zzz_make_ro_f64vector (int len)
{
  return zzz_create_tagged_cell (zzz_tagged_type_f64vector | tagged_info_ro,
				 (void *) ((zzz_object_t) len), NULL, NULL);
}

/*:doc
  s8vector->string
  (s8vector->string vec) => string
  Convert the homogenous signed 8-bit vector @var{vec} to a string by taking
  each value from the vector, converting it to a character and composing
  the characters to a string.
  doc:*/
#define FUNC_NAME "s8vector->string"
static result_t
s8vector_to_string_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;

  CHECK_TYPE (1, s8vector_p (vec), zzz_s8vector_type_name);
  *result = zzz_make_string ((char *) s8vector_val (vec), s8vector_len (vec));
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  string->s8vector
  (string->s8vector str) => s8vector
  Convert the string @var{str} to a homogenous signed 8-bit vector by taking
  each character from @var{str}, converting them to integer values and
  composing them to a vector.
  doc:*/
#define FUNC_NAME "string->s8vector"
static result_t
string_to_s8vector_func (zzz_scm_t env, zzz_scm_t str, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  zzz_scm_t res;
  unsigned x;

  CHECK_TYPE (1, string_p (str), zzz_string_type_name);
  res = zzz_make_s8vector (string_len (str));
  for (x = 0; x < string_len (str); x++)
    s8vector_val (res)[x] = string_val (str)[x];
  *result = res;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  u8vector->string
  (u8vector->string vec) => string
  Convert the homogenous unsigned 8-bit vector @var{vec} to a string by taking
  each value from the vector, converting it to a character and composing
  the characters to a string.
  doc:*/
#define FUNC_NAME "u8vector->string"
static result_t
u8vector_to_string_func (zzz_scm_t env, zzz_scm_t vec, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;

  CHECK_TYPE (1, u8vector_p (vec), zzz_u8vector_type_name);
  *result = zzz_make_string ((char *) u8vector_val (vec), u8vector_len (vec));
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  string->u8vector
  (string->u8vector str) => u8vector
  Convert the string @var{str} to a homogenous unsigned 8-bit vector by taking
  each character from @var{str}, converting them to integer values and
  composing them to a vector.
  doc:*/
#define FUNC_NAME "string->u8vector"
static result_t
string_to_u8vector_func (zzz_scm_t env, zzz_scm_t str, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  zzz_scm_t res;
  unsigned x;

  CHECK_TYPE (1, string_p (str), zzz_string_type_name);
  res = zzz_make_u8vector (string_len (str));
  for (x = 0; x < string_len (str); x++)
    u8vector_val (res)[x] = string_val (str)[x];
  *result = res;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

result_t
zzz_init_uvector (void)
{
  zzz_tagged_type_s8vector =
    zzz_define_tagged_type (s8vector_constructor, s8vector_print,
			    s8vector_free, NULL, s8vector_equal);
  zzz_tagged_type_u8vector =
    zzz_define_tagged_type (u8vector_constructor, u8vector_print,
			    u8vector_free, NULL, u8vector_equal);
  zzz_tagged_type_s16vector =
    zzz_define_tagged_type (s16vector_constructor, s16vector_print,
			    s16vector_free, NULL, s16vector_equal);
  zzz_tagged_type_u16vector =
    zzz_define_tagged_type (u16vector_constructor, u16vector_print,
			    u16vector_free, NULL, u16vector_equal);
  zzz_tagged_type_s32vector =
    zzz_define_tagged_type (s32vector_constructor, s32vector_print,
			    s32vector_free, NULL, s32vector_equal);
  zzz_tagged_type_u32vector =
    zzz_define_tagged_type (u32vector_constructor, u32vector_print,
			    u32vector_free, NULL, u32vector_equal);
  zzz_tagged_type_f32vector =
    zzz_define_tagged_type (f32vector_constructor, f32vector_print,
			    f32vector_free, NULL, f32vector_equal);
  zzz_tagged_type_f64vector =
    zzz_define_tagged_type (f64vector_constructor, f64vector_print,
			    f64vector_free, NULL, f64vector_equal);

  zzz_define_function ("s8vector?", (zzz_prim_t) s8vector_p_func, argv_1_0_0);
  zzz_define_function ("make-s8vector", (zzz_prim_t) make_s8vector_func,
		       argv_1_1_0);
  zzz_define_function ("s8vector-length", (zzz_prim_t) s8vector_length_func,
		       argv_1_0_0);
  zzz_define_function ("s8vector", (zzz_prim_t) s8vector_func, argv_0_0_1);
  zzz_define_function ("s8vector-ref", (zzz_prim_t) s8vector_ref_func,
		       argv_2_0_0);
  zzz_define_function ("s8vector-set!", (zzz_prim_t) s8vector_set_x_func,
		       argv_3_0_0);
  zzz_define_function ("s8vector->list", (zzz_prim_t) s8vector_to_list_func,
		       argv_1_0_0);
  zzz_define_function ("list->s8vector", (zzz_prim_t) list_to_s8vector_func,
		       argv_1_0_0);
  zzz_define_function ("s8vector-fill!", (zzz_prim_t) s8vector_fill_x_func,
		       argv_2_0_0);

  zzz_define_function ("u8vector?", (zzz_prim_t) u8vector_p_func, argv_1_0_0);
  zzz_define_function ("make-u8vector", (zzz_prim_t) make_u8vector_func,
		       argv_1_1_0);
  zzz_define_function ("u8vector-length", (zzz_prim_t) u8vector_length_func,
		       argv_1_0_0);
  zzz_define_function ("u8vector", (zzz_prim_t) u8vector_func, argv_0_0_1);
  zzz_define_function ("u8vector-ref", (zzz_prim_t) u8vector_ref_func,
		       argv_2_0_0);
  zzz_define_function ("u8vector-set!", (zzz_prim_t) u8vector_set_x_func,
		       argv_3_0_0);
  zzz_define_function ("u8vector->list", (zzz_prim_t) u8vector_to_list_func,
		       argv_1_0_0);
  zzz_define_function ("list->u8vector", (zzz_prim_t) list_to_u8vector_func,
		       argv_1_0_0);
  zzz_define_function ("u8vector-fill!", (zzz_prim_t) u8vector_fill_x_func,
		       argv_2_0_0);

  zzz_define_function ("s16vector?", (zzz_prim_t) s16vector_p_func,
		       argv_1_0_0);
  zzz_define_function ("make-s16vector", (zzz_prim_t) make_s16vector_func,
		       argv_1_1_0);
  zzz_define_function ("s16vector-length", (zzz_prim_t) s16vector_length_func,
		       argv_1_0_0);
  zzz_define_function ("s16vector", (zzz_prim_t) s16vector_func, argv_0_0_1);
  zzz_define_function ("s16vector-ref", (zzz_prim_t) s16vector_ref_func,
		       argv_2_0_0);
  zzz_define_function ("s16vector-set!", (zzz_prim_t) s16vector_set_x_func,
		       argv_3_0_0);
  zzz_define_function ("s16vector->list", (zzz_prim_t) s16vector_to_list_func,
		       argv_1_0_0);
  zzz_define_function ("list->s16vector", (zzz_prim_t) list_to_s16vector_func,
		       argv_1_0_0);
  zzz_define_function ("s16vector-fill!", (zzz_prim_t) s16vector_fill_x_func,
		       argv_2_0_0);

  zzz_define_function ("u16vector?", (zzz_prim_t) u16vector_p_func,
		       argv_1_0_0);
  zzz_define_function ("make-u16vector", (zzz_prim_t) make_u16vector_func,
		       argv_1_1_0);
  zzz_define_function ("u16vector-length", (zzz_prim_t) u16vector_length_func,
		       argv_1_0_0);
  zzz_define_function ("u16vector", (zzz_prim_t) u16vector_func, argv_0_0_1);
  zzz_define_function ("u16vector-ref", (zzz_prim_t) u16vector_ref_func,
		       argv_2_0_0);
  zzz_define_function ("u16vector-set!", (zzz_prim_t) u16vector_set_x_func,
		       argv_3_0_0);
  zzz_define_function ("u16vector->list", (zzz_prim_t) u16vector_to_list_func,
		       argv_1_0_0);
  zzz_define_function ("list->u16vector", (zzz_prim_t) list_to_u16vector_func,
		       argv_1_0_0);
  zzz_define_function ("u16vector-fill!", (zzz_prim_t) u16vector_fill_x_func,
		       argv_2_0_0);

  zzz_define_function ("s32vector?", (zzz_prim_t) s32vector_p_func,
		       argv_1_0_0);
  zzz_define_function ("make-s32vector", (zzz_prim_t) make_s32vector_func,
		       argv_1_1_0);
  zzz_define_function ("s32vector-length", (zzz_prim_t) s32vector_length_func,
		       argv_1_0_0);
  zzz_define_function ("s32vector", (zzz_prim_t) s32vector_func, argv_0_0_1);
  zzz_define_function ("s32vector-ref", (zzz_prim_t) s32vector_ref_func,
		       argv_2_0_0);
  zzz_define_function ("s32vector-set!", (zzz_prim_t) s32vector_set_x_func,
		       argv_3_0_0);
  zzz_define_function ("s32vector->list", (zzz_prim_t) s32vector_to_list_func,
		       argv_1_0_0);
  zzz_define_function ("list->s32vector", (zzz_prim_t) list_to_s32vector_func,
		       argv_1_0_0);
  zzz_define_function ("s32vector-fill!", (zzz_prim_t) s32vector_fill_x_func,
		       argv_2_0_0);

  zzz_define_function ("u32vector?", (zzz_prim_t) u32vector_p_func,
		       argv_1_0_0);
  zzz_define_function ("make-u32vector", (zzz_prim_t) make_u32vector_func,
		       argv_1_1_0);
  zzz_define_function ("u32vector-length", (zzz_prim_t) u32vector_length_func,
		       argv_1_0_0);
  zzz_define_function ("u32vector", (zzz_prim_t) u32vector_func, argv_0_0_1);
  zzz_define_function ("u32vector-ref", (zzz_prim_t) u32vector_ref_func,
		       argv_2_0_0);
  zzz_define_function ("u32vector-set!", (zzz_prim_t) u32vector_set_x_func,
		       argv_3_0_0);
  zzz_define_function ("u32vector->list", (zzz_prim_t) u32vector_to_list_func,
		       argv_1_0_0);
  zzz_define_function ("list->u32vector", (zzz_prim_t) list_to_u32vector_func,
		       argv_1_0_0);
  zzz_define_function ("u32vector-fill!", (zzz_prim_t) u32vector_fill_x_func,
		       argv_2_0_0);
  zzz_define_function ("f32vector?", (zzz_prim_t) f32vector_p_func,
		       argv_1_0_0);
  zzz_define_function ("make-f32vector", (zzz_prim_t) make_f32vector_func,
		       argv_1_1_0);
  zzz_define_function ("f32vector-length", (zzz_prim_t) f32vector_length_func,
		       argv_1_0_0);
  zzz_define_function ("f32vector", (zzz_prim_t) f32vector_func, argv_0_0_1);
  zzz_define_function ("f32vector-ref", (zzz_prim_t) f32vector_ref_func,
		       argv_2_0_0);
  zzz_define_function ("f32vector-set!", (zzz_prim_t) f32vector_set_x_func,
		       argv_3_0_0);
  zzz_define_function ("f32vector->list", (zzz_prim_t) f32vector_to_list_func,
		       argv_1_0_0);
  zzz_define_function ("list->f32vector", (zzz_prim_t) list_to_f32vector_func,
		       argv_1_0_0);
  zzz_define_function ("f32vector-fill!", (zzz_prim_t) f32vector_fill_x_func,
		       argv_2_0_0);

  zzz_define_function ("f64vector?", (zzz_prim_t) f64vector_p_func,
		       argv_1_0_0);
  zzz_define_function ("make-f64vector", (zzz_prim_t) make_f64vector_func,
		       argv_1_1_0);
  zzz_define_function ("f64vector-length", (zzz_prim_t) f64vector_length_func,
		       argv_1_0_0);
  zzz_define_function ("f64vector", (zzz_prim_t) f64vector_func, argv_0_0_1);
  zzz_define_function ("f64vector-ref", (zzz_prim_t) f64vector_ref_func,
		       argv_2_0_0);
  zzz_define_function ("f64vector-set!", (zzz_prim_t) f64vector_set_x_func,
		       argv_3_0_0);
  zzz_define_function ("f64vector->list", (zzz_prim_t) f64vector_to_list_func,
		       argv_1_0_0);
  zzz_define_function ("list->f64vector", (zzz_prim_t) list_to_f64vector_func,
		       argv_1_0_0);
  zzz_define_function ("f64vector-fill!", (zzz_prim_t) f64vector_fill_x_func,
		       argv_2_0_0);

  zzz_define_function ("s8vector->string",
		       (zzz_prim_t) s8vector_to_string_func, argv_1_0_0);
  zzz_define_function ("string->s8vector",
		       (zzz_prim_t) string_to_s8vector_func, argv_1_0_0);
  zzz_define_function ("u8vector->string",
		       (zzz_prim_t) u8vector_to_string_func, argv_1_0_0);
  zzz_define_function ("string->u8vector",
		       (zzz_prim_t) string_to_u8vector_func, argv_1_0_0);

  /* Initialize the uniform vector procedures for 64-bit integers,
     which live in another module.  */
  zzz_init_uvector64 ();

  return RESULT_SUCCESS;
}

int zzz_config_have_uvector = 1;

#else /* !ENABLE_UVECTOR */

int zzz_config_have_uvector = 0;

#endif /* !ENABLE_UVECTOR */
