summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2016-06-09add (web server ethreads)wip-ethreadsAndy Wingo2-0/+173
* module/web/server/ethreads.scm: New file, an ethreads-based HTTP server. * module/Makefile.am: Add to build.
2016-06-09add examples/ethreads/memcached-{client,server}Andy Wingo2-0/+299
* examples/ethreads/memcached-client.scm: * examples/ethreads/memcached-server.scm: Two new ethreads examples. Not really optimized, no consideration for memory use, but perhaps instructive.
2016-06-09add (ice-9 ethreads)Andy Wingo2-0/+266
* module/ice-9/ethreads.scm: New module, providing cooperative lightweight threads that yield when they would otherwise sleep or wait for I/O. * module/Makefile.am: Add to build.
2016-06-09add (ice-9 epoll)Andy Wingo4-1/+265
* configure.ac: Add checks for sys/epoll.h, epoll_create, and epoll_create1. * libguile/poll.c (scm_primitive_epoll_create, scm_primitive_epoll_ctl) (scm_primitive_epoll_wait): New primitives for (ice-9 epoll). Registered via a scm_init_epoll extension. * module/Makefile.am: Add ice-9/epoll.scm. * module/ice-9/epoll.scm: New file.
2016-06-09Non-blocking accept/connect Scheme supportAndy Wingo1-1/+22
* module/ice-9/sports.scm (accept, connect): New Scheme functions.
2016-06-09Support `connect' on nonblocking socketsAndy Wingo2-6/+11
* libguile/socket.c (scm_connect): * doc/ref/posix.texi (Network Sockets and Communication): Support connect on nonblocking ports.
2016-06-09`accept' on nonblocking socket can return #fAndy Wingo2-18/+32
* doc/ref/posix.texi (Network Sockets and Communication): * libguile/socket.c (scm_accept): Return #f if the socket is nonblocking and no connection is ready.
2016-06-09put-char in SchemeAndy Wingo3-3/+35
* libguile/ports.c (scm_port_encode_char): New function. * module/ice-9/ports.scm (port-encode-char): Export port-encode-char to the internals module. * module/ice-9/sports.scm (put-char): New function. (port-bindings): Add put-char and put-string.
2016-06-09Update port documentation, rename sports to suspendable portsAndy Wingo6-247/+216
* module/ice-9/suspendable-ports.scm: Rename from ice-9/sports.scm, and adapt module names. Remove exports that are not related to the suspendable ports facility; we want people to continue using the port operations from their original locations. Add put-string to the replacement list. * module/Makefile.am: Adapt to rename. * test-suite/tests/suspendable-ports.test: Rename from sports.test. * test-suite/Makefile.am: Adapt to rename. * module/ice-9/textual-ports.scm (unget-char, unget-string): New functions. * doc/ref/api-io.texi (Textual I/O, Simple Output): Flesh out documentation. (Line/Delimited): Undocument write-line, read-string, and read-string!. This is handled by (ice-9 textual-ports). (Bytevector Ports): Fix duplicated section. (String Ports): Move the note about encodings down to the end. (Custom Ports): Add explanatory text. Remove mention of C functions; they should use the C port interface. (Venerable Port Interfaces): Add text, and make documentation refer to recommended interfaces. (Using Ports from C): Add documentation. (Non-Blocking I/O): Document more fully and adapt to suspendable-ports name change.
2016-06-08Big ports documentation updateAndy Wingo8-1282/+1253
* doc/ref/api-io.texi: Update to document ports more thoroughly. Still some work needed. * doc/ref/r6rs.texi: Move ports documentation back to r6rs.texi, now that Guile has a more thorough binary/textual I/O story, heavily based on R6RS. * doc/ref/api-control.texi: * doc/ref/api-data.texi: * doc/ref/api-options.texi: * doc/ref/misc-modules.texi: * doc/ref/posix.texi: * doc/ref/srfi-modules.texi: Update references.
2016-06-08Undocument (ice-9 rw)Andy Wingo1-101/+0
* doc/ref/api-io.texi (Block Reading and Writing): Undocument (ice-9 rw). The R6RS routines do the same job and are not so clunky.
2016-06-08Add (ice-9 textual-ports)Andy Wingo2-0/+58
* module/ice-9/textual-ports.scm: New module. * module/Makefile.am: Add new module.
2016-06-08put-char, put-string in (ice-9 ports internals)Andy Wingo3-3/+28
* libguile/ports.h (scm_put_char): * libguile/ports.c (scm_put_char): New function. (scm_put_string): Add docstrings, and expose to the internal ports module. * module/ice-9/ports.scm (put-char, put-string): Expose these bindings only through the internals module.
2016-06-04socket: TCP_CORK, TCP_NODELAYAndy Wingo3-0/+21
* libguile/socket.c (scm_init_socket): Define TCP_NODELAY and TCP_CORK if they are available. * doc/ref/posix.texi (Network Sockets and Communication): Add documentation. * NEWS: Add entry.
2016-06-01put-string in SchemeAndy Wingo2-0/+26
* module/ice-9/ports.scm: Export port-encode-chars and port-clear-stream-start-for-bom-write via the internals module. * module/ice-9/sports.scm (put-string): New function.
2016-06-01Rework text encoding to be more Scheme-friendlyAndy Wingo1-285/+290
* libguile/ports.c (scm_port_clear_stream_start_for_bom_write): Instead of returning the BOM, take an optional buffer in which to write the BOM. Return number of bytes written. (port_clear_stream_start_for_bom_write): Remove. (scm_i_write): Adapt scm_port_clear_stream_start_for_bom_write call. (try_encode_char_to_iconv_buf, encode_latin1_chars_to_latin1_buf): (encode_latin1_chars_to_utf8_buf, encode_latin1_chars_to_iconv_buf): (encode_latin1_chars, encode_utf32_chars_to_latin1_buf): (encode_utf32_chars_to_utf8_buf, encode_utf32_chars_to_iconv_buf): (encode_utf32_chars, port_encode_chars): New helpers. (scm_port_encode_chars): New procedure. (scm_c_put_latin1_chars, scm_c_put_utf32_chars): Rework to use new encoding helpers. (scm_lfwrite): Use scm_c_put_latin1_chars.
2016-05-30Simplify string, symbol, char display/write implsAndy Wingo2-527/+74
* libguile/print.h: * libguile/print.c: Use the new routines from ports.[ch].
2016-05-30Add scm_c_put_escaped_char, scm_c_can_put_charAndy Wingo2-1/+50
* libguile/ports.h: * libguile/ports.c (scm_c_put_escaped_char, scm_c_can_put_char): New helpers.
2016-05-30iprin1 uses scm_c_put_stringAndy Wingo2-6/+3
* libguile/print.c (iprin1): Use scm_c_put_string for strings. * test-suite/test-suite/lib.scm (exception:encoding-error): Add an additional expected error string for `encoding-error'.
2016-05-30print_normal_symbol uses new port functionsAndy Wingo1-7/+9
* libguile/print.c (print_normal_symbol): Use new port functions.
2016-05-30Beginnings of supporting encoding text in ports.cAndy Wingo2-31/+480
* libguile/ports.h (scm_c_put_latin1_chars, scm_c_put_utf32_chars) (scm_c_put_char, scm_c_put_string, scm_print_string): New public functions. The plan is to move encoding to ports.c and out of print.c. * libguile/ports.c (UTF8_BUFFER_SIZE, ESCAPE_BUFFER_SIZE): New internal defines. (update_port_position): Take a position instead of a port. Update callers. (utf8_to_codepoint): Allow lengths that are larger than necessary. (port_clear_stream_start_for_bom_write): Require that io_mode be BOM_IO_TEXT to write a BOM. (scm_fill_input): Add a related comment about BOM handling. (scm_i_write): use BOM_IO_TEXT, at least for now. (encode_escape_sequence, codepoint_to_utf8, utf8_to_codepoint) (put_utf8_chars_to_iconv_port, put_latin1_chars_to_utf8_port) (put_latin1_chars_to_iconv_port, put_utf32_chars_to_latin1_port) (put_utf32_chars_to_utf8_port, put_utf32_chars_to_iconv_port): New helpers. (scm_putc, scm_puts): Use scm_c_put_char and scm_put_latin1_chars.
2016-05-25Add port-line-buffered?Andy Wingo2-0/+15
* libguile/ports.c (scm_port_line_buffered_p): New function. * module/ice-9/ports.scm: Plump port-line-buffered? and port-auxiliary-write-buffer through to the internals module
2016-05-25port_clear_stream_start_for_bom_write refactorAndy Wingo1-13/+48
* libguile/ports.c (port_clear_stream_start_for_bom_write): Rework to be friendly to Scheme write implementations.
2016-05-24Speed up scm_c_write / scm_lfwriteAndy Wingo3-3/+49
* libguile/ports-internal.h (scm_t_port): Add write_buf_aux field. * libguile/ports.h (scm_port_auxiliary_write_buffer): New internal decl. * libguile/ports.c (AUXILIARY_WRITE_BUFFER_SIZE): New constant. (initialize_port_buffers): Init aux write buf. (scm_port_auxiliary_write_buffer): Lazily allocate an aux write buffer. (scm_c_write): Arrange to write through an aux buffer if the port is unbuffered.
2016-05-24Speed golf on Scheme put-u8, put-bytevectorAndy Wingo1-4/+4
* module/ice-9/sports.scm (put-u8, put-bytevector): Speed hack.
2016-05-24Add put-u8 implementation in SchemeAndy Wingo1-1/+16
* module/ice-9/sports.scm (put-u8): Add implementation. (port-bindings): Add put-u8.
2016-05-24`put-bytevector' in SchemeAndy Wingo1-4/+52
* module/ice-9/sports.scm (flush-input): New helper. (put-bytevector): New function. (port-bindings): Add put-bytevector.
2016-05-24Wire up non-blocking support in sport writesAndy Wingo1-35/+40
* module/ice-9/sports.scm (write-bytes): Support non-blocking writes. (force-output, flush-output): Rearrange placement.
2016-05-24close-port implementation in sportsAndy Wingo1-2/+12
* module/ice-9/sports.scm (close-port): New function. (port-bindings): Add close-port.
2016-05-24Add force-output to sportsAndy Wingo1-2/+8
* module/ice-9/sports.scm (force-output): New implementation. (port-bindings): Add force-output.
2016-05-23Thread-safety fixes for iconv and portsAndy Wingo3-130/+128
* libguile/ports-internal.h (scm_t_port): Rework to store iconv descriptors inline, so that the port finalizer doesn't race with the iconv descriptor finalizer. Access is serialized through a lock. Fixes a bug whereby if the port finalizer and the descriptor finalizer run on different threads, the close-port run by the port finalizer could try to free the iconv descriptors at the same time as the descriptor finalizer. * libguile/ports.c (iconv_lock): New static variable. (scm_c_make_port_with_encoding): Initialize iconv-related fields. (scm_close_port): Lock while frobbing iconv descriptors. (prepare_iconv_descriptors): Adapt. (scm_specialize_port_encoding_x, scm_i_set_port_encoding_x): Lock while preparing iconv descriptors. (scm_port_acquire_iconv_descriptors) (scm_port_release_iconv_descriptors): New functions, which replace scm_i_port_iconv_descriptors. (scm_port_decode_char): Lock around iconv operations. (port_clear_stream_start_for_bom_write): Acquire iconv descriptors before checking precise_encoding, to make sure precise_encoding is initialized. * libguile/print.c (display_string_using_iconv): Adapt to use the new interface to get iconv descriptors from a port.
2016-05-22get-bytevector-n in Scheme.Andy Wingo2-3/+51
* module/ice-9/sports.scm (fill-input): Add io-mode optional arg. (get-bytevector-n): New implementation. (port-bindings): Add get-bytevector-n. * test-suite/tests/sports.test: Add r6rs-ports tests.
2016-05-22Fix range checking in new Scheme-to-C port codeAndy Wingo1-4/+6
* libguile/ports.c (trampoline_to_c_read, trampoline_to_c_write): Fix bugs checking ranges of start and count parameters.
2016-05-22More thorough ice-9 sports testingAndy Wingo2-13/+23
* module/ice-9/sports.scm: Export read-line, %read-line, and read-delimited. Add these latest three to install-sports!, and fix install-sports! if the current module isn't (ice-9 sports). * test-suite/tests/sports.test: Use install-sports! instead of lexical bindings, to allow us to nicely frob bindings in rdelim. Include rdelim tests.
2016-05-22Merge from stable-2.0Andy Wingo49-886/+2209
This cherry-picks changes from stable-2.0, starting from acd2c8e36a25d77e9e9c9b6782780b23a1764973 and ending in 461b62efc90135d3ca8719ba0f3b6ced4ad13754, inclusively. I did not cherry-pick patches that were already on master and did not cherry-pick ones that don't make sense on master (for example because of the port re-write). I did pick all tests though. I also did not cherry-pick the "Revert foreign objects" patch from ff98cbb643d43c9f8c6ee0e0b4e1bad72aced62e; further discussion necessary.
2016-05-22doc: Fix typo in Web documentation.Luribert1-2/+2
* doc/ref/web.texi (Http Headers): Fixed typo. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2016-05-22http: Accept date strings with a leading space for hours.Ludovic Courtès2-0/+30
Fixes <http://bugs.gnu.org/23421>. Reported by Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>. * module/web/http.scm (parse-rfc-822-date): Add two clauses for hours with a leading space. * test-suite/tests/web-http.test ("general headers"): Add two tests.
2016-05-22Bump user-visible copyright years to 2016.Mark H Weaver3-6/+5
* doc/ref/guile.texi: Add 2016 to user-visible copyright notice. * module/ice-9/command-line.scm (version-etc): Bump 'copyright-year' to 2016. * module/system/repl/common.scm (*version*): Add 2016 to the range of copyright years.
2016-05-22SRFI-19: Update the table of leap seconds.Mark H Weaver1-3/+4
* module/srfi/srfi-19.scm (leap-second-table): Update to include the most recent leap second.
2016-05-22http: Use 'read-header-line' instead of 'read-line*'.Ludovic Courtès1-19/+3
* module/web/http.scm (read-line*): Remove. (read-continuation-line, read-header, read-request-line): Use 'read-header-line' instead of 'read-line*'.
2016-05-22http: Accept empty reason phrases.Ludovic Courtès2-6/+25
Fixes <http://bugs.gnu.org/22273>. Reported by Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>. * module/web/http.scm (read-header-line): New procedure. (read-response-line): Use it instead of 'read-line*'. * test-suite/tests/web-http.test ("read-response-line"): Add test.
2016-05-22http: Test that responses lacking CR/LF are rejected.Ludovic Courtès1-0/+5
* test-suite/tests/web-http.test ("read-response-line")["missing CR/LF"]: New test.
2016-05-22Bump user-visible copyright years to 2015.Mark H Weaver2-2/+2
* module/ice-9/command-line.scm (version-etc): Bump 'copyright-year' to 2015. * module/system/repl/common.scm (*version*): Add 2015 to the range of copyright years.
2016-05-22Fix getsockopt/setsockopt handling of SO_SNDBUF/SO_RCVBUF options.Mark H Weaver1-28/+2
Reported by Park SungMin <byulparan_eng@icloud.com> in <https://lists.gnu.org/archive/html/guile-user/2015-11/msg00026.html>. * libguile/socket.c (scm_getsockopt, scm_setsockopt): Remove code that incorrectly assumed that the argument for SO_SNDBUF and SO_RCVBUF options was of type 'size_t'. Both the Linux and POSIX documentation indicates that the argument is of type 'int', as is the case for most options.
2016-05-22Regenerate SRFI-14 character set data.Ludovic Courtès1-387/+1279
Suggested by Mike Gran <spk121@yahoo.com>. * libguile/srfi-14.i.c: Regenerate for Unicode 8.0.0, <ftp://unicode.org/Public/UNIDATA/UnicodeData.txt> with SHA256 38b17e1118206489a7e0ab5d29d7932212d38838df7d3ec025ecb58e8798ec20.
2016-05-22build: Add SCM_T_OFF_MAX and SCM_T_OFF_MIN to scmconfig.h.Mark H Weaver1-0/+6
* libguile/gen-scmconfig.c (main): Add SCM_T_OFF_MAX and SCM_T_OFF_MIN to the generated 'scmconfig.h' file.
2016-05-22doc: Mention a known-good Flex version number.Ludovic Courtès1-2/+3
Suggested by Jamil Egdemir <unclejamil@gmail.com>. * HACKING: Mention a Flex version number.
2016-05-22Thank David and Kouhei.Ludovic Courtès1-0/+2
2016-05-22build: Remove libguile/mkstemp.c, redundant with Gnulib.Ludovic Courtès3-131/+2
Fixes <http://bugs.gnu.org/21425>. Reported by Kouhei Sutou <kou@cozmixng.org>. * configure.ac: Remove 'AC_REPLACE_FUNCS' for 'mkstemp'. * libguile/Makefile.am (EXTRA_libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): Remove mkstemp.c. * libguile/mkstemp.c: Remove.
2016-05-22Remove SIGEV constant definitions.David Michael2-7/+1
* libguile/Makefile.am (chknew-E chknew-SIG): Anchor the end of the signal/error name pattern to only match alphanumeric symbols. * libguile/cpp-SIG.syms (SIGEV_MAX_SIZE, SIGEV_NONE): Remove. (SIGEV_PAD_SIZE, SIGEV_SIGNAL, SIGEV_THREAD): Likewise. (SIGEV_THREAD_ID): Likewise. Signed-off-by: Ludovic Courtès <ludo@gnu.org>