These are due to:
- differences between module and file names.
- redundant imports
- the recent change from math.domain_error -> exception.domain_error.
benchmarks/*/*.m:
extras/*/*.m:
As above.
extras/net/Makefile:
Build a Mercury.modules as some file names do not match
their module names and the compiler no longer accepts this.
extras/net/errno.m:
Ensure we can see the definition of MR_STRERROR_BUF_SIZE.
Discussion of these changes can be found on the Mercury developers
mailing list archives from June 2018.
COPYING.LIB:
Add a special linking exception to the LGPL.
*:
Update references to COPYING.LIB.
Clean up some minor errors that have accumulated in copyright
messages.
Add a Mercury interface to the C function getaddrinfo. getaddrinfo
superceeds gethostbyname and getservbyname. It is reenterant and also makes
it easier to support IPv6 amoung other things. Other predicates in netdb.m
should be written in terms of getaddrinfo.
extras/net/getaddrinfo.m:
As above.
extras/net/netdb.m:
Add predicates that use getaddrinfo to perform lookups.
extras/net/types.m:
Add predicates to convert to and from the raw values for family and
socktype.
extras/net/test_lookups.m:
extras/net/Makefile:
Add a test program.
.gitignore:
This .gitignore file was causing git to ignore the Mercury.options file
in net/extras. A leading slash in .gitignore patterns matches the start
of a path, this allows us to ignore these patterns when they're only in
the root directory.
extras/net/Mercury.options:
Work around a Mercury bug.
Add this missing file.
Move type definitions from netdb.m and sockets.m to types.m. This makes the
coupling between these modules looser.
netdb.m:
Move port type to types.m
sockets.m:
Move family and socktype types into types.m
types.m:
Add the above types.
types.m:
MSVC doesn't know that abort() cannot return, so add a return statement.
Use inet_pton rather than inet_aton.
sockets.m:
Sockets are not file descriptors on windows, so we cannot use read and
write system calls. Instead use recv and send.
netdb.m:
Windows doesn't provide getprotobyname_r() so use getprotobyname() on
Windows.
To make winsock2.h useable we have to include mercury_windows first,
which includes windows.h in such a way as not to include the conflicting
winsock.h.
Julien caught this bug in my previous commit. Thanks.
extras/net/netdb.m:
extras/net/sockets.m:
extras/net/tcp.m:
extras/net/types.m:
As above.
extras/net/netdb.m:
extras/net/sockets.m:
extras/net/tcp.m:
extras/net/types.m:
Include the correct header files.
Fix the order of statements in a code block.
Workarround the missing SHUT_RDWR macro on windows.
Avoid use of socklen_t.
extras/net/streams.m:
Add a socket/1 function to get the socket of a stream.
Add a reader instance for lines and a writer instance for strings.
These don't do any character encoding or buffering. They're pretty
terrible but better than nothing.
extras/net/sockets.m:
Use shutdown() rather than close() for sockets.
This file-specific setting will override a default setting of expandtabs
in $HOME/.vimrc.
*/Makefile:
*/Mmakefile:
As above.
tests/hard_coded/.gitignore:
Don't ignore the purity subdir. This ignore must have been left over
from when purity.m was a test in hard_coded, not hard_coded/purity,
and it ignored an executable, not a directory.
extras/net/sockets.m:
Add read and write predicates.
extras/net/streams.m:
New file containing implementations of stream typeclasses.
extras/net/net.m:
Include the new streams module.
extras/net/echo.m:
Use the new streams typeclass instances to complete the implementation
of the echo server. It works one byte at a time (making it slow) and
will not handle simultanious connections.
extras/net/Makefile:
Add clean target
This library had been neglected for a while and came to my attention when it
used deprecated (or at least old) C interfaces rather than newer reentrant
ones. I've started to improve this library by giving a more typesafe and
Mercury-esque API, using only reentrant C functions, and eventually adding
support for more protocols, (eg: IPv6 and UDP) better integration with
Mercury's io module and generally making it easier to use.
What's working now:
+ creating sockets,
+ binding and listening,
+ connecting (untested),
+ accepting,
+ closing.
+ The interface is generally more type-safe, using new types suck as
"socket" and "address" rather than "int" and "c_pointer".
What's not working/incomplete:
+ I havn't yet touched the tcp.m module, but I intend to remove it and
create a new high-level interface for various protocols.
+ Any kind of reading / writing over sockets at all.
+ Name lookups.
+ A lot of the interface is incomplete / missing useful functions and
predicates.
This is a work in progress.
Makefile:
New Makefile.
README.md:
New Readme file.
net.m:
net is now a module containing the other modules as submodules.
sockets.m:
Many changes as described above.
netdb.m:
This new module contains host and other name lookups. Only service
lookups are currently implemented.
types.m:
Types shared by sockets.m and netdb.m.
echo.m:
An example echo server.
errno.m:
strerror functionality.
tcp.m:
Conform to changes in net.m.
sockets.m:
This file used a static C variable to store the most recent value of
errno. This has been removed and replaced with better return values
making more calls thread safe. Some non-thread safe calls still remain
where the C library call itself is not thread safe.
This change fixes two problems with the net library in extras/.
The h_addr field of the hostent structure (see gethostbyname(3)) is
deprecated. gethostbyname can return multiple addresses in a list in the
field h_addr_list. I've updated code to use the first item in this list.
Note that use of gethostbyname is also discouraged and getaddrinfo(3) is
recommended. In a later change I intend to update this library to use
getaddrinfo.
The library used a macro error() to retrieve the error either from errno, or
on Windows from WSAGetLastError. WSAGetLastError is a function however the
parentheses were missing from the macro causing it to be returned as a value
rather than called.
extras/net/sockets.m:
extras/net/tcp.m:
As above.
Add MR_strerror as a thread-safe alternative to strerror.
The current implementation wraps strerror_r(), strerror_s()
or sys_errlist as appropriate for the platform. Bug #340.
configure.ac:
runtime/mercury_conf.h.in:
Check for strerror_r, strerror_s.
Delete irrelevant code in the sockets test for the external debugger.
runtime/mercury_runtime_util.c:
runtime/mercury_runtime_util.h:
Add MR_strerror and use it.
library/io.m:
Use MR_strerror. In particular, mercury_output_error was not
thread-safe.
Pass errno to mercury_output_error explicitly for clarity.
Delete req_lock parameter in ML_maybe_make_err_msg macro which is not
needed any more.
compiler/prog_event.m:
runtime/mercury_deep_profiling.c:
runtime/mercury_misc.c:
runtime/mercury_term_size.c:
runtime/mercury_trace_base.c:
trace/mercury_trace_cmd_developer.c:
trace/mercury_trace_cmd_exp.c:
trace/mercury_trace_cmd_misc.c:
trace/mercury_trace_declarative.c:
trace/mercury_trace_external.c:
trace/mercury_trace_internal.c:
Use MR_strerror.
compiler/notes/coding_standards.html:
Update coding standard.
extras/net/sockets.m:
extras/net/tcp.m:
Use MR_strerror.
NEWS:
Announce change.
Branches: 11.07, main
Fix problems that prevent the sockets library in the extras distribution
compiling when using MSVC as the C compiler.
extras/net/sockets.mr
Fix bitrot: socketets.init/2 referred to a variable that does
not exist. (Presumably, it was deleted with the initialise
directive was added to this module.)
extras/net/tcp.m:
Include the header file that defines the type off_t.
SIGPIPE does not exist on Windows so protect any uses of
it inside #ifdefs. (Execution will abort if calls are made
to {ignore,unignore}_sigpipe on Windows.)
Branches: 11.07, main
Fix some problems in the TCP binding.
extras/net/tcp.m:
Conform the recent removal of MR_update_io from the standard library.
Use don't-care variables for the I/O state in all foreign procs.
Avoid a warning from gcc concerning mismatched signedness due
to difference betweeen the Windows and POSIX versions of the
accept function.
Branches: main
Implement a new form of memory profiling, which tells the user what memory
is being retained during a program run. This is done by allocating an extra
word before each cell, which is used to "attribute" the cell to an
allocation site. The attribution, or "allocation id", is an address to an
MR_AllocSiteInfo structure generated by the Mercury compiler, giving the
procedure, filename and line number of the allocation, and the type
constructor and arity of the cell that it allocates.
The user must manually instrument the program with calls to
`benchmarking.report_memory_attribution', which forces a GC and summarises
the live objects on the heap using the attributions. The mprof tool is
extended with a new mode to parse and present that data.
Objects which are unattributed (e.g. by hand-written C code which hasn't
been updated) are still accounted for, but show up in profiles as "unknown".
Currently this profiling mode only works in conjunction with the Boehm
garbage collector, though in principle it can work with any memory allocator
for which we can access a list of the live objects. Since term size
profiling relies on the same technique of using an extra word per memory
cell, the two profiling modes are incompatible.
The output from `mprof -s' looks like this:
------ [1] some label ------
cells words cumul procedure / type (location)
14150 38872 total
* 1949/ 13.8% 4872/ 12.5% 12.5% <predicate `parser.parse_rest/7' mode 0>
975/ 6.9% 1950/ 5.0% list.list/1 (parser.m:502)
487/ 3.4% 1948/ 5.0% term.term/1 (parser.m:501)
487/ 3.4% 974/ 2.5% term.const/0 (parser.m:501)
* 1424/ 10.1% 4272/ 11.0% 23.5% <predicate `parser.parse_simple_term_2/6' mode 0>
708/ 5.0% 2832/ 7.3% term.term/1 (parser.m:643)
708/ 5.0% 1416/ 3.6% term.const/0 (parser.m:643)
...
boehm_gc/alloc.c:
boehm_gc/include/gc.h:
boehm_gc/misc.c:
boehm_gc/reclaim.c:
Add a callback function to be called for every live object after a GC.
Add a function to write out the GC_size_map array.
compiler/layout.m:
Define the alloc_site_info type which is equivalent to the
MR_AllocSiteInfo C structure.
Add alloc_site_array as a kind of "layout" array.
compiler/llds.m:
Add allocation sites to `cfile' structure.
Replace TypeMsg argument (which was also for profiling) on `incr_hp'
instructions by an allocation site identifier.
Add a new foreign_proc_component for allocation site ids.
compiler/code_info.m:
compiler/global_data.m:
compiler/proc_gen.m:
Keep the set of allocation sites in the code_info and global_data
structures.
compiler/unify_gen.m:
Add allocation sites to LLDS allocation instructions.
compiler/layout_out.m:
compiler/llds_out_file.m:
compiler/llds_out_instr.m:
Output MR_AllocSiteInfo arrays in generated C files.
Output code to register the MR_AllocSiteInfo array with the Mercury
runtime.
Output allocation site ids for memory allocation instructions.
compiler/llds_out_util.m:
Add allocation sites to llds_out_info.
compiler/pragma_c_gen.m:
compiler/ml_foreign_proc_gen.m:
Generate a macro MR_ALLOC_ID which resolves to an allocation site
structure, for every foreign_proc whose C code contains the string
"MR_ALLOC_ID". This is to be used by hand-written C code which
allocates memory.
MR_PROC_LABELs are retained for backwards compatibility. Though
they were introduced for profiling, they seem to have been co-opted
for printf-debugging since then.
compiler/ml_global_data.m:
Add allocation site structures to the MLDS global data.
compiler/mlds.m:
compiler/ml_unify_gen.m:
Add allocation site id to `new_object' instruction.
compiler/mlds_to_c.m:
Output allocation site arrays and allocation ids in high-level C code.
Output a call to register the allocation site array with the Mercury
runtime.
Delete an unused predicate.
compiler/exprn_aux.m:
compiler/jumpopt.m:
compiler/livemap.m:
compiler/mercury_compile_llds_back_end.m:
compiler/middle_rec.m:
compiler/ml_accurate_gc.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_util.m:
compiler/mlds_to_cs.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/use_local_vars.m:
compiler/var_locn.m:
Conform to changes.
compiler/pickle.m:
compiler/prog_event.m:
compiler/timestamp.m:
Conform to changes in memory allocation macros.
library/benchmarking.m:
Add the `report_memory_attribution' instrumentation predicates.
Conform to changes to MR_memprof_record.
library/array.m:
library/bit_buffer.m:
library/bitmap.m:
library/construct.m:
library/deconstruct.m:
library/dir.m:
library/io.m:
library/mutvar.m:
library/store.m:
library/string.m:
library/thread.semaphore.m:
library/version_array.m:
Use attributed memory allocation throughout the standard library so
that objects don't show up in the memory profile as "unknown".
Replace MR_PROC_LABEL by MR_ALLOC_ID.
mdbcomp/program_representation.m:
mdbcomp/rtti_access.m:
Replace MR_PROC_LABEL by MR_ALLOC_ID.
profiler/Mercury.options:
profiler/globals.m:
profiler/mercury_profile.m:
profiler/options.m:
profiler/output.m:
profiler/snapshots.m:
Add a new mode to `mprof' to parse and present the data from
`Prof.Snapshots' files.
Add options for the new profiling mode.
profiler/process_file.m:
Fix a typo.
runtime/mercury_conf_param.h:
#define MR_MPROF_PROFILE_MEMORY_ATTRIBUTION if memory profiling
is enabled and we are using Boehm GC.
runtime/mercury.h:
Make MR_new_object take an allocation id argument.
Conform to changes in memory allocation macros.
runtime/mercury_memory.c:
runtime/mercury_memory.h:
runtime/mercury_types.h:
Define MR_AllocSiteInfo.
Add memory allocation functions and macros which take into the
account the additional word necessary for the new profiling mode.
These should be used in preferences to the raw memory allocation
functions wherever possible so that objects do not show up in the
profile as "unknown".
Add analogues of realloc/free which take into account the offset
introduced by the attribution word.
Add function versions of the MR_new_object macros, which can't be
written in standard C. They are only used when necessary.
Add built-in allocation site ids, to be used in the runtime and
other hand-written code when context-specific ids are unavailable.
runtime/mercury_heap.h:
Make MR_tag_offset_incr_hp_msg and MR_tag_offset_incr_hp_atomic_msg
allocate an extra word when memory attribution is desired, and store
the allocation id there.
Similarly for MR_create{1,2,3}_msg.
Replace proclabel arguments in allocation macros by alloc_id
arguments.
Replace MR_hp_alloc_atomic by MR_hp_alloc_atomic_msg. It was only
used for boxing floats.
Conform to change to MR_new_object macro.
runtime/mercury_bootstrap.h:
Delete obsolete macro hp_alloc_atomic.
runtime/mercury_heap_profile.c:
runtime/mercury_heap_profile.h:
Add the code to summarise the live objects on the Boehm GC heap and
writes out the data to `Prof.Snapshots', for display by mprof.
Don't store the procedure name in MR_memprof_record: the procedure
address is enough and faster to compare.
runtime/mercury_prof.c:
Finish and close the `Prof.Snapshots' file when the program
terminates.
Conform to changes in MR_memprof_record.
runtime/mercury_misc.h:
Add a macro to expand to the name of the allocation sites array
in LLDS grades.
runtime/mercury_bitmap.c:
runtime/mercury_bitmap.h:
Pass allocation id through bitmap allocation functions.
Delete unused function MR_string_to_bitmap.
runtime/mercury_string.h:
Add MR_make_aligned_string_copy_msg.
Make string allocation macros take allocation id arguments.
runtime/mercury.c:
runtime/mercury_array_macros.h:
runtime/mercury_context.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deconstruct_macros.h:
runtime/mercury_dlist.c:
runtime/mercury_engine.c:
runtime/mercury_float.h:
runtime/mercury_hash_table.c:
runtime/mercury_ho_call.c:
runtime/mercury_label.c:
runtime/mercury_prof_mem.c:
runtime/mercury_stacks.c:
runtime/mercury_stm.c:
runtime/mercury_string.c:
runtime/mercury_thread.c:
runtime/mercury_trace_base.c:
runtime/mercury_trail.c:
runtime/mercury_type_desc.c:
runtime/mercury_type_info.c:
runtime/mercury_wsdeque.c:
Use attributed memory allocation throughout the runtime so that
objects don't show up in the profile as "unknown".
runtime/mercury_memory_zones.c:
Attribute memory zones to the Mercury runtime.
runtime/mercury_tabling.c:
runtime/mercury_tabling.h:
Use attributed memory allocation macros for tabling structures.
Delete unused MR_table_realloc_* and MR_table_copy_bytes macros.
runtime/mercury_deep_copy_body.h:
Try to retain the original attribution word when copying values.
runtime/mercury_ml_expand_body.h:
Conform to changes in memory allocation macros.
runtime/mercury_tags.h:
Replace proclabel arguments by alloc_id arguments in allocation macros.
runtime/mercury_wrapper.c:
If memory attribution is enabled, tell Boehm GC that pointers may be
displaced by an extra word.
trace/mercury_trace.c:
trace/mercury_trace_tables.c:
Conform to changes in memory allocation macros.
extras/net/tcp.m:
extras/solver_types/library/any_array.m:
extras/trailed_update/tr_array.m:
Conform to changes in memory allocation macros.
doc/user_guide.texi:
Document the new profiling mode.
doc/reference_manual.texi:
Update a commented out example.
Estimated hours taken:
Branches: main
extras/net/sockets.m:
extras/net/tcp.m:
s/memcpy/MR_memcpy/
Fix a spot where a global variable was declared twice but never
defined.
Convert the latter module to 4-space indentation.
s/__/./
Conform to our C coding standard.
Use the new foreign language interface throughout.
Add tabled_for_io attributes to a few foreign_procs.
Estimated hours taken: 0.5
Branches: main
Make the stream error type specific to each reader, not specific to an entire
input stream. This means that different readers attached to the same stream
can return different types of error; this is useful in the case where a
reader can return a partial result.
library/stream.m:
Change the definition of input streams so that they no longer include
parameter for the error type.
Introduce the error type as a parameter of the reader class.
This means that different readers attached to the same stream may
now have different error types. The error type is functionally
dependent upon the reader's handle and unit types.
library/io.m:
extras/net/tcp.m:
tests/valid/logged_stream.m:
Conform to the above change.
Estimated hours taken: 2
Branches: main
Introduce a standard way to read lines and files efficiently but generically
using stream.get/4.
library/string.m:
Add the types string.line and string.text_file.
library/io.m:
Make io.input_stream instances of stream.reader with units
string.line and string.text_file.
compiler/error_util.m:
Rename error_util.line to error_line to disambiguate it from
string.line.
extras/net/tcp.m:
Remove the tcp.line type and use string.line instead.
NEWS:
Announce the change.
extras/net/tcp.m:
Add :- type line ---> line(string).
Make tcp an instance of the `reader' typeclass with unit `line' and
implement line reading efficiently in C.
Do input buffering on sockets so it's not necessary to call recv() for
each character read.
Delete `is_eof' predicate. This is no longer needed due to the change
in the way characters are read.
Add predicates tcp__ignore_sigpipe and tcp__unignore_sigpipe to ignore
SIGPIPE signals that are sent if writing to a broken socket. Disabling
SIGPIPE allows write calls to return an error code instead of aborting
the process.
Fix an incorrect `will_not_call_mercury' annotation on
`handle_shutdown'.
Fix memory leaks caused by calling MR_NEW instead of MR_GC_NEW.
Estimated hours taken: 0.2
Branches: main
Fix some dodgy usage of the foreign language interface with the sockets
library.
Cleanups and formatting fixes for the same.
extras/net/sockets.m:
Convert this module to 4-space indentation.
s/__/./
Use the new foreign language interface exclusively.
Change the linkage of the global variable socket_errno to extern
so that is visible in cases foreign_procs in this module are
inlined in other modules.
s/MR_TRUE/MR_YES/ and s/MR_FALSE/MR_NO/ in foreign code where
the (Mercury) types of the values were bool.bool/0.
Other minor formatting fixes.
Estimated hours taken: 0.5
Branches: main
extras/README:
Document that streams has been depreceated.
extras/net/net.m:
extras/net/sockets.m:
extras/net/tcp.m:
A network binding to the streams interface.