1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00
Commit graph

8493 commits

Author SHA1 Message Date
Andy Wingo
1f14900a07 Use gnulib for basename / dirname
* libguile/filesys.c (scm_dirname, scm_basename): Rewrite to use
  gnulib's dirname-lgpl.
2016-07-25 11:49:55 +02:00
Eli Zaretskii
0cf155be72 Untabify posix-w32.c 2016-07-25 11:49:32 +02:00
Eli Zaretskii
62843d5475 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-25 11:49:27 +02:00
Andy Wingo
aae3561584 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-25 11:46:18 +02:00
Eli Zaretskii
d87915f25d 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-25 11:44:45 +02:00
Andy Wingo
da0ee4dc80 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-25 11:44:29 +02:00
Andy Wingo
513344e33d 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-25 11:43:54 +02:00
Eli Zaretskii
3231d7658d 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-25 11:42:09 +02:00
Andy Wingo
b2d77c38c4 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-25 11:41:50 +02:00
Andy Wingo
10ae9cc601 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-25 11:24:55 +02:00
Andy Wingo
f632d45c69 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-25 11:24:49 +02:00
Andy Wingo
9222e05ef1 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-25 11:24:41 +02:00
Andy Wingo
a1cb59c47e 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-25 11:24:33 +02:00
Andy Wingo
a9e726eda7 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-25 11:24:26 +02:00
Ludovic Courtès
b505ad9ad3 Add missing 'const' qualifier.
* libguile/stime.c (tzvar): Add 'const'.
2016-07-25 11:22:52 +02:00
Ludovic Courtès
abb0b54be8 Unconditionally include <time.h> from Gnulib.
* libguile/stime.c: Unconditionally include <time.h>.
2016-07-25 11:22:45 +02:00
Andy Wingo
38f23e75a5 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/bootstrap.am (.scm.go):
* am/guilec (.scm.go): Use build-env.
* configure.ac: Create build-env.
2016-07-10 14:10:26 +02:00
Andy Wingo
6a5b44de68 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-24 17:52:30 +02:00
Andy Wingo
d848af9a16 Parse bytecode to determine minimum arity
* libguile/programs.c (try_parse_arity): New helper, to parse bytecode
  to determine the minimum arity of a function in a cheaper way than
  grovelling through the debug info.  Should speed up all thunk? checks
  and similar.
  (scm_i_program_arity): Simplify.
* libguile/gsubr.h:
* libguile/gsubr.c (scm_i_primitive_arity):
* libguile/foreign.h:
* libguile/foreign.c (scm_i_foreign_arity):
2016-06-24 14:15:38 +02:00
Andy Wingo
7d550c4ea0 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-24 09:50:23 +02:00
Andy Wingo
f23dfc0fb5 Locale is default port encoding
* libguile/ports.c (scm_init_ports): Use the locale as the default
  charset.  After the switch to default GUILE_INSTALL_LOCALE=1, this
  harmonizes the default port encoding with the installed locale.
2016-06-24 07:43:58 +02:00
Andy Wingo
2c8ea5a008 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 14:57:50 +02:00
Andy Wingo
c01a2a757e 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:13:02 +02:00
Andy Wingo
9a95167871 Fix relative file name canonicalization on paths with "."
* libguile/filesys.c (scm_i_relativize_path): Canonicalize the file
  names elements that we will be using as prefixes.  Fixes the case
  where a load path contains a relative file name: #19540.
* test-suite/tests/ports.test ("%file-port-name-canonicalization"): Add
  tests that elements of the load path are canonicalized.
2016-06-23 10:17:57 +02:00
Andy Wingo
d84f25c271 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:47:40 +02:00
Andy Wingo
0ef4b76221 Remove a stale variable use in libguile/Makefile.am
* libguile/Makefile.am (BUILT_SOURCES): Remove a use of a variable that
  doesn't exist in 2.2.
2016-06-22 16:47:40 +02:00
Andy Wingo
3abd8e1ac1 Fix SCM_DEBUG_TYPING_STRICTNESS bug
* libguile/ports.c (scm_setvbuf): Fix bad use of SCM as a test value.
  Actually all ports have read buffers, so we can remove the condition
  entirely.  Thanks Hydra for building in this way :)
2016-06-22 12:50:16 +02:00
Andy Wingo
f1c0434403 `define!' instruction returns the variable
* doc/ref/vm.texi (Top-Level Environment Instructions): Update
  documentation.
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump, sadly.
* module/system/vm/assembler.scm (*bytecode-minor-version*): Bump.
* libguile/vm-engine.c (define!): Change to store variable in dst slot.
* module/language/tree-il/compile-cps.scm (convert):
* module/language/cps/compile-bytecode.scm (compile-function): Adapt to
  define! change.
* module/language/cps/effects-analysis.scm (current-module): Fix define!
  effects.  Incidentally here was the bug: in Guile 2.2 you can't have
  effects on different object kinds in one instruction, without
  reverting to &unknown-memory-kinds.
* test-suite/tests/compiler.test ("regression tests"): Add a test.
2016-06-21 22:40:31 +02:00
Andy Wingo
dc7bc06f69 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-20 17:15:21 +02:00
Andy Wingo
0c1ee6eae6 Fix ports bug when size_t is 32 bits
* libguile/ports.c (scm_end_input): I am a complete idiot.  I had no
  idea that `- (uint32_t) x' is actually still a uint32_t.
2016-06-18 13:08:12 +02:00
Andy Wingo
7142005a05 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-12 10:32:45 +02:00
Andy Wingo
2cb7c4c4d7 Remove unused static definitions
* libguile/expand.c:
* libguile/vm.c: Remove unused static definitions.
2016-06-11 18:29:35 +02:00
Andy Wingo
be6194e32a Fix shuffling of unboxed stack elements on 32-bit systems
* libguile/vm-engine.c (SP_REF_SLOT, SP_SET_SLOT): New defines.
  (push, pop, mov, long-mov): Move full slots.  Fixes 32-bit with
  unboxed 64-bit stack values; before when shuffling these values
  around, we were only shuffling the lower 32 bits on 32-bit platforms.
2016-06-11 14:44:59 +02:00
Andy Wingo
100b048097 VM type checking refactor
* libguile/vm-engine.c (VM_VALIDATE): Refactor some type-related
  assertions to use a common macro.
  (vector-length, vector-set!/immediate): Fix the proc mentioned in the
  error message.
2016-06-11 13:03:20 +02:00
Andy Wingo
ddce05e819 vm: Make sure IP is stored before potentially GCing.
* libguile/vm-engine.c: Add a number of SYNC_IP calls that were missing
  before calls that could GC.
2016-06-11 12:26:26 +02:00
Andy Wingo
7e502d57e0 Fix bad backtraces
* libguile/vm-engine.c (BV_REF, BV_BOUNDED_SET, BV_SET, integer->char)
  (char->integer): Use VM_ASSERT so that we save the IP before erroring
  out.
2016-06-10 15:33:09 +02:00
Andy Wingo
d1b99ea2ae Minor VM fixes
* libguile/vm-engine.c (string-ref): Unpack the index into a 64-bit
  integer.
  (br-if-u64-<-scm): Tighten up the fast path.
2016-06-10 08:23:04 +02:00
Andy Wingo
69ea1fc45b Support `connect' on nonblocking sockets
* libguile/socket.c (scm_connect):
* doc/ref/posix.texi (Network Sockets and Communication): Support
  connect on nonblocking ports.
2016-06-09 10:59:08 +02:00
Andy Wingo
e6cc051f8c `accept' on nonblocking socket can return #f
* doc/ref/posix.texi (Network Sockets and Communication):
* libguile/socket.c (scm_accept): Return #f if the socket is nonblocking
  and no connection is ready.
2016-06-09 10:59:08 +02:00
Andy Wingo
d8067213dc put-char in Scheme
* libguile/ports.c (scm_port_encode_char): New function.
* module/ice-9/ports.scm (port-encode-char): Export port-encode-char to
  the internals module.
* module/ice-9/sports.scm (put-char): New function.
  (port-bindings): Add put-char and put-string.
2016-06-09 10:59:02 +02:00
Andy Wingo
4bceba876b put-char, put-string in (ice-9 ports internals)
* libguile/ports.h (scm_put_char):
* libguile/ports.c (scm_put_char): New function.
  (scm_put_string): Add docstrings, and expose to the internal ports
  module.
* module/ice-9/ports.scm (put-char, put-string): Expose these bindings
  only through the internals module.
2016-06-08 07:44:16 +02:00
Andy Wingo
d7f39a36b1 socket: TCP_CORK, TCP_NODELAY
* libguile/socket.c (scm_init_socket): Define TCP_NODELAY and TCP_CORK
  if they are available.
* doc/ref/posix.texi (Network Sockets and Communication): Add
  documentation.
* NEWS: Add entry.
2016-06-04 12:49:47 +02:00
Andy Wingo
5bec3261b4 Rework text encoding to be more Scheme-friendly
* libguile/ports.c (scm_port_clear_stream_start_for_bom_write): Instead
  of returning the BOM, take an optional buffer in which to write the
  BOM.  Return number of bytes written.
  (port_clear_stream_start_for_bom_write): Remove.
  (scm_i_write): Adapt scm_port_clear_stream_start_for_bom_write call.
  (try_encode_char_to_iconv_buf, encode_latin1_chars_to_latin1_buf):
  (encode_latin1_chars_to_utf8_buf, encode_latin1_chars_to_iconv_buf):
  (encode_latin1_chars, encode_utf32_chars_to_latin1_buf):
  (encode_utf32_chars_to_utf8_buf, encode_utf32_chars_to_iconv_buf):
  (encode_utf32_chars, port_encode_chars): New helpers.
  (scm_port_encode_chars): New procedure.
  (scm_c_put_latin1_chars, scm_c_put_utf32_chars): Rework to use new
  encoding helpers.
  (scm_lfwrite): Use scm_c_put_latin1_chars.
2016-06-01 12:07:20 +02:00
Andy Wingo
0e888cd00b Simplify string, symbol, char display/write impls
* libguile/print.h:
* libguile/print.c: Use the new routines from ports.[ch].
2016-05-30 18:49:25 +02:00
Andy Wingo
2affb9accf Add scm_c_put_escaped_char, scm_c_can_put_char
* libguile/ports.h:
* libguile/ports.c (scm_c_put_escaped_char, scm_c_can_put_char): New
  helpers.
2016-05-30 18:48:09 +02:00
Andy Wingo
934b6dc398 iprin1 uses scm_c_put_string
* libguile/print.c (iprin1): Use scm_c_put_string for strings.
* test-suite/test-suite/lib.scm (exception:encoding-error): Add an
  additional expected error string for `encoding-error'.
2016-05-30 15:07:23 +02:00
Andy Wingo
8f615cde45 print_normal_symbol uses new port functions
* libguile/print.c (print_normal_symbol): Use new port functions.
2016-05-30 15:07:20 +02:00
Andy Wingo
43b6feeb1a Beginnings of supporting encoding text in ports.c
* libguile/ports.h (scm_c_put_latin1_chars, scm_c_put_utf32_chars)
  (scm_c_put_char, scm_c_put_string, scm_print_string): New public
  functions.  The plan is to move encoding to ports.c and out of
  print.c.
* libguile/ports.c (UTF8_BUFFER_SIZE, ESCAPE_BUFFER_SIZE): New internal
  defines.
  (update_port_position): Take a position instead of a port.  Update
  callers.
  (utf8_to_codepoint): Allow lengths that are larger than necessary.
  (port_clear_stream_start_for_bom_write): Require that io_mode be
  BOM_IO_TEXT to write a BOM.
  (scm_fill_input): Add a related comment about BOM handling.
  (scm_i_write): use BOM_IO_TEXT, at least for now.
  (encode_escape_sequence, codepoint_to_utf8, utf8_to_codepoint)
  (put_utf8_chars_to_iconv_port, put_latin1_chars_to_utf8_port)
  (put_latin1_chars_to_iconv_port, put_utf32_chars_to_latin1_port)
  (put_utf32_chars_to_utf8_port, put_utf32_chars_to_iconv_port): New
  helpers.
  (scm_putc, scm_puts): Use scm_c_put_char and scm_put_latin1_chars.
2016-05-30 15:06:38 +02:00
Andy Wingo
1123002a9e Add port-line-buffered?
* libguile/ports.c (scm_port_line_buffered_p): New function.
* module/ice-9/ports.scm: Plump port-line-buffered? and
  port-auxiliary-write-buffer through to the internals module
2016-05-25 21:56:19 +02:00
Andy Wingo
2f836e2384 port_clear_stream_start_for_bom_write refactor
* libguile/ports.c (port_clear_stream_start_for_bom_write): Rework to be
  friendly to Scheme write implementations.
2016-05-25 21:56:16 +02:00