summaryrefslogtreecommitdiff
path: root/libguile
AgeCommit message (Collapse)AuthorFilesLines
2021-10-01Add frame-local-ref / frame-local-set! support for type 'ptrAndy Wingo1-2/+9
* libguile/frames.c (enum stack_item_representation): (scm_to_stack_item_representation): (scm_frame_local_ref): (scm_frame_local_set_x): Add support for "ptr" representations.
2021-09-17Revert shift of ndim in array tag from 3df3ba1a2c956bba122328e1fc4be614171a4f42Daniel Llorens1-2/+2
To avoid breaking ABI. * libguile/arrays.h (SCM_I_ARRAY_DIM, scm_i_raw_array): As stated. * module/system/vm/assembler.scm: As stated.
2021-08-17Extend bytevector-fill! to handle a partial fillDaniel Llorens2-24/+35
* libguile/bytevectors.c (bytevector-fill!): As stated. (scm_bytevector_fill_x): Stub to avoid changing the C API. * doc/ref/api-data.texi: Documentation. * libguile/vectors.c (vector-fill!): Less confusing variable names. * test-suite/tests/bytevectors.test: Test partial fill cases for bytevector-fill!.
2021-08-17Refactor srfi-4 declarationsDaniel Llorens1-246/+31
2021-08-16Remove array contp flagDaniel Llorens5-54/+20
This flag was set, but never used in Guile, and there was no documented API to access it. To check if an array is contiguous, use (array-contents <> #t). * libguile/arrays.h (scm_i_raw_array): New function. SCM_I_ARRAY_CONTIGUOUS, SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG, SCM_I_ARRAY_CONTP: Remove. scm_t_array_dim: Declare here, not in array-handle.h. SCM_I_ARRAY_NDIM: Shift by one bit since the contp flag isn't there anymore. * module/syste/vm/assembler.scm: Match removal of contp flag. * libguile/arrays.c (scm_i_make_array): Reuse scm_i_raw_array. (scm_i_ra_set_contp): Remove. (scm_transpose_array): Don't set or clear the contp flag. (scm_make_shared_array): Don't set or clear the contp flag. (scm_make_typed_array): Don't set the contp flag. * libguile/array-map.c (scm_i_array_rebase): Reuse scm_i_raw_array.
2021-08-16Deprecate scm_from_contiguous_typed_arrayDaniel Llorens4-60/+71
This was never documented and it's not used in Guile itself, either.
2021-08-16Remove the 'simple vector' conceptDaniel Llorens5-17/+20
* Deprecate scm_is_simple_vector. * libguile/vectors.c (scm_vector_elements, scm_vector_writable_elements): These functions take an array; reword to make this clear. * libguile/print.h: Remove reference to 'simple vector'. * doc/ref/api-data.texi: Remove documentation for scm_is_simple_vector. Remove references to 'simple vector'. Fix documentation for scm_vector_elements, scm_vector_writable_elements. * test-suite/tests/arrays.test: * test-suite/tests/vectors.test: Remove references to 'simple vector'.
2021-08-06Add function vector-copy! to coreDaniel Llorens2-3/+45
This is up to 20%-30% faster than the previous versions in (scheme base) or (srfi srfi-43) that used vector-move-left!/vector-move-right!. * libguile/vectors.h: * libguile/vectors.c: As stated. * doc/ref/api-data.texi (vector-copy!): Document the new function. (vector-fill!): Document optional arguments. (vector-copy): Document optional arguments. * module/scheme/base.scm: Reuse core vector-copy!. * module/srfi/srfi-43.scm: Reuse core vector-copy!.
2021-08-06Extend core vector-copy to r7rs vector-copyDaniel Llorens2-7/+35
* libguile/vectors.h: Declare scm_vector_copy_partial. * libguile/vectors.c (scm_vector_copy_partial): As stated. (scm_vector_copy): Reuse scm_vector_copy_partial. * module/scheme/base.scm: Reuse core vector-copy. * module/srfi/srfi-43: Reuse core vector-copy. * test-suite/tests/vectors.test: Test vector-copy.
2021-08-06Deprecate use of vector-move-left! and vector-move-right! on non-vector arraysDaniel Llorens1-53/+104
These functions weren't advertised to work on non-vector arrays. They did try to, but only incorrectly. For example: (define a (vector 1 2 3 4 5)) (define b (make-array 0 '(1 5))) (vector-move-right! a 0 2 b 2) b => #1@1(0 0 1 2 0) instead of the correct result #1@1(0 1 2 0 0). * libguile/vectors.c (vector-move-left!, vector-move-right!): As stated.
2021-08-05Deprecate using vector->list, vector-copy on arraysDaniel Llorens1-32/+60
* libguile/vectors.c (vector-copy, vector->list): As stated. Provide array free implementation for the supported case.
2021-08-03Merge libguile/generalized-arrays.* into libguile/arrays.*Daniel Llorens10-713/+614
* libguile/arrays.h: * libguile/arrays.c: As stated. * libguile/init.c: Remove call to scm_init_generalized_arrays(). Elsewhere fix references to generalized-arrays.*.
2021-05-11Bump objcode versionAndy Wingo1-1/+1
* libguile/loader.h (SCM_OBJCODE_MINOR_VERSION): * module/system/vm/assembler.scm (*bytecode-minor-version*): Bump, as we're going to start adding inlinable exports.
2021-05-08'primitive-fork' closes and recreates the current thread's 'sleep_pipe'.Ludovic Courtès1-1/+28
Partly fixes <https://bugs.gnu.org/41948>. Previously, the child process could end up using the same 'sleep_pipe' as its parent, leading to a race condition handling signals. * libguile/posix.c (do_fork): New function. (scm_fork): Call 'do_fork' via 'scm_without_guile'. * test-suite/standalone/test-signal-fork: New test. * test-suite/standalone/Makefile.am (check_SCRIPTS, TESTS): Add it.
2021-05-08Close the finalization pipe before forking.Andrew Whatson1-17/+28
Partly fixes <https://bugs.gnu.org/41948>. Reported by Mathieu Othacehe <othacehe@gnu.org>. Previously, after 'fork', the child process could end up sharing the finalization thread with its parent. * libguile/finalizers.c (finalization_pipe): Initialize. (reset_finalization_pipe): Factored out. (start_finalization_thread): Create the pipe immediately before launching the thread. Ensure the pipe is cleaned up if thread creation fails. Update the finalizer callback if thread creation succeeds. (stop_finalization_thread): Clean up the pipe after stopping the thread. (spawn_finalizer_thread): Remove finalizer callback logic. (scm_set_automatic_finalization_enabled): Remove pipe management. (scm_init_finalizer_thread): Remove pipe management. Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2021-05-07Define `O_NOFOLLOW' and various other flags when supported.Maxime Devos1-0/+36
* libguile/filesys.c (scm_init_filesys): Define ‘O_IGNORE_CTTY’, ‘O_NOLINK’, ‘O_NOFOLLOW’, ‘O_PATH’, ‘O_TMPFILE’, ‘O_SHLOCK’, ‘O_EXLOCK’, ‘O_ASYNC’, ‘O_NOATIME’, ‘O_DIRECTORY’, ‘O_CLOEXEC’ and ‘O_DIRECT’ when available. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2021-05-01Include config.h in mini-gmp.c, if presentAndy Wingo1-0/+4
* libguile/mini-gmp.c: Add config.h include. Handles the case in which gnulib provides some part of the standard library of mini-gmp, as is apparently the case on FreeBSD for example. Thanks to RhodiumToad for the report and fix.
2021-04-27Add GUILE_INSTALL_GMP_MEMORY_FUNCTIONS to NEWS; use at build-timeAndy Wingo1-0/+1
* NEWS (GUILE_INSTALL_GMP_MEMORY_FUNCTIONS): Update * libguile/numbers.c: Add needed include. * meta/build-env.in (GUILE_INSTALL_GMP_MEMORY_FUNCTIONS): Set when building Guile.
2021-04-26Allow users to force gmp to use libgcAndy Wingo1-0/+9
* doc/ref/guile-invoke.texi (Environment Variables): Document GUILE_INSTALL_GMP_MEMORY_FUNCTIONS. * libguile/numbers.c (scm_init_numbers): Use environment variable.
2021-04-26Bump minor objcode version for new intrinsicsAndy Wingo1-2/+2
* libguile/loader.h (SCM_OBJCODE_MINOR_VERSION): Bump. * module/system/vm/assembler.scm (*bytecode-minor-version*): Bump.
2021-04-26Fix error when argument to < not a realAndy Wingo1-1/+2
* libguile/intrinsics.c (less_p): scm_nan_p raises an error if arg is not a real; guard.
2021-04-26Simplify module variable lookup slow-pathAndy Wingo4-4/+96
* libguile/intrinsics.h: * libguile/intrinsics.c (lookup_bound_public, lookup_bound_private): Two new intrinsics. (scm_bootstrap_intrinsics): Wire them up. * libguile/jit.c (compile_call_scm_from_scmn_scmn): (compile_call_scm_from_scmn_scmn_slow): (COMPILE_X8_S24__N32__N32__C32): Add JIT support for new instruction kind. * libguile/vm-engine.c (call-scm<-scmn-scmn): New instruction, takes arguments as non-immediate offsets, to avoid needless loads and register pressure. * module/language/cps/effects-analysis.scm: Add cases for new primcalls. * module/language/cps/compile-bytecode.scm (compile-function): Add new primcalls. * module/language/cps/reify-primitives.scm (cached-module-box): If the variable is bound, call lookup-bound-public / lookup-bound-private as appropriate instead of separately resolving the module, name, and doing the bound check. * module/language/tree-il/compile-bytecode.scm (emit-cached-module-box): Use new instructions. * module/system/vm/assembler.scm (define-scm<-scmn-scmn-intrinsic): (lookup-bound-public, lookup-bound-private): Add assembler support.
2021-04-12Compile fix for x86_64-MinGW.Jan (janneke) Nieuwenhuizen1-3/+3
* libguile/posix-w32.h (start_child): Return pid_t.
2020-10-05Document write-line.Jan (janneke) Nieuwenhuizen1-1/+1
* libguile/rdelim.c (SCM_DEFINE): Use "procedure" rather than "function". * doc/ref/api-io.texi (Line/Delimited): Use it to document 'write-line'.
2021-03-15Fix buffer overread in string-locale<?Andy Wingo1-23/+18
* libguile/i18n.c (compare_strings): In all cases, convert to a null-terminated string. While we're doing that, might as well use utf-8. * test-suite/tests/i18n.test ("text collation (French)"): Add test. Thanks again to Rob Browning for the report.
2021-03-15Fix buffer overread in string-locale-ci=? and related functionsAndy Wingo1-9/+11
* libguile/i18n.c (u32_locale_casecoll): Take lengths of incoming strings as parameters rather than assuming "nul" termination. (compare_u32_strings_ci): Pass string lengths as computed from the Scheme strings. * test-suite/tests/i18n.test ("text collation (English)"): Add a test case. Thanks a million to Rob Browning for the report.
2021-03-13Add JIT capability for MinGWMike Gran2-14/+52
* libguile/jit.c [__MING32__]: add windows.h on Win32 (struct code_arena) [__MINGW32__]: a HANDLE for Win32 mmap (BIGENDIAN): rename to JIT_BIGENDIAN, to avoid collision with Win32 BIGENDIAN constant. All users changed (allocate_code_arena) [__MINGW32__]: add Win32 mmap allocator (emit_code) [__MINGW32__]: add Win32 munmap * libguile/lightening/lightening/lightening.c: remove unnecessary mman.h
2021-03-12Don't force installation of GMP allocators in guile shellAndy Wingo1-1/+0
* libguile/guile.c (main): Don't override initial setting of scm_install_gmp_memory_functions. Thanks to Andrew Whatson for the fix.
2021-03-12Revert "Handle CRLF and Unicode line endings in read-line"Andy Wingo1-37/+10
This reverts commit 0f983e3db0c43ad7c89f57ea84f792ede373ba0c. After discussing with Mike we are going to punt the read-line changes for now. Open the port in O_TEXT mode if you want to chomp the CR in CFLF sequences.
2021-03-11Handle CRLF and Unicode line endings in read-lineMike Gran1-10/+37
* libguile/rdelim.c (scm_read_line): handle CRLF, LS and PS * module/ice-9/suspendable-ports.scm (read-line): handle CRLF, LS, and PS * module/web/http.scm (read-header-line): take advantage of CRLF in read-line (read-header): don't need to test for \return * test-suite/tests/rdelim.test: new tests for read-line CRLF, LS and PS * doc/ref/api-io.texi: update doc for read-line
2021-03-11For MinGW use Windows filepaths in libpath.hMichael Gran1-1/+46
* configure.ac (MINGW_LIBPATH): new automake conditional and test * libguile/Makefile.am (libpath.h) [MINGW_LIBPATH]: use Windows-style paths
2021-03-11on MinGW, prefer winsock2.h over sys/select in iselectMike Gran1-0/+4
* libguile/iselect.h [__MINGW32__]: add winsock2 include
2021-03-11Add windows stubs for dlopen, dlclose, dlsym, dlerrorMike Gran3-1/+66
* libguile/dynl.c [__MING32__] (dlopen, dlsym, dlclose, dlerror): use windows stubs * libguile/posix-w32.c (dlopen_w32, dlsym_w32, dlclose_w32, dlerror_w32): new procedures (dlerror_str): new module-level variable (DLERROR_LEN): new define * libguile/posix-w32.h: declare dlopen_w32, dlsym_w32, dlclose_w32, dlerror_w32. Declare RTLD_NOW, RTLD_LAZY, RTLD_GLOBAL, RTLD_LOCAL
2021-03-10Add mkstemp; undocument mkstemp!Andy Wingo2-23/+57
* doc/ref/posix.texi (File System): Update to document mkstemp only. * libguile/filesys.c: Make a mkstemp that doesn't modify the input template. Instead the caller has to get the file name from port-filename. (scm_mkstemp): Use the new mkstemp to implement mkstemp!. Can't deprecate yet though as the replacement hasn't been there for long enough. * libguile/posix.c (scm_tempnam): Update to mention mkstemp instead. * module/system/base/compile.scm (call-with-output-file/atomic): Use mkstemp. * test-suite/tests/posix.test: * test-suite/tests/r6rs-files.test: Use mkstemp. * NEWS: Update.
2021-03-10On Win32, prefer winsock2 header for socket declarationsMike Gran1-3/+8
* libguile/posix-w32.h: prefer lowercase windows.h for MinGW cross-builds * libguile/socket.c [HAVE_WINSOCK2_H]: use only winsock2.h for socket declarations
2021-03-10remove 2nd attempt at invoking ComSpec when spawning childMichael Gran1-17/+1
The start_child procedure is used to spawn a child process. If it fails to launch the given argv[0] as if it were a command, it has logic to retry using the ComSpec as a command interpreter, treating argv[0] as a batch file name. Usually, this fails because batch files would have been handled in the first pass if they were valid. Also, this has the unfortunate side effect of spawning a shell awaiting user input. It is safer to remove this attempt. * libguile/posix-w32.c (start_child): remove fallback processing
2021-03-10Use lower-case windows.hMichael Gran1-1/+1
On some linux cross-builds, Windows.h is windows.h. On MinGW case is irrelevant. * libguile/posix-w32.h: modified
2021-03-08Fix define error for mini-gmpMichael Gran1-1/+1
* libguile/gen-scmconfig.c [!SCM_I_GSC_ENABLE_MINI_GMP]: define SCM_ENABLE_MINI_GMP as zero, not undef
2021-03-08Only install libgc as GMP allocator with mini-gmpAndy Wingo1-5/+19
* libguile/numbers.c (scm_install_gmp_memory_functions): Default to 1 only if mini-gmp is enabled.
2021-03-08Don't expose mini-gmp to usersAndy Wingo1-2/+23
* libguile.h: Don't import anything GMP-related. * libguile/numbers.h: Import GMP here instead. If we are using mini-GMP, only import it when building Guile. (scm_to_mpz, scm_from_mpz): Don't define when mini-gmp is enabled.
2021-03-03don't presume availability of gmp.pcMichael Gran7-16/+25
This suggests moving the conditional that determines if mini-gmp is used into scmconfig.h. * configure.ac: replace PKG_CHECK_MODULES for gmp with AC_LIB_HAVE_LINKFLAGS Remove ENABLE_MINI_GMP define. Also don't run mpz_inits test for --enable-mini-gmp. * libguile/gen-scmconfig.c (main) [ENABLE_MINI_GMP]: replace ENABLE_MINI_GMP with SCM_I_GSC_ENABLE_MINI_GMP * libguile/bytevectors.c [ENABLE_MINI_GMP]: replace ENABLE_MINI_GMP with SCM_ENABLE_MINI_GMP * libguile/init.c [ENABLE_MINI_GMP]: replace ENABLE_MINI_GMP with SCM_ENABLE_MINI_GMP * libguile/numbers.c: include scm.h [SCM_ENABLE_MINI_GMP]: provide mpz_inits and mpz_clears [ENABLE_MINI_GMP]: prefer SCM_ENABLE_MINI_GMP to ENABLE_MINI_GMP * libguile/numbers.h: include scm.h * libguile/random.c [ENABLE_MINI_GMP]: replace ENABLE_MINI_GMP with SCM_ENABLE_MINI_GMP * libguile/socket.c [ENABLE_MINI_GMP]: replace ENABLE_MINI_GMP with SCM_ENABLE_MINI_GMP
2021-03-03Remove read extension support from primitive-readAndy Wingo1-37/+5
* libguile/read.c (scm_read_sharp_extension): Remove. (scm_read_sharp): Adapt.
2021-03-03More read.c simplificationsAndy Wingo1-30/+28
* libguile/read.c: Use "return EXPR" instead of "return (EXPR)". Avoid passing around line and column info, as we don't use it any more.
2021-03-03primitive-read handles only default reader optionsAndy Wingo1-656/+122
* libguile/read.c: Remove support for all non-default reader options. Also remove support for source positions. The idea is that primitive-read should just be a stripped-down, easy-to-understand reader that is enough to bootstrap the C reader. Probably more refactoring will follow.
2021-03-03Scheme reader fully replaces C readerAndy Wingo2-4/+22
* libguile/read.h: * libguile/read.c (scm_primitive_read): New name for C reader. (scm_read): Call current value of "read" variable. (scm_init_read): Initialize "read" binding to "primitive-read". Replaced later in boot-9.
2021-03-03Invalid charset at EOF does not cause decoding errorAndy Wingo1-9/+2
* libguile/ports.c (peek_iconv_codepoint): If the input has no bytes, there's little point in raising a decoding error here. Therefore remove the needless iconv acquisition, harmonising with suspendable-ports. * test-suite/tests/ports.test ("port-encoding"): Update test to include some input so that the exception gets raised.
2021-03-02improve autoconfigury for minigmpMichael Gran8-10/+13
* configure.ac: add SCM_I_GSC_ENABLE_MINI_GMP var and rename GUILE_MINI_GMP to ENABLE_MINI_GMP * libguile/bytevectors (GUILE_MINI_GMP): rename to ENABLE_MINI_GMP * libguile/gen-scmconfig.c: renamed GUILE_MINI_GMP to ENABLE_MINI_GMP. rename GUILE_MINI_GMP to SCM_ENABLE_MINI_GMP * libguile/gen-scmconfig.h: add SCM_I_GSC_ENABLE_MINI_GMP * libguile/init.c [GUILE_MINI_GMP]: prefer ENABLE_MINI_GMP * libguile/numbers.c [GUILE_MINI_GMP]: prefer ENABLE_MINI_GMP * libguile/numbers.h: include scmconfig.h rename GUILE_MINI_GMP to SCM_ENABLE_MINI_GMP * libguile/random.c [GUILE_MINI_GMP]: prefer ENABLE_MINI_GMP * libguile/socket.c [GUILE_MINI_GMP]: prefer ENABLE_MINI_GMP * libguile.h [GUILE_MINI_GMP]: prefer SCM_ENABLE_MINI_GMP
2021-03-02Enable option to prefer mini-gmp over libgmpMichael Gran10-8/+4922
* configure.ac: rework gmp library detection. Add new flag. * libguile.h: modify gmp header inclusion * libguile/Makefile.am: add mini-gmp.[ch] files * libguile/bytevectors.c: add mini-gmp headers * libguile/gen-scmconfig.c: new #include variable GUILE_MINI_GMP * libguile/init.c: add mini-gmp header * libguile/mini-gmp.c: new file * libguile/mini-gmp.h: new file * libguile/numbers.c: add fallback for missing mpz_get_d_2exp * libguile/numbers.h: yse mini-gmp header * libguile/random.c: use mini-gmp header * libguile/socket.c: use mini-gmp header
2021-02-25Add syntax-sourcevAndy Wingo2-3/+53
* libguile/syntax.c (sourcev_to_props, props_to_sourcev) (scm_syntax_source, scm_syntax_sourcev): Add alternate source representation for syntax objects.
2021-02-20Syntax objects have "source" fieldAndy Wingo2-10/+51
* libguile/syntax.c (scm_make_syntax): Add optional "source" argument. Note that this function is internal. (scm_syntax_source): New function, replacing definition in boot-9.scm. * libguile/syntax.h: Add new declarations. * module/ice-9/psyntax-pp.scm: * module/ice-9/psyntax.scm (source-annotation): For syntax objects, the source annotation comes direct from the syntax object. * module/system/vm/assembler.scm (link-data, intern-constant): Write 5-word syntax objects.