Add integer multiplication based on Karatsuba's algorithm

  library/integer.m:
    Adds Karatsuba based fast integer algorithm in the function
    `pos_mul_karatsuba' which replaces the call to `pos_mul_list' in `pos_mul'.

    It is a divide and conquer algorithm which uses O(n^1.585) basic
    operations instead of O(n^2). The function expects two positive
    integer variables, the first one must have at most as many digits as
    the second one. It falls back to quadratic multiplication if the
    larger factor has less than `karatsuba_threshold' digits.

    If compiled in a parallel grade, the function uses parallelism for the
    divide and conquer part for numbers with more than
    `karatsuba_parallel_threshold' digits.

    The current values for `karatsuba_threshold' is 35,
    `karatsuba_parallel_threshold' is 10 times this value.
Fix a problem that broke low-level C grades on Windows.

runtime/mercury_debug.c:
	Protect a reference to the memory zone hardmax with MR_PROTECTPAGE.
Disable executable stripping on Mac OS X for now.

Currently attempting to run dynamically linked executables that are stripped
fails in the presence of programs that use env runtime trace goal conditions.
This is because stripping such executables with just "strip" (as we currently
do) removes the global variable introduced by env runtime trace goal
conditions.  (The long term fix is to invoke strip with the -x flag, but this
needs to be conditional on the value of --mercury-linkage and we currently
don't have the command line options to support that.)

configure.ac:
	Disable stripping of executables on Mac OS X.
Fix a build error on MinGW systems.

Some versions of the MinGW system headers rely on the types off_t and off64_t
being defined, but they will not be defined if -ansi is enabled.
(This seems to affect MinGW systems using GCC 4.8; I haven't checked other
GCC versions yet.)

configure.ac:
scripts/mgnuc.in:
	Do not compile with -ansi on MinGW systems.
Fix another build error on MinGW systems.

On MinGW system do not try to link against libpthread if that library is not
actually present on the system.  This is an issue in the compiler directory
because we link the compiler against the thread libraries regardless of the
grade.  This is due to the implementation of --make.

configure.ac:
	On MinGW, if we cannot find pthreads then set THREAD_LIBS to empty.
Merge branch 'version-14_01-branch'
Fix executable stripping on Mac OS X.

Stripping executables on Mac OS X that were built with --mercury-linkage=shared
was resulting in the symbols for the global variables introduced for runtime
trace goal env flags being incorrectly removed.  We need to pass the "-x" flag
to strip to prevent this happening.  This diff adds the ability to pass
different flags to strip depending on the value of --mercury-linkage.

compiler/options.m:
	Add two new options, --strip-executable-{shared,static}-flags, that
	specify what flags are passed to the strip command when --mercury-linkage
	is set to shared or static respectively.

	Add a new option to test that the compiler is sufficiently up-to-date.

compiler/compile_target_code.m:
	Implement the new options.

doc/user_guide.texi:
	Document the new options.

NEWS:
	Adjust the entry for the --strip-executable-command option to mention
	the additional two new options.
Merge branch 'version-14_01-branch'
Re-enable executable stripping on Mac OS X.

configure.ac:
	Pass -x to strip when linking an executable against Mercury shared
	libraries on Mac OS X.

	Make the up-to-date check require {14.01.-beta,rotd}-2014-05-05
        or later.

scripts/Mercury.config.in:
	Set the default values of --strip-executable-{shared,static}-flags.
Merge pull request #13 from mgudemann/integer_arithmetic

Add integer multiplication based on Karatsuba's algorithm
Fix resource leaks in dir fold predicates.

The directory stream was not closed if dir.open succeeded in opening
the directory, but failing to read the first entry (which may be as
simple as an empty directory).

The directory stream was also not closed when dir.foldl2_process_dir2
returns an error value.

library/dir.m:
	As above.

tests/hard_coded/Mmakefile:
tests/hard_coded/dir_fold.exp:
tests/hard_coded/dir_fold.m:
	Add regression test.

NEWS:
	Announce change.
Announce recent fixes to the MinGW and MinGW64 ports.

NEWS:
	As above.
Add barriers (for concurrency) to the standard library

Mission Critical IT has maintained a library of code for concurrent
programming.  We're happy to contribute this upstream to the Mercury
project starting with this module implementing barriers.

library/thread.barrier.m:
    Add the new module implementing barriers.

library/thread.m:
library/library.m:
    Add new module.

NEWS:
    Announce the new module.

library/thread.semaphore.m:
    Add a comment.
Add a test case for barriers and fix a bug.

This test case is based off Sebastian Godelet's work, which found a bug that
can occur when release/3 is called on a barrier and then other calls to
wait/3 are made.  The final call to wait/3 tries to execute the normal
'unblock the barrier' code and deadlocks there because the barrier is
already unlocked, specifically a value is already present in the "Go" mvar.
Thanks Sebastian for your test case.

library/thread.barrier.m:
    Handle release/3 properly: release/3 now sets the number of remaining
    threads to reach the barrier to zero, and wait/3 will determine why this
    iz zero (it's normally at least one), and if it is because release was
    called then no error is raised.  The other reasion why the number of
    remaining threads may be zero is because wait has been called too many
    times, in this case wait/3 will throw an exception.

tests/hard_coded/Mmakefile:
tests/hard_coded/thread_barrier_test.exp:
tests/hard_coded/thread_barrier_test.m:
    Add new test case.

tests/hard_coded/thread_test_utils.m
    This module contains code that may be useful for other concurrency
    tests.
Added the times operator for regular expressions, such that one can express
/[a-z]{10}/ in this way: `Regex = range('a', 'z') * 10'.

extras/lex/lex.m:
    Removed unused and unsafe str_foldr function,
    added (T * int) = regexp function.

extras/lex/samples/lex_demo.m:
    Removed whitespace in comments,
    added an input prompt,
    added a lexeme for '//' C++ comments using the new '*' operator.
Fixes for lex_demo.m

lex_demo.m wasn't compiling because io.print_line doesn't exist.  I also
found that drawing the "> " prompt wasn't working as expected.  This patch
fixes both these issues.

extras/lex/samples/lex_demo.m:
    As above.
Re-enable executable stripping on Mac OS X.

configure.ac:
	Pass -x to strip when linking an executable against Mercury shared
	libraries on Mac OS X.

	Make the up-to-date check require {14.01.-beta,rotd}-2014-05-05
        or later.

scripts/Mercury.config.in:
	Set the default values of --strip-executable-{shared,static}-flags.
Fix resource leaks in dir fold predicates.

The directory stream was not closed if dir.open succeeded in opening
the directory, but failing to read the first entry (which may be as
simple as an empty directory).

The directory stream was also not closed when dir.foldl2_process_dir2
returns an error value.

library/dir.m:
	As above.

tests/hard_coded/Mmakefile:
tests/hard_coded/dir_fold.exp:
tests/hard_coded/dir_fold.m:
	Add regression test.

NEWS:
	Announce change.
Announce recent fixes to the MinGW and MinGW64 ports.

NEWS:
	As above.
Make the thread_barrier_test a conditional test.

When I added this test recently I forgot to make it condition on any grade
with a par component, or the java and csharp grades.  This patch fixes this.

tests/hard_coded/Mmakefile:
    As above.