Commit Graph

17 Commits

Author SHA1 Message Date
Julien Fischer
e7d28ff90f Update copyright notices in stdlib.
library/*.m:
    As above.
2022-06-07 21:51:03 +10:00
Zoltan Somogyi
cb1da20600 Stop ancestor imports "shadowing" unused local imports.
compiler/make_hlds_passes.m:
    We used to add all modules imported by an ancestor of the current module
    to the set of used modules. Once upon a time, this was meant to stop
    the compiler generating misleading warnings about imports being unused
    when the import wasn't even done by the current module. However, since
    we introduced structured representations of import- and use_module
    declarations and taught unused_imports.m to use them, that has not been
    an issue. However, a bad side-effect remained, which was that if
    a module A imported a module B but did not use it, or it imported
    module B in its interface but did not use in its interface, then
    any warning we could generate about that import being unused was
    suppressed by any import of module B in any of module A's ancestors.
    (The "shadowing" mentioned above.)

    Fix the problem by adding modules imported by ancestors of the
    current module NOT to the set of used modules, but to a new field
    in the module_info.

compiler/hlds_module.m:
    Add this new field. As it happens, it is not needed right now,
    but it may be needed later.

    Update some documentation.

    Note an only-tangentially-related problem.

compiler/unused_imports.m:
    Fix a bug that was hiding behind the shadowing, which was that whether
    the text of the warning message we generated for an unused local import-
    or use_module declaration could be affected by the presence of an
    import- or use_module declaration in an ancestor module.

    Improve debugging infrastructure.

    Make a predicate name more descriptive.

NEWS:
    Announce the bugfix.

compiler/add_pragma_tabling.m:
compiler/add_solver.m:
compiler/add_type.m:
compiler/parse_string_format.m:
compiler/recompilation.usage.m:
compiler/recompilation.used_file.m:
library/io.call_system.m:
library/io.text_read.m:
library/random.sfc32.m:
library/random.sfc64.m:
library/random.system_rng.m:
library/string.parse_runtime.m:
library/string.parse_util.m:
library/string.to_string.m:
library/thread.closeable_channel.m:
mdbcomp/feedback.automatic_parallelism.m:
    Delete imports that the fixed compiler now generates unused import
    warnings for.
2022-03-30 13:06:37 +11:00
Zoltan Somogyi
06f81f1cf0 Add end_module declarations ...
.. to modules which did not yet have them.
2022-01-09 10:36:15 +11:00
Julien Fischer
74724bec37 Fix wording.
library/random.system_rng.m:
    As above.
2021-11-10 12:03:16 +11:00
Julien Fischer
ee1b1ba68f Fix a typo.
library/random.system_rng.m:
    As above.
2021-08-10 20:46:27 +10:00
Julien Fischer
23e0c34afe Fix a typo.
library/random.system_rng.m:
     s/MR_/ML_/ in a spot.
2021-02-21 14:40:52 +11:00
Julien Fischer
2f99fbb1d3 Respond to review comments.
library/random.system_rng.m:
      Shift most of the #includes into a local foreign_decl pragma
      so that they do not get included in the .mh file.

      Position the C# and Java foreign code pragmas to the end of the file,
      with the C one.
2021-02-20 16:13:00 +11:00
Julien Fischer
c2df9af6a8 Document and announce the system RNG module.
library/random.system_rng.m:
    Document what sources of randomness are used by the C backends.

library/MODULES_DOC:
library/MODULES_UNDOC:
    Include random.system_rng module in the library documentation.

NEWS:
    Announce the random.system_rng module.
2021-02-20 10:44:31 +11:00
Julien Fischer
7f87e4a686 Fix system RNG handles for non-urandom C implementations.
Ensure it is not possible to use a system RNG handle after it has been closed
with the arc4random() and rand_s() based implementations.

library/random.system_rng.m:
    As above.
2021-02-20 01:12:25 +11:00
Julien Fischer
b7d3cb7c32 Fix system RNG handles in the C# and Java grades.
Ensure it is not possible to use a system RNG handle after it has been closed
in the C# and Java grades. This brings the implementation for these backends
into line with the /dev/urandom implementation on C.  (The other C implementation
will be made to conform in a separate change.)

library/random.system_rng.m:
    Add wrapper classes around the C# and Java system RNGs that allow
    us to track if they have already been closed.
2021-02-19 23:20:06 +11:00
Julien Fischer
2ff14bd80b Implement the system RNG on Windows.
On Windows we implement the system RNG by calling the CRT's rand_s() function.

library/random.system_rng.m:
    Implement the system RNG on Windows using rand_s().

runtime/mercury_std.h:
    On Windows define the macro _CRT_RAND_S before the initial
    inclusion of stdlib.h -- we must do this otherwise the declaration
    of rand_s() will not be visible.
2021-02-14 20:30:08 +11:00
Julien Fischer
6cd07540fe Use the arc4random() based system RNG on Cygwin.
library/random.system_rng.m:
    Cygwin provides the arc4random() family of functions; use
    that to implement the system RNG on Cygwin.
2021-02-06 03:16:28 +11:00
Julien Fischer
7b4fe0bdc3 Address review comment.
library/random.system_rng.m:
    Escape a backslash in foreign_decl pragma.
2021-02-02 16:01:12 +11:00
Julien Fischer
1e262841c1 Add an arc4random() based system RNG implementation.
library/random.system_rng.m:
    As above.

    Use the arc4random() based implementation on FreeBSD >= 12.0
    and macOS >= 10.12, falling back to the urandom approach on earlier
    versions.

    Always use the arc4random() approach on NetBSD and OpenBSD,
    both of which have used ChaCha20 in their implementation
    of arc4random() since 2014.
2021-02-02 00:52:46 +11:00
Julien Fischer
4109cb8347 Add a system RNG implementation for the C backends.
Add a system RNG implementation for the C backends that works by
reading random bits from /dev/urandom. We use this on Linux,
AIX and Solaris.

library/random.system_rng.m:
    Add two implementations of the system RNG for the C backends, one that
    reads from /dev/urandom and one that just aborts.  The former is used
    on Linux and the latter is used everywhere else (for now).
2021-02-01 16:57:29 +11:00
Julien Fischer
8c236f10bf Fix library build failure with older versions of .NET.
library/random.system_rng.m:
    Avoid the use of the BitConverter class as older versions
    of .NET (Mono) do not provide some of the methods we use.
2021-01-31 20:14:44 +11:00
Julien Fischer
65566350b5 Add the system random number generator interface.
This is work-in-progress, currently only the C# and Java backends
are supported. Support for the C backends will be added separately.

library/random.system_rng.m:
    A new submodule containing the system RNG.

library/random.m:
library/library.m:
    Include the new submodule.

library/MODULES_UNDOC:
    Do not generate documentation for the new submodule.
2021-01-29 16:30:18 +11:00