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

6693 commits

Author SHA1 Message Date
Andy Wingo
557abc4978 fix bugs in primitive-poll
* libguile/poll.c (scm_primitive_poll): Only mark POLLOUT for output
  ports. Don't override results from the syscall, add to them.
2010-12-13 20:25:36 +01:00
Ludovic Courtès
f0c0141fe4 Add total-processor-count' and current-processor-count'.
* 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'.
2010-12-07 23:13:20 +01:00
Ludovic Courtès
3ae78cac88 Improve doc of getaffinity' and setaffinity'.
* 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.
2010-12-07 23:13:20 +01:00
Brian Templeton
a8aa4c0b56 variable-unset!
* libguile/variable.c (scm_variable_unset_x): New function.
* libguile/variable.h (scm_variable_unset_x): New prototype.
2010-12-07 13:21:01 +01:00
Brian Templeton
ef94624eaf unbound fluids
* 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.
2010-12-07 13:21:01 +01:00
Andy Wingo
d107921794 better unbound variable errors in the vm
* 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.
2010-12-07 13:21:01 +01:00
Andy Wingo
67a72dc13c scm_setvbuf doesn't throw away current buffers
* 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...
2010-12-06 19:59:15 +01:00
Andy Wingo
e9634465e3 ice-9 poll handles buffered io too
* 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.
2010-12-06 19:27:22 +01:00
Andy Wingo
3ef6650def make-string et al nulls memory if not given an initializer
* 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...
2010-12-04 19:31:20 +01:00
Andy Wingo
51c1dba88a ASYNC_TICK after catching EINTR in SCM_SYSCALL
* libguile/_scm.h (SCM_SYSCALL): As in scm_syserror, do a SCM_ASYNC_TICK
  before resuming the syscall after an EINTR.
2010-12-03 15:17:35 +01:00
Andy Wingo
6f81b18abe add (ice-9 poll), a poll wrapper
* libguile/poll.c:
* libguile/poll.h:
* module/ice-9/poll.scm: New module, (ice-9 poll).

* module/Makefile.am:
* libguile/init.c:
* libguile/Makefile.am: Adapt.

* configure.ac: Check for poll.h and poll.
2010-12-03 15:16:37 +01:00
Ludovic Courtès
fe613fe25d Add bindings to GNU sched_setaffinity' and sched_getaffinity'.
* 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.
2010-12-03 00:38:29 +01:00
Andy Wingo
50a4533f82 no need for fport_fill_input to select() before read()
* libguile/fports.c (fport_fill_input): Likewise to the previous commit,
  no need to select() before read().
2010-12-02 23:41:00 +01:00
Andy Wingo
e68e0369cc scm_accept no longer leaves guile mode
* 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.
2010-12-02 23:24:39 +01:00
Andy Wingo
e1ee45e78b indentation fix in ports.c
* libguile/ports.c (scm_i_get_conversion_strategy): Indentation fix.
2010-12-02 12:46:15 +01:00
Andreas Rottmann
1044537dff Add implementation of "transcoded ports"
* libguile/r6rs-ports.c (make_tp, tp_write, tp_fill_input, tp_flush)
  (tp_close, initialize_transcoded_ports, scm_i_make_transcoded_port): New
  functions.
  (scm_init_r6rs_ports): Call `initialize_transcoded_ports'.
* module/rnrs/ports.scm (transcoded-port): Actually implement,
  using `%make-transcoded-port'.
* test-suite/tests/r6rs-ports.test ("8.2.6 Input and output ports"): Added a
  few tests for `transcoded-port'.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2010-11-24 23:04:24 +01:00
Andy Wingo
644c5165ee fix regexp matches to refer to chars, not bytes
* 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.
2010-11-23 22:39:20 +01:00
Andreas Rottmann
a653d32a8d Fix missing port-table locking and bytevector output port segfault
* 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>
2010-11-20 23:55:19 +01:00
Andreas Rottmann
b710608c87 Allow specifying load extensions on the command line
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>
2010-11-20 01:11:23 +01:00
Andy Wingo
1c20cf1175 bump objcode version
* 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.
2010-11-19 17:51:16 +01:00
Andy Wingo
9fe717e23c fix string-filter and string-delete argument order
* 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.
2010-11-19 17:08:36 +01:00
Andy Wingo
57ced5b97a scm_c_define_module uses define-module*
* libguile/modules.c (scm_c_define_module):
* module/ice-9/boot-9.scm: Update to have the C function call
  define-module*.
2010-11-19 15:22:43 +01:00
Andy Wingo
e25f37271a fix a number of assuptions that a long could hold an inum
* 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.
2010-11-19 15:22:43 +01:00
Andy Wingo
d2aed81f7c simpos tweak
* libguile/simpos.c (scm_system_star): Use scm_from_ulong, as we do cast
  to ulong.
2010-11-19 15:22:43 +01:00
Andy Wingo
3d27ef4bd3 fix a number of assumptions that a pointer could fit into a long
* 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.
2010-11-19 15:22:43 +01:00
Ludovic Courtès
cdd47ec7e5 Include <alloca.h> wherever `alloca' is used.
Patch provided by <carlo.bramix@libero.it> (tiny change).

* libguile/control.c, libguile/fluids.c, libguile/foreign.c,
  libguile/hashtab.c, libguile/strings.c: Include <alloca.h>.
2010-11-19 14:14:53 +01:00
Ludovic Courtès
0b54eea09a Optimize fixnum comparison.
* libguile/vm-i-scheme.c (REL): Don't untag X and Y since tagging
  preserves ordering.
2010-11-19 13:34:44 +01:00
Ludovic Courtès
0c57673a11 Add optimized tagged integer addition/subtractions for x86_64.
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.
2010-11-19 13:34:43 +01:00
Ludovic Courtès
553d4bf8ea Add `SCM_GNUC_PREREQ'.
* libguile/__scm.h (SCM_GNUC_PREREQ): New macro.
  Use it in this file in lieu of hand-written GCC version tests.
2010-11-19 13:34:43 +01:00
Andy Wingo
9b5fcde6f9 lower-case hexadecimal digits again
* libguile/numbers.c: Default to lower-case hexadecimal digits again.
2010-11-18 13:10:45 +01:00
Andy Wingo
cd28785f79 deprecate cuserid
* 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.
2010-11-18 11:15:16 +01:00
Andy Wingo
eeb48bc27e fix the C syntax-error pretty-printer
* libguile/throw.c (handler_message): Fix up a bit.
2010-11-16 03:00:01 +01:00
Andy Wingo
2090f909b4 add proper pretty-printing for syntax errors
* 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.
2010-11-16 02:57:27 +01:00
Andy Wingo
a6f3af1618 fix string->number for bases > 16
* 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.
2010-11-15 23:43:30 +01:00
Andy Wingo
190fa72a8f NUL vs NULL fix
* libguile/read.c (scm_i_scan_for_encoding): Fix NUL rather than NULL.
2010-11-12 17:18:08 +01:00
Julian Graham
f25e1b6713 Fix buffer over-read in port encoding scan.
* libguile/read.c (scm_i_scan_for_encoding): Add a NULL terminator to the
  end of header to prevent over-read by subsequent call to strstr.
2010-11-12 08:45:09 -05:00
Ludovic Courtès
42f7c01e0a Add FFI support for short' and unsigned short'.
* libguile/foreign.c (sym_short, sym_unsigned_short): New variables.
  (scm_init_foreign): Define Scheme variables SYM_SHORT and
  SYM_UNSIGNED_SHORT.

* module/system/foreign.scm (short, unsigned-short): New exports.
  (integer-ref, integer-set): Support (= (sizeof TYPE) 2).
  (%read-short, %write-short!, %read-unsigned-short,
  %write-unsigned-short!): New variables.
  (*writers*): Add support for `short' and `unsigned-short'.
  (*readers*): Likewise.

* test-suite/tests/foreign.test ("structs")["int8, pointer, short,
  double"]: New test.
2010-11-11 16:41:15 +01:00
Michael Gran
a4e4722944 need read error for extra closing square brackets
* libguile/read.c (scm_read_expression): add test
2010-11-04 22:07:50 -07:00
Andreas Rottmann
d458073bc0 Use a fluid for the list of the reader's "hash procedures"
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>
2010-11-03 00:09:57 +01:00
Ludovic Courtès
abd7e37ab7 configure: Don't needlessly augment $LIBS (and $GUILE_LIBS.)
* configure.ac: Don't augment $LIBS with $LTLIBUNISTRING and
  $BDW_GC_LIBS.

* libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_LDFLAGS):
  Remove @LTLIBINTL@.  Add $(BDW_GC_LIBS).
2010-10-20 23:45:58 +02:00
Tristan Colgate-McFarlane
511246a193 Add support for more multicast sockopts.
* libguile/socket.c: Add support for IP_MULTICAST_TTL and IP_MILTICAST_IF sockopts.
2010-10-20 23:11:34 +02:00
Andy Wingo
534bbcc168 more -Wundef on darwin fixes
* 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.
2010-10-18 13:35:46 +02:00
Andy Wingo
c1a0ba1cef uninitialized var in scm_read_character
* libguile/read.c (scm_read_character): Fix error condition where
  charname could be uninitialized.
2010-10-18 13:29:58 +02:00
Andy Wingo
ddffdd788d _scm GUILE_USE_64_CALLS compilation warning fix
* libguile/_scm.h: Check that GUILE_USE_64_CALLS is defined. Fixes an
  error on i386-apple-darwin9.8.0.
2010-10-18 13:27:17 +02:00
Ludovic Courtès
3fff6e71ff Update cpp-E.syms' and cpp-SIG.syms'.
* libguile/cpp-E.syms, libguile/cpp-SIG.syms: Update on a Glibc 2.11.1
  system.
2010-10-15 15:56:03 +02:00
Ludovic Courtès
9253d0905d Fix the chknew-E' and chknew-SIG' rules.
* 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.)
2010-10-15 15:56:01 +02:00
Michael Gran
45dc6b347d Unresolved var errors don't work for top-level vars
* libguile/vm-i-system.c (toplevel_ref, long_toplevel_ref): modified
2010-10-14 18:27:41 -07:00
Michael Gran
4ad7f6cf9f Update charsets to Unicode 6.0.0
* libguile/srfi-14.i.c: regenerated
2010-10-14 18:21:28 -07:00
Andy Wingo
2b41a37b3c fix bug in with-fluids in a non-tail position
* 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.
2010-10-13 21:20:23 +02:00
Ludovic Courtès
e78d4bf9a9 Optimize 1+' and 1-' on fixnums.
* 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.
2010-10-13 01:31:19 +02:00