* libguile/posix.c (scm_total_processor_count,
scm_current_processor_count): New functions.
* libguile/posix.h (scm_total_processor_count,
scm_current_processor_count): New declarations.
* test-suite/tests/posix.test ("nproc"): New test prefix.
* doc/ref/posix.texi (Processes): Document `total-processor-count' and
`current-processor-count'.
* doc/ref/posix.texi (Processes): Add cross-reference from `setaffinity'
and `getaffinity' to the corresponding node in the glibc manual.
* libguile/posix.c (scm_getaffinity, scm_setaffinity): Likewise.
* libguile/fluids.c (scm_make_undefined_fluid, scm_fluid_unset_x)
(scm_fluid_bound_p): New functions.
(fluid_ref): New function; like scm_fluid_ref, but will not throw an
error for unbound fluids.
(scm_fluid_ref, swap_fluid): Use `fluid_ref'.
* libguile/fluids.h (scm_make_undefined_fluid, scm_fluid_unset_x)
(scm_fluid_bound_p): New prototypes.
* libguile/vm-i-system.c (fluid_ref): If fluid is unbound, jump to
`vm_error_unbound_fluid'.
* libguile/vm-engine.c (VM_NAME)[vm_error_unbound_fluid]: New error
message.
* test-suite/tests/fluids.test ("unbound fluids")["fluid-ref of unbound
fluid", "fluid-bound? of bound fluid", "fluid-bound? of unbound
fluid", "unbound fluids can be set", "bound fluids can be unset"]: New
tests.
* libguile/vm-i-system.c (variable-ref, toplevel-ref)
(long-toplevel-ref): Fixup callers.
* libguile/vm-engine.c (vm_error_unbound): Don't use vm-error for
unbound vars, use misc-error. Don't include VM: in the string. Take
the name directly in finish_args, not as a list.
* libguile/ports.c (scm_drain_input): Slight optimization.
* libguile/fports.c (scm_setvbuf): If there is buffered output, flush
it. If there is input, drain it, and then unread it after updating
the buffers. Much more sensible than dropping it silently...
* libguile/poll.c (scm_primitive_poll): Account for buffered I/O.
* module/ice-9/poll.scm (poll): Adapt to call primitive-poll with the
port vector too.
* libguile/gc-malloc.c: Add a note that the gc-malloc does not clear the
memory block, so users need to make sure it is initialized.
* libguile/bitvectors.c (scm_c_make_bitvector):
* libguile/bytevectors.c (scm_make_bytevector):
* libguile/strings.c (scm_c_make_string): If no initializer is given,
initialize the bytes to 0. Prevents information leakage if an app uses
make-string et al without initializers.
* libguile/foreign.c (make_cif): Initialize this too, to prevent leakage
in the struct holes. Paranoia...
* configure.ac: Add checks for `sched_setaffinity' and
`sched_getaffinity'.
* doc/ref/posix.texi (Processes): Document `getaffinity' and
`setaffinity'.
* libguile/posix.c (cpu_set_to_bitvector,
scm_getaffinity)[HAVE_SCHED_GETAFFINITY]: New functions.
(scm_setaffinity)[HAVE_SCHED_SETAFFINITY]: New function.
* libguile/posix.h (scm_getaffinity, scm_setaffinity): New declarations.
* test-suite/tests/posix.test ("affinity"): New test prefix.
* libguile/socket.c (scm_accept): Revert
7d1fc87217. Now that we don't need to
leave guile mode in order for GC to happen, don't do so, as we assume
that anyone who cares has already done a select() beforehand.
* libguile/regex-posix.c (fixup_multibyte_match): Fixup the match
structure to refer to character offsets, not byte offsets. Fixes bug
31650.
* test-suite/tests/regexp.test: Add a test.
* libguile/r6rs-ports.c (make_bip, make_cbip, make_bop, make_cbop): Lock
the port table.
* libguile/r6rs-ports.c (make_bop): Let the returned extraction
procedure refer to the port's buffer instead of the port itself. This
fixes a segfault if the port is closed before the extraction procedure
is called.
(bop_proc_apply): Adapt accordingly.
* test-suite/tests/r6rs-ports.test (8.2.10 Output ports): Add testcase
for extraction after close.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Add a new command-line switch `-x', which manipulates the
%load-extensions list.
* libguile/script.c (scm_compile_shell_switches): Process the new "-x"
switch.
(scm_shell_usage): Mention the "-x" switch.
* doc/ref/scheme-scripts.texi (Invoking Guile): Add "-x" switch to the
list of command-line switches.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump, as the
process-define-module deprecation means that outside compiled code
won't find process-define-module in the (guile) module, as they would
before.
* libguile/srfi-13.h:
* libguile/srfi-13.c (scm_string_filter, scm_string_delete): Swap
char_pred and s argument order, to comply with SRFI-13. There is a
back-compat shim that will detect programs that used the old,
erroneous interface, while giving a warning.
* doc/ref/api-data.texi: Update docs.
* libguile/bytevectors.c:
* libguile/goops.c:
* libguile/instructions.c:
* libguile/numbers.c:
* libguile/random.c:
* libguile/read.c:
* libguile/vm-i-scheme.c: Fix a number of assumptions that a long could
hold an inum. This is not the case on platforms whose void* is larger
than their long.
* libguile/numbers.c (scm_i_inum2big): New helper, only implemented for
sizeof(void*) == sizeof(long); produces a compile error on other
platforms. Basically gmp doesn't have a nice interface for converting
between mpz values and intmax_t.
* libguile/debug.c:
* libguile/eval.c:
* libguile/frames.c:
* libguile/objcodes.c:
* libguile/print.c:
* libguile/programs.c:
* libguile/read.c:
* libguile/struct.c:
* libguile/vm.c: Fix a number of instances in which we assumed we could
fit a pointer into a long.
This results in a 17% improvement in the execution time of the "+" and
"-" benchmarks for fixnums.
* libguile/vm-i-scheme.c (ASM_ADD, ASM_SUB)[defined __x86_64__ &&
SCM_GNUC_PREREQ (4, 5)]: New macros.
(add)[defined ASM_ADD]: Use `ASM_ADD' for the fast path.
(sub)[defined ASM_SUB]: Use `ASM_SUB' for the fast path.
* test-suite/tests/numbers.test ("+")["fixnum + fixnum = bignum
(32-bit)", "fixnum + fixnum = bignum (64-bit)", "bignum + fixnum =
fixnum", "wrong type"]: New tests.
("-")["fixnum - fixnum = bignum (32-bit)", "fixnum - fixnum = bignum
(64-bit)", "bignum - fixnum = fixnum", "wrong type"]: New tests.
* test-suite/tests/00-initial-env.test ("goopsless")["+ wrong type
argument"]: Use `with-test-prefix/c&e' instead of `with-test-prefix'.
["- wrong type argument"]: New test prefix.
* libguile/posix.c:
* libguile/posix.h:
* libguile/deprecated.h:
* libguile/deprecated.c (scm_cuserid): Deprecate cuserid, as it only
returns 8 bytes of a user's login.
* doc/ref/posix.texi: Remove cuserid from docs.
* module/system/repl/repl.scm (display-syntax-error): New helper,
displays a syntax error.
(abort-on-error, run-repl): Use it.
* libguile/throw.c (handler_message): Re-code the same thing in C.
* libguile/numbers.c (scm_iuint2str): Add an assertion on the domain of
the radix. Use the number_chars table to write the string, instead of
doing strange math. Same effect, though.
(mem2uinteger, char_decimal_value): Change logic to allow all ascii
alphabetic chars as decimals, not just a-f. Thanks to Nils Gey for the
report.
* test-suite/tests/numbers.test ("number->string"): Add some tests.
This allows customizing the reader behavior for a dynamic extent more easily.
* libguile/read.c (scm_read_hash_procedures): Renamed to
`scm_i_read_hash_procedures'.
(scm_i_read_hash_procedures_ref, scm_i_read_hash_procedures_set_x):
New (internal) accessor functions for the fluid.
(scm_read_hash_extend, scm_get_hash_procedure): Use these accessor
functions.
(scm_init_read): Create the fluid, named `%read-hash-procedures' instead of
the previous plain list `read-hash-procedures'.
* test-suite/tests/reader.test: Adapt the "R6RS/SRFI-30 block comment
syntax overridden" test to make use of the fluid.
* module/ice-9/deprecated.scm (read-hash-procedures):
New identifier macro -- backward-compatibility shim.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* libguile/threads.c:
* libguile/posix.c: Change a couple #if HAVE_FOO to #ifdef HAVE_FOO to
pacify -Wundef. Some vars are defined or not, whereas some are always
defined to 0 or 1. The inconsistency is unfortunate.
* libguile/Makefile.am (chknew-E chknew-SIG): Run gcc without `-undef'
since otherwise it ends up trying to include headers that are not
available (e.g., <gnu/stubs-32.h> on an x86_64-linux-gnu system.)
* libguile/vm-i-system.c (VM_DEFINE_INSTRUCTION): Drop the stack items
corresponding the the with-fluids object. Thanks very much to Stefan
Israelsson Tampe for the fix.
* libguile/vm-i-scheme.c (INUM_MAX, INUM_MIN): New macros.
(add1, sub1): Add/subtract without untagging the operand. This leads
to a 44% run time improvement compared to the previous
implementation.
* libguile/vm.c: Include <stdint.h>.
* test-suite/tests/numbers.test ("1+", "1-"): Add tests for
MOST-POSITIVE-FIXNUM, resp. MOST-NEGATIVE-FIXNUM, for 32-bit and
34-bit values thereof.
* benchmark-suite/benchmarks/arithmetic.bm: New file.
* benchmark-suite/Makefile.am (SCM_BENCHMARKS): Add it.