Commit Graph

38 Commits

Author SHA1 Message Date
Zoltan Somogyi
9b6390b17e Bring the programming style of extras up to date.
extras/curs/curs.m:
extras/curs/curs.panel.m:
    Make panel a separate submodule of curs, not a nested submodule.

extras/base64/base64.m:
extras/curses/mcurses.basics.m:
extras/curses/mcurses.m:
extras/curses/mcurses.misc.m:
extras/curses/mcurses.user.m:
extras/gator/evolve.m:
extras/gator/genotype.m:
extras/gator/phenotype.m:
extras/gator/tausworthe3.m:
extras/monte/dots.m:
extras/monte/geom.m:
extras/monte/hg.m:
extras/monte/monte.m:
extras/monte/rnd.m:
extras/moose/grammar.m:
extras/moose/moose.m:
extras/mopenssl/mopenssl.m:
extras/net/echo.m:
extras/net/errno.m:
extras/net/getaddrinfo.m:
extras/net/net.m:
extras/net/netdb.m:
extras/net/sockets.m:
extras/net/streams.m:
extras/net/tcp.m:
extras/net/test_lookups.m:
extras/net/types.m:
extras/odbc/odbc.m:
extras/odbc/odbc_test.m:
extras/references/README:
extras/references/reference.m:
extras/references/scoped_update.m:
extras/solver_types/library/any.m:
extras/solver_types/library/any_array.m:
extras/solver_types/library/any_assoc_list.m:
extras/solver_types/library/any_list.m:
extras/solver_types/library/any_map.m:
extras/solver_types/library/any_tree234.m:
extras/solver_types/library/any_util.m:
extras/trail/trail.m:
extras/trailed_update/samples/interpreter.m:
extras/trailed_update/samples/vqueens.m:
extras/trailed_update/tests/var_test.m:
extras/trailed_update/tr_array.m:
extras/trailed_update/tr_store.m:
extras/trailed_update/trailed_update.m:
extras/trailed_update/unsafe.m:
extras/trailed_update/var.m:
    Bring programming style up to date.
2023-03-30 21:48:10 +11:00
Darren Bane
7d349d0074 Fix build of extras/net on macOS. 2023-02-10 22:33:36 +11:00
Zoltan Somogyi
818d69a861 Minor improvements to .md files.
Convert extras/README to .md.
2022-01-07 14:54:00 +11:00
Julien Fischer
a908799acb Fix issues in extras caused by recent changes.
extras/*/*.m:
     Avoid ambiguous pragmas.

     Replace an use of is.

     Fix module imports.
2021-06-19 21:11:35 +10:00
Julien Fischer
84e2536618 Fix minor compilation problems in extras and benchmarks.
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.
2020-05-15 16:00:41 +10:00
Julien Fischer
ee69c1432c Fix the networking library.
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.
2020-01-13 21:49:25 +11:00
Mark Brown
d465fa53cb Update the COPYING.LIB file and references to it.
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.
2018-06-09 17:43:12 +10:00
Julien Fischer
b1e04e2bb1 Delete trailing whitespace in extras/net.
extras/net/tcp.m:
    As above.
2017-05-07 22:53:47 +10:00
Julien Fischer
a14de83344 Minor cleanups for the networking library.
extras/net/*.m:
    As above.
2016-09-28 11:06:06 +10:00
Julien Fischer
1781ca757b Fix compilation of extras/net on OS X.
extras/net/netdb.m:
    The function getprotobyname_r is a GNU extension and isn't available
    on systems that don't use the GNU libc (not just Windows).
2015-11-16 10:24:52 +11:00
Julien Fischer
578d172995 Fix documentation in extras/net.
extras/net/types.m:
    Fix spelling errors.
2015-08-19 21:22:00 +10:00
Paul Bone
42b610f825 [net] Add support for IPv6
extras/net/types.m:
    Add IPv6 support

extras/net/test_lookups.m:
    Conform to above change.
2015-04-13 11:23:15 +10:00
Julien Fischer
8c7559ebd3 Fix spelling in networking library.
extras/net/getaddrinfo.m:
extras/net/netdb.m:
extras/net/sockets.m:
extras/net/types.m:
	As above.
2015-04-08 12:03:42 +10:00
Paul Bone
3c9ebf0969 [net] Impement a Mercury interface to getaddrinfo
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.
2015-04-07 16:38:10 +10:00
Paul Bone
cbf0975e9e [net] Refactoring
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.
2015-04-07 16:38:10 +10:00
Paul Bone
8f4051d7a2 [net] Improve compatibility with Windows
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.
2015-03-02 21:34:10 +11:00
Paul Bone
621337fb5f [net] Include mercury_windows.h before winsock2.h
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.
2015-01-13 12:13:37 +11:00
Paul Bone
657511f87f [net] Make the C code compatible with Windows
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.
2015-01-10 15:18:52 +11:00
Paul Bone
12556fd2f6 [net] Networking library improvments
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.
2015-01-10 15:13:22 +11:00
Zoltan Somogyi
d33273d033 Tell vim not to expand tabs in Makefiles.
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.
2015-01-08 22:07:29 +11:00
Paul Bone
5700e17e7a Update networking library
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
2015-01-08 12:45:45 +11:00
Paul Bone
ad60ac4fcd extras/net: Fix syntax error.
sockets.m:
    Fix syntax error.
2014-10-29 23:34:38 +11:00
Paul Bone
89b66d0228 extras/ Update the net library
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.
2014-09-29 09:47:49 +10:00
Paul Bone
5c4bf04598 extras/net: Document sockets.m
sockets.m:
    As above.
2014-09-04 12:36:29 +10:00
Paul Bone
8bbfc5ab2b extras/net: Make sockets.m more thread safe
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.
2014-09-04 12:36:17 +10:00
Paul Bone
95e48fce93 extras/net: Fixes for the net library
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.
2014-09-04 12:35:56 +10:00
Peter Wang
31d3897e22 Thread-safe alternative to strerror.
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.
2014-06-25 17:32:58 +10:00
Sebastian Godelet
35b09651a5 Change extras/net/*.m file mode to 0644
extras/net/net.m:
extras/net/sockets.m:
extras/net/tcp.m:
    chmod 644
2014-03-05 09:46:21 +11:00
Julien Fischer
e16e1b8389 Fix problems that prevent the sockets library in the extras distribution
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.)
2011-10-25 17:38:19 +00:00
Julien Fischer
4a2af7c639 Fix some problems in the TCP binding.
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.
2011-10-21 10:49:34 +00:00
Peter Wang
7e26b55e74 Implement a new form of memory profiling, which tells the user what memory
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.
2011-05-20 04:16:58 +00:00
Julien Fischer
9aa671dde1 s/memcpy/MR_memcpy/
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.
2007-05-07 07:31:55 +00:00
Julien Fischer
35424dcd58 Make the stream error type specific to each reader, not specific to an entire
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.
2007-04-23 02:44:01 +00:00
Peter Wang
b23c0dc171 Introduce a standard way to read lines and files efficiently but generically
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.
2007-04-20 00:48:50 +00:00
Peter Wang
bcabd4ddaa Fix a typo.
Branches: main

tcp.m:
	Fix a typo.
2007-04-18 05:12:37 +00:00
Peter Wang
4f8b783bd3 Improvements to the tcp module.
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.
2007-04-11 05:58:50 +00:00
Julien Fischer
6673468b14 Fix some dodgy usage of the foreign language interface with the sockets
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.
2007-02-23 05:46:30 +00:00
Peter Ross
c6b1bd902c Document that streams has been depreceated.
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.
2006-11-16 04:01:49 +00:00