1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-02 21:10:27 +02:00
Commit graph

7575 commits

Author SHA1 Message Date
Andy Wingo
61b8794e04 Rename win32-uname.[ch] to posix-w32.[ch]
* libguile/posix-w32.c:
* libguile/posix-w32.h: Rename from win32-uname.c and win32-uname.h.
* libguile/posix.c:
* libguile/Makefile.am
  (EXTRA_libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES)
  (noinst_HEADERS): Adapt.
2016-07-11 23:18:27 +02:00
Andy Wingo
f6dd212045 Factor start_child out of open_process
* libguile/posix.c (start_child): Factor out from open_process.  Based
  on initial work by Eli Zaretskii.
2016-07-11 22:54:33 +02:00
Andy Wingo
0fb3e82cee More specific status:exit-val et al compilation guards
* libguile/posix.c (scm_status_exit_val, scm_status_term_sig)
  (scm_status_stop_sig): Guard on WIFEXITED et al macros instead of on
  MinGW.
2016-07-11 22:54:33 +02:00
Andy Wingo
2ef67d08ef getaffinity, setaffinity docstring cleanup
* libguile/posix.c (scm_getaffinity, scm_setaffinity): Clean up
  docstrings.  Obviously if you have the function, you don't need to be
  told that you have it in the docstring.
2016-07-11 22:17:59 +02:00
Andy Wingo
2247a56d5d Provide `kill' only if supported by the host
* libguile/posix.c (scm_kill): Only provide if the host has `kill'.  An
  incompatible change on MinGW, where this function would work only if
  the PID was the current PID, but that will be fixed by the next
  process.
2016-07-11 22:17:09 +02:00
Andy Wingo
509c4205ba More robust setuid, setgid, etc detection
* configure.ac: Check for getuid, getgid, setuid, and setgid.
* libguile/posix.c (scm_getuid, scm_getgid, scm_setuid, scm_setgid):
  Only provide Scheme functions if the OS provides these facilities.
  (scm_geteuid, scm_getegid, scm_seteuid, scm_setegid): Provide if the
  host has getuid, getgid, etc, instead of being in a MinGW guard.
2016-07-11 22:14:38 +02:00
Andy Wingo
e2c1659d95 Locale is default port encoding
* libguile/ports.c (scm_init_ports): Use the locale as the default
  charset.  This allows GUILE_INSTALL_LOCALE=1 to work properly,
  harmonizing the default port encoding with the installed locale.
2016-07-11 18:21:52 +02:00
Ludovic Courtès
a14e873cce Fix invalid use of 'PTR2SCM'.
Fixes a typo introduced in 04359b42b9.

* libguile/load.c (try_load_thunk_from_file): Use 'SCM2PTR', not
'PTR2SCM'.
2016-07-11 11:04:34 +02:00
Ludovic Courtès
2c5ab455c2 Add missing 'const' qualifier.
* libguile/stime.c (tzvar): Add 'const'.
2016-07-11 11:01:51 +02:00
Ludovic Courtès
2bdd40a696 Unconditionally include <time.h> from Gnulib.
* libguile/stime.c: Unconditionally include <time.h>.
2016-07-11 11:01:51 +02:00
Andy Wingo
5b7b5749e1 Add meta/build-env
* meta/build-env.in: New file which sets up an environment that does not
  inherit GUILE_LOAD_PATH / GUILE_LOAD_COMPILED_PATH (unless
  cross-compiling).
* doc/ref/Makefile.am (autoconf-macros.texi):
* libguile/Makefile.am (snarf2checkedtexi):
* module/Makefile.am (ice-9/psyntax-pp.go):
* test-suite/standalone/Makefile.am (GUILE_INSTALL_LOCALE):
* am/guilec (.scm.go): Use build-env.
* configure.ac: Create build-env.
2016-07-10 13:21:38 +02:00
Andy Wingo
04359b42b9 Skip incompatible .go files
* libguile/load.c (load_thunk_from_path, try_load_thunk_from_file):
  New functions.
  (search_path): Simplify.
  (scm_primitive_load_path, scm_init_eval_in_scheme): Use the new
  functions to load compiled files.
* module/ice-9/boot-9.scm (load-in-vicinity): Skip invalid .go files.

Inspired by a patch from Jan Nieuwenhuizen <janneke@gnu.org>.
2016-06-29 18:10:24 +02:00
Andy Wingo
96f55b7f36 Check for strtod_l before using it.
Based on a patch by Andy Stormont <astormont@racktopsystems.com>.

* configure.ac: Check for strtod_l.
* libguile/i18n.c (scm_locale_string_to_integer): Fix style.
  (scm_locale_string_to_inexact): Check for strtod_l.
2016-06-26 22:37:47 +02:00
Andy Wingo
1d5e60df84 Fix ,profile in pure modules
* libguile/scmsigs.c (close_1): Make the async closure in an environment
  where `lambda' has its usual meaning.  Fixes #21013.
2016-06-26 22:27:49 +02:00
Andy Wingo
f763f353e4 Register R6RS port and bytevector internals early
* libguile/bytevectors.c (sym_big, sym_little): Rename from scm_sym_big
  and scm_sym_little, and don't use the snarf mechanism as we need to
  initialize this value eagerly in case the C API is used before the
  Scheme module is loaded.
  (scm_bootstrap_bytevectors): Initialize the endianness symbols here.
* libguile/r6rs-ports.c (scm_register_r6rs_ports): Register the R6RS
  port kinds here, for the same reason.
2016-06-23 18:31:55 +02:00
Andy Wingo
cf1d313940 Fix memory leak in scm_from_{u,}int64 on 32-bit platforms
* libguile/conv-integer.i.c (SCM_FROM_TYPE_PROTO):
* libguile/conv-uinteger.i.c (SCM_FROM_TYPE_PROTO): Fix a big in which
  scm_from_int64 and scm_from_uint64 on a 32-bit platform leaked memory
  if they needed to allocate a bignum.  Fixes #20079.
2016-06-23 15:00:00 +02:00
Andy Wingo
8dff3af087 Fix race between SMOB marking and finalization
* libguile/smob.c (clear_smobnum): New helper.
  (finalize_smob): Re-set the smobnum to the "finalized smob" type
  before finalizing.  Fixes #19883.
  (scm_smob_prehistory): Pre-register a "finalized smob" type, which has
  no mark procedure.
* test-suite/standalone/test-smob-mark-race.c: New file.
* test-suite/standalone/Makefile.am: Arrange to build and run the new
  test.
2016-06-23 12:17:51 +02:00
Andy Wingo
08df681976 Remove unused internal i18n functions
* libguile/i18n.c (str_upcase, str_downcase, str_upcase_l)
  (str_downcase_l): Remove unused inline functions.  Based on a patch by
  Pedro Aguilar <paguilar@paguilar.org>.  Fixes #19172.
2016-06-22 16:48:03 +02:00
Andy Wingo
b77642dff2 Fix size measurement in bytevector_large_set
* libguile/bytevectors.c (bytevector_large_set): Fix computation of
  value size in words.
* test-suite/tests/bytevectors.test: Add test.

Thanks to Ben Rocer <fleabyte@mail.com> for the bug report and fix.
2016-06-21 18:02:14 +02:00
Mark H Weaver
ee3381c94d FFI: Add support for functions that set 'errno'.
Implements wishlist item <https://debbugs.gnu.org/18592>.
Requested by Frank Terbeck <ft@bewatermyfriend.org>.
Based on a proposed patch by Nala Ginrut <nalaginrut@gmail.com>.

* libguile/foreign.c (cif_to_procedure): Add 'return_errno' argument.
  Store its boolean value in the object table of the generated program.
  (scm_i_foreign_call): If the stored 'return_errno' flag is true, then
  clear 'errno' before the call, save it after the call, and return it
  as a second return value.
  (pointer_to_procedure): New static function.
  (scm_pointer_to_procedure_with_errno): New C API function, implemented
  in terms of 'pointer_to_procedure'.
  (scm_pointer_to_procedure): Reimplement in terms of
  'pointer_to_procedure', no longer bound to "pointer->procedure".  See
  below.
  (scm_i_pointer_to_procedure): New C function bound to
  "pointer->procedure" which now accepts the optional #:return-errno?
  keyword argument, implemented in terms of 'pointer_to_procedure'.
  (k_return_errno): New keyword #:return-errno?.
* libguile/foreign.h (scm_pointer_to_procedure_with_errno): Add prototype.
* doc/ref/api-foreign.texi (Dynamic FFI): Adjust documentation.
2016-06-20 15:22:27 -04:00
Mark H Weaver
b0a702d773 Do not assume that sizeof (long) == sizeof (void *) == sizeof (SCM).
This assumption does not hold on systems that use the LLP64 data model.

Partially fixes <https://debbugs.gnu.org/22406>.
Reported by Peter TB Brett <peter@peter-b.co.uk>.

* libguile/numbers.h (scm_t_inum): Move here from numbers.c, and change
  to be equivalent to 'long' (formerly 'scm_t_signed_bits').
  (SCM_MOST_POSITIVE_FIXNUM, SCM_MOST_NEGATIVE_FIXNUM): Define based on
  SCM_I_FIXNUM_BIT instead of SCM_T_SIGNED_BITS_MAX.
  (SCM_I_INUM): Adjust definitions to return a 'scm_t_inum', and avoiding
  the assumption that SCM_UNPACK returns a 'long'.
* libguile/numbers.c (scm_t_inum): Move definition to numbers.h.
  Verify that 'scm_t_inum' fits within a SCM value.
  (scm_i_inum2big): Remove preprocessor code that forced a compile error
  unless sizeof (long) == sizeof (void *).
* libguile/vm-i-scheme.c (_CX): For fixnum assembly functions, choose
  the register size based on SCM_I_FIXNUM_BIT instead of SIZEOF_VOID_P.
  (ASM_MUL, "ash", "vector-ref", "vector-set", BV_FIXABLE_INT_REF)
  (BV_INT_REF, BV_FLOAT_REF, BV_FIXABLE_INT_SET, BV_INT_SET)
  (BV_FLOAT_SET): Use 'scm_t_inum' for fixnums instead of
  'scm_t_signed_bits'.
2016-06-20 15:22:27 -04:00
Mark H Weaver
1e86dc32a4 Fix fat_mutex owner corruption and other problems in fat_mutex_unlock.
Fixes <https://debbugs.gnu.org/22152>.
Reported by Iwan Aucamp <aucampia@gmail.com>.

* libguile/threads.c (fat_mutex_unlock): Avoid repeatedly decrementing
  m->level and changing the owner of the mutex when 'block_self' returns
  EINTR.  Unblock asyncs before calling scm_syserror.  Refactor the code
  to clarify the EINTR loop, and to make it more apparent that the async
  blocks and unblocks are balanced.
2016-06-20 15:22:27 -04:00
Mark H Weaver
4b60562820 Avoid signed integer overflows in numeric conversions.
Reported by Miroslav Lichvar <mlichvar@redhat.com>
in <https://lists.gnu.org/archive/html/guile-devel/2016-02/msg00045.html>

* libguile/conv-integer.i.c: Avoid signed overflow.
* libguile/numbers.c (scm_is_signed_integer): Avoid signed overflow.
2016-06-20 15:22:27 -04:00
Mark H Weaver
ff51de66bd unget-bytevector: Allow start == length when count is not given.
* libguile/r6rs-ports.c (scm_unget_bytevector): Allow 'start' to be
  equal to the bytevector length when the 'count' optional argument is
  not passed.
2016-06-20 15:22:27 -04:00
Ludovic Courtès
6b73c87f58 Remove unused C variables and functions.
Reported by GCC 6.1.0.

* libguile/expand.c (s_empty_combination, s_missing_body_expression)
(s_mixed_body_forms, s_bad_case_clause, s_bad_case_labels)
(s_duplicate_case_label, s_bad_exit_clause, s_splicing)
(s_bad_slot_number): Remove.
* libguile/ports.c (scm_utf8_bom, scm_utf16be_bom, scm_utf32be_bom):
Remove.
* libguile/vm.c (vm_error_stack_underflow): Remove.
2016-05-08 21:38:06 +02:00
Ludovic Courtès
ff98cbb643 Revert foreign objects.
For a long time the API failed to reach consensus among maintainers.
See <https://lists.gnu.org/archive/html/guile-devel/2015-11/msg00005.html>
and <https://lists.gnu.org/archive/html/guile-devel/2014-04/msg00069.html>.

This revert intends to break the deadlock and help further discussion to
take place with less pressure.

* libguile/foreign-object.c, libguile/foreign-object.h: Remove.
* libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES)
(modinclude_HEADERS): Adjust accordingly.
* libguile/init.c (scm_i_init_guile): Remove call to
'scm_register_foreign_object'.
* libguile.h: Remove inclusion of "libguile/foreign-object.h".
* module/system/foreign-object.scm: Remove.
* module/Makefile.am (SYSTEM_SOURCES): Adjust accordingly.
* test-suite/standalone/test-foreign-object-c.c,
test-suite/standalone/test-foreign-object-scm: Remove.
* test-suite/standalone/Makefile.am (check_SCRIPTS, check_PROGRAMS)
(TESTS): Adjust accordingly.
(test_foreign_object_c_SOURCES, test_foreign_object_c_CFLAGS)
(test_foreign_object_c_LDADD): Remove.
* doc/ref/libguile-foreign-objects.texi: Remove.
* doc/ref/api-foreign-objects.texi: Remove.
* doc/ref/libguile-smobs.texi: New file.
* doc/ref/Makefile.am (guile_TEXINFOS): Adjust accordingly.
* doc/ref/api-control.texi, doc/ref/api-smobs.texi,
doc/ref/api-utility.texi, doc/ref/guile.texi,
doc/ref/libguile-concepts.texi, doc/ref/libguile-program.texi:
Revert d9a4a1cd and 6e4630e0.
2016-02-01 22:29:33 +01:00
Mark H Weaver
e94a42c7f0 Fix getsockopt/setsockopt handling of SO_SNDBUF/SO_RCVBUF options.
Reported by Park SungMin <byulparan_eng@icloud.com>
in <https://lists.gnu.org/archive/html/guile-user/2015-11/msg00026.html>.

* libguile/socket.c (scm_getsockopt, scm_setsockopt): Remove code that
  incorrectly assumed that the argument for SO_SNDBUF and SO_RCVBUF
  options was of type 'size_t'.  Both the Linux and POSIX documentation
  indicates that the argument is of type 'int', as is the case for most
  options.
2015-11-13 11:45:00 -05:00
Ludovic Courtès
c028c64eb8 Regenerate SRFI-14 character set data.
Suggested by Mike Gran <spk121@yahoo.com>.

* libguile/srfi-14.i.c: Regenerate for Unicode 8.0.0,
  <ftp://unicode.org/Public/UNIDATA/UnicodeData.txt> with SHA256
  38b17e1118206489a7e0ab5d29d7932212d38838df7d3ec025ecb58e8798ec20.
2015-11-05 21:05:57 +01:00
Mark H Weaver
133ec4c491 string ports: Add overflow checks and other fixes.
* libguile/strports.c (st_resize_port): Check that 'new_size' fits in a
  size_t.
  (st_end_input): Improve code clarity.
  (st_seek): Check for overflow during computation of target position.
  Check for invalid 'whence' argument.  Resize the port when seeking to
  a position beyond the end of the buffer.  Check for overflow during
  computation of new buffer size when resizing the port.
2015-11-01 21:30:01 -05:00
Mark H Weaver
448eb30e3d Fix seeking on binary input ports with putback buffers.
Fixes <http://bugs.gnu.org/20302>.
Reported by David Kastrup <dak@gnu.org>.

* libguile/r6rs-ports.c (bip_end_input): New static function.
  (initialize_bytevector_input_ports): Register it.
  (bip_seek): Rewrite to handle putback buffers, based on st_seek from
  strports.c.
2015-11-01 21:29:45 -05:00
Mark H Weaver
e1788828df build: Add SCM_T_OFF_MAX and SCM_T_OFF_MIN to scmconfig.h.
* libguile/gen-scmconfig.c (main): Add SCM_T_OFF_MAX and SCM_T_OFF_MIN
  to the generated 'scmconfig.h' file.
2015-11-01 21:29:32 -05:00
Ludovic Courtès
efd8a438b3 build: Remove libguile/mkstemp.c, redundant with Gnulib.
Fixes <http://bugs.gnu.org/21425>.
Reported by Kouhei Sutou <kou@cozmixng.org>.

* configure.ac: Remove 'AC_REPLACE_FUNCS' for 'mkstemp'.
* libguile/Makefile.am (EXTRA_libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES):
  Remove mkstemp.c.
* libguile/mkstemp.c: Remove.
2015-10-29 23:55:05 +01:00
David Michael
c3f95ec2c2 Remove SIGEV constant definitions.
* libguile/Makefile.am (chknew-E chknew-SIG): Anchor the end of the
  signal/error name pattern to only match alphanumeric symbols.
* libguile/cpp-SIG.syms (SIGEV_MAX_SIZE, SIGEV_NONE): Remove.
  (SIGEV_PAD_SIZE, SIGEV_SIGNAL, SIGEV_THREAD): Likewise.
  (SIGEV_THREAD_ID): Likewise.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2015-10-29 23:39:55 +01:00
David Michael
1be3063bf6 Add Hurd signal and error constants.
* libguile/cpp-E.syms (EAUTH, EBACKGROUND): New definitions.
  (EBADRPC, ED, EDIED, EFTYPE, EGRATUITOUS, EGREGIOUS): Likewise.
  (EIEIO, ENEEDAUTH, EPROCLIM, EPROCUNAVAIL): Likewise.
  (EPROGMISMATCH, EPROGUNAVAIL, ERPCMISMATCH): Likewise.
* libguile/cpp-SIG.syms (SIGEMT, SIGEV_MAX_SIZE): Likewise.
  (SIGEV_PAD_SIZE, SIGINFO, SIGLOST): Likewise.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2015-10-29 23:39:38 +01:00
David Michael
ead362f8d1 Add new Linux errno constants.
* libguile/cpp-E.syms (EHWPOISON, ERFKILL): New definitions.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2015-10-29 23:39:18 +01:00
David Michael
9a4215b8c2 Fix the rule to check for new signals and errors
Fixes <http://bugs.gnu.org/21114>.

* libguile/Makefile.am (chknew-E chknew-SIG): Remove the line
  continuation after the targets, and include numbers in the
  recipe's signal/error regexp to catch names like E2BIG.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2015-10-29 23:37:39 +01:00
Andreas Rottmann
27df2f3439 Heed the reader settings implied by #!r6rs
When encountering the #!r6rs directive, apply the appropriate reader
settings to the port.

* libguile/read.scm (read-string-as-list): New helper procedure.
  (scm_read_shebang): Set reader options implied by the R6RS syntax
  upon encountering the #!r6rs directive.
* test-suite/tests/reader.test (per-port-read-options): Add tests for
  the #!r6rs directive.
2015-07-28 23:06:36 +02:00
Mark H Weaver
e3c59bfb8d Fix atan procedure when applied to complex numbers.
Fixes a regression introduced in commit
ad79736c68.

* libguile/numbers.c (scm_atan): Fix the complex case.
* test-suite/tests/numbers.test ("atan"): Add test.
2015-07-22 21:03:05 -04:00
Ken Raeburn
67d8ccc0e4 FFI: sizeof: Account for trailing padding of structs.
* libguile/foreign.c (scm_sizeof): Make sure the overall size is a
  multiple of the alignment of the structure.
* test-suite/tests/foreign.test: Test size of { double, int8 }.
2015-06-25 14:45:55 +02:00
Natanael Copa
ed0c14769a i18n: Check for non-POSIX strtol_l.
* configure.ac: Check for strtol_l.
* libguile/i18n.c: Check HAVE_STRTOL_L before using strtol_l.
2015-06-19 16:04:37 -04:00
Ludovic Courtès
6bfd298c56 gdb: Support builds with SCM_DEBUG_TYPING_STRICTNESS=2.
* libguile/libguile-2.0-gdb.scm (scm-value->integer): New procedure.
  (%scm-pretty-printer): Use it instead of 'value->integer'.
2015-06-02 21:09:31 +02:00
Ludovic Courtès
2a4d21b5fa gdb: Remove unused procedure.
* libguile/libguile-2.0-gdb.scm (scm-value->string): Remove.
2015-06-02 21:09:28 +02:00
Ludovic Courtès
6001fa35c6 Fix test in 'fport_write'.
Reported by Doug Evans <xdje42@gmail.com>
at <http://lists.gnu.org/archive/html/guile-devel/2015-03/msg00023.html>.

* libguile/fports.c (fport_write): Change SIZE to REMAINING in
  condition.  This doesn't have any observable effect.
2015-03-31 21:26:29 +02:00
Mark H Weaver
d574d96f87 Fix bytevector and custom binary ports to actually use ISO-8859-1 encoding.
Fixes <http://bugs.gnu.org/20200>, introduced in
  commit 337edc591f.
Reported by David Kastrup <dak@gnu.org>.

* libguile/r6rs-ports.c (make_bip, make_cbip, make_bop, make_cbop):
  After setting port encoding = NULL, update 'encoding_mode'
  accordingly.
* libguile/ports.c (scm_i_set_port_encoding_x): Add warning comment.
* test-suite/tests/r6rs-ports.test: Add tests.
2015-03-28 16:01:23 -04:00
Taylan Ulrich Bayırlı/Kammer
bfdea17192 Correct docstring of 'symlink'.
* libguile/filesys.c (symlink): Correct the docstring, which had
  'oldpath' and 'newpath' confused.
2015-03-05 22:45:29 +01:00
Ludovic Courtès
b4f7e24c84 Use 'scm_is_eq' to compare 'SCM' objects.
* libguile/goops.c (scm_compute_applicable_methods): Use 'scm_is_eq'
  rather than direct comparison (regression introduced in 649ec8d8.)
2015-03-04 09:50:06 +01:00
Mark H Weaver
15673f1fd2 Don't return expressions from void functions in numbers.c
Although popular compilers allow it as long as the expression is of type
void, it violates C99 and some compilers choke on it.

* libguile/numbers.c (scm_euclidean_divide, scm_floor_divide)
  (scm_ceiling_divide, scm_truncate_divide, scm_centered_divide)
  (scm_round_divide): Don't use the return statement with an expression
  from functions with return type void.
2015-03-01 22:04:07 -05:00
Mark H Weaver
9f0ec10fc9 Implement 'string-utf8-length' and 'scm_c_string_utf8_length'.
* libguile/strings.c (utf8_length, scm_c_string_utf8_length)
  (scm_string_utf8_length): New functions.
* libguile/strings.h (scm_c_string_utf8_length, scm_string_utf8_length):
  New prototypes.
* doc/ref/api-data.texi (Bytevectors as Strings): Add docs.
* doc/ref/guile.texi: Update manual copyright date to 2015.
* test-suite/tests/strings.test (string-utf8-length): Add tests.
2015-03-01 22:04:07 -05:00
Andy Wingo
79072a210a Struct and array GDB pretty printers hint as arrays
* libguile/libguile-2.0-gdb.scm (make-scm-pretty-printer-worker):
  (%scm-pretty-printer): Refactor to avoid printing all struct / array
  fields by hinting these as arrays.  The resulting print is not as
  faithful to the original data, but that's probably OK.
2015-02-25 21:55:22 +01:00
Andy Wingo
649ec8d823 Accessor methods only apply to subclasses with their slot
* libguile/goops.c (is_accessor_method, scm_compute_applicable_methods):
  Fix regression from 51f66c9120 (2009).
  Accessor methods are added on each subclass on which the slot is
  present; therefore if a subclass doesn't have a method, then the
  methods doesn't apply.  Truly fixes #17355, unlike
  583a23bf10.

* module/oop/goops.scm (compute-cmethod, compute-getter-method)
  (compute-setter-method): Revert earlier changes.

* test-suite/tests/goops.test ("accessor slots"): Update for new
  expectations, in agreement with Guile 1.8.
2015-01-26 17:57:44 +01:00