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

15149 commits

Author SHA1 Message Date
Andy Wingo
58942f30d6 http web server: allow concurrent write operations
* module/web/server/http.scm (<http-server>, http-open)
  (read-request!, write-request!, enqueue-write!, http-write): As in the
  previous commit, add support for concurrent writes.
  (http-read): Pop off keepalive ports in this, the main loop.
  (http-close): Shut down writers appropriately.
2012-03-12 17:12:37 +01:00
Andy Wingo
f20ae551a1 http web server: allow concurrent read operations
* module/web/server/http.scm (<http-server>): Add fields for a reader
  thread-pool, and some async queues that it operates on.  Also, a flag,
  http-threaded?.
  (http-open): Add #:threaded? and #:read-workers kwargs.  Create a
  thread pool for reading if threads are available.
  (read-request!): New function, factored out of http-read.
  (enqueue-read!, http-read): Instead of reading the client directly,
  enqueue a read.  In the case where threads are not available, this
  will call read-request! directly.  read-request! takes care of adding
  to the handle-queue.  The read polling loop will pop items off the
  handle-queue.
  (seconds-from-now, async-queue-for-each): New helpers.
  (http-write): Shut down the queues and threads, hopefully in a
  nonblocking fashion.
2012-03-12 17:12:37 +01:00
Andy Wingo
31a04ee239 add ability to wake up the poll() in http.scm
* module/web/server/http.scm (make-waker, flush-wake-port): New
  functions, to wake up a poll().
  (http-open): Add a wakeup port to the poll set.
  (http-read): Handle the wakeup port specially.
2012-03-12 17:12:37 +01:00
Andy Wingo
5f54be9b3d add ice-9 thread-pool
* module/ice-9/thread-pool.scm: New file.

* module/Makefile.am: Add to build.
2012-03-12 17:12:37 +01:00
Andy Wingo
c62bbee320 add (ice-9 async-queue)
* module/ice-9/async-queue.scm: New file.
* module/Makefile.am: Add it to the make file.
2012-03-12 17:12:37 +01:00
Andy Wingo
d5e1f82240 Merge remote-tracking branch 'origin/stable-2.0' 2012-03-12 17:00:09 +01:00
Andy Wingo
da23abd970 Merge branch 'master' of git.sv.gnu.org:/srv/git/guile 2012-03-12 17:00:02 +01:00
Andy Wingo
89d45e8507 web http: fix Ma -> Mar
* module/web/http.scm (write-date): Fix serialization of Mar.  Oops.
2012-03-12 16:58:15 +01:00
Andy Wingo
9effafa444 fix bad-request-printer
* module/web/request.scm (bad-request-printer): Fix printer to expect
  args as a list.
2012-03-11 11:06:39 +01:00
Andy Wingo
8b49b6b1f5 Merge remote-tracking branch 'local-2.0/stable-2.0'
Conflicts:
	configure.ac
2012-03-11 11:06:14 +01:00
Andy Wingo
e0dc497832 add bad-request printer
* module/web/request.scm (bad-request-printer): Add printer for these
  exceptions.
2012-03-11 10:57:05 +01:00
Andy Wingo
02360ed605 web server http: 400 Bad Request on bad requests
* module/web/server/http.scm (bad-request, http-read): If an exception
  is raised while reading a response, write out a 400 Bad Request
  response before closing the port.
2012-03-11 10:29:06 +01:00
Andy Wingo
aaaa0eef9c add exception printers for bad-header, bad-header-component
* module/web/http.scm (bad-header-component): Throw
  'bad-header-component instead of 'bad-header.
  (bad-header-printer, bad-header-component-printer): Add exception
  printers.
2012-03-11 10:24:08 +01:00
Andy Wingo
9adbf27f4e more libgc 7.1 compat
* configure.ac:
* libguile/gc.c (GC_set_finalize_on_demand): Check for this function,
  and shim if it isn't present.
2012-03-08 23:50:41 +01:00
BT Templeton
52d2472441 elisp rng
* module/language/elisp/boot.el (random): New function.
2012-03-08 17:08:30 -05:00
BT Templeton
43ff6804d6 elisp i/o
* module/language/elisp/boot.el (send-string-to-terminal)
  (read-from-minibuffer, prin1-to-string): New functions.
2012-03-08 17:08:30 -05:00
BT Templeton
5c65ee510f elisp: symbol-name, intern
* module/language/elisp/boot.el (symbol-name, intern): New functions.
2012-03-08 17:08:30 -05:00
BT Templeton
c0652730bc elisp: when, unless
* module/language/elisp/boot.el (when, unless): New macros.
2012-03-08 17:08:30 -05:00
BT Templeton
12c00a0453 elisp sequence functions
* module/language/elisp/boot.el (nreverse, assoc, assq, rplaca, rplacd)
  (caar, cadr, cdar, cddr, dolist, stringp, string-equal, string=)
  (substring, upcase, downcase, string-match, make-vector, mapc, aref)
  (aset, concat): New functions.
2012-03-08 17:08:30 -05:00
BT Templeton
fc45b7e8e8 integerp, wholenump return nil for non-numbers
* module/language/elisp/boot.el (integerp, wholenump): Call `integer?'
  before `exact?' so that these predicates return nil for non-numbers
  instead of signalling an error.
2012-03-08 17:08:30 -05:00
Andy Wingo
bc61280992 Merge remote-tracking branch 'local-2.0/stable-2.0'
Conflicts:
	configure.ac
	libguile/finalizers.c
	libguile/finalizers.h
	libguile/gc.c
	libguile/gc.h
	libguile/inline.c
	libguile/inline.h
	libguile/ports.c
	libguile/smob.c
	libguile/smob.h
	module/ice-9/deprecated.scm
	module/ice-9/r4rs.scm
2012-03-08 13:22:09 +01:00
Andy Wingo
f740445a9b run finalizers asynchronously in asyncs
* libguile/finalizers.c: New excitement!  We'll be running finalizers
  asynchronously, from asyncs.  This will make it safer to allocate
  while holding a mutex.
  (GC_set_finalizer_notifier): Add back-compat shim.

* libguile/init.c (scm_i_init_guile): Init the async finalizer mechanism
  during boot.

* libguile/gc.c (scm_storage_prehistory): Tell libgc we'll be finalizing
  on demand.
  (scm_gc): Explicitly run finalizers here.

* libguile/threads.c (guilify_self_2): Run finalizers here if
  queue_finalizer_async happened to run during guilify_self_1.

* configure.ac: Add check for GC_set_finalizer_notifier.
2012-03-08 13:12:10 +01:00
Andy Wingo
75ba64d679 use the new finalizer helpers
* libguile/foreign.c (scm_set_pointer_finalizer_x)
* libguile/ports.c (finalize_port)
* libguile/smob.c (scm_i_new_smob, scm_i_new_double_smob)
* libguile/struct.c (scm_i_alloc_struct)
* libguile/numbers.c (make_bignum): Use the new API.
2012-03-08 12:40:27 +01:00
Andy Wingo
7b327550e2 add scm_i_set_finalizer, scm_i_add_finalizer, scm_i_add_resuscitator
* libguile/finalizers.h:
* libguile/finalizers.c: New files.

* libguile.h:
* libguile/Makefile.am: Add to build.
2012-03-08 12:40:27 +01:00
Andy Wingo
c46fee438c scm_new_smob, scm_new_double_smob inline functions
* libguile/smob.h (scm_new_smob, scm_new_double_smob): New constructors,
  which do what SCM_NEWSMOB / SCM_NEWSMOB3 had done, but with inline
  functions instead of macros.  They also bail to scm_i_new_smob /
  scm_i_new_double_smob in either the mark or the free case, so that the
  inline definition doesn't reference other internal details like libgc
  stuff.
  (SCM_SMOB_TYPE_MASK et al): Move definitions up so the new_smob see
  them as already being declared.
  (SCM_NEWSMOB, SCM_RETURN_NEWSMOB, SCM_NEWSMOB2, SCM_RETURN_NEWSMOB2):
  (SCM_NEWSMOB3, SCM_RETURN_NEWSMOB3): Reimplement in terms of the new
  inline functions.

  Remove now-unneeded bdw-gc include.

* libguile/smob.c (finalize_smob): Rename from scm_i_finalize_smob, and
  make static.
  (scm_i_new_smob, scm_i_new_double_smob): Slow-path allocators.
  (scm_i_finalize_smob, scm_i_new_smob_with_mark_proc): Add
  back-compatibility shims to preserve ABI.

* libguile/inline.c: Include smob.h, so as to reify scm_new_smob and
  scm_new_double_smob.
2012-03-08 12:40:27 +01:00
Andy Wingo
42d691ee16 scm_cell, scm_double_cell, scm_words back to gc.h
* libguile/inline.h:
* libguile/gc.h (scm_cell, scm_double_cell, scm_words): Move
  declarations and definitions back here, from inline.h.  It's more
  natural.

* libguile/inline.c: Include gc.h as well.
2012-03-08 12:40:27 +01:00
Andy Wingo
46163e52e5 simplify inline function infrastructure
* libguile/__scm.h (SCM_C_EXTERN_INLINE): Move this definition here,
  from inline.h.  We'd like to support inline function definitions in
  more header files: not just inline.h.
  (SCM_CAN_INLINE, SCM_INLINE, SCM_INLINE_IMPLEMENTATION): New
  definitions.

* libguile/gc.h (SCM_GC_MALLOC, SCM_GC_MALLOC_POINTERLESS): Define these
  wrappers, which redirect to the GC_MALLOC macros when building Guile,
  and the scm_gc_malloc functions otherwise.  A step towards getting
  BDW-GC out of Guile's API.

* libguile/inline.h: Simplify, using SCM_INLINE,
  SCM_INLINE_IMPLEMENTATION, and SCM_IMPLEMENT_INLINES.  Also use the
  new SCM_GC_MALLOC macros.
2012-03-08 12:40:27 +01:00
Ian Price
be79627c21 Fix flush on soft ports, so that it actually runs.
* libguile/vports.c (sf_flush): Remove conditional testing the
  position in the port's write_buf, as it is no longer used.
2012-03-07 23:54:24 -05:00
Ludovic Courtès
c336514976 Change `scm_words' to accept a 32-bit word number.
Fixes <http://bugs.gnu.org/10914>.
Reported by Tobias Brandt <tob.brandt@googlemail.com>.

* libguile/gc.h (scm_words): Change `n_words' to be `scm_t_uint32'.
* libguile/inline.h: Update extraneous declaration.
2012-03-07 22:50:44 +01:00
Ludovic Courtès
da35d2eaa9 Improve port benchmark.
* benchmark-suite/benchmarks/ports.bm (sequence): New macro, formerly
  local to the "rdelim" benchmark prefix.
  (large-string): New procedure.
  (%latin1-port, %utf8/ascii-port, %utf8/wide-port): Use it.
  ("peek-char", "char-ready?", "read-char"): Use `sequence'.
2012-03-07 21:58:07 +01:00
Giuseppe Scrivano
3658a3744b Fix a segfault when /dev/urandom is not accessible
* libguile/init.c (scm_i_init_guile): Call `scm_init_random' before
`scm_init_macros'.
2012-03-07 21:25:11 +01:00
Andy Wingo
283ab48d3f faster (make-prompt-tag); default-prompt-tag is a parameter
* module/ice-9/boot-9.scm (default-prompt-tag): Once parameters have
  booted, redefine as a parameter.
  (make-prompt-tag): Change from a gensym to a list.  Thanks to Mark
  Weaver for the suggestion.

* doc/ref/api-control.texi (Prompt Primitives): Update docs.
2012-03-07 19:02:00 +01:00
Andy Wingo
a62b5c3d54 call-with-{input,output}-string implemented in scheme
* module/ice-9/boot-9.scm (call-with-input-string)
  (call-with-output-string): Implement in Scheme.

* libguile/strports.c (scm_call_with_output_string):
  (scm_call_with_input_string): Dispatch to Scheme.
2012-03-07 13:34:06 +01:00
Andy Wingo
4df9e5eb0f micro-optimizations to string-trim-both, and to (web http)
* libguile/srfi-13.c (scm_string_trim, scm_string_trim_right)
  (scm_string_trim_both): Take the whitespace fast-path if the char_pred
  is scm_char_set_whitespace.

* module/web/http.scm (read-header, split-and-trim, parse-quality-list):
  (parse-param-component, parse-credentials, "Content-Type"):
  (read-request-line, read-response-line): Use char-set:whitespace
  instead of char-whitespace?.  It avoids recursing into the VM.
2012-03-07 13:04:53 +01:00
Andy Wingo
8ebd06c64b names of encodings are ascii
* libguile/ports.c (scm_mode_bits): Parse the mode bits as latin1.
  (scm_i_set_default_port_encoding, open_iconv_descriptors)
  (scm_port_encoding, scm_set_port_encoding_x): Restrict the names of
  encodings to ASCII.
2012-03-07 12:10:28 +01:00
Andy Wingo
9d381ba478 dynstack: pushing a prompt no longer allocates memory
* libguile/control.h: Remove scm_t_prompt_registers and
  scm_c_make_prompt_registers.
  (scm_c_abort): Take a pointer to a jmpbuf instead of a cookie.  It
  will serve the same purpose.
* libguile/control.c (reify_partial_continuation, scm_at_abort): Adapt
  to new prompt representation.

* libguile/dynstack.h:
* libguile/dynstack.c (scm_dynstack_push_prompt): Prompts now have 5
  words instead of 2, as they now push the fp, sp, ip, and jmpbuf on the
  stack separately.  This avoids allocation.
  (scm_dynstack_find_prompt): Likewise, add return values for fp, sp,
  etc.
  (scm_dynstack_wind_prompt): Replaces scm_dynstack_relocate_prompt.

* libguile/eval.c (eval):
* libguile/stacks.c (find_prompt):
* libguile/throw.c (pre_init_catch): Adapt to the new prompt mechanism.

* libguile/vm-engine.c (vm_engine): Setjmp an on-stack jmpbuf every time
  the VM enters.  We can then re-use that jmpbuf for all prompts in that
  invocation.

* libguile/vm-i-system.c (partial_cont_call): Adapt to change in prompt
  representation.  We don't need to wind here any more, since we pass in
  the prompt's jmpbuf.
  (prompt): Adapt to scm_dynstack_push_prompt change.
  (abort): Adapt to vm_abort change.

* libguile/vm.h (struct scm_vm): No more cookie.

* libguile/vm.c (vm_abort): Adapt to scm_c_abort change.
  (vm_reinstate_partial_continuation): Rewind the dynamic stack here,
  now that we do have a valid jmpbuf.
  (make_vm): No need to initialize a cookie.
2012-03-07 10:27:16 +01:00
Andy Wingo
3c12fc3595 micro-optimization in (web server)
* module/web/server.scm (extend-response): Micro-optimize to not mutate
  data, and to copy as little as possible.
2012-03-06 22:22:31 +01:00
Andy Wingo
24ea9f9c3a ports.c: inline get_codepoint
* libguile/ports.c (get_codepoint): Add inline keyword.  It showed up
  high in benchmarks, and it's static, so it's probably important to
  inline.
2012-03-06 22:21:39 +01:00
Andy Wingo
4164dd6d1f optimize symbol printing
* libguile/print.h: Remove internal declaration of
  scm_i_print_symbol_name.

* libguile/print.c (symbol_has_extended_read_syntax): Optimize to avoid
  calling symbol_to_string if we know the symbol cannot be mistaken for
  a number.
  (print_normal_symbol): Optimize to call display_string directly,
  instead of jumping through scm_display.
  (print_symbol): Rename from scm_i_print_symbol_name.
  (scm_print_symbol_name, iprin1): Adapt to print_symbol name change.
2012-03-06 11:19:06 +01:00
Andy Wingo
f6e6b5181a shuffle r4rs procedures into boot-9
* module/ice-9/boot-9.scm: Refine a comment about low-level port
  functions.  Move call-with-foo-port, with-input-from-foo, etc later in
  the file, and define using `parameterize' instead of `dynamic-wind'.
  Somewhat cleaner, and avoids thunk? checks for "swaports" in the old
  implementation.
2012-03-06 00:51:50 +01:00
Andy Wingo
124bc316a6 load parameters earlier in boot-9
* module/ice-9/boot-9.scm: Move parameters earlier in the boot process.
  The new with-output-to-port code will use it.
2012-03-06 00:51:49 +01:00
Andy Wingo
d867c7496c slight tweak to file-exists?, file-is-directory?
* module/ice-9/boot-9.scm (file-exists?, file-is-directory?): For the
  fallback cases, use open-input-file instead of open-file with
  OPEN_READ.
2012-03-06 00:51:49 +01:00
Andy Wingo
f7955da966 bootstrapping shenanigans in `warn'
* module/ice-9/boot-9.scm (warn): Don't use with-output-to-port, as
  we'll move that definition after the psyntax boot.
2012-03-06 00:51:49 +01:00
Andy Wingo
f28dc43c95 more clear comments in boot-9.scm
* module/ice-9/boot-9.scm: Update comment header for language
  primitives.
2012-03-06 00:51:49 +01:00
Andy Wingo
0f6f5fb7f8 remove deprecated close-io-port
* module/ice-9/boot-9.scm (close-io-port): Remove proc that was
  deprecated in 2.0.
2012-03-06 00:51:49 +01:00
Andy Wingo
418321524a inline ice-9/r4rs.scm into ice-9/boot-9.scm
* module/ice-9/boot-9.scm: Inline r4rs.scm, in anticipation of more
  refactorings.

* module/ice-9/r4rs.scm: Remove.
* module/Makefile.am: Update.
2012-03-06 00:51:49 +01:00
BT Templeton
663c5875f5 use #nil as default for elisp rest parameters
* module/langauge/elisp/compile-tree-il.scm (compile-lambda): Bind the
  rest parameter to `#nil' instead of `()' by default.
2012-03-05 18:10:29 -05:00
Andy Wingo
1fa0fde495 deprecate close-io-port
* module/ice-9/r4rs.scm:
* module/ice-9/deprecated.scm (close-io-port): Deprecate.
2012-03-05 23:52:28 +01:00
BT Templeton
5ddd9645c9 Merge branch 'bt/elisp'
Conflicts:
	am/guilec
	libguile/_scm.h
	libguile/vm-i-scheme.c
	module/language/elisp/compile-tree-il.scm
	module/language/elisp/runtime.scm
	module/language/elisp/runtime/macros.scm
	module/language/tree-il/compile-glil.scm
	module/language/tree-il/primitives.scm
2012-03-05 16:52:05 -05:00
Mark H Weaver
1a4d765381 Don't call SYMBOL_STRINGBUF on a string
* libguile/strings.c (scm_i_make_symbol): Use STRING_STRINGBUF
  instead of SYMBOL_STRINGBUF to get the stringbuf of a string.
2012-03-04 22:47:04 -05:00