1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-01 12:20:26 +02:00
Commit graph

399 commits

Author SHA1 Message Date
Kevin Ryde
f9811f9f2e (scm_lognot): Rewrite using ~ and mpz_com, for directness
and to have non-integer types rejected as per other logical funcs.
2003-08-30 00:04:42 +00:00
Kevin Ryde
708f22c6af (scm_difference): Correction to bignum - negative inum. 2003-08-22 01:17:48 +00:00
Marius Vollmer
570b6821e3 * __scm.h (SCM_C_INLINE_KEYWORD): New.
* numbers.c: Use it in place of SCM_C_INLINE so that the code
compiles when SCM_C_INLINE is undefined.
2003-07-27 13:34:32 +00:00
Kevin Ryde
c8ae173e8a (scm_angle): Use scm_flo0 for non-negative inum, bignum and real. 2003-07-24 01:03:40 +00:00
Kevin Ryde
7650633547 (scm_product): In complex * bignum, correction to
REAL/IMAG fetch, x is the complex, not y.
2003-07-17 23:38:34 +00:00
Mikael Djurfeldt
0aacf84ee6 (scm_odd_p, scm_even_p): Bugfix: Treat result of
scm_inf_p test as Scheme values.
(scm_sum): Bugfix: Normalize bignum created from a negative bignum
and a positive inum.
Use GNU indentation style.
2003-07-13 16:13:57 +00:00
Kevin Ryde
6efadd7cb6 (scm_make_polar): Use sincos, when available.
(scm_magnitude): Use hypot.
2003-07-08 00:27:03 +00:00
Kevin Ryde
fa60559018 (_GNU_SOURCE): #define, to get C99 things.
(scm_asinh, scm_acosh, scm_atanh, scm_truncate, $asinh, $acosh,
$atanh, truncate): Use C library asinh, acosh, atanh and trunc, when
available.
(scm_inexact_to_exact): Expand isfinite to its definition !isinf.
(isfinite): Remove, conflicts with C99 isfinite().
2003-06-21 00:12:51 +00:00
Kevin Ryde
e06beeadda (scm_max, scm_min): For inum, bignum and real, if other
operand is NaN, then return NaN.  Also avoid passing NaN to mpz_cmp_d.
2003-06-04 16:09:38 +00:00
Dirk Herrmann
14b18ed6f5 This set of patches separates the representation of the cxr family
of functions (car, cdr etc.) from the dsubr family of functions
	(i. e. functions that take a double precision floating point
	argument).  Further, the algorithm for handling the cxr function
	is improved.

	* eval.c (SCM_CEVAL, SCM_APPLY, scm_trampoline_1), numbers.c
	(scm_asinh, scm_acosh, scm_atanh, scm_truncate, scm_round, floor,
	ceil, sqrt, fabs, exp, log, sin, cos, tan, asin, acos, atan, sinh,
	cosh, tanh), objects.c (scm_class_of), procprop.c
	(scm_i_procedure_arity), ramap.c (scm_array_map_x), tags.h
	(scm_tc7_dsubr, scm_tcs_subrs): Introduce scm_tc7_dsubr as new
	typecode for the dsubr family of functions.

	* ramap.c (ramap_cxr, ramap_dsubr): Renamed ramap_cxr to
	ramap_dsubr.

	* eval.c (SCM_CEVAL, SCM_APPLY, call_cxr_1), pairs.c
	(scm_init_pairs): Make use of the (now usable) second cell element
	of a scm_tc7_cxr function to implement the cxr family of functions
	more efficiently.
2003-06-01 13:58:42 +00:00
Kevin Ryde
713a425913 (z_negative_one): New variable.
(scm_init_numbers): Initialize it.
(scm_logcount): Use it and mpz_hamdist to count zeros for negatives.
2003-05-30 00:23:11 +00:00
Kevin Ryde
b127c712ea (xmpz_cmp_d): New macro, handling infs if gmp doesn't.
(scm_num_eq_p, scm_less_p, scm_max, scm_min): Use it.
2003-05-12 23:16:43 +00:00
Kevin Ryde
8c5b0afcbf (scm_gcd): In bignum/inum, don't pass yy==0 to mpz_gcd_ui
since we're only using the ulong return value, and x might not fit.
2003-05-10 00:20:05 +00:00
Kevin Ryde
2c57607ca8 (scm_integer_length): On negative bignums, adjust
mpz_sizeinbase to account for it looking at absolute value where we
want ones-complement.
2003-05-10 00:05:51 +00:00
Kevin Ryde
2b031f4f65 (scm_num_eq_p, scm_less_p): Don't pass NaN to mpz_cmp_d. 2003-05-09 23:14:35 +00:00
Kevin Ryde
c78b590e56 (scm_logcount): Use mpz_com, not mpz_neg. 2003-05-05 23:01:30 +00:00
Kevin Ryde
9c4443d38c (scm_difference): In inum - bignum, handle negative inum. 2003-05-05 22:55:46 +00:00
Marius Vollmer
9dd023e147 Doc fix for the usage of num2intergral. 2003-05-03 23:19:51 +00:00
Dirk Herrmann
aec16f9972 * numbers.c (scm_logtest): Fixed argument bug in the call to
mpz_and, which showed up when compiling with SCM_DEBUG defined.
2003-04-20 08:55:50 +00:00
Rob Browning
1c35cb199f * numbers.c (scm_integer_expt): fix case where we were declaring
vars in the middle of a statement block.  Thanks to Thamer
Al-Harbash.
2003-04-17 22:15:37 +00:00
Rob Browning
b4fb7de868 * numbers.c (PTRDIFF_MIN): use SCM_CHAR_BIT. 2003-04-16 19:44:02 +00:00
Rob Browning
876173478e *** empty log message *** 2003-04-07 17:36:17 +00:00
Marius Vollmer
73be1d9e8e Changed license terms to the plain LGPL thru-out. 2003-04-05 19:15:35 +00:00
Rob Browning
ca46fb9018 * numbers.c: rewrite *many* functions to handle GMP bignums. 2003-04-04 21:49:44 +00:00
Rob Browning
ee33d62a8d * numbers.c: #include <config.h> if HAVE_CONFIG_H. Replace usage
of HAVE_LONG_LONGS with "SCM_SIZEOF_LONG_LONG != 0".  Replace
usage of ptrdiff_t with scm_t_ptrdiff.  Replace usage of
SIZEOF_PTRDIFF_T with SCM_SIZEOF_SCM_T_PTRDIFF.
2003-03-25 23:57:51 +00:00
Mikael Djurfeldt
a48d60b1c0 * srfi-1.c (scm_init_srfi_1): Extend root module map and for-each
with the versions in this module using
scm_c_extend_primitive_generic.

* goops.scm (equal?): Define default method.

* goops.c (scm_primitive_generic_generic): Enable primitive
generic if not enabled.
(scm_sys_goops_loaded): Setup unextended primitive generics.

* goops.c, goops.h (scm_c_extend_primitive_generic): New function.

* snarf.h (SCM_PRIMITIVE_GENERIC, SCM_PRIMITIVE_GENERIC_1): New
snarf macros.

* numbers.c (scm_abs): Use SCM_PRIMITIVE_GENERIC.  (This is only a
testing example.  All uses of SCM_GPROC should be converted.)

* procprop.c (scm_stand_in_scm_proc): Use scm_assq instead of
scm_assoc.

* eq.c (scm_equal_p): Turned into a primitive generic.
2003-03-06 12:51:57 +00:00
Marius Vollmer
7b3381f44d (scm_integer_expt): Make 0^z == 0 for z != 0. Also for reals. 2002-11-03 21:57:48 +00:00
Marius Vollmer
d57ed70201 (scm_integer_expt): Make 0^z == 0 for z != 0. 2002-11-03 17:13:50 +00:00
Rob Browning
20bf9a3cfe * numbers.c (s_scm_integer_expt): (expt 0 1) should be 1. 2002-10-05 04:27:35 +00:00
Gary Houston
3553e1d1f0 * inline.h (scm_double_cell): prevent reordering of statements
with any following code (for GCC 3 strict-aliasing).
	* numbers.c (scm_make_real), num2float.i.c (FLOAT2NUM): removed
	the earlier version of the reordering prevention.
2002-09-24 22:21:01 +00:00
Han-Wen Nienhuys
8fa5786d7c (scm_make_real): prevent reordering of statements
num2float.i.c (FLOAT2NUM): idem
2002-08-28 22:50:32 +00:00
Han-Wen Nienhuys
7200a36b83 (scm_make_real): prevent reordering of statements 2002-08-28 22:45:48 +00:00
Han-Wen Nienhuys
c8a1bdc460 new gc 2002-08-04 00:17:18 +00:00
Han-Wen Nienhuys
34d19ef643 2002-07-20 Han-Wen <hanwen@cs.uu.nl>
* *.c: add space after commas everywhere.

* *.c: use SCM_VECTOR_SET everywhere, where a vector is written.
Document cases where SCM_WRITABLE_VELTS() is used.

* vectors.h (SCM_VELTS): prepare for write barrier, and let
SCM_VELTS() return a const pointer
(SCM_VECTOR_SET): add macro.

* autogen.sh (mscripts): find and check version number of
autoconf. Complain if 2.53 is not found.
2002-07-20 14:08:34 +00:00
Dirk Herrmann
8505e285ec * backtrace.c (SCM_ASSERT), debug.c (scm_debug_options), eval.c
(scm_lookupcar, scm_lookupcar1, scm_badargsp, SCM_CEVAL,
SCM_APPLY, scm_map, scm_for_each), feature.c (scm_init_feature),
gsubr.c (scm_gsubr_apply), numbers.c (scm_logand, scm_logior,
scm_logxor, scm_i_dbl2big), srcprop.c (scm_source_properties,
scm_set_source_properties_x, scm_source_property):  Removed
compile time option SCM_RECKLESS to clean up the code.  Full
number of arguments checking of closures is mandatory now.
However, the option to disable the checking has most probably not
been used anyway.

* srcprop.c (scm_source_properties, scm_set_source_properties_x,
scm_source_property): Use !SCM_CONSP instead of SCM_NCONSP.
2002-06-30 22:03:43 +00:00
Marius Vollmer
164d248174 * numbers.c (mem2ureal): When returning an inexact zero, make sure it
is represented as a floating point value so that we can change its
sign.
2002-05-22 19:55:40 +00:00
Marius Vollmer
abb7e44d16 (idbl2str): Don't omit sign when printing negative zero. 2002-05-22 13:50:20 +00:00
Marius Vollmer
fc19457701 Include <string.h>, for strncmp.
(mem2complex): Do not create negative NaNs.
(scm_leq_p, scm_geq_p): Explicitely return #f when comparing a
NaN.
(scm_inexact_to_exact): Signal error when converting a NaN.
2002-05-08 20:08:16 +00:00
Marius Vollmer
7351e20717 From John W. Eaton.
* numbers.h: Conditionally include floatingpoint.h, ieeefp.h, and
nan.h.	Provide declarations for scm_inf_p, scm_nan_p, scn_inf,
and scm_nan.
* numbers.c: [SCO && ! HAVE_ISNAN] (isnan): New function.
[SCO && ! HAVE_ISINF] (isinf): New function.
(xisinf, xisnan): New functions.
(IS_INF): Delete.
(isfinite): Define in terms of xisinf.
(scm_inf_p, scm_nan_p): New functions.
(guile_Inf, guile_NaN): New file-scope vars.
(guile_ieee_init): New function.
(scm_inf, scm_nan): New functions.
(idbl2str): Handle Inf and NaN.	Remove funny label and
corresponding gotos.
(ALLOW_DIVIDE_BY_ZERO): New macro.
(scm_divide): Allow division by zero to occur if
ALLOW_DIVIDE_BY_ZERO is defined.
Handle bignums and ints as special cases.

Additional stuff by me:

numbers.c (mem2ureal): Recognize "inf.0" and "nan.xxx".
(scm_even_p, scm_odd_p): Treat infinity as even and odd.
(iflo2str): Don't output a '+' for negative numbers or for Inf and
NaN.  They will provide their own sign.
(scm_divide): Only allow divides by inexact zeros.  Dividing by
exact zeros still signals an errors.
2002-05-06 22:33:10 +00:00
Neil Jerram
bb2c02f237 Small docstring fixes. 2002-03-15 10:37:40 +00:00
Thien-Thi Nguyen
a6b844c224 Retire inclusion guard macro SCM_MAGIC_SNARFER. 2002-03-14 03:47:43 +00:00
Marius Vollmer
ba74ef4eae (scm_divide): Adapt code from libstdc++/f2c to void potential overflow
problems.  Thanks to John W Eaton!
2002-03-11 19:10:01 +00:00
Dirk Herrmann
228a24ef30 Changes in doc/ref:
* api.txt, data-rep.texi: Renamed the struct scm_cell to
scm_t_cell.

* data-rep.texi: Renamed scm_alloc_cell to scm_cell and
scm_alloc_double_cell to scm_double_cell.

Changes in libguile:

* gc.c (SCM_HEAP_SEG_SIZE, CELL_UP, CELL_DN, NEXT_DATA_CELL,
init_heap_seg, alloc_some_heap), gc.h (struct scm_cell, struct
scm_t_cell, SCM_CELLPTR, SCM_GC_CARD_SIZE,
SCM_GC_IN_CARD_HEADERP), tags.h (SCM_CELLP):  Renamed the struct
scm_cell and all its uses to scm_t_cell in accordance to Guile's
naming scheme for types.

* alist.c (scm_acons), convert.i.c (CTYPES2UVECT,
CTYPES2UVECT_OPTIONAL), coop-threads.c (scm_call_with_new_thread,
scm_spawn_thread), debug.c (scm_make_debugobj), environments.c
(scm_make_environment), eval.c (scm_closure), fports.c
(scm_fdes_to_port), gc.c (scm_deprecated_newcell,
scm_deprecated_newcell2), inline.h (scm_alloc_cell, scm_cell),
list.c (SCM_I_CONS), numbers.c (scm_i_mkbig), pairs.c (scm_cons),
ports.c (scm_void_port), procs.c (scm_c_make_subr, scm_makcclo),
smob.c (scm_make_smob), smob.h (SCM_NEWSMOB), strings.c
(scm_take_str, scm_allocate_string), strports.c (scm_mkstrport),
unif.c (scm_make_uve), variable.c (make_variable), vectors.c
(scm_c_make_vector), vports.c (scm_make_soft_port): Renamed
scm_alloc_cell to scm_cell.

* environments.c (core_environments_observe), gc.c
(scm_deprecated_newcell2), goops.c (wrap_init, scm_wrap_object),
inline.h (scm_alloc_double_cell, scm_double_cell), num2float.i.c
(FLOAT2NUM), numbers.c (scm_make_real), procs.c
(scm_make_procedure_with_setter), smob.h (SCM_NEWSMOB2,
SCM_NEWSMOB3), struct.c (scm_make_struct, scm_make_vtable_vtable),
symbols.c (scm_mem2symbol, scm_mem2uninterned_symbol), weaks.c
(allocate_weak_vector): Renamed scm_alloc_double_cell to
scm_double_cell.
2002-03-01 00:19:20 +00:00
Marius Vollmer
4c9419ac31 * gc.h, gc.c (scm_gc_sweep): Issue deprecation warning when
non-zero is returned from a port or smob free function.
(scm_malloc, scm_realloc, scm_strndup, scm_strdup,
scm_gc_register_collectable_memory,
scm_gc_unregister_collectable_memory, scm_gc_malloc,
scm_gc_realloc, scm_gc_free, scm_gc_strndup, scm_gc_strdup): New.

* backtrace.c, continuations.c, convert.i.c, coop-threads.c,
debug-malloc.c, dynl.c, environments.c, environments.h,
extensions.c, filesys.c, fports.c, gc.c, gc.h, gh_data.c, goops.c,
guardians.c, hooks.c, init.c, keywords.c, load.c, numbers.c,
ports.c, posix.c, procs.c, rdelim.c, regex-posix.c, root.c,
smob.c, stime.c, strings.c, struct.c, struct.h, symbols.c, unif.c,
vectors.c, weaks.c: Use scm_gc_malloc/scm_malloc and
scm_gc_free/free instead of scm_must_malloc and scm_must_free, as
appropriate.  Return zero from smob and port free functions.

* debug-malloc.c (scm_malloc_reregister): Handle "old == NULL".

* fports.c (scm_setvbuf): Reset read buffer to saved values when
it is pointing to the putback buffer.
2002-02-11 18:06:50 +00:00
Marius Vollmer
16d4699b6b Replaced SCM_NEWCELL and SCM_NEWCELL2 with scm_alloc_cell and
scm_alloc_double_cell, respectively.
2001-11-25 15:21:07 +00:00
Dirk Herrmann
5eec27e9c5 * numbers.c (scm_divide): Fix more division by zero errors. 2001-11-22 21:30:24 +00:00
Dirk Herrmann
164826d3ae * numbers.c (scm_divide): Fix (/ 0). Thanks to Keith Wright for
reporting the bug.
2001-11-21 23:23:53 +00:00
Stefan Jahn
6063dc1ddd 2001-11-21 Stefan Jahn <stefan@lkcc.org>
* win32-socket.c (getservent, setservent, endservent,
        getprotoent, setprotoent, endprotoent): New functions.
        Appropriate replacements for M$-Windows.

        * numbers.c (SIZE_MAX, PTRDIFF_MAX, PTRDIFF_MIN): Reintroduced
        these definitions for GUILE_DEBUG.

        * net_db.c: Include "win32-socket.h" if compiling with a native
        M$-Windows compiler.  Include some pieces of code (protoent and
        servent interface) protected by HAVE_* macros when using a
        native M$-Windows compiler.
2001-11-21 07:59:53 +00:00
Marius Vollmer
3d2e8ceb97 * numbers.c: Document macros to define when including
num2integral.i.c.  MAX_VALUE and MIN_VALU are no longer used, we
now rely on SIZEOF_ macros that have been figured out at
configure time.

* num2integral.i.c: Adapt to new interface.
(NUM2INTEGRAL): Test whether a fixnum can be represented in the
target type by casting it and checking whether it is still the
same.  Do not try to handle bignums for integral types that are
smaller than fixnums.  When handling bignums, collect the
magnituse first into a unsigned type, and correctly check for
overflow.
(INTEGRAL2BIG): Do not use MIN_VALUE explicitely by observing that
only -MIN_VALUE can still be negative of all negative numbers (in
twos-complement).
2001-11-12 01:12:37 +00:00
Stefan Jahn
b4e15479e9 2001-11-07 Stefan Jahn <stefan@lkcc.org>
* configure.in: Include `win32-socket.o' in the list of object
        files if networking is enabled on Win32.

2001-11-07  Stefan Jahn  <stefan@lkcc.org>

        * win32-socket.[ch]: New files.  Defines Winsock-API error codes
        and makes them available through Guile.  That is because the
        Winsock-API does not store its errors in `errno' and thus cannot
        return error messages via `strerror (errno)'.

        * socket.c (scm_init_socket): Initialize `win32-socket' part
        here under M$-Windows.

        * numbers.h: Added missing declaration of
        `scm_sys_check_number_conversions()'.

        * error.c: Local definition of SCM_I_STRERROR and SCM_I_ERRNO
        and use in `(strerror)' and `(system-error)'.

        * Makefile.am (EXTRA_libguile_la_SOURCES): Added
        `win32-socket.[ch]' to extra source and header files.
2001-11-07 15:08:45 +00:00