summaryrefslogtreecommitdiff
path: root/libguile
AgeCommit message (Collapse)AuthorFilesLines
2013-03-19Optimize scm_i_divide2double for integers less than 2^DBL_MANT_DIG.Mark H Weaver1-1/+11
* libguile/numbers.c (scm_i_divide2double): Optimize for common case when both operands are less than 2^DBL_MANT_DIG (normally 2^53).
2013-03-19Use scientific notation only if there are enough trailing zeroes.Mark H Weaver1-17/+46
* libguile/numbers.c (idbl2str): Print large numbers in scientific notation only if the exponent is >= 7 and the least significant non-zero digit has value >= radix^4. * test-suite/tests/numbers.test ("number->string"): Add tests.
2013-03-18Use byte-oriented functions in `get-bytevector*'.Ludovic Courtès1-7/+9
* libguile/r6rs-ports.c (scm_get_bytevector_some, scm_get_bytevector_n, scm_get_bytevector_n_x, scm_get_bytevector_all): Use `scm_get_byte_or_eof' and `scm_peek_byte_or_eof' instead of their `char' counterparts. Reported by Chris K. Jester-Young.
2013-03-18Define the new Linux-specific `SO_REUSEPORT'.Ludovic Courtès1-0/+5
* libguile/socket.c (scm_init_socket)[SO_REUSEPORT]: Define `SO_REUSEPORT'. (scm_setsockopt, scm_getsockopt): Update docstring. * doc/ref/posix.texi (Network Sockets and Communication): List `SO_REUSEPORT'.
2013-03-17Reimplement idbl2str number printer.Mark H Weaver1-212/+179
Fixes <http://bugs.gnu.org/13757>. * libguile/numbers.c (idbl2str): Reimplement. (mem2decimal_from_point): Accept negative exponents larger than SCM_MAXEXP that produce subnormals. (SCM_MAX_DBL_PREC): Removed preprocessor macro. (scm_dblprec, fx_per_radix): Removed static variables. (init_dblprec, init_fx_radix): Removed static functions. (scm_init_numbers): Remove initialization code for 'scm_dblprec' and 'fx_per_radix'. * test-suite/tests/numbers.test ("number->string"): Restore tests that previously failed. Remove comments about problems in the number printer that are now fixed.
2013-03-17Improve inexact division of exact integers.Mark H Weaver1-80/+204
* libguile/numbers.c (scm_i_divide2double): New function. (scm_i_divide2double_lo2b): New variable. (scm_i_fraction2double, log_of_fraction): Use 'scm_i_divide2double'. (do_divide): Removed. Its code is now in 'scm_divide'. (scm_divide2real): Removed. Superceded by 'scm_i_divide2double'. (scm_divide): Inherit code from 'do_divide', but without support for forcing a 'double' result (that functionality is now implemented by 'scm_i_divide2double'). Add FIXME comments in cases where divisions might not be as precise as they should be. (scm_init_numbers): Initialize 'scm_i_divide2double_lo2b'. * test-suite/tests/numbers.test (dbl-epsilon-exact, dbl-max-exp): New variables. ("exact->inexact"): Add tests. ("inexact->exact"): Add test for largest finite inexact.
2013-03-13allow for spurious wakeups from pthread_cond_waitAndy Wingo1-3/+9
* libguile/threads.c (scm_call_with_new_thread, scm_spawn_thread): Allow for spurious wakeups while waiting on cond variables. Should fix bug 10641.
2013-03-12Reimplement 'inexact->exact' to avoid mpq functions.Mark H Weaver1-14/+27
* libguile/numbers.c (scm_inexact_to_exact): Implement conversion of a double to an exact rational without using the mpq functions. * test-suite/tests/numbers.test (dbl-mant-dig): Simplify initializer. (dbl-epsilon, dbl-min-exp): New variables. ("inexact->exact"): Add tests. Fix broken "2.0**i to exact and back" test, and change it to "2.0**i to exact", to avoid use of 'exact->inexact'.
2013-03-12Optimize logarithms using scm_i_big2dbl_2expMark H Weaver1-18/+12
* libguile/numbers.c (log_of_exact_integer_with_size): Removed. (log_of_exact_integer): Handle bignums too large to fit in a double using 'scm_i_big2dbl_2exp' instead of 'scm_integer_length' and 'scm_ash'. (log_of_fraction): Use 'log_of_exact_integer' instead of 'log_of_exact_integer_with_size'.
2013-03-12Simplify and improve scm_i_big2dbl, and add scm_i_big2dbl_2expMark H Weaver1-65/+36
* libguile/numbers.c (scm_i_big2dbl_2exp): New static function. (scm_i_big2dbl): Reimplement in terms of 'scm_i_big2dbl_2exp', with proper rounding. * test-suite/tests/numbers.test ("exact->inexact"): Add tests.
2013-03-12Add 'round-ash', a rounding arithmetic shift operatorMark H Weaver2-75/+154
* libguile/numbers.c (left_shift_exact_integer, floor_right_shift_exact_integer, round_right_shift_exact_integer): New static functions. (scm_round_ash): New procedure. (scm_ash): Reimplement in terms of 'left_shift_exact_integer' and 'floor_right_shift_exact_integer'. * libguile/numbers.h: Add prototype for scm_round_ash. Rename the second argument of 'scm_ash' from 'cnt' to 'count'. * test-suite/tests/numbers.test (round-ash, ash): Add new unified testing framework for 'ash' and 'round-ash'. Previously, the tests for 'ash' were not very comprehensive; for example, they did not include a single test where the number to be shifted was a bignum. * doc/ref/api-data.texi (Bitwise Operations): Add documentation for 'round-ash'. Improve documentation for `ash'.
2013-03-12Optimize and simplify fractions code.Mark H Weaver1-91/+153
* libguile/numbers.c (scm_exact_integer_quotient, scm_i_make_ratio_already_reduced): New static functions. (scm_i_make_ratio): Rewrite in terms of 'scm_i_make_ratio_already_reduced'. (scm_integer_expt): Optimize fraction case. (scm_abs, scm_magnitude, scm_difference, do_divide): Use 'scm_i_make_ratio_already_reduced'. * test-suite/tests/numbers.test (expt, integer-expt): Add tests.
2013-03-10rely on gnulib for `poll'Jason Earl2-43/+2
* configure.ac: * libguile/fports.c (fport_input_waiting): * libguile/poll.c (scm_primitive_poll): Rely on gnulib to provide poll for us.
2013-03-10add %site-ccache-dirJason Earl2-1/+15
* libguile/load.h: * libguile/load.c (scm_sys_site_ccache_dir): New procedure. * doc/ref/scheme-using.texi (Installing Site Packages): * doc/ref/api-options.texi (Build Config): Add docs. Fixes bug 10326.
2013-03-09provide getlogin declaration if needed.Andy Wingo1-0/+7
* configure.ac: Check for getlogin decl. * libguile/posix.c: Declare getlogin if needed.
2013-03-09fix mingw issues with posix.cAndy Wingo1-32/+10
* libguile/posix.c (scm_execl, scm_execlp, scm_execle) (scm_open_process): Remove casts for ancient mingw. (scm_utime): If we fall back to utime, assert that flags is 0. (scm_getlogin): Rely on gnulib.
2013-03-09don't provide scm_std_select on mingw and similar platformsAndy Wingo4-42/+40
* libguile/iselect.h: If we do not have sys/select.h, don't provide scm_std_select, SELECT_TYPE, FD_SET, FD_ZERO, FD_ISSET, or FD_CLR. Guile should not be setting these macros in public API. This is an incompatible change on mingw, but oh well. * libguile/threads.c: Rely on gnulib's select, and use that to implement scm_std_select. * libguile/deprecated.h: * libguile/deprecated.c: Only provide scm_internal_select if we have sys/select.h.
2013-03-09simplify posix.cAndy Wingo1-44/+17
* libguile/posix.c: Reorder includes to fix mingw include-order problem. Remove ttyname shims; gnulib is the place to fix that. Remove winsock2 include, as gnulib seems to handle that OK. Rely on the new pipe-posix gnulib module. Don't bother shimming getlogin, etc on mingw; gnulib is the place for shims.
2013-03-09simplify stime back-compat shims for tznameAndy Wingo1-8/+1
* libguile/stime.c: Remove tzname declarations for ancient mingw and SGI RS6000.
2013-03-09mingw include order for socket.cAndy Wingo1-17/+19
* libguile/socket.c: Reorder includes to fix include order on mingw.
2013-03-09fix include-order problem in net_db.c for mingwAndy Wingo1-10/+10
* libguile/net_db.c: Reorder includes to avoid include-order problem on mingw.
2013-03-09silence mingw32 warning in i18n.cAndy Wingo1-1/+3
* libguile/i18n.c (scm_make_locale): Silence a warning.
2013-03-09fports uses gnulib's selectAndy Wingo1-29/+21
* libguile/fports.c: Reorder includes to put system includes first; fixes windows/winsock2 include error problem. Rely on Gnulib's select module. (fport_input_waiting): Use select instead of scm_std_select.
2013-03-09simplify filesys.c via gnulib's select and fstat modulesAndy Wingo1-53/+10
* libguile/filesys.c: Instead of using scm_std_select, just use select, relying on gnulib to provide it to us. Likewise, rely on fstat.
2013-03-09if we have threads on windows, we have pthreads; inform bdw-gc of thatAndy Wingo1-1/+6
* libguile/bdw-gc.h: If we have threads enabled on mingw32, explicitly mark GC_WIN32_PTHREADS. See http://thread.gmane.org/gmane.comp.programming.garbage-collection.boehmgc/5564 for more info.
2013-03-09remove init.c iselect includeAndy Wingo1-2/+1
* libguile/init.c: Remove iselect include.
2013-03-09portability simplification with scmsigs.c and alarmAndy Wingo1-20/+14
* configure.ac (alarm): Check for decl. * libguile/scmsigs.c: Reorder includes to put system includes first. Fixes include order on mingw. Remove #define for alarm, as we will use HAVE_DECL_ALARM. Remove #defines for sleep and usleep, as they are not used. (scm_alarm): Only define if HAVE_DECL_ALARM.
2013-03-09squish remove some mingw-specific code that is covered by gnulibAndy Wingo6-606/+18
* libguile/socket.c (scm_init_socket): Remove mingw-specific code. * libguile/fports.c: Remove ftruncate redefine; mingw is fine. (scm_i_fdes_to_port): If we have no F_GETFL, just do an fstat. The right place for an F_GETFL replacement would be in gnulib. (fport_input_waiting): Remove an outdated comment. * libguile/error.c (SCM_I_STRERROR, SCM_I_ERRNO): Remove, replacing uses with strerror and errno. * libguile/win32-socket.c: * libguile/win32-socket.h: Remove. Mingw has suitable replacements. * configure.ac: * libguile/Makefile.am (EXTRA_libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): (noinst_HEADERS): Update for win32-socket removal.
2013-03-09remove mingw32 implementations of {get,end,set}{serv,proto}entAndy Wingo3-187/+11
* libguile/win32-socket.h: * libguile/win32-socket.c (getservent, endservent, setservent) (getprotoent, endprotoent, setprotoent): Remove mingw32 wrappers. Their place is in gnulib, if anywhere.
2013-03-09add check for struct pollfdAndy Wingo2-6/+6
* configure.ac: Add check for struct pollfd. * libguile/fports.c (fport_input_waiting): * libguile/poll.c (scm_primitive_poll): Require struct pollfd. Fixes bug 13903.
2013-03-09allow case-lambda expressions with no clausesAndy Wingo1-3/+22
* module/ice-9/psyntax-pp.scm: * module/ice-9/psyntax.scm (case-lambda, case-lambda*): Allow 0 clauses. * module/language/scheme/decompile-tree-il.scm (do-decompile): (choose-output-names): * module/language/tree-il.scm (unparse-tree-il): (tree-il-fold, post-order!, pre-order!): * module/language/tree-il/effects.scm (make-effects-analyzer): * module/language/tree-il/cse.scm (cse): * module/language/tree-il/debug.scm (verify-tree-il): * module/language/tree-il/peval.scm (peval): Allow for lambda-body to be #f. * libguile/memoize.c (memoize): * module/language/tree-il/canonicalize.scm (canonicalize!): Give a body to empty case-lambda before evaluating it or compiling it, respectively. * test-suite/tests/optargs.test ("case-lambda", "case-lambda*"): Add tests.
2013-03-07Improve standards conformance of string->number.Mark H Weaver1-26/+50
Fixes <http://bugs.gnu.org/11887>. * libguile/numbers.c (mem2ureal): New argument 'allow_inf_or_nan'. Accept infinities and NaNs only if 'allow_inf_or_nan' is true and "#e" is not present. Check for "inf.0" or "nan." case-insensitively. Do not accept rationals with zero divisors. (mem2complex): Pass new 'allow_inf_or_nan' argument to 'mem2ureal', which is set if and only if a explicit sign was present. * test-suite/tests/numbers.test ("string->number"): Add tests.
2013-03-07add GUILE_STACK_SIZE environment variableStefan Israelsson Tampe1-2/+16
* libguile/vm.c (initialize_default_stack_size): New helper. (scm_bootstrap_vm): Call initialize_default_stack_size. * doc/ref/guile-invoke.texi (Environment Variables): Add docs. Based on a patch by Stefan Israelsson Tampe.
2013-03-07GUILE_INSTALL_LOCALE=1 during buildAndy Wingo1-1/+2
* doc/ref/Makefile.am (autoconf-macros.texi): * libguile/Makefile.am (snarf2checkedtexi): * module/Makefile.am (ice-9/psyntax-pp.scm.gen, ice-9/psyntax-pp.go): * test-suite/Makefile.am (GUILE_AUTO_COMPILE): * test-suite/standalone/Makefile.am (GUILE_INSTALL_LOCALE): * test-suite/vm/Makefile.am (TESTS_ENVIRONMENT): * am/guilec (.scm.go): Set GUILE_INSTALL_LOCALE to 1 during the build. Fixes bug 12887.
2013-03-07Install the current locale if GUILE_INSTALL_LOCALE is nonzero.Ludovic Courtès1-2/+39
* libguile/guile.c (get_integer_from_environment) (should_install_locale): New functions. (main): Add `setlocale' call. * doc/ref/guile-invoke.texi (Environment Variables): Add documentation.
2013-03-07structs with tail arrays are not simpleAndy Wingo2-8/+7
* libguile/struct.h (SCM_VTABLE_FLAG_SIMPLE, SCM_VTABLE_FLAG_SIMPLE_RW): * libguile/struct.c (set_vtable_layout_flags): Vtable whose layouts include a tail array are not simple. Fixes bug 12808.
2013-03-07fix compilation under mingwAndy Wingo1-7/+9
* libguile/load.c (is_absolute_file_name, search_path): Fix compilation under mingw.
2013-03-07Make `SCM_LONG_BIT' usable in preprocessor conditionals.Ludovic Courtès1-1/+1
Reported by Jan Schukat <shookie@email.de>. Partly fixes <http://bugs.gnu.org/13848>. * libguile/__scm.h (SCM_LONG_BIT)[!defined LONG_BIT]: Use SCM_SIZEOF_LONG since `sizeof' cannot be used in #if directives as found in numbers.c.
2013-03-07Use `scm_is_eq' in load.c.Ludovic Courtès1-2/+2
* libguile/load.c (is_file_name_separator): Use `scm_is_eq' instead of `=='.
2013-03-06Verify that FLT_RADIX is 2.Mark H Weaver1-0/+3
* libguile/numbers.c: Trigger a compilation error if FLT_RADIX is not 2. This has long been assumed by code in numbers.c.
2013-03-06Improve code in scm_gcd for inum/inum caseMark H Weaver1-24/+30
* libguile/numbers.c (scm_gcd): Improve implementation of inum/inum case to be more clear and efficient.
2013-03-05Fix thread-unsafe lazy initializations.Mark H Weaver3-9/+20
* libguile/debug.c (scm_local_eval): libguile/ports.c (scm_current_warning_port): libguile/strports.c (scm_eval_string_in_module): Perform lazy-initialization while holding a mutex. Use SCM_UNDEFINED as the uninitialized value. Use 'scm_c_*_variable'. * doc/ref/api-modules.texi (Accessing Modules from C): Fix 'my_eval_string' example to be thread-safe.
2013-03-04Use `scm_is_eq' in filesys.c.Ludovic Courtès1-2/+2
* libguile/filesys.c (is_file_name_separator): Use `scm_is_eq' instead of `=='. Fixes <http://hydra.nixos.org/build/4261579>.
2013-03-01Allow the SMOB mark procedures to be called when libgc uses parallel markers.Ludovic Courtès2-27/+29
Fixes <http://bugs.gnu.org/13611>. Reported by Mike Gran <spk121@yahoo.com>. * libguile/smob.c (current_mark_stack_pointer, current_mark_stack_limit): New variables. (smob_mark): Use CURRENT_MARK_STACK_POINTER and CURRENT_MARK_STACK_LIMIT instead of the same-named fields of `SCM_I_CURRENT_THREAD'. (scm_gc_mark): Likewise. (scm_smob_prehistory): Initialize CURRENT_MARK_STACK_LIMIT and CURRENT_MARK_STACK_POINTER. * libguile/threads.h (scm_i_thread): Add comment that `current_mark_stack_ptr' and `current_mark_stack_limit' are no longer used.
2013-03-01Use accessors instead of symbols deprecated in libgc 7.3.Ludovic Courtès2-2/+22
* configure.ac: Check for `GC_set_all_interior_pointers', `GC_get_gc_no', and `GC_set_java_finalization'. * libguile/gc.c (scm_gc_stats)[HAVE_GC_GET_GC_NO]: Use `GC_get_gc_no'. (scm_storage_prehistory)[HAVE_GC_SET_ALL_INTERIOR_POINTERS]: Use `GC_set_all_interior_pointers'. * libguile/guardians.c (scm_init_guardians)[HAVE_GC_SET_JAVA_FINALIZATION]: Use `GC_set_java_finalization'.
2013-02-28Fix later-bindings-win logic in with-fluids.Mark H Weaver1-3/+3
Based on a patch by David Kastrup <dak@gnu.org>. Fixes <http://bugs.gnu.org/13843>. * libguile/fluids.c (scm_i_make_with_fluids): Reverse direction of inner loop that checks for duplicates, to properly handle more than two bindings to the same fluid.
2013-02-28Fix duplicate removal of with-fluids.Mark H Weaver1-1/+4
Based on a patch by David Kastrup <dak@gnu.org>. Fixes <http://bugs.gnu.org/13838>. * libguile/fluids.c (scm_i_make_with_fluids): Remove the duplicate binding instead of the last binding. * test-suite/tests/fluids.test: Add test, and fix existing duplicate tests. * THANKS: Thanks David Kastrup.
2013-02-28Support calling foreign functions of 10 arguments or more.Mark H Weaver1-35/+80
* libguile/foreign.c (OBJCODE_HEADER, META_HEADER, META): Change these into higher-order macros. (GEN_CODE): New higher-order macro based on 'CODE'. (M_STATIC, M_DYNAMIC): New macros. (CODE): Reimplement using 'GEN_CODE' and 'M_STATIC'. (make_objcode_trampoline): New static function. (large_objcode_trampolines, large_objcode_trampolines_mutex): New static variables. (get_objcode_trampoline): New static function. (cif_to_procedure): Use 'get_objcode_trampoline'. * test-suite/standalone/test-ffi-lib.c (test_ffi_sum_many): New function. * test-suite/standalone/test-ffi: Add test.
2013-02-27Let reverse! accept arbitrary types as second argument (new_tail)David Kastrup1-2/+0
* libguile/list.c (scm_reverse_x): remove typecheck for 2nd arg. Signed-off-by: Mark H Weaver <mhw@netris.org>
2013-02-27Fix cross-compilation of `c-tokenize.o'.Ludovic Courtès1-1/+1
* libguile/Makefile.am (c-tokenize.$(OBJEXT)): Pass -I$(top_builddir) when cross-compiling.