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

7591 commits

Author SHA1 Message Date
Andy Wingo
edd6d6e280 Snarfing .x depends on built headers
* libguile/Makefile.am (BUILT_INCLUDES): New variable.
  (BUILT_SOURCES): Put .i and other generated .h to BUILT_INCLUDES.
  (.c.x, .c.doc): Depend on BUILT_INCLUDES.  Fixes
  https://bugs.gentoo.org/show_bug.cgi?id=590528.
2016-08-07 12:25:35 +02:00
Eli Zaretskii
8a1fb459eb Avoid compilation warnings about alloca in read.c
* libguile/read.c: Include alloca.h.
2016-07-24 18:13:29 +03:00
Andy Wingo
b491b32cd1 Fix --without-threads against threaded BDW-GC
* libguile/gc.c (scm_storage_prehistory): Prevent BDW-GC from spawning
  marker threads if Guile was built without threading support.
2016-07-24 15:29:48 +02:00
Andy Wingo
bee0bbf4a5 Reimplement null-threads as inline functions
* libguile/null-threads.h: Reimplement null-threads stubs for pthread
  data types, initializers, and functions in terms of types and inline
  functions instead of CPP macros.  Fixes unused-value warnings, and
  tightens things up in general.
  (scm_i_pthread_cleanup_push, scm_i_pthread_cleanup_pop): Remove these,
  as they were unused and incorrect -- they would never run the cleanup
  handler even if 1 was passed to pop.
2016-07-24 13:16:45 +02:00
Andy Wingo
1d128fb4e8 Use non-deprecated HAVE_STRUCT_TM_TM_ZONE
* libguile/stime.c: Change uses of the deprecated HAVE_TM_ZONE to the
  new HAVE_STRUCT_TM_TM_ZONE.
2016-07-23 14:07:11 +02:00
Andy Wingo
681914d2f0 Use gnulib for basename / dirname
* libguile/filesys.c (scm_dirname, scm_basename): Rewrite to use
  gnulib's dirname-lgpl.
2016-07-23 13:49:39 +02:00
Eli Zaretskii
3dcd6341ac Untabify posix-w32.c 2016-07-16 20:00:56 +03:00
Eli Zaretskii
5079adea75 Improve process handling on MS-Windows
* libguile/posix-w32.c: Include gc.h and threads.h.
(proc_record): New structure tag.
<procs, proc_size>: New static variables.
(find_proc, proc_handle, record_proc, delete_proc): New utility
functions.
(start_child): Return value is now pid_t, as it is on Posix
platforms.  Record the new process and returns its PID, instead of
returning a handle.  Fix the recursive call.
(waitpid, kill, getpriority, setpriority, sched_getaffinity)
(sched_setaffinity): Look up the PID in the recorded subprocesses
before trying to open a process that is not our subprocess.  Make
sure any open handle is closed before returning, unless it's our
subprocess.
2016-07-16 19:58:25 +03:00
Andy Wingo
3f9ae30bd9 Fix mkstemp! with 1 argument
* libguile/filesys.c (scm_i_mkstemp): Add SCM_OPN to flags if mode
  argument not given.
2016-07-16 15:45:37 +02:00
Andy Wingo
0cf62c576d Allow mkstemp! to have optional "mode" argument
* m4/mkstemp.m4: Remove.
* lib/mkstemp.c: Remove.
* lib/mkostemp.c: New file.
* m4/mkostemp.m4: New file.
* lib/Makefile.am:
* m4/gnulib-cache.m4:
* m4/gnulib-comp.m4: Remove mkstemp module, replace with mkostemp.

* libguile/fports.h:
* libguile/fports.c (scm_i_mode_to_open_flags): Factor out helper to
  parse mode string to open flags.
  (scm_open_file_with_encoding): Use the new helper.
* libguile/filesys.c:
  (scm_i_mkstemp): Adapt to take optional second argument, being a mode
  string.  Use mkostemp.
  (scm_mkstemp): Backwards compatible shim that calls scm_i_mkstemp.

* doc/ref/posix.texi:
* NEWS: Update.

* module/system/base/compile.scm (call-with-output-file/atomic): Pass
  "wb" as mode, to cause O_BINARY to be added on MinGW.
2016-07-16 15:37:55 +02:00
Eli Zaretskii
cfb2d58c92 Update uname implementation in posix-w32
* libguile/posix-w32.c (uname): Update to modern processors (ia64 and
  x86_64) and OS versions (Vista to Windows 10).  Delete trailing
  whitespace.
2016-07-16 10:54:45 +02:00
Andy Wingo
21e40ea74c Fix unused static variables in net_db.c
* libguile/net_db.c (SCM_DEFINE_CONSTANT): New helper.  Use it to
  define constants and avoid the unneeded static variables that were
  used before, named "sym_" but actually holding variables.  Thanks to
  Eli Zaretskii for the report.
2016-07-16 10:51:38 +02:00
Andy Wingo
e8c93013e3 Add popen feature
* doc/ref/api-options.texi (Common Feature Symbols): Document the popen
  feature.
* doc/ref/posix.texi (Pipes): Depend on the popen feature, not fork.
* libguile/posix.c (scm_init_posix): Add popen feature if we can.
2016-07-14 16:33:32 +02:00
Andy Wingo
da757c6814 Refactor implementation of current-warning-port
* module/ice-9/boot-9.scm (current-warning-port):
* libguile/init.c (scm_init_standard_ports):
* libguile/ports.c (cur_warnport_fluid, scm_current_warning_port)
  (scm_set_current_warning_port, scm_init_ports): Define the warning
  port in the same way as the error/output/input ports, with a fluid
  that doesn't require calling out to Scheme.
2016-07-14 16:18:47 +02:00
Eli Zaretskii
1c98b78848 Add POSIX shims for MinGW
* libguile/posix-w32.h:
* libguile/posix-w32.c (kill, waitpid, getpriority, setpriority)
  (sched_getaffinity, sched_setaffinity): Add MinGW implementations.
  Also, provides macros that on Posix hosts are in sys/wait.h, like
  WIFEXITED and WTERMSIG.
  (start_child): Add implementation.
2016-07-12 16:06:22 +02:00
Andy Wingo
e1cb762c9a Keep trucking on weak table corruption
* libguile/hashtab.c (vacuum_weak_hash_table): Don't abort if we
  apparently remove more items than are in the table; instead print a
  warning.  "Fixes" #19180.
2016-07-12 09:30:10 +02:00
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