Fix array.sort.

array.sort was broken since 2001 when the implementation was changed
from merge sort to SAM sort.

library/array.m:
	Fix the confusion as to which output argument of samsort_up is
	sorted.

	Add optional runtime checks of the pre- and post-conditions
	of samsort_up and samsort_down when built with a trace flag.

	Add array.sort_fix_2014.

tests/hard_coded/Mmakefile:
tests/hard_coded/array_sort.exp:
tests/hard_coded/array_sort.m:
	Add test program.

NEWS:
	Announce the fix.
Avoid module qualification in the interface of the io module where possible.

library/io.m:
	Avoid module qualification in the interface where possible.
	I've left the module qualifiers on the types io.state/0 and io.error/0
	since they just look strange without them.  (We don't really use io.state/0
	much these days anyway.)

	Most the result types (e.g. io.res/0) still require module
	qualification in order to distinguish them from the result types
	in the stream module.

	s/input_stream/text_input_stream/ for the all uses of the type
	input_stream.  Similarly for output streams.  This was what was
	intended when the equivalences were originally introduced and the
	debugger has used the text_* names for many years now.

library/store.m:
	s/io\.state/io/ in a few spots.
Merge branch 'version-14_01-branch'
Restore promise_pure declaration for catch_impl.

I inadvertently deleted a promise_pure declaration for catch_impl in
commit 3f220a009735b1bda71e1ce320025e66811fb4b5.  It is necessary in
java and csharp grades as catch_impl is implemented with mode-specific
clauses in those grades so the compiler infers impure.

library/exception.m:
	Restore the promise_pure declaration.

	Add Zoltan's explanation for why catch_impl is impure.

	Explain why we currently pretend catch_impl is pure.
boehm_gc: Apply upstream BoehmGC changes for lock elision bug workaround

This code was written by Ivan Maidanski <ivmai@mail.ru> in response to my
patch to the the Boehm GC to work-around the lock elision bug in glibc.

Fix and code refactoring of lock elision workaround (Linux/x64)
https://github.com/ivmai/bdwgc/commit/3d342554dc03af8d27925706a6513080995e1904

boehm_gc/private/gcconfig.h:
    + (GLIBC_2_19_TSX_BUG): New macro defined for Linux/x86_64 (if Glibc
      used) to workaround a bug in Glibc lock elision implementation.

boehm_gc/misc.c:
    + (GC_init): Reformat code.

boehm_gc/pthread_support.c:
    + Move include of gnu/libc-version.h to gcconfig.h (used to check
      whether lock elision workaround needed).

    + (mark_mutex): Initialize (to PTHREAD_MUTEX_INITIALIZER) even lock
      elision workaround is needed (revert change in previous commit).

    + (parse_version): New static function (defined only if
      GLIBC_2_19_TSX_BUG).

    + (GC_setup_mark_lock): Use parse_version to check target Glibc version
      properly; do not reinitialize mutex unless workaround needed; call
      ABORT (with the appropriate message) in case of a failure in
      pthread_mutexattr_init/settype, pthread_mutex_init.
boehm_gc: Use PTHREAD_MUTEX_NORMAL in the lock elision bug workaround

Peter Wang found that PTHREAD_MUTEX_NORMAL is sufficient to disable lock
elision for a mutex and avoid comprimising performance with
PTHREAD_MUTEX_ERRORCHECK.

I'll be writing to Ivan to let him know about this change.

boehm_gc/pthread_support.c:
    As above.
boehm_gc: Fix declration of setup_mark_lock()

These patches have been applied to upstream boehm_gc by Ivan Maidanski.
We're applying them here as we're tracking their fixes for the TSX lock
elision bug.

boehm_gc/pthread_support.c:
    Rename GC_setup_mark_lock() to setup_mark_lock() and make it static.
    Add static declration of setup_mark_lock();
    Call setup_mark_lock() while setting up parallel marking.

boehm_gc/include/private/pthread_support.h:
    Remove declaration of GC_setup_mark_lock();

boehm_gc/misc.c:
    Remove call to GC_setup_mark_lock();
boehm_gc: Enable the TSX bug workaround on x86

Jan Alexander Steffens made this change to upstream boehm_gc.

boehm_gc/include/private/gcconfig.h:
    As above.
Merge branch 'version-14_01-branch'

Merge boehm_gc changes.
Improve the cohesion of modules.m.

Once upon a time, modules.m contained all the code in the compiler that dealt
with interface files, and it was by far the biggest module in the compiler
(almost 9000 lines). Once before, I moved cohesive bunches of functionality
out of modules.m into new modules, such as file_util.m and module_cmds.m.
This diff does likewise, creating three new modules.

Besides that main task, it has two minor algorithmic changes that should
have no overall effect on correctness. First, it merges some traversals of
the item list, which should yield a very minor speedup, and second,
in order to avoid the need for an undesirable module import, it eliminates
an unnecessary sorting of the item list that we used to do when reading
in interface files. (The sorting makes sense only when *creating* interface
files).

This diff also gives more meaningful names to some predicates.

compiler/module_deps_graph.m:
    This new module defines the module dependency graph, and provides
    predicates for building it and using it.

compiler/write_module_iterface_files.m:
    This new module does what its name says it does.

compiler/item_util.m:
    This new module contains utility predicates that deal with items that are
    now needed in more than one module.

compiler/parse_tree.m:
compiler/notes/compiler_design.html:
    Include the new modules.

compiler/write_deps_file.m:
    Move some predicates here from modules.m, since they belong here.
    E.g. one prints .d files, and related code to print .dv and .dep files
    was already here.

compiler/mercury_compile.m:
    Move a predicate here from modules.m, since it was only called from here,
    and related code is also here.

compiler/prog_item.m:
    Move a predicate here from modules.m, since it is a utility predicate
    for a type that is defined here.

compiler/prog_type.m:
    Move a predicate here from modules.m, since it is a utility predicate
    for types, like all the other predicates in this module.

compiler/modules.m:
    Remove the code that is now in other modules. Impose some structure
    on the remaining code. (It used to be too jumbled up to make much sense of,
    which was one reason why working with this code was unnecessarily hard).

compiler/deps_map.m:
    Note the relationship to the new module module_deps_graph.m.

compiler/*.m:
    Import the new modules as well as (or instead of) modules.m, and/or conform
    to new names for predicates.
Print more specific errors when creating an mdb breakpoint fails.

trace/mercury_trace_spy.c:
    When giving a command such as

        mdb> break badfilename.m:42

    and the debugger has no information about any file named "badfilename.m",
    print an error message that says just that. If the file exists but the
    line number doesn't, say that. Previously, the error message didn't tell
    the user whether it was the filename or the line number that was in error.

trace/mercury_trace_tables.[ch]:
    Collect the information that mercury_trace_spy.c needs for its new task.

tests/debugger/breakpoints.{inp,exp,exp2}:
    Add a test of both kinds of bad breakpoint specification to this test case.
Print precise contexts for duplicate field names.

compiler/add_type.m:
    Record the context of the field name, not the context of the data
    constructor as a whole. The more fields a constructor has, and the
    more extensive comments they each have, the more misleading the
    overall context will be. (The code that uses these contexts does not
    need changing.)

compiler/prog_data.m:
    To store the information that add_type.m needs, create a space for
    the context of each field name next to the name itself. This requires
    breaking an old type equivalence; most of the "conform" changes below
    result from this.

compiler/prog_io_type_defn.m:
    When parsing type definitions, record the context of each field name
    in the new space.

compiler/field_access.m:
compiler/hlds_data.m:
compiler/hlds_pred.m:
compiler/make_hlds_passes.m:
compiler/mercury_to_mercury.m:
compiler/ml_code_util.m:
compiler/prog_type.m:
compiler/recompilation.check.m:
compiler/type_ctor_info.m:
compiler/typecheck.m:
compiler/typecheck_errors.m:
compiler/xml_documentation.m:
    Conform to the changes above.

compiler/post_typecheck.m:
    Conform to the changes above.

    Move some code out of a loop.

    Give a predicate a more meaningful name.

tests/invalid/repeated_field_name.{m,err_exp}:
    A new test case for this change, which defines a field named f2
    three times. Before this change, the compiler reported:

    repeated_field_name.m:008: Error: field `repeated_field_name.f2' multiply
    repeated_field_name.m:008:   defined.
    repeated_field_name.m:008:   Here is the previous definition of field
    repeated_field_name.m:008:   `repeated_field_name.f2'.

    which is a bit baffling. We now report

    repeated_field_name.m:011: Error: field `repeated_field_name.f2' multiply
    repeated_field_name.m:011:   defined.
    repeated_field_name.m:010:   Here is the previous definition of field
    repeated_field_name.m:010:   `repeated_field_name.f2'.
    repeated_field_name.m:012: Error: field `repeated_field_name.f2' multiply
    repeated_field_name.m:012:   defined.
    repeated_field_name.m:010:   Here is the previous definition of field
    repeated_field_name.m:010:   `repeated_field_name.f2'.

    which gives the correct contexts, and also reports BOTH duplicates.
    (Previously, we generated two identical error messages, but then sorting
    the list of errors removed one of them.)

tests/invalid/Mmakefile:
    Enable the new test case.
Merge remote-tracking branch 'upstream/master' into merge-java-on-windows
Add string.is_all_alnum/1.

library/string.m:
	Add a predicate for testing whether a string contains
	only alphabetic characters or digits.

	Avoid excessive module qualification.

NEWS:
	Announce the addition.
extras/net: Fix syntax error.

sockets.m:
    Fix syntax error.
Merge remote-tracking branch 'upstream/master' into merge-java-on-windows