1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

* numbers.h, numbers.c, discouraged.h, discouraged.c (scm_short2num,

scm_ushort2num, scm_int2num, scm_uint2num, scm_long2num,
scm_ulong2num, scm_size2num, scm_ptrdiff2num, scm_num2short,
scm_num2ushort, scm_num2int, scm_num2uint, scm_num2long,
scm_num2ulong, scm_num2size, scm_num2ptrdiff, scm_long_long2num,
scm_ulong_long2num, scm_num2long_long, scm_num2ulong_long):
Discouraged by moving to discouraged.h and discouraged.c and
reimplementing in terms of scm_from_* and scm_to_*.  Changed all uses
to the new scm_from_* and scm_to_* functions.
This commit is contained in:
Marius Vollmer 2004-08-02 16:14:04 +00:00
parent 531bf3e6a8
commit b9bd8526f0
28 changed files with 232 additions and 221 deletions

View file

@ -238,7 +238,7 @@ SCM_DEFINE (scm_char_to_integer, "char->integer", 1, 0, 0,
#define FUNC_NAME s_scm_char_to_integer
{
SCM_VALIDATE_CHAR (1, chr);
return scm_ulong2num((unsigned long)SCM_CHAR(chr));
return scm_from_ulong (SCM_CHAR(chr));
}
#undef FUNC_NAME

View file

@ -32,7 +32,7 @@ SCM2CTYPES (SCM obj, CTYPE *data)
/* check big number ranges */
else if (SCM_BIGP (val))
{
scm_t_signed_bits v = scm_num2long (val, SCM_ARG1, FUNC_NAME);
scm_t_signed_bits v = scm_to_long (val);
CTYPE c = (CTYPE) v;
SCM_ASSERT_RANGE (SCM_ARG1, val, v != (scm_t_signed_bits) c);
}
@ -61,7 +61,7 @@ SCM2CTYPES (SCM obj, CTYPE *data)
if (SCM_I_INUMP (val))
data[i] = (CTYPE) SCM_I_INUM (val);
else if (SCM_BIGP (val))
data[i] = (CTYPE) scm_num2long (val, SCM_ARG1, FUNC_NAME);
data[i] = (CTYPE) scm_to_long (val);
#if defined (FLOATTYPE)
else
data[i] = (CTYPE) SCM_REAL_VALUE (val);
@ -92,7 +92,7 @@ SCM2CTYPES (SCM obj, CTYPE *data)
/* check big number ranges */
else if (SCM_BIGP (val))
{
scm_t_signed_bits v = scm_num2long (val, SCM_ARG1, FUNC_NAME);
scm_t_signed_bits v = scm_to_long (val);
CTYPE c = (CTYPE) v;
SCM_ASSERT_RANGE (SCM_ARG1, val, v != (scm_t_signed_bits) c);
}
@ -120,7 +120,7 @@ SCM2CTYPES (SCM obj, CTYPE *data)
if (SCM_I_INUMP (val))
data[i] = (CTYPE) SCM_I_INUM (val);
else if (SCM_BIGP (val))
data[i] = (CTYPE) scm_num2long (val, SCM_ARG1, FUNC_NAME);
data[i] = (CTYPE) scm_to_long (val);
#if defined (FLOATTYPE)
else
data[i] = (CTYPE) SCM_REAL_VALUE (val);
@ -194,7 +194,7 @@ CTYPES2UVECT (const CTYPE *data, long n)
char *v;
#endif
SCM_ASSERT_RANGE (SCM_ARG2, scm_long2num (n),
SCM_ASSERT_RANGE (SCM_ARG2, scm_from_long (n),
n > 0 && n <= SCM_UVECTOR_MAX_LENGTH);
#if SIZEOF_CTYPE != SIZEOF_UVECTTYPE
v = scm_gc_malloc (n * SIZEOF_UVECTTYPE, "uvect");
@ -220,7 +220,7 @@ CTYPES2UVECT_OPTIONAL (const unsigned CTYPE *data, long n)
char *v;
#endif
SCM_ASSERT_RANGE (SCM_ARG2, scm_long2num (n),
SCM_ASSERT_RANGE (SCM_ARG2, scm_from_long (n),
n > 0 && n <= SCM_UVECTOR_MAX_LENGTH);
#if SIZEOF_CTYPE != SIZEOF_UVECTTYPE
v = scm_gc_malloc (n * SIZEOF_UVECTTYPE, "uvect");
@ -247,7 +247,7 @@ CTYPES2SCM (const CTYPE *data, long n)
long i;
SCM v;
SCM_ASSERT_RANGE (SCM_ARG2, scm_long2num (n),
SCM_ASSERT_RANGE (SCM_ARG2, scm_from_long (n),
n > 0 && n <= SCM_VECTOR_MAX_LENGTH);
v = scm_c_make_vector (n, SCM_UNSPECIFIED);

View file

@ -217,8 +217,9 @@ SCM_DEFINE (scm_dynamic_func, "dynamic-func", 2, 0, 0,
char *chars;
chars = SCM_STRING_CHARS (name);
func = (void (*) ()) sysdep_dynl_func (chars, DYNL_HANDLE (dobj), FUNC_NAME);
return scm_ulong2num ((unsigned long) func);
func = (void (*) ()) sysdep_dynl_func (chars, DYNL_HANDLE (dobj),
FUNC_NAME);
return scm_from_ulong ((unsigned long) func);
}
}
#undef FUNC_NAME

View file

@ -480,7 +480,7 @@ observer_mark (SCM observer)
static int
observer_print (SCM type, SCM port, scm_print_state *pstate SCM_UNUSED)
{
SCM address = scm_ulong2num (SCM_UNPACK (type));
SCM address = scm_from_size_t (SCM_UNPACK (type));
SCM base16 = scm_number_to_string (address, scm_from_int (16));
scm_puts ("#<observer ", port);
@ -978,7 +978,7 @@ leaf_environment_free (SCM env)
static int
leaf_environment_print (SCM type, SCM port, scm_print_state *pstate SCM_UNUSED)
{
SCM address = scm_ulong2num (SCM_UNPACK (type));
SCM address = scm_from_size_t (SCM_UNPACK (type));
SCM base16 = scm_number_to_string (address, scm_from_int (16));
scm_puts ("#<leaf environment ", port);
@ -1220,7 +1220,7 @@ eval_environment_folder (SCM extended_data, SCM symbol, SCM value, SCM tail)
if (!SCM_ENVIRONMENT_BOUND_P (local, symbol))
{
SCM proc_as_nr = SCM_CADR (extended_data);
unsigned long int proc_as_ul = scm_num2ulong (proc_as_nr, 0, NULL);
unsigned long int proc_as_ul = scm_to_ulong (proc_as_nr);
scm_environment_folder proc = (scm_environment_folder) proc_as_ul;
SCM data = SCM_CDDR (extended_data);
@ -1238,7 +1238,7 @@ eval_environment_fold (SCM env, scm_environment_folder proc, SCM data, SCM init)
{
SCM local = EVAL_ENVIRONMENT (env)->local;
SCM imported = EVAL_ENVIRONMENT (env)->imported;
SCM proc_as_nr = scm_ulong2num ((unsigned long int) proc);
SCM proc_as_nr = scm_from_ulong ((unsigned long) proc);
SCM extended_data = scm_cons2 (local, proc_as_nr, data);
SCM tmp_result = scm_c_environment_fold (imported, eval_environment_folder, extended_data, init);
@ -1338,7 +1338,7 @@ eval_environment_free (SCM env)
static int
eval_environment_print (SCM type, SCM port, scm_print_state *pstate SCM_UNUSED)
{
SCM address = scm_ulong2num (SCM_UNPACK (type));
SCM address = scm_from_size_t (SCM_UNPACK (type));
SCM base16 = scm_number_to_string (address, scm_from_int (16));
scm_puts ("#<eval environment ", port);
@ -1625,7 +1625,7 @@ import_environment_folder (SCM extended_data, SCM symbol, SCM value, SCM tail)
SCM imported_env = SCM_CADR (extended_data);
SCM owner = import_environment_lookup (import_env, symbol);
SCM proc_as_nr = SCM_CADDR (extended_data);
unsigned long int proc_as_ul = scm_num2ulong (proc_as_nr, 0, NULL);
unsigned long int proc_as_ul = scm_to_ulong (proc_as_nr);
scm_environment_folder proc = (scm_environment_folder) proc_as_ul;
SCM data = SCM_CDDDR (extended_data);
@ -1643,7 +1643,7 @@ import_environment_folder (SCM extended_data, SCM symbol, SCM value, SCM tail)
static SCM
import_environment_fold (SCM env, scm_environment_folder proc, SCM data, SCM init)
{
SCM proc_as_nr = scm_ulong2num ((unsigned long int) proc);
SCM proc_as_nr = scm_from_ulong ((unsigned long) proc);
SCM result = init;
SCM l;
@ -1757,7 +1757,7 @@ static int
import_environment_print (SCM type, SCM port,
scm_print_state *pstate SCM_UNUSED)
{
SCM address = scm_ulong2num (SCM_UNPACK (type));
SCM address = scm_from_size_t (SCM_UNPACK (type));
SCM base16 = scm_number_to_string (address, scm_from_int (16));
scm_puts ("#<import environment ", port);
@ -2062,7 +2062,7 @@ static int
export_environment_print (SCM type, SCM port,
scm_print_state *pstate SCM_UNUSED)
{
SCM address = scm_ulong2num (SCM_UNPACK (type));
SCM address = scm_from_size_t (SCM_UNPACK (type));
SCM base16 = scm_number_to_string (address, scm_from_int (16));
scm_puts ("#<export environment ", port);

View file

@ -427,28 +427,28 @@ scm_stat2scm (struct stat *stat_temp)
{
SCM ans = scm_c_make_vector (15, SCM_UNSPECIFIED);
SCM_VECTOR_SET(ans, 0, scm_ulong2num ((unsigned long) stat_temp->st_dev));
SCM_VECTOR_SET(ans, 1, scm_ulong2num ((unsigned long) stat_temp->st_ino));
SCM_VECTOR_SET(ans, 2, scm_ulong2num ((unsigned long) stat_temp->st_mode));
SCM_VECTOR_SET(ans, 3, scm_ulong2num ((unsigned long) stat_temp->st_nlink));
SCM_VECTOR_SET(ans, 4, scm_ulong2num ((unsigned long) stat_temp->st_uid));
SCM_VECTOR_SET(ans, 5, scm_ulong2num ((unsigned long) stat_temp->st_gid));
SCM_VECTOR_SET(ans, 0, scm_from_ulong (stat_temp->st_dev));
SCM_VECTOR_SET(ans, 1, scm_from_ulong (stat_temp->st_ino));
SCM_VECTOR_SET(ans, 2, scm_from_ulong (stat_temp->st_mode));
SCM_VECTOR_SET(ans, 3, scm_from_ulong (stat_temp->st_nlink));
SCM_VECTOR_SET(ans, 4, scm_from_ulong (stat_temp->st_uid));
SCM_VECTOR_SET(ans, 5, scm_from_ulong (stat_temp->st_gid));
#ifdef HAVE_STRUCT_STAT_ST_RDEV
SCM_VECTOR_SET(ans, 6, scm_ulong2num ((unsigned long) stat_temp->st_rdev));
SCM_VECTOR_SET(ans, 6, scm_from_ulong (stat_temp->st_rdev));
#else
SCM_VECTOR_SET(ans, 6, SCM_BOOL_F);
#endif
SCM_VECTOR_SET(ans, 7, scm_ulong2num ((unsigned long) stat_temp->st_size));
SCM_VECTOR_SET(ans, 8, scm_ulong2num ((unsigned long) stat_temp->st_atime));
SCM_VECTOR_SET(ans, 9, scm_ulong2num ((unsigned long) stat_temp->st_mtime));
SCM_VECTOR_SET(ans, 10, scm_ulong2num ((unsigned long) stat_temp->st_ctime));
SCM_VECTOR_SET(ans, 7, scm_from_ulong (stat_temp->st_size));
SCM_VECTOR_SET(ans, 8, scm_from_ulong (stat_temp->st_atime));
SCM_VECTOR_SET(ans, 9, scm_from_ulong (stat_temp->st_mtime));
SCM_VECTOR_SET(ans, 10, scm_from_ulong (stat_temp->st_ctime));
#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
SCM_VECTOR_SET(ans, 11, scm_ulong2num ((unsigned long) stat_temp->st_blksize));
SCM_VECTOR_SET(ans, 11, scm_from_ulong (stat_temp->st_blksize));
#else
SCM_VECTOR_SET(ans, 11, scm_ulong2num (4096L));
SCM_VECTOR_SET(ans, 11, scm_from_ulong (4096L));
#endif
#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
SCM_VECTOR_SET(ans, 12, scm_ulong2num ((unsigned long) stat_temp->st_blocks));
SCM_VECTOR_SET(ans, 12, scm_from_ulong (stat_temp->st_blocks));
#else
SCM_VECTOR_SET(ans, 12, SCM_BOOL_F);
#endif
@ -1558,62 +1558,62 @@ scm_init_filesys ()
scm_dot_string = scm_permanent_object (scm_makfrom0str ("."));
#ifdef O_RDONLY
scm_c_define ("O_RDONLY", scm_long2num (O_RDONLY));
scm_c_define ("O_RDONLY", scm_from_long (O_RDONLY));
#endif
#ifdef O_WRONLY
scm_c_define ("O_WRONLY", scm_long2num (O_WRONLY));
scm_c_define ("O_WRONLY", scm_from_long (O_WRONLY));
#endif
#ifdef O_RDWR
scm_c_define ("O_RDWR", scm_long2num (O_RDWR));
scm_c_define ("O_RDWR", scm_from_long (O_RDWR));
#endif
#ifdef O_CREAT
scm_c_define ("O_CREAT", scm_long2num (O_CREAT));
scm_c_define ("O_CREAT", scm_from_long (O_CREAT));
#endif
#ifdef O_EXCL
scm_c_define ("O_EXCL", scm_long2num (O_EXCL));
scm_c_define ("O_EXCL", scm_from_long (O_EXCL));
#endif
#ifdef O_NOCTTY
scm_c_define ("O_NOCTTY", scm_long2num (O_NOCTTY));
scm_c_define ("O_NOCTTY", scm_from_long (O_NOCTTY));
#endif
#ifdef O_TRUNC
scm_c_define ("O_TRUNC", scm_long2num (O_TRUNC));
scm_c_define ("O_TRUNC", scm_from_long (O_TRUNC));
#endif
#ifdef O_APPEND
scm_c_define ("O_APPEND", scm_long2num (O_APPEND));
scm_c_define ("O_APPEND", scm_from_long (O_APPEND));
#endif
#ifdef O_NONBLOCK
scm_c_define ("O_NONBLOCK", scm_long2num (O_NONBLOCK));
scm_c_define ("O_NONBLOCK", scm_from_long (O_NONBLOCK));
#endif
#ifdef O_NDELAY
scm_c_define ("O_NDELAY", scm_long2num (O_NDELAY));
scm_c_define ("O_NDELAY", scm_from_long (O_NDELAY));
#endif
#ifdef O_SYNC
scm_c_define ("O_SYNC", scm_long2num (O_SYNC));
scm_c_define ("O_SYNC", scm_from_long (O_SYNC));
#endif
#ifdef F_DUPFD
scm_c_define ("F_DUPFD", scm_long2num (F_DUPFD));
scm_c_define ("F_DUPFD", scm_from_long (F_DUPFD));
#endif
#ifdef F_GETFD
scm_c_define ("F_GETFD", scm_long2num (F_GETFD));
scm_c_define ("F_GETFD", scm_from_long (F_GETFD));
#endif
#ifdef F_SETFD
scm_c_define ("F_SETFD", scm_long2num (F_SETFD));
scm_c_define ("F_SETFD", scm_from_long (F_SETFD));
#endif
#ifdef F_GETFL
scm_c_define ("F_GETFL", scm_long2num (F_GETFL));
scm_c_define ("F_GETFL", scm_from_long (F_GETFL));
#endif
#ifdef F_SETFL
scm_c_define ("F_SETFL", scm_long2num (F_SETFL));
scm_c_define ("F_SETFL", scm_from_long (F_SETFL));
#endif
#ifdef F_GETOWN
scm_c_define ("F_GETOWN", scm_long2num (F_GETOWN));
scm_c_define ("F_GETOWN", scm_from_long (F_GETOWN));
#endif
#ifdef F_SETOWN
scm_c_define ("F_SETOWN", scm_long2num (F_SETOWN));
scm_c_define ("F_SETOWN", scm_from_long (F_SETOWN));
#endif
#ifdef FD_CLOEXEC
scm_c_define ("FD_CLOEXEC", scm_long2num (FD_CLOEXEC));
scm_c_define ("FD_CLOEXEC", scm_from_long (FD_CLOEXEC));
#endif
#include "libguile/filesys.x"

View file

@ -105,7 +105,7 @@ scm_mark_all (void)
SCM l = SCM_HASHTABLE_BUCKETS (scm_gc_registered_roots)[i];
for (; !SCM_NULLP (l); l = SCM_CDR (l))
{
SCM *p = (SCM *) (scm_num2long (SCM_CAAR (l), 0, NULL));
SCM *p = (SCM *) (scm_to_ulong (SCM_CAAR (l)));
scm_gc_mark (*p);
}
}

View file

@ -340,25 +340,38 @@ SCM_DEFINE (scm_gc_stats, "gc-stats", 0, 0, 0,
for (i = table_size; i--;)
{
heap_segs = scm_cons (scm_cons (scm_ulong2num (bounds[2*i]),
scm_ulong2num (bounds[2*i+1])),
heap_segs = scm_cons (scm_cons (scm_from_ulong (bounds[2*i]),
scm_from_ulong (bounds[2*i+1])),
heap_segs);
}
answer = scm_list_n (scm_cons (sym_gc_time_taken, scm_ulong2num (local_scm_gc_time_taken)),
scm_cons (sym_cells_allocated, scm_ulong2num (local_scm_cells_allocated)),
scm_cons (sym_heap_size, scm_ulong2num (local_scm_heap_size)),
scm_cons (sym_mallocated, scm_ulong2num (local_scm_mallocated)),
scm_cons (sym_mtrigger, scm_ulong2num (local_scm_mtrigger)),
scm_cons (sym_times, scm_ulong2num (local_scm_gc_times)),
scm_cons (sym_gc_mark_time_taken, scm_ulong2num (local_scm_gc_mark_time_taken)),
scm_cons (sym_cells_marked, scm_i_dbl2big (local_scm_gc_cells_marked)),
scm_cons (sym_cells_swept, scm_i_dbl2big (local_scm_gc_cells_swept)),
scm_cons (sym_malloc_yield, scm_long2num (local_scm_gc_malloc_yield_percentage)),
scm_cons (sym_cell_yield, scm_long2num (local_scm_gc_cell_yield_percentage)),
scm_cons (sym_protected_objects, scm_ulong2num (local_protected_obj_count)),
scm_cons (sym_heap_segments, heap_segs),
SCM_UNDEFINED);
answer =
scm_list_n (scm_cons (sym_gc_time_taken,
scm_from_ulong (local_scm_gc_time_taken)),
scm_cons (sym_cells_allocated,
scm_from_ulong (local_scm_cells_allocated)),
scm_cons (sym_heap_size,
scm_from_ulong (local_scm_heap_size)),
scm_cons (sym_mallocated,
scm_from_ulong (local_scm_mallocated)),
scm_cons (sym_mtrigger,
scm_from_ulong (local_scm_mtrigger)),
scm_cons (sym_times,
scm_from_ulong (local_scm_gc_times)),
scm_cons (sym_gc_mark_time_taken,
scm_from_ulong (local_scm_gc_mark_time_taken)),
scm_cons (sym_cells_marked,
scm_from_double (local_scm_gc_cells_marked)),
scm_cons (sym_cells_swept,
scm_from_double (local_scm_gc_cells_swept)),
scm_cons (sym_malloc_yield,
scm_from_long(local_scm_gc_malloc_yield_percentage)),
scm_cons (sym_cell_yield,
scm_from_long (local_scm_gc_cell_yield_percentage)),
scm_cons (sym_protected_objects,
scm_from_ulong (local_protected_obj_count)),
scm_cons (sym_heap_segments, heap_segs),
SCM_UNDEFINED);
SCM_ALLOW_INTS;
free (bounds);
@ -406,7 +419,7 @@ SCM_DEFINE (scm_object_address, "object-address", 1, 0, 0,
"returned by this function for @var{obj}")
#define FUNC_NAME s_scm_object_address
{
return scm_ulong2num ((unsigned long) SCM_UNPACK (obj));
return scm_from_ulong (SCM_UNPACK (obj));
}
#undef FUNC_NAME
@ -762,7 +775,7 @@ void
scm_gc_register_root (SCM *p)
{
SCM handle;
SCM key = scm_long2num ((long) p);
SCM key = scm_from_ulong ((unsigned long) p);
/* This critical section barrier will be replaced by a mutex. */
SCM_REDEFER_INTS;
@ -778,7 +791,7 @@ void
scm_gc_unregister_root (SCM *p)
{
SCM handle;
SCM key = scm_long2num ((long) p);
SCM key = scm_from_ulong ((unsigned long) p);
/* This critical section barrier will be replaced by a mutex. */
SCM_REDEFER_INTS;

View file

@ -36,17 +36,17 @@ gh_bool2scm (int x)
SCM
gh_int2scm (int x)
{
return scm_long2num ((long) x);
return scm_from_long ((long) x);
}
SCM
gh_ulong2scm (unsigned long x)
{
return scm_ulong2num (x);
return scm_from_ulong (x);
}
SCM
gh_long2scm (long x)
{
return scm_long2num (x);
return scm_from_long (x);
}
SCM
gh_double2scm (double x)
@ -187,17 +187,17 @@ gh_scm2bool (SCM obj)
unsigned long
gh_scm2ulong (SCM obj)
{
return scm_num2ulong (obj, SCM_ARG1, "gh_scm2ulong");
return scm_to_ulong (obj);
}
long
gh_scm2long (SCM obj)
{
return scm_num2long (obj, SCM_ARG1, "gh_scm2long");
return scm_to_long (obj);
}
int
gh_scm2int (SCM obj)
{
return (int) scm_num2int (obj, SCM_ARG1, "gh_scm2int");
return scm_to_int (obj);
}
double
gh_scm2double (SCM obj)
@ -353,7 +353,7 @@ gh_scm2longs (SCM obj, long *m)
val = SCM_VELTS (obj)[i];
m[i] = SCM_I_INUMP (val)
? SCM_I_INUM (val)
: scm_num2long (val, 0, NULL);
: scm_to_long (val);
}
break;
#if SCM_HAVE_ARRAYS
@ -405,7 +405,7 @@ gh_scm2floats (SCM obj, float *m)
if (SCM_I_INUMP (val))
m[i] = SCM_I_INUM (val);
else if (SCM_BIGP (val))
m[i] = scm_num2long (val, 0, NULL);
m[i] = scm_to_long (val);
else
m[i] = SCM_REAL_VALUE (val);
}
@ -468,7 +468,7 @@ gh_scm2doubles (SCM obj, double *m)
if (SCM_I_INUMP (val))
m[i] = SCM_I_INUM (val);
else if (SCM_BIGP (val))
m[i] = scm_num2long (val, 0, NULL);
m[i] = scm_to_long (val);
else
m[i] = SCM_REAL_VALUE (val);
}

View file

@ -171,7 +171,7 @@ scm_i_rehash (SCM table,
handle = SCM_CAR (ls);
h = hash_fn (SCM_CAR (handle), new_size, closure);
if (h >= new_size)
scm_out_of_range (func_name, scm_ulong2num (h));
scm_out_of_range (func_name, scm_from_ulong (h));
SCM_VECTOR_SET (new_buckets, h,
scm_cons (handle, SCM_VELTS (new_buckets)[h]));
ls = SCM_CDR (ls);
@ -433,7 +433,7 @@ scm_hash_fn_get_handle (SCM table, SCM obj, unsigned long (*hash_fn)(), SCM (*as
return SCM_BOOL_F;
k = hash_fn (obj, SCM_VECTOR_LENGTH (table), closure);
if (k >= SCM_VECTOR_LENGTH (table))
scm_out_of_range ("hash_fn_get_handle", scm_ulong2num (k));
scm_out_of_range ("hash_fn_get_handle", scm_from_ulong (k));
h = assoc_fn (obj, SCM_VELTS (table)[k], closure);
return h;
}
@ -461,7 +461,7 @@ scm_hash_fn_create_handle_x (SCM table, SCM obj, SCM init, unsigned long (*hash_
k = hash_fn (obj, SCM_VECTOR_LENGTH (buckets), closure);
if (k >= SCM_VECTOR_LENGTH (buckets))
scm_out_of_range ("hash_fn_create_handle_x", scm_ulong2num (k));
scm_out_of_range ("hash_fn_create_handle_x", scm_from_ulong (k));
it = assoc_fn (obj, SCM_VELTS (buckets)[k], closure);
if (scm_is_true (it))
return it;
@ -530,7 +530,7 @@ scm_hash_fn_remove_x (SCM table, SCM obj, unsigned long (*hash_fn)(), SCM (*asso
k = hash_fn (obj, SCM_VECTOR_LENGTH (buckets), closure);
if (k >= SCM_VECTOR_LENGTH (buckets))
scm_out_of_range ("hash_fn_remove_x", scm_ulong2num (k));
scm_out_of_range ("hash_fn_remove_x", scm_from_ulong (k));
h = assoc_fn (obj, SCM_VELTS (buckets)[k], closure);
if (scm_is_true (h))
{
@ -772,9 +772,7 @@ typedef struct scm_t_ihashx_closure
static unsigned long
scm_ihashx (SCM obj, unsigned long n, scm_t_ihashx_closure *closure)
{
SCM answer = scm_call_2 (closure->hash,
obj,
scm_ulong2num ((unsigned long) n));
SCM answer = scm_call_2 (closure->hash, obj, scm_from_ulong (n));
return scm_to_ulong (answer);
}

View file

@ -182,7 +182,7 @@ SCM_DEFINE (scm_gethost, "gethost", 0, 1, 0,
while (i--)
{
inad = *(struct in_addr *) argv[i];
lst = scm_cons (scm_ulong2num (ntohl (inad.s_addr)), lst);
lst = scm_cons (scm_from_ulong (ntohl (inad.s_addr)), lst);
}
SCM_VECTOR_SET(result, 4, lst);
return result;

View file

@ -245,7 +245,7 @@ SCM_DEFINE (scm_getgroups, "getgroups", 0, 0, 0,
result = scm_c_make_vector (ngroups, SCM_BOOL_F);
while (--ngroups >= 0)
SCM_VECTOR_SET (result, ngroups, scm_ulong2num (groups[ngroups]));
SCM_VECTOR_SET (result, ngroups, scm_from_ulong (groups[ngroups]));
free (groups);
return result;
@ -332,8 +332,8 @@ SCM_DEFINE (scm_getpwuid, "getpw", 0, 1, 0,
SCM_VECTOR_SET(result, 0, scm_makfrom0str (entry->pw_name));
SCM_VECTOR_SET(result, 1, scm_makfrom0str (entry->pw_passwd));
SCM_VECTOR_SET(result, 2, scm_ulong2num ((unsigned long) entry->pw_uid));
SCM_VECTOR_SET(result, 3, scm_ulong2num ((unsigned long) entry->pw_gid));
SCM_VECTOR_SET(result, 2, scm_from_ulong (entry->pw_uid));
SCM_VECTOR_SET(result, 3, scm_from_ulong (entry->pw_gid));
SCM_VECTOR_SET(result, 4, scm_makfrom0str (entry->pw_gecos));
if (!entry->pw_dir)
SCM_VECTOR_SET(result, 5, scm_makfrom0str (""));
@ -399,7 +399,7 @@ SCM_DEFINE (scm_getgrgid, "getgr", 0, 1, 0,
SCM_VECTOR_SET(result, 0, scm_makfrom0str (entry->gr_name));
SCM_VECTOR_SET(result, 1, scm_makfrom0str (entry->gr_passwd));
SCM_VECTOR_SET(result, 2, scm_ulong2num ((unsigned long) entry->gr_gid));
SCM_VECTOR_SET(result, 2, scm_from_ulong (entry->gr_gid));
SCM_VECTOR_SET(result, 3, scm_makfromstrs (-1, entry->gr_mem));
return result;
}
@ -1910,7 +1910,7 @@ scm_init_posix ()
scm_c_define ("LC_ALL", scm_from_int (LC_ALL));
#endif
#ifdef PIPE_BUF
scm_c_define ("PIPE_BUF", scm_long2num (PIPE_BUF));
scm_c_define ("PIPE_BUF", scm_from_long (PIPE_BUF));
#endif
#ifdef PRIO_PROCESS

View file

@ -85,16 +85,16 @@ SCM_DEFINE (scm_read_delimited_x, "%read-delimited!", 3, 3, 0,
scm_ungetc (c, port);
return scm_cons (SCM_MAKE_CHAR (c),
scm_long2num (j - cstart));
scm_from_long (j - cstart));
}
}
if (c == EOF)
return scm_cons (SCM_EOF_VAL,
scm_long2num (j - cstart));
scm_from_long (j - cstart));
buf[j] = c;
}
return scm_cons (SCM_BOOL_F, scm_long2num (j - cstart));
return scm_cons (SCM_BOOL_F, scm_from_long (j - cstart));
}
#undef FUNC_NAME

View file

@ -88,8 +88,8 @@ scm_input_error(char const * function,
scm_simple_format (string_port,
scm_makfrom0str ("~A:~S:~S: ~A"),
scm_list_4 (scm_makfrom0str (fn),
scm_int2num (SCM_LINUM (port) + 1),
scm_int2num (SCM_COL (port) + 1),
scm_from_int (SCM_LINUM (port) + 1),
scm_from_int (SCM_COL (port) + 1),
scm_makfrom0str (message)));

View file

@ -257,10 +257,12 @@ SCM_DEFINE (scm_regexp_exec, "regexp-exec", 2, 2, 0,
SCM_VECTOR_SET(mvec,0, str);
for (i = 0; i < nmatches; ++i)
if (matches[i].rm_so == -1)
SCM_VECTOR_SET(mvec,i+1, scm_cons (scm_from_int (-1), scm_from_int (-1)));
SCM_VECTOR_SET(mvec, i+1,
scm_cons (scm_from_int (-1), scm_from_int (-1)));
else
SCM_VECTOR_SET(mvec,i+1,scm_cons (scm_long2num (matches[i].rm_so + offset),
scm_long2num (matches[i].rm_eo + offset)));
SCM_VECTOR_SET(mvec, i+1,
scm_cons (scm_from_long (matches[i].rm_so + offset),
scm_from_long (matches[i].rm_eo + offset)));
}
free (matches);
SCM_ALLOW_INTS;
@ -282,14 +284,14 @@ scm_init_regex_posix ()
scm_set_smob_free (scm_tc16_regex, regex_free);
/* Compilation flags. */
scm_c_define ("regexp/basic", scm_long2num (REG_BASIC));
scm_c_define ("regexp/extended", scm_long2num (REG_EXTENDED));
scm_c_define ("regexp/icase", scm_long2num (REG_ICASE));
scm_c_define ("regexp/newline", scm_long2num (REG_NEWLINE));
scm_c_define ("regexp/basic", scm_from_long (REG_BASIC));
scm_c_define ("regexp/extended", scm_from_long (REG_EXTENDED));
scm_c_define ("regexp/icase", scm_from_long (REG_ICASE));
scm_c_define ("regexp/newline", scm_from_long (REG_NEWLINE));
/* Execution flags. */
scm_c_define ("regexp/notbol", scm_long2num (REG_NOTBOL));
scm_c_define ("regexp/noteol", scm_long2num (REG_NOTEOL));
scm_c_define ("regexp/notbol", scm_from_long (REG_NOTBOL));
scm_c_define ("regexp/noteol", scm_from_long (REG_NOTEOL));
#include "libguile/regex-posix.x"

View file

@ -333,7 +333,7 @@ SCM_DEFINE (scm_dynamic_root, "dynamic-root", 0, 0, 0,
"in no way depend on this.")
#define FUNC_NAME s_scm_dynamic_root
{
return scm_ulong2num (SCM_SEQ (scm_root->rootcont));
return scm_from_ulong (SCM_SEQ (scm_root->rootcont));
}
#undef FUNC_NAME

View file

@ -147,7 +147,7 @@ SCM_DEFINE (scm_read_string_x_partial, "read-string!/partial", 1, 3, 0,
else if (chars_read == 0)
return SCM_BOOL_F;
}
return scm_long2num (chars_read);
return scm_from_long (chars_read);
}
#undef FUNC_NAME
@ -229,7 +229,7 @@ SCM_DEFINE (scm_write_string_partial, "write-string/partial", 1, 3, 0,
{
memcpy (pt->write_pos, src, write_len);
pt->write_pos += write_len;
return scm_long2num (write_len);
return scm_from_long (write_len);
}
if (pt->write_pos > pt->write_buf)
scm_flush (port);
@ -247,7 +247,7 @@ SCM_DEFINE (scm_write_string_partial, "write-string/partial", 1, 3, 0,
SCM_SYSERROR;
}
return scm_long2num (rv);
return scm_from_long (rv);
}
}
#undef FUNC_NAME

View file

@ -223,7 +223,7 @@ really_install_handler (void *data)
{
SCM_VECTOR_SET (*signal_handlers, signum, handler);
SCM_VECTOR_SET (signal_cell_handlers, signum,
close_1 (handler, scm_int2num (signum)));
close_1 (handler, scm_from_int (signum)));
}
/* Now fix up the cell. It might contain the old handler but since
@ -424,7 +424,7 @@ SCM_DEFINE (scm_sigaction_for_thread, "sigaction", 1, 3, 0,
orig_handlers[csig] = old_action;
}
if (old_action.sa_handler == SIG_DFL || old_action.sa_handler == SIG_IGN)
old_handler = scm_long2num ((long) old_action.sa_handler);
old_handler = scm_from_long ((long) old_action.sa_handler);
SCM_ALLOW_INTS;
return scm_cons (old_handler, scm_from_int (old_action.sa_flags));
#else
@ -443,7 +443,7 @@ SCM_DEFINE (scm_sigaction_for_thread, "sigaction", 1, 3, 0,
orig_handlers[csig] = old_chandler;
}
if (old_chandler == SIG_DFL || old_chandler == SIG_IGN)
old_handler = scm_long2num ((long) old_chandler);
old_handler = scm_from_long ((long) old_chandler);
SCM_ALLOW_INTS;
return scm_cons (old_handler, scm_from_int (0));
#endif
@ -536,10 +536,10 @@ SCM_DEFINE (scm_setitimer, "setitimer", 5, 0, 0,
if(rv != 0)
SCM_SYSERROR;
return scm_list_2(scm_cons(scm_long2num(old_timer.it_interval.tv_sec),
scm_long2num(old_timer.it_interval.tv_usec)),
scm_cons(scm_long2num(old_timer.it_value.tv_sec),
scm_long2num(old_timer.it_value.tv_usec)));
return scm_list_2 (scm_cons (scm_from_long (old_timer.it_interval.tv_sec),
scm_from_long (old_timer.it_interval.tv_usec)),
scm_cons (scm_from_long (old_timer.it_value.tv_sec),
scm_from_long (old_timer.it_value.tv_usec)));
}
#undef FUNC_NAME
#endif /* HAVE_SETITIMER */
@ -572,10 +572,10 @@ SCM_DEFINE (scm_getitimer, "getitimer", 1, 0, 0,
if(rv != 0)
SCM_SYSERROR;
return scm_list_2(scm_cons(scm_long2num(old_timer.it_interval.tv_sec),
scm_long2num(old_timer.it_interval.tv_usec)),
scm_cons(scm_long2num(old_timer.it_value.tv_sec),
scm_long2num(old_timer.it_value.tv_usec)));
return scm_list_2 (scm_cons (scm_from_long (old_timer.it_interval.tv_sec),
scm_from_long (old_timer.it_interval.tv_usec)),
scm_cons (scm_from_long (old_timer.it_value.tv_sec),
scm_from_long (old_timer.it_value.tv_usec)));
}
#undef FUNC_NAME
#endif /* HAVE_GETITIMER */
@ -676,14 +676,14 @@ scm_init_scmsigs ()
#endif
}
scm_c_define ("NSIG", scm_long2num (NSIG));
scm_c_define ("SIG_IGN", scm_long2num ((long) SIG_IGN));
scm_c_define ("SIG_DFL", scm_long2num ((long) SIG_DFL));
scm_c_define ("NSIG", scm_from_long (NSIG));
scm_c_define ("SIG_IGN", scm_from_long ((long) SIG_IGN));
scm_c_define ("SIG_DFL", scm_from_long ((long) SIG_DFL));
#ifdef SA_NOCLDSTOP
scm_c_define ("SA_NOCLDSTOP", scm_long2num (SA_NOCLDSTOP));
scm_c_define ("SA_NOCLDSTOP", scm_from_long (SA_NOCLDSTOP));
#endif
#ifdef SA_RESTART
scm_c_define ("SA_RESTART", scm_long2num (SA_RESTART));
scm_c_define ("SA_RESTART", scm_from_long (SA_RESTART));
#endif
#if defined(HAVE_SETITIMER) || defined(HAVE_GETITIMER)

View file

@ -545,7 +545,7 @@ scm_compile_shell_switches (int argc, char **argv)
num = strtol (p, &end, 10);
if (end - p > 0)
{
srfis = scm_cons (scm_long2num (num), srfis);
srfis = scm_cons (scm_from_long (num), srfis);
if (*end)
{
if (*end == ',')

View file

@ -151,9 +151,9 @@ SCM_DEFINE (scm_system_star, "system*", 0, 0, 1,
execargv = allocate_string_pointers (args);
/* make sure the child can't kill us (as per normal system call) */
sig_ign = scm_long2num ((long) SIG_IGN);
sigint = scm_long2num (SIGINT);
sigquit = scm_long2num (SIGQUIT);
sig_ign = scm_from_long ((unsigned long) SIG_IGN);
sigint = scm_from_long (SIGINT);
sigquit = scm_from_long (SIGQUIT);
oldint = scm_sigaction (sigint, sig_ign, SCM_UNDEFINED);
oldquit = scm_sigaction (sigquit, sig_ign, SCM_UNDEFINED);

View file

@ -103,7 +103,7 @@ SCM_DEFINE (scm_htonl, "htonl", 1, 0, 0,
{
scm_t_uint32 c_in = SCM_NUM2ULONG (1, value);
return scm_ulong2num (htonl (c_in));
return scm_from_ulong (htonl (c_in));
}
#undef FUNC_NAME
@ -116,7 +116,7 @@ SCM_DEFINE (scm_ntohl, "ntohl", 1, 0, 0,
{
scm_t_uint32 c_in = SCM_NUM2ULONG (1, value);
return scm_ulong2num (ntohl (c_in));
return scm_from_ulong (ntohl (c_in));
}
#undef FUNC_NAME
@ -139,7 +139,7 @@ SCM_DEFINE (scm_inet_aton, "inet-aton", 1, 0, 0,
SCM_VALIDATE_STRING (1, address);
if (inet_aton (SCM_STRING_CHARS (address), &soka) == 0)
SCM_MISC_ERROR ("bad address", SCM_EOL);
return scm_ulong2num (ntohl (soka.s_addr));
return scm_from_ulong (ntohl (soka.s_addr));
}
#undef FUNC_NAME
@ -175,7 +175,7 @@ SCM_DEFINE (scm_inet_netof, "inet-netof", 1, 0, 0,
{
struct in_addr addr;
addr.s_addr = htonl (SCM_NUM2ULONG (1, address));
return scm_ulong2num ((unsigned long) inet_netof (addr));
return scm_from_ulong (inet_netof (addr));
}
#undef FUNC_NAME
#endif
@ -193,7 +193,7 @@ SCM_DEFINE (scm_lnaof, "inet-lnaof", 1, 0, 0,
{
struct in_addr addr;
addr.s_addr = htonl (SCM_NUM2ULONG (1, address));
return scm_ulong2num ((unsigned long) inet_lnaof (addr));
return scm_from_ulong (inet_lnaof (addr));
}
#undef FUNC_NAME
#endif
@ -216,7 +216,7 @@ SCM_DEFINE (scm_inet_makeaddr, "inet-makeaddr", 2, 0, 0,
netnum = SCM_NUM2ULONG (1, net);
lnanum = SCM_NUM2ULONG (2, lna);
addr = inet_makeaddr (netnum, lnanum);
return scm_ulong2num (ntohl (addr.s_addr));
return scm_from_ulong (ntohl (addr.s_addr));
}
#undef FUNC_NAME
#endif
@ -299,7 +299,7 @@ scm_from_ipv6 (const scm_t_uint8 *src)
#else
memcpy (&x, addr, sizeof (x));
#endif
return scm_ulong_long2num (x);
return scm_from_ulong_long (x);
}
}
else
@ -315,7 +315,7 @@ scm_from_ipv6 (const scm_t_uint8 *src)
#else
memcpy (&x, addr, sizeof (x));
#endif
return scm_ulong2num (x);
return scm_from_ulong (x);
}
}
/* otherwise get the big hammer */
@ -408,7 +408,7 @@ SCM_DEFINE (scm_inet_pton, "inet-pton", 2, 0, 0,
else if (rv == 0)
SCM_MISC_ERROR ("Bad address", SCM_EOL);
if (af == AF_INET)
return scm_ulong2num (ntohl (*(scm_t_uint32 *) dst));
return scm_from_ulong (ntohl (*(scm_t_uint32 *) dst));
else
return scm_from_ipv6 ((char *) dst);
}
@ -546,10 +546,10 @@ SCM_DEFINE (scm_getsockopt, "getsockopt", 3, 0, 0,
#ifdef HAVE_STRUCT_LINGER
struct linger *ling = (struct linger *) optval;
return scm_cons (scm_long2num (ling->l_onoff),
scm_long2num (ling->l_linger));
return scm_cons (scm_from_long (ling->l_onoff),
scm_from_long (ling->l_linger));
#else
return scm_cons (scm_long2num (*(int *) optval),
return scm_cons (scm_from_long (*(int *) optval),
scm_from_int (0));
#endif
}
@ -564,10 +564,10 @@ SCM_DEFINE (scm_getsockopt, "getsockopt", 3, 0, 0,
#endif
)
{
return scm_long2num (*(size_t *) optval);
return scm_from_size_t (*(size_t *) optval);
}
}
return scm_long2num (*(int *) optval);
return scm_from_int (*(int *) optval);
}
#undef FUNC_NAME
@ -949,9 +949,12 @@ scm_addr_vector (const struct sockaddr *address, int addr_size,
result = scm_c_make_vector (3, SCM_UNSPECIFIED);
SCM_VECTOR_SET(result, 0, scm_ulong2num ((unsigned long) fam));
SCM_VECTOR_SET(result, 1, scm_ulong2num (ntohl (nad->sin_addr.s_addr)));
SCM_VECTOR_SET(result, 2, scm_ulong2num ((unsigned long) ntohs (nad->sin_port)));
SCM_VECTOR_SET(result, 0,
scm_from_short (fam));
SCM_VECTOR_SET(result, 1,
scm_from_ulong (ntohl (nad->sin_addr.s_addr)));
SCM_VECTOR_SET(result, 2,
scm_from_ushort (ntohs (nad->sin_port)));
}
break;
#ifdef HAVE_IPV6
@ -960,12 +963,12 @@ scm_addr_vector (const struct sockaddr *address, int addr_size,
const struct sockaddr_in6 *nad = (struct sockaddr_in6 *) address;
result = scm_c_make_vector (5, SCM_UNSPECIFIED);
SCM_VECTOR_SET(result, 0, scm_ulong2num ((unsigned long) fam));
SCM_VECTOR_SET(result, 0, scm_from_short (fam));
SCM_VECTOR_SET(result, 1, scm_from_ipv6 (nad->sin6_addr.s6_addr));
SCM_VECTOR_SET(result, 2, scm_ulong2num ((unsigned long) ntohs (nad->sin6_port)));
SCM_VECTOR_SET(result, 3, scm_ulong2num ((unsigned long) nad->sin6_flowinfo));
SCM_VECTOR_SET(result, 2, scm_from_ushort (ntohs (nad->sin6_port)));
SCM_VECTOR_SET(result, 3, scm_from_uint32 (nad->sin6_flowinfo));
#ifdef HAVE_SIN6_SCOPE_ID
SCM_VECTOR_SET(result, 4, scm_ulong2num ((unsigned long) nad->sin6_scope_id));
SCM_VECTOR_SET(result, 4, scm_from_ulong (nad->sin6_scope_id));
#else
SCM_VECTOR_SET(result, 4, SCM_INUM0);
#endif
@ -979,7 +982,7 @@ scm_addr_vector (const struct sockaddr *address, int addr_size,
result = scm_c_make_vector (2, SCM_UNSPECIFIED);
SCM_VECTOR_SET(result, 0, scm_ulong2num ((unsigned long) fam));
SCM_VECTOR_SET(result, 0, scm_from_short (fam));
/* When addr_size is not enough to cover sun_path, do not try
to access it. */
if (addr_size <= offsetof (struct sockaddr_un, sun_path))
@ -1321,16 +1324,16 @@ scm_init_socket ()
/* standard addresses. */
#ifdef INADDR_ANY
scm_c_define ("INADDR_ANY", scm_ulong2num (INADDR_ANY));
scm_c_define ("INADDR_ANY", scm_from_ulong (INADDR_ANY));
#endif
#ifdef INADDR_BROADCAST
scm_c_define ("INADDR_BROADCAST", scm_ulong2num (INADDR_BROADCAST));
scm_c_define ("INADDR_BROADCAST", scm_from_ulong (INADDR_BROADCAST));
#endif
#ifdef INADDR_NONE
scm_c_define ("INADDR_NONE", scm_ulong2num (INADDR_NONE));
scm_c_define ("INADDR_NONE", scm_from_ulong (INADDR_NONE));
#endif
#ifdef INADDR_LOOPBACK
scm_c_define ("INADDR_LOOPBACK", scm_ulong2num (INADDR_LOOPBACK));
scm_c_define ("INADDR_LOOPBACK", scm_from_ulong (INADDR_LOOPBACK));
#endif
/* socket types. */

View file

@ -122,14 +122,16 @@ SCM_DEFINE (scm_get_internal_real_time, "get-internal-real-time", 0, 0, 0,
SCM tmp;
ftime (&time_buffer);
time_buffer.time -= scm_your_base.time;
tmp = scm_long2num (time_buffer.millitm - scm_your_base.millitm);
tmp = scm_from_long (time_buffer.millitm - scm_your_base.millitm);
tmp = scm_sum (tmp,
scm_product (scm_from_int (1000),
scm_from_int (time_buffer.time)));
return scm_quotient (scm_product (tmp, SCM_I_MAKINUM (SCM_TIME_UNITS_PER_SECOND)),
return scm_quotient (scm_product (tmp,
scm_from_int (SCM_TIME_UNITS_PER_SECOND)),
scm_from_int (1000));
#else
return scm_long2num((time((timet*)0) - scm_your_base) * (int)SCM_TIME_UNITS_PER_SECOND);
return scm_from_long ((time((timet*)0) - scm_your_base)
* (int)SCM_TIME_UNITS_PER_SECOND);
#endif /* HAVE_FTIME */
}
#undef FUNC_NAME
@ -168,11 +170,11 @@ SCM_DEFINE (scm_times, "times", 0, 0, 0,
rv = times (&t);
if (rv == -1)
SCM_SYSERROR;
SCM_VECTOR_SET (result, 0, scm_long2num (rv));
SCM_VECTOR_SET (result, 1, scm_long2num (t.tms_utime));
SCM_VECTOR_SET (result, 2, scm_long2num (t.tms_stime));
SCM_VECTOR_SET (result ,3, scm_long2num (t.tms_cutime));
SCM_VECTOR_SET (result, 4, scm_long2num (t.tms_cstime));
SCM_VECTOR_SET (result, 0, scm_from_long (rv));
SCM_VECTOR_SET (result, 1, scm_from_long (t.tms_utime));
SCM_VECTOR_SET (result, 2, scm_from_long (t.tms_stime));
SCM_VECTOR_SET (result ,3, scm_from_long (t.tms_cutime));
SCM_VECTOR_SET (result, 4, scm_from_long (t.tms_cstime));
return result;
}
#undef FUNC_NAME
@ -193,7 +195,7 @@ SCM_DEFINE (scm_get_internal_run_time, "get-internal-run-time", 0, 0, 0,
"included but subprocesses are not.")
#define FUNC_NAME s_scm_get_internal_run_time
{
return scm_long2num (scm_c_get_internal_run_time ());
return scm_from_long (scm_c_get_internal_run_time ());
}
#undef FUNC_NAME
@ -216,7 +218,7 @@ SCM_DEFINE (scm_current_time, "current-time", 0, 0, 0,
if ((timv = time (0)) == -1)
SCM_MISC_ERROR ("current time not available", SCM_EOL);
SCM_ALLOW_INTS;
return scm_long2num((long) timv);
return scm_from_long (timv);
}
#undef FUNC_NAME
@ -235,14 +237,14 @@ SCM_DEFINE (scm_gettimeofday, "gettimeofday", 0, 0, 0,
if (gettimeofday (&time, NULL) == -1)
SCM_SYSERROR;
SCM_ALLOW_INTS;
return scm_cons (scm_long2num ((long) time.tv_sec),
scm_long2num ((long) time.tv_usec));
return scm_cons (scm_from_long (time.tv_sec),
scm_from_long (time.tv_usec));
#else
# ifdef HAVE_FTIME
struct timeb time;
ftime(&time);
return scm_cons (scm_long2num ((long) time.time),
return scm_cons (scm_from_long (time.time),
scm_from_int (time.millitm * 1000));
# else
timet timv;
@ -251,7 +253,7 @@ SCM_DEFINE (scm_gettimeofday, "gettimeofday", 0, 0, 0,
if ((timv = time (0)) == -1)
SCM_SYSERROR;
SCM_ALLOW_INTS;
return scm_cons (scm_long2num (timv), scm_from_int (0));
return scm_cons (scm_from_long (timv), scm_from_int (0));
# endif
#endif
}
@ -549,7 +551,7 @@ SCM_DEFINE (scm_mktime, "mktime", 1, 1, 0,
else if (utc->tm_yday > lt.tm_yday)
zoff += 24 * 60 * 60;
result = scm_cons (scm_long2num ((long) itime),
result = scm_cons (scm_from_long (itime),
filltime (&lt, zoff, zname));
SCM_ALLOW_INTS;
if (zname)
@ -727,7 +729,7 @@ void
scm_init_stime()
{
scm_c_define ("internal-time-units-per-second",
scm_long2num((long) SCM_TIME_UNITS_PER_SECOND));
scm_from_long (SCM_TIME_UNITS_PER_SECOND));
#ifdef HAVE_FTIME
if (!scm_your_base.time) ftime(&scm_your_base);

View file

@ -106,7 +106,7 @@ scm_take_str (char *s, size_t len)
{
SCM answer;
SCM_ASSERT_RANGE (2, scm_ulong2num (len), len <= SCM_STRING_MAX_LENGTH);
SCM_ASSERT_RANGE (2, scm_from_ulong (len), len <= SCM_STRING_MAX_LENGTH);
answer = scm_cell (SCM_MAKE_STRING_TAG (len), (scm_t_bits) s);
scm_gc_register_collectable_memory (s, len+1, "string");
@ -163,7 +163,7 @@ scm_allocate_string (size_t len)
char *mem;
SCM s;
SCM_ASSERT_RANGE (1, scm_long2num (len), len <= SCM_STRING_MAX_LENGTH);
SCM_ASSERT_RANGE (1, scm_from_size_t (len), len <= SCM_STRING_MAX_LENGTH);
mem = (char *) scm_gc_malloc (len + 1, "string");
mem[len] = 0;

View file

@ -163,7 +163,7 @@ scm_struct_init (SCM handle, SCM layout, scm_t_bits * mem, int tail_elts, SCM in
*mem = 0;
else
{
*mem = scm_num2long (SCM_CAR (inits), SCM_ARGn, "scm_struct_init");
*mem = scm_to_long (SCM_CAR (inits));
inits = SCM_CDR (inits);
}
break;
@ -174,9 +174,7 @@ scm_struct_init (SCM handle, SCM layout, scm_t_bits * mem, int tail_elts, SCM in
*mem = 0;
else
{
*mem = scm_num2ulong (SCM_CAR (inits),
SCM_ARGn,
"scm_struct_init");
*mem = scm_to_ulong (SCM_CAR (inits));
inits = SCM_CDR (inits);
}
break;
@ -577,12 +575,12 @@ SCM_DEFINE (scm_struct_ref, "struct-ref", 2, 0, 0,
switch (field_type)
{
case 'u':
answer = scm_ulong2num (data[p]);
answer = scm_from_ulong (data[p]);
break;
#if 0
case 'i':
answer = scm_long2num (data[p]);
answer = scm_from_long (data[p]);
break;
case 'd':
@ -694,7 +692,7 @@ SCM_DEFINE (scm_struct_vtable_tag, "struct-vtable-tag", 1, 0, 0,
#define FUNC_NAME s_scm_struct_vtable_tag
{
SCM_VALIDATE_VTABLE (1, handle);
return scm_long2num ((long) SCM_STRUCT_DATA (handle) >> 3);
return scm_from_ulong (((unsigned long)SCM_STRUCT_DATA (handle)) >> 3);
}
#undef FUNC_NAME

View file

@ -315,7 +315,7 @@ SCM_DEFINE (scm_symbol_hash, "symbol-hash", 1, 0, 0,
#define FUNC_NAME s_scm_symbol_hash
{
SCM_VALIDATE_SYMBOL (1, symbol);
return scm_ulong2num (SCM_SYMBOL_HASH (symbol));
return scm_from_ulong (SCM_SYMBOL_HASH (symbol));
}
#undef FUNC_NAME

View file

@ -141,7 +141,7 @@ static SCM
make_uve (long type, long k, size_t size)
#define FUNC_NAME "scm_make_uve"
{
SCM_ASSERT_RANGE (1, scm_long2num (k), k <= SCM_UVECTOR_MAX_LENGTH);
SCM_ASSERT_RANGE (1, scm_from_long (k), k <= SCM_UVECTOR_MAX_LENGTH);
return scm_cell (SCM_MAKE_UVECTOR_TAG (k, type),
(scm_t_bits) scm_gc_malloc (k * size, "vector"));
@ -157,8 +157,8 @@ scm_make_uve (long k, SCM prot)
if (k > 0)
{
long i;
SCM_ASSERT_RANGE (1,
scm_long2num (k), k <= SCM_BITVECTOR_MAX_LENGTH);
SCM_ASSERT_RANGE (1, scm_from_long (k),
k <= SCM_BITVECTOR_MAX_LENGTH);
i = sizeof (long) * ((k + SCM_LONG_BIT - 1) / SCM_LONG_BIT);
return scm_cell (SCM_MAKE_BITVECTOR_TAG (k),
(scm_t_bits) scm_gc_malloc (i, "vector"));
@ -1277,21 +1277,17 @@ SCM_DEFINE (scm_array_set_x, "array-set!", 2, 0, 1,
((char *) SCM_UVECTOR_BASE (v))[pos] = scm_to_char (obj);
break;
case scm_tc7_uvect:
((unsigned long *) SCM_UVECTOR_BASE (v))[pos]
= scm_num2ulong (obj, SCM_ARG2, FUNC_NAME);
((unsigned long *) SCM_UVECTOR_BASE (v))[pos] = scm_to_ulong (obj);
break;
case scm_tc7_ivect:
((long *) SCM_UVECTOR_BASE (v))[pos]
= scm_num2long (obj, SCM_ARG2, FUNC_NAME);
((long *) SCM_UVECTOR_BASE (v))[pos] = scm_to_long (obj);
break;
case scm_tc7_svect:
((short *) SCM_UVECTOR_BASE (v))[pos]
= scm_num2short (obj, SCM_ARG2, FUNC_NAME);
((short *) SCM_UVECTOR_BASE (v))[pos] = scm_to_short (obj);
break;
#if SCM_SIZEOF_LONG_LONG != 0
case scm_tc7_llvect:
((long long *) SCM_UVECTOR_BASE (v))[pos]
= scm_num2long_long (obj, SCM_ARG2, FUNC_NAME);
((long long *) SCM_UVECTOR_BASE (v))[pos] = scm_to_long_long (obj);
break;
#endif
case scm_tc7_fvect:
@ -2137,7 +2133,7 @@ SCM_DEFINE (scm_array_to_list, "array->list", 1, 0, 0,
{
short *data = (short *)SCM_VELTS(v);
for (k = SCM_UVECTOR_LENGTH(v) - 1; k >= 0; k--)
res = scm_cons(scm_short2num (data[k]), res);
res = scm_cons (scm_from_short (data[k]), res);
return res;
}
#if SCM_SIZEOF_LONG_LONG != 0
@ -2145,7 +2141,7 @@ SCM_DEFINE (scm_array_to_list, "array->list", 1, 0, 0,
{
long long *data = (long long *)SCM_VELTS(v);
for (k = SCM_UVECTOR_LENGTH(v) - 1; k >= 0; k--)
res = scm_cons(scm_long_long2num(data[k]), res);
res = scm_cons(scm_from_long_long (data[k]), res);
return res;
}
#endif

View file

@ -40,57 +40,55 @@
#define SCM_WRONG_TYPE_ARG(pos, obj) \
do { scm_wrong_type_arg (FUNC_NAME, pos, obj); } while (0)
#define SCM_NUM2SIZE(pos, arg) (scm_num2size (arg, pos, FUNC_NAME))
#define SCM_NUM2SIZE(pos, arg) (scm_to_size_t (arg))
#define SCM_NUM2SIZE_DEF(pos, arg, def) \
(SCM_UNBNDP (arg) ? def : scm_num2size (arg, pos, FUNC_NAME))
(SCM_UNBNDP (arg) ? def : scm_to_size_t (arg))
#define SCM_NUM2PTRDIFF(pos, arg) (scm_num2ptrdiff (arg, pos, FUNC_NAME))
#define SCM_NUM2PTRDIFF(pos, arg) (scm_to_ssize_t (arg))
#define SCM_NUM2PTRDIFF_DEF(pos, arg, def) \
(SCM_UNBNDP (arg) ? def : scm_num2ptrdiff (arg, pos, FUNC_NAME))
(SCM_UNBNDP (arg) ? def : scm_to_ssize_t (arg))
#define SCM_NUM2SHORT(pos, arg) (scm_num2short (arg, pos, FUNC_NAME))
#define SCM_NUM2SHORT(pos, arg) (scm_to_short (arg))
#define SCM_NUM2SHORT_DEF(pos, arg, def) \
(SCM_UNBNDP (arg) ? def : scm_num2short (arg, pos, FUNC_NAME))
(SCM_UNBNDP (arg) ? def : scm_to_short (arg))
#define SCM_NUM2USHORT(pos, arg) (scm_num2ushort (arg, pos, FUNC_NAME))
#define SCM_NUM2USHORT(pos, arg) (scm_to_ushort (arg))
#define SCM_NUM2USHORT_DEF(pos, arg, def) \
(SCM_UNBNDP (arg) ? def : scm_num2ushort (arg, pos, FUNC_NAME))
(SCM_UNBNDP (arg) ? def : scm_to_ushort (arg))
#define SCM_NUM2INT(pos, arg) (scm_num2int (arg, pos, FUNC_NAME))
#define SCM_NUM2INT(pos, arg) (scm_to_int (arg))
#define SCM_NUM2INT_DEF(pos, arg, def) \
(SCM_UNBNDP (arg) ? def : scm_num2int (arg, pos, FUNC_NAME))
(SCM_UNBNDP (arg) ? def : scm_to_int (arg))
#define SCM_NUM2UINT(pos, arg) (scm_num2uint (arg, pos, FUNC_NAME))
#define SCM_NUM2UINT(pos, arg) (scm_to_uint (arg))
#define SCM_NUM2UINT_DEF(pos, arg, def) \
(SCM_UNBNDP (arg) ? def : scm_num2uint (arg, pos, FUNC_NAME))
(SCM_UNBNDP (arg) ? def : scm_to_uint (arg))
#define SCM_NUM2ULONG(pos, arg) (scm_num2ulong (arg, pos, FUNC_NAME))
#define SCM_NUM2ULONG(pos, arg) (scm_to_ulong (arg))
#define SCM_NUM2ULONG_DEF(pos, arg, def) \
(SCM_UNBNDP (arg) ? def : scm_num2ulong (arg, pos, FUNC_NAME))
(SCM_UNBNDP (arg) ? def : scm_to_ulong (arg))
#define SCM_NUM2LONG(pos, arg) (scm_num2long (arg, pos, FUNC_NAME))
#define SCM_NUM2LONG(pos, arg) (scm_to_long (arg))
#define SCM_NUM2LONG_DEF(pos, arg, def) \
(SCM_UNBNDP (arg) ? def : scm_num2long (arg, pos, FUNC_NAME))
(SCM_UNBNDP (arg) ? def : scm_to_long (arg))
#define SCM_NUM2LONG_LONG(pos, arg) \
(scm_num2long_long (arg, pos, FUNC_NAME))
#define SCM_NUM2LONG_LONG(pos, arg) (scm_to_long_long (arg))
#define SCM_NUM2LONG_LONG_DEF(pos, arg, def) \
(SCM_UNBNDP (arg) ? def : scm_num2long_long (arg, pos, FUNC_NAME))
(SCM_UNBNDP (arg) ? def : scm_to_long_long (arg))
#define SCM_NUM2ULONG_LONG(pos, arg) \
(scm_num2ulong_long (arg, pos, FUNC_NAME))
#define SCM_NUM2ULONG_LONG(pos, arg) (scm_to_ulong_long (arg))
#define SCM_NUM2ULONG_LONG_DEF(pos, arg, def) \
(SCM_UNBNDP (arg) ? def : scm_num2ulong_long (arg, pos, FUNC_NAME))
(SCM_UNBNDP (arg) ? def : scm_to_ulong_long (arg))
#define SCM_NUM2FLOAT(pos, arg) \
(scm_num2float (arg, pos, FUNC_NAME))

View file

@ -184,7 +184,7 @@ scm_c_make_vector (unsigned long int k, SCM fill)
{
unsigned long int j;
SCM_ASSERT_RANGE (1, scm_ulong2num (k), k <= SCM_VECTOR_MAX_LENGTH);
SCM_ASSERT_RANGE (1, scm_from_ulong (k), k <= SCM_VECTOR_MAX_LENGTH);
base = scm_gc_malloc (k * sizeof (scm_t_bits), "vector");
for (j = 0; j != k; ++j)

View file

@ -126,7 +126,7 @@ sf_input_waiting (SCM port)
{
SCM f = SCM_VELTS (p)[5];
if (scm_is_true (f))
return scm_num2int (scm_call_0 (f), SCM_ARGn, NULL);
return scm_to_int (scm_call_0 (f));
}
/* Default is such that char-ready? for soft ports returns #t, as it
did before this extension was implemented. */