SRFI-4 predicates, length accessors only accept bytevectors (not arrays)

* module/srfi/srfi-4.scm (define-bytevector-type): For the predicates
  and length accessors, only accept bytevectors.  Since arrays don't
  work for u32vector-ref et al, they shouldn't pass u32vector?.
Remove private unused duplicate c32/c64vector definitions

* module/srfi/srfi-4.scm: Remove vestigial definitions for c32vectors
  and c64vectors.  Those are defined in (srfi srfi-4 gnu).
(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.
Fix truncated-print for uniform vectors

* module/ice-9/pretty-print.scm (truncated-print): Use bytevector?
  instead of uniform-vector?; the latter could be true for shared arrays
  with non-zero lower bounds.
Fix 'weak-vector?' doc: Weak hash tables are not weak vectors.

* doc/ref/api-memory.texi (Weak vectors): In 'weak-vector?' entry, don't
  claim that weak hash tables are weak vectors.  Remove statement that
  weak vectors are mainly useful for implementing weak hash tables.
Make size argument optional to 'make-doubly-weak-hash-table'; fix docs.

* libguile/hashtab.c (scm_make_doubly_weak_hash_table): Make 'size'
  argument optional, like the weak hash table constructors.

* doc/ref/api-memory.texi (Weak hash tables): Document that 'size'
  argument is optional for the weak hash table constructors.
Better error reporting in 'weak-vector-ref' and 'weak-vector-set!'.

* libguile/weaks.c (scm_c_weak_vector_ref, scm_c_weak_vector_set_x):
  Pass procedure name to 'scm_out_of_range'.
Improve handling of locales in the test suite.

* test-suite/guile-test (run-tests): Load each test file within
  (with-locale "C" ...).

* test-suite/tests/encoding-iso88591.test:
* test-suite/tests/encoding-iso88597.test:
* test-suite/tests/encoding-utf8.test:
* test-suite/tests/srfi-14.test: Remove broken code to save and restore
  the previous locale.

* test-suite/tests/bytevectors.test:
* test-suite/tests/format.test:
* test-suite/tests/regexp.test:
* test-suite/tests/srfi-19.test:
* test-suite/tests/tree-il.test: Make sure 'setlocale' is defined before
  calling it.
Deprecate htons, htonl, ntohs, ntohl

* libguile/sockets.h:
* libguile/sockets.c:
* libguile/deprecated.h:
* libguile/deprecated.c (scm_htons, scm_htonl, scm_ntohs, scm_ntohl):
  Deprecate.  Bytevectors adequately subsume their functionality.

* doc/ref/posix.texi:
* test-suite/tests/00-socket.test: Update.
Simplify srfi-4 C implementation

* libguile/srfi-4.c (DEFINE_SRFI_4_C_FUNCS): In the raw element
  accessors (e.g scm_u32vector_writable_elements), only permit
  bytevectors, as the constructors will only make bytevectors.  This
  harmonizes with the Scheme interfaces as well, which expect packed
  bytevectors.
  (scm_make_srfi_4_vector): Knowing that the new value is a bytevector
  with base 0 and inc 1, simplify initialization.
Deprecate general "uniform-vector" interface

* libguile/uniform.h:
* libguile/uniform.c (scm_is_uniform_vector, scm_uniform_vector_p)
  (scm_c_uniform_vector_length, scm_uniform_vector_length)
  (scm_uniform_vector_element_type, scm_uniform_vector_element_size)
  (scm_c_uniform_vector_ref, scm_uniform_vector_ref):
  (scm_c_uniform_vector_set_x, scm_uniform_vector_set_x):
  (scm_uniform_vector_to_list)
  (scm_uniform_vector_elements, scm_uniform_vector_writable_elements):
  Deprecate.  This interface lacked both generality and specificity.
  The general replacement is array-length, array-ref, and friends on the
  scheme side, or the array handle interface on the C side.  On the
  specific side of things, there are the specific bytevector, srfi-4,
  and bitvector interfaces.

* test-suite/tests/arrays.test:
* test-suite/tests/bitvectors.test:
* test-suite/tests/ports.test:
* test-suite/tests/srfi-4.test: Update to use array interfaces.

* doc/ref/api-foreign.texi (Void Pointers and Byte Access):
* doc/ref/srfi-modules.texi (SRFI-4): Update.
Deprecate use of vector-length, vector-ref, vector-set! as primitive-generics

* libguile/vectors.c (scm_vector_length, scm_c_vector_ref):
  (scm_c_vector_set_x): Deprecate the use of vector-length, vector-ref,
  and vector-set! as primitive generics.
Deprecate the use of the vector interface on arrays

* libguile/vectors.c (scm_is_vector): Deprecate use on weak vectors and
  arrays.
  (scm_is_simple_vector): Deprecate use on weak vectors.
  (scm_vector_length, scm_c_vector_ref, scm_c_vector_set_x): Deprecate
  use on arrays.

* libguile/sort.c: Adapt to check explicitly for arrays.
Fix improper use of 'with-locale'.

* test-suite/guile-test (run-tests): Use 'setlocale' with check
  instead of 'with-locale'.
guile.m4 tweaks

* meta/guile.m4 (GUILE_PKG): Don't print "checking for guile 2.0" if
  we've already found 2.2.  Print the correct effective version at the
  end.
  (GUILE_PROGS): Allow prereleases, whose micro version does not yet
  match the effective version.  Default to the already-chosen effective
  version.
REPL Server: Fix 'stop-server-and-clients!'.

* module/system/repl/server.scm: Import (ice-9 match) and (srfi srfi-1).
  (*open-sockets*): Add comment.  This is now a list of pairs with a
  'force-close' procedure in the cdr.
  (close-socket!): Add comment noting that it is unsafe to call this
  from another thread.
  (add-open-socket!): Add 'force-close' argument, and put it in the cdr
  of the '*open-sockets*' entry.
  (stop-server-and-clients!): Use 'match'.  Remove the first element
  from *open-sockets* immediately.  Call the 'force-close' procedure
  instead of 'close-socket!'.
  (errs-to-retry): New variable.
  (run-server): Add a pipe, used in the 'force-close' procedure to
  cleanly shut down the server.  Put the server socket into non-blocking
  mode.  Use 'select' to monitor both the server socket and the pipe.
  Don't call 'add-open-socket!' on the client-socket.  Close the pipe
  and the server socket cleanly when we're asked to shut down.
  (serve-client): Call 'add-open-socket!' with a 'force-close' procedure
  that cancels the thread.  Set the thread cleanup handler to call
  'close-socket!', instead of calling it in the main body.

* doc/ref/api-evaluation.texi (REPL Servers): Add a caveat to the manual
  entry for 'stop-servers-and-clients!'.
Add cooperative REPL server module.

Modified-by: Mark H Weaver <mhw@netris.org>

* module/system/repl/coop-server.scm: New module.

* module/system/repl/repl.scm (start-repl): Extract body to start-repl*.
  (start-repl*): New procedure.
  (run-repl): Extract body to run-repl*.
  (run-repl*): New procedure.

* module/system/repl/server.scm (run-server): Extract body to
  run-server*.
  (run-server*): New procedure.

* doc/ref/api-evaluation.texi (Cooperative REPL Servers): New node.

* module/Makefile.am (SYSTEM_SOURCES): Add system/repl/coop-server.scm.
Import 'lstat' and 'mkstemp' modules from Gnulib.

* lib/mkstemp.c:
* lib/secure_getenv.c:
* lib/tempname.c:
* lib/tempname.h:
* m4/mkstemp.m4:
* m4/secure_getenv.m4:
* m4/tempname.m4: New files.

* lib/Makefile.am:
* m4/gnulib-cache.m4:
* m4/gnulib-comp.m4: Add modules.
Rely on Gnulib for 'select', 'lstat', and 'mkstemp'.

* libguile/iselect.h:
* libguile/threads.c:
* libguile/deprecated.h: Rely on Gnulib for sys/select.h.

* libguile/filesys.c: Rely on Gnulib for 'lstat' and 'mkstemp'.
Fix inline asm of VM numerical operations for x32.

* libguile/vm-i-scheme.c (_CX): Choose register size based on
  'SIZEOF_VOID_P' instead of '__x86_64__'.