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

238 commits

Author SHA1 Message Date
Andy Wingo
5870188eb4 Replace "pr" struct fields with "pw" fields
* libguile/struct.h (SCM_VTABLE_BASE_LAYOUT): Layout is a "pr" field.
* module/ice-9/boot-9.scm (record-type-vtable): Record vtable fields are
  writable.
  (<parameter>): "pw" fields.
* module/oop/goops.scm (<class>, %compute-layout): <read-only> fields
  are "pw" underneath.
* module/rnrs/records/procedural.scm (record-type-vtable)
  (record-constructor-vtable, make-record-type-descriptor): Use "pw"
  fields in vtables.
* module/srfi/srfi-35.scm (%condition-type-vtable)
  (struct-layout-for-condition): "pw" fields in vtables.
* test-suite/tests/goops.test:
* test-suite/tests/structs.test: Use "pw" fields only.
* benchmark-suite/benchmarks/structs.bm: Update for make-struct/no-tail,
  to use pw fields, and also to remove useless tests that the compiler
  would optimize away.
* doc/ref/api-data.texi (Vtables): Add a note about the now-vestigial
  permissions character and update documentation.
  (Structure Basics, Meta-Vtables): Update examples.
* libguile/hash.c (scm_i_struct_hash): Remove code that would handle
  opaque/self fields.
* libguile/print.h (SCM_PRINT_STATE_LAYOUT): Use "pw" fields.
* libguile/struct.c (scm_struct_init): Simplify check for hidden
  fields.
* libguile/values.c (scm_init_values): Field is "pw".
2017-09-23 15:33:02 +02:00
Andy Wingo
2f9ad7d9bc Merge stable-2.2 into master
This commit resolves conflicts by removing the deprecated make-struct.
2017-09-22 12:02:25 +02:00
Andy Wingo
dd11b82162 Use make-struct/no-tail instead of make-struct
* module/ice-9/boot-9.scm:
* module/language/cps/effects-analysis.scm:
* module/language/elisp/falias.scm:
* module/language/tree-il.scm:
* module/language/tree-il/primitives.scm:
* module/rnrs/records/procedural.scm:
* module/srfi/srfi-35.scm:
* module/system/base/syntax.scm: Change uses of make-struct to
  make-struct/no-tail.
2017-09-20 22:07:18 +02:00
Andy Wingo
ee5994a517 remove self field of vtables
* libguile/struct.h (SCM_VTABLE_BASE_LAYOUT, scm_vtable_index_self):
  Remove "self" field.  Renumber the other fields.
* module/oop/goops.scm (<self-slot>): Remove.
  (fold-class-slots): Adapt for "self" slot removal.  Adapt all users.
  (class-redefinition): Now that there is no "self" slot to update, use
  %modify-instance instead of %modify-class.
* libguile/goops.c (class_self): Remove.
  (scm_sys_modify_class): Remove.
* libguile/goops.h (scm_sys_modify_class): Remove.
* module/rnrs/records/procedural.scm: Import vtable-offset-user.
  Renumber rtd indexes using vtable-offset-user.
* module/srfi/srfi-35.scm (%condition-type-vtable): Remove mention of
  vtable fields.
* module/system/base/types.scm (address->inferior-struct): Adapt for
  different vtable field layout.
2017-09-14 09:49:55 +02:00
Ludovic Courtès
886ac3e2ab SRFI-19: Swap seconds and nanoseconds in 'current-time-monotonic'.
* module/srfi/srfi-19.scm (current-time-monotonic): Swap the 2nd and 3rd
arguments.  Fixes a regression introduced in
commit b11e2922c3.
2017-04-22 01:01:32 +02:00
Thomas Danckaert
02cf38514d SRFI-37: Account for zero-length arguments.
* module/srfi/srfi-37.scm (args-fold): When checking if an argument is
an option (starts with #\-), first check if the length is non-zero.
2017-04-20 10:58:54 +02:00
Andy Wingo
4b39c1a9e5 Fix date->string ~f operator to not emit leading zeros
* module/srfi/srfi-19.scm (directives): Format ~f without leading
  zeroes.  Fixes https://bugs.gnu.org/26260.
* test-suite/tests/srfi-19.test ("SRFI date/time library"): Add test.
2017-04-19 15:42:03 +02:00
Andrew Moss
1978085b22 Fixed bug: ~N mishandles small nanoseconds value
Fixes <http://bugs.gnu.org/26261>.
Reported by Zefram <zefram@fysh.org>.

* module/srfi/srfi-19.scm ("define directives"): N padding increased from 7 to 9

* test-suite/tests/srfi-19.test ("date->string"): New test.
2017-04-19 15:13:09 +02:00
Andy Wingo
b11e2922c3 SRFI-19 current-time-monotonic returns time of right type
* module/srfi/srfi-19.scm (current-time-monotonic): Actually return a
  time with the correct type.  Fixes #26329.
2017-04-19 15:08:46 +02:00
Andy Wingo
b43f11469a SRFI-18 mutexes are not recursive
* module/srfi/srfi-18.scm (make-mutex): Not recursive.
2016-11-05 10:30:54 +01:00
Andy Wingo
b197a6a5af Move more functionality to SRFI-18 mutex-unlock!
* module/srfi/srfi-18.scm (mutex-unlock!): Implement the
  ignore-unlock-errors and wait-condition-variable behavior of
  mutex-unlock! directly, without relying on Guile.
2016-11-05 10:30:54 +01:00
Andy Wingo
c6a8092b3f SRFI-18 manages own mutex "abandoned" state
* module/srfi/srfi-18.scm (<mutex>, with-thread-mutex-cleanup)
  (make-mutex, mutex-state, abandon-mutex!, mutex-lock!): Manage
  "abandoned" bit on Scheme side with no need for thread cleanup
  handler.
2016-11-05 00:13:55 +01:00
Andy Wingo
3ce76c38cb SRFI-18 threads disjoint from guile threads
* doc/ref/srfi-modules.texi (SRFI-18 Threads): Update.
* module/srfi/srfi-18.scm (<mutex>): Add owner field.
  (<thread>): New data type.
  (make-thread): Adapt for boxed threads.
  (thread-start!, thread-terminate!): Likewise.
  (mutex-state): Adapt for boxed threads.
  (mutex-lock!, mutex-unlock!): Update owner field.
2016-11-04 22:35:19 +01:00
Andy Wingo
846f7e116e srfi-18 condition variables disjoint
* module/srfi/srfi-18.scm (<condition-variable>): New data type.
  (make-thread): Use srfi-18 interfaces.
  (mutex-unlock!): Adapt to optional cond argument being disjoint from
  Guile condition variables.
  (make-condition-variable, condition-variable-signal!)
  (condition-variable-broadcast!): Adapt.
2016-11-04 20:29:44 +01:00
Andy Wingo
3794935fed Remove export srfi-18 never had
* module/srfi/srfi-18.scm (condition-variable-wait!): Remove undefined
  export.
2016-11-04 20:20:04 +01:00
Andy Wingo
2559631869 SRFI-18 mutexes disjoint from Guile mutexes
* module/srfi/srfi-18.scm (<mutex>): Define as a wrapper type around
  Guile mutexes.
  (thread-mutexes): New variable.
  (with-thread-mutex-cleanup): New facility to abandon mutexes on
  SRFI-18 thread exit.  Not yet used.
  (make-thread): Use SRFI-18 interfaces.
  (make-mutex): Reimplement for our boxed mutexes.
  (mutex-state): Adapt.
  (mutex-lock!): Adapt.
  (mutex-unlock!): Adapt.
* test-suite/tests/srfi-18.test: Don't assume that SRFI-18 mutexes are
  the same as Guile mutexes.
2016-11-04 20:17:58 +01:00
Andy Wingo
b85f033526 srfi-18: thread-terminate! without cleanup handlers
* module/srfi/srfi-18.scm (%cancel-sentinel, thread-terminate!): Just
  use cancel-thread to cause the thread to return a sentinel value.
  (%timeout-sentinel): Rename from %sentinel.
  (thread-join!): Adapt and transform %cancel-sentinel to a
  &terminated-thread-exception.
2016-10-31 22:11:43 +01:00
Andy Wingo
6bf9c65419 Trim srfi-18 thread startup machinery
* module/srfi/srfi-18.scm (make-thread): Use just one cond/mutex pair
  for signalling in both directions: waiting for launch and waiting for
  start.
2016-10-31 21:42:47 +01:00
Andy Wingo
59fdf9cdcd Refactor thread-join! to use optional args.
* module/srfi/srfi-18.scm (thread-join!): Use optional args.  Also don't
  treat false return values from threads as meaning anything.
2016-10-31 21:36:56 +01:00
Andy Wingo
8e305ee045 Rationalize exception handling in srfi-18
* module/srfi/srfi-18.scm (make-thread): Inline some helpers, and use
  just one catch block.
  (thread->exception): Move up definition.
  (exception-handler-for-foreign-threads): Use this as the default
  handler, not the one that squirrels away exceptions in
  thread->exception.
  (thread-terminate!): Don't instate an exception handler for the thread
  cleanup proc.
2016-10-31 21:20:47 +01:00
Andy Wingo
789a4d8d87 srfi-18: Avoid call/cc.
* module/srfi/srfi-18.scm (with-exception-handlers-here): New function.
  (wrap): Remove.
  (thread-join!, mutex-lock!): Use with-exception-handlers-here instead
  of the call/cc+wrap mess.
2016-10-31 20:52:08 +01:00
Andy Wingo
c3f08aa866 srfi-18: Inline uses of srfi-18-exception-preserver.
* module/srfi/srfi-18.scm (srfi-18-exception-preserver): Inline into
  call sites.
2016-10-30 22:37:49 +01:00
Andy Wingo
177a058a40 srfi-18: Use srfi-35 conditions.
* module/srfi/srfi-18.scm: Use srfi-35 conditions instead of our
  home-grown equivalent system.
  (thread-exception-handlers): Remove unused table.
  (srfi-18-exception-handler): Always capture key consed to args; no
  special case for bare key.
* test-suite/tests/srfi-18.test (provided?): Adapt to reason always
  being key+args.
2016-10-30 22:30:21 +01:00
Andy Wingo
0d57476f0a srfi-18: Use parameters.
* module/srfi/srfi-18.scm: Use srfi-34 internally with srfi-34: prefix.
  (current-exception-handler): Be a parameter.
  (with-exception-handler): Adapt to current-exception-handler change.
  (thread-join!, mutex-lock!): Adapt to use srfi-34: prefix.
2016-10-30 22:16:37 +01:00
Andy Wingo
7078218a92 srfi-18: Use lambda* optional arguments.
* module/srfi/srfi-18.scm (make-mutex, make-condition-variable): Use
  optional arguments.
2016-10-30 21:44:35 +01:00
Andy Wingo
bbcc128153 srfi-18: Simplify thread-sleep!, thread-terminate!.
* module/srfi/srfi-18.scm (thread-sleep!): Use `when'.
  (thread-terminate!): Simplify.
2016-10-30 21:43:51 +01:00
Andy Wingo
4d23c835c4 srfi-18: Use `match' in thread-start!.
* module/srfi/srfi-18.scm (thread-start!): Use `match'.
2016-10-30 21:43:08 +01:00
Andy Wingo
501c0e67b1 srfi-18: Improve style.
* module/srfi/srfi-18.scm (raise): Rely on SRFI-34 to #:replace raise.
  (make-thread): Use lambda* and when.
2016-10-30 20:43:07 +01:00
Andy Wingo
e5399d3e7c Fix srfi-34 indentation
* module/srfi/srfi-34.scm (with-exception-handler): Fix indentation.
2016-10-30 20:31:57 +01:00
Andy Wingo
d74e0fed0d Move thread bindings to (ice-9 threads)
* libguile/init.c (scm_i_init_guile): Don't call scm_init_thread_procs.
* libguile/threads.c (scm_init_ice_9_threads): Rename from
  scm_init_thread_procs, make static.
  (scm_init_threads): Register scm_init_thread_procs extension.
* libguile/threads.h (scm_init_thread_procs): Remove decl.
* module/ice-9/boot-9.scm: Load (ice-9 threads), so that related side
  effects occur early.
* module/ice-9/deprecated.scm (define-deprecated): Fix to allow
  deprecated bindings to appear in operator position.  Export deprecated
  bindings.
  (define-deprecated/threads, define-deprecated/threads*): Trampoline
  thread bindings to (ice-9 threads).
* module/ice-9/futures.scm: Use ice-9 threads.
* module/ice-9/threads.scm: Load scm_init_ice_9_threads extension.
  Reorder definitions and imports so that the module circularity
  with (ice-9 futures) continues to work.
* module/language/cps/intmap.scm:
* module/language/cps/intset.scm:
* module/language/tree-il/primitives.scm: Use (ice-9 threads).
* module/language/cps/reify-primitives.scm: Reify current-thread
  in (ice-9 threads) module.
* module/srfi/srfi-18.scm: Use ice-9 threads with a module prefix, and
  adapt all users.  Use proper keywords in module definition form.
* test-suite/tests/filesys.test (test-suite):
* test-suite/tests/fluids.test (test-suite):
* test-suite/tests/srfi-18.test: Use ice-9 threads.
* NEWS: Add entry.
* doc/ref/api-scheduling.texi (Threads): Update.
* doc/ref/posix.texi (Processes): Move current-processor-count and
  total-processor-count docs to Threads.
2016-10-23 22:29:44 +02:00
Mark H Weaver
994b7d70e6 SRFI-19: Update the table of leap seconds.
* module/srfi/srfi-19.scm (leap-second-table): Update to include the
  most recent leap second.
2016-05-22 20:02:37 +02:00
Andy Wingo
a5b5cb422e Merge commit '8cf2a7ba74' 2015-01-22 13:24:30 +01:00
Chris Jester-Young
cffa9bd6a3 Implement SRFI 28: Basic Format Strings.
* module/srfi/srfi-28.scm: New module.
* module/Makefile.am (SRFI_SOURCES): Add srfi/srfi-28.scm.
* doc/ref/srfi-modules.texi (SRFI-28): New node.
2014-12-02 11:49:05 -05:00
Mark H Weaver
856d318a9f Merge branch 'stable-2.0'
Conflicts:
	benchmark-suite/benchmarks/ports.bm
	libguile/async.h
	libguile/bytevectors.c
	libguile/foreign.c
	libguile/gsubr.c
	libguile/srfi-1.c
	libguile/vm-engine.h
	libguile/vm-i-scheme.c
	module/Makefile.am
	module/language/tree-il/analyze.scm
	module/language/tree-il/peval.scm
	module/scripts/compile.scm
	module/scripts/disassemble.scm
	test-suite/tests/asm-to-bytecode.test
	test-suite/tests/peval.test
	test-suite/tests/rdelim.test
2014-09-30 03:50:47 -04:00
Mark H Weaver
ff4af3df23 doc: Improve description of vector-unfold and vector-unfold-right.
* doc/ref/srfi-modules.texi (SRFI-43 Constructors)[vector-unfold]:
  Improve description.
* module/srfi/srfi-43.scm (vector-unfold, vector-unfold-right):
  Improve docstrings.
2014-09-24 22:03:58 -04:00
Mark H Weaver
8f230e3341 SRFI-43: vector-concatenate: Fix error message.
* module/srfi/srfi-43.scm (vector-concatenate): Fix the 'who' of an
  error message.
2014-09-20 05:44:15 -04:00
Andy Wingo
9de674e6e6 Rewrite boot-9 map to be recursive and pure
* module/ice-9/boot-9.scm (map): Rewrite to be recursive and pure
  instead of iterative and effectful.  At best this is faster; at worst
  it is slower.  In any case it resolves continuation-related issues.

* module/srfi/srfi-1.scm (fold): Specialize the two-arg case.
  (map): Rewrite to be recursive.

* test-suite/tests/r5rs_pitfall.test (8.3): Update for new expected map
  behavior.
2014-05-01 21:17:28 +02:00
Mark H Weaver
475772ea57 Merge branch 'stable-2.0'
Conflicts:
	GUILE-VERSION
	NEWS
	guile-readline/ice-9/readline.scm
	libguile/async.c
	libguile/backtrace.c
	libguile/deprecated.h
	libguile/gc-malloc.c
	libguile/gdbint.c
	libguile/init.c
	libguile/ioext.c
	libguile/mallocs.c
	libguile/print.c
	libguile/rw.c
	libguile/scmsigs.c
	libguile/script.c
	libguile/simpos.c
	libguile/snarf.h
	libguile/strports.c
	libguile/threads.c
	libguile/vm-i-scheme.c
	libguile/vm-i-system.c
	module/srfi/srfi-18.scm
	test-suite/Makefile.am
	test-suite/standalone/test-num2integral.c
2014-04-25 02:06:01 -04:00
Andy Wingo
3625351955 Match and srfi-9 expose their bailouts to the CSE pass
* module/ice-9/match.upstream.scm (match-next): Inline a call to
  "error", so the new CSE pass will see this case as a bailout.

* module/srfi/srfi-9.scm (throw-bad-struct): Reimplement as a syntax
  rule, so that the CSE pass sees the "throw" call.
2014-04-05 11:56:44 +02:00
Andy Wingo
f082c5f30a Optimize two-list srfi-1 map
* module/srfi/srfi-1.scm (map): Optimize the two-list variant.
2014-04-01 20:52:15 +02:00
Andy Wingo
4926024cfb Simplify boot-9 and srfi-1 map
* module/ice-9/boot-9.scm (map):
* module/srfi/srfi-1.scm (map): Simplify the implementations to check
  for list? beforehand.  It's faster, and it will be needed if we decide
  to go recursive.
2014-03-31 18:21:04 +02:00
Nathaniel Alderson
8d124d2077 Calculate usecs correctly in thread-sleep!
* module/srfi/srfi-18.scm (thread-sleep!): Correctly compute
  microseconds.

* test-suite/tests/srfi-18.test: Add test.
2014-03-23 21:58:54 +01:00
Andy Wingo
f883ae59a0 Optimize srfi-1 for-each with two lists.
* module/srfi/srfi-1.scm (for-each): Optimize for the two-list case.
2014-03-16 19:58:30 +01:00
Andy Wingo
f87a7327a5 More for-each micro-optimizations
* module/ice-9/boot-9.scm (for-each):
* module/srfi/srfi-1.scm (for-each): Re-implement one-list case using an
  explicit check for list? instead of the tortoise-hare thing.  Seems to
  be faster!
2014-03-16 19:41:51 +01:00
Mark H Weaver
bf0d59e54d SRFI-19: Update the table of leap seconds.
* module/srfi/srfi-19.scm (leap-second-table): Update to include the two
  most recent leap seconds.
2014-03-03 17:31:51 -05:00
Andy Wingo
3c3de73d4d Port unrolled one-argument for-each from boot-9 to srfi-1
* module/srfi/srfi-1.scm (for-each): Port unrolled one-argument
  implementation here from the boot-9 version.
2014-03-02 12:05:32 +01:00
Mark H Weaver
6587bcfa53 SRFI-18: Export 'current-thread'.
Fixes <http://debbugs.gnu.org/16890>.
Reported by Xin Wang <dram.wang@gmail.com>.

* module/srfi/srfi-18.scm: Reexport 'current-thread'.
* THANKS: Add "Xin Wang" to fixes section.
2014-02-27 22:38:53 -05:00
Andy Wingo
5fc051babe Merge commit '2f3b7e9a41'
Conflicts:
	module/ice-9/pretty-print.scm
2014-02-08 14:44:11 +01:00
Andy Wingo
730639e9a7 Merge commit 'a675a2e81b' 2014-02-08 14:31:42 +01:00
Andy Wingo
85d3339d7e (srfi srfi-4 gnu) uses private define-bytevector-type from (srfi srfi-4)
* module/srfi/srfi-4/gnu.scm: Re-use implementation of
  define-bytevector-type from srfi-4.
2014-02-07 18:00:04 +01:00