Commit Graph

55 Commits

Author SHA1 Message Date
Julien Fischer
71624374c4 Fix compilation of a posix sample.
extras/posix/samples/mdprof_cgid.m:
    Conform to changes in the getopt module.
2021-01-25 20:28:23 +11:00
Julien Fischer
77cdaf36d2 Delete references to erlang grade.
extras/base64/Mercury.options:
extras/graphics/mercury_cairo/Mercury.options:
extras/graphics/mercury_glfw/Mercury.options:
extras/posix/Mercury.options:
extras/trail/Mercury.options:
     As above.
2021-01-23 19:46:15 +11:00
Julien Fischer
d36d42b4de Add chdir() and sleep() to POSIX binding.
Contributed by Volker Wysk.

extras/posix/posix.chdir.m
extras/posix/posix.sleep.m:
     As above.
2020-03-21 02:10:09 +11:00
Peter Wang
33da7c82b4 Fix use of MR_strerror.
extras/posix/posix.strerror.m:
    Fix use of MR_strerror (it may return a pointer to a static string
    instead of modifying the provided buffer).

    Allocate string such that it will be attributed to the predicate
    when profiling memory retention.
2019-10-31 23:47:18 +11:00
Julien Fischer
da5fe0974e Adjust a predicate.
extras/posix/posix.m:
    Always return a valid error number from error_to_cerrno/2.
2019-10-31 21:43:00 +11:00
Julien Fischer
2c0351aea9 Add a binding to sterror().
Contributed by Volker Wysk.

extras/posix/posix.strerror.m:
extras/posix/posix.m:
    As above.
2019-10-31 11:26:03 +11:00
Julien Fischer
16b629d31c Add realpath() to POSIX binding.
Contributed by Volker Wysk.

extras/posix/posix.realpath.m:
extras/posix/posix.m:
    As above.
2019-10-26 01:19:12 +11:00
Julien Fischer
5668e1a614 Fix readdir() in the POSIX binding.
The binding for readdir() was reporting the end of the directory stream as an
unknown error.  This problem was reported by Volker Wysk, to whom the initial
version of the fix is also due.

extras/posix/posix.readdir.m:
    Add a new result type that distinguishes between the end of the directory
    stream and an error.

    Add and export to C an enumeration whose values describe the result of
    a call to readdir().  Use this, rather than small integers, when
    communicating the result of readdir() call back to Mercury.

    Always the string output argument of a foreign_proc to a valid value;
    this avoids problems if the debugger attempts to print them out.
2019-10-17 22:00:04 +11:00
Volker Wysk
0236fbc21c extras/posix: Extend exec module.
extras/posix/posix.exec.m:
    Add execvp, execv, execve predicates.
2019-03-29 14:48:03 +11:00
Julien Fischer
14c234a34a Fix the install target for the posix binding.
extras/posix/Makefile:
    Delete dangling references to posix_workarounds.o.
2019-03-28 05:45:10 +00:00
Peter Wang
f0407d62c6 extras/posix: Fix warnings.
extras/posix/posix.socket.m:
    Fix compiler warnings in accept0.

    Delete unused predicate cons_sockaddr (the code should be improved
    if required).
2019-03-24 14:09:17 +11:00
Peter Wang
676e06b205 extras/posix: Don't abuse Mercury arrays for exec().
extras/posix/posix.exec.m:
    Allocate arrays of the correct type instead of passing Mercury array
    elements as (char **).
2019-03-24 13:58:49 +11:00
Julien Fischer
9751360ca4 Style and formatting fixes for the POSIX binding.
extras/posix/*.m:
    As above.
2019-03-22 10:53:31 +00:00
Julien Fischer
27a7199efb Replace workarounds in the POSIX binding.
Delete the workarounds for FD_{ZERO,SET,ISSET,CLR} in the POSIX binding.  The
stated reason for their existence was that the Linux headers defined them using
inline assembler that conflicted with our use of global register variables.

Since the runtime (now) defines a wrapper for FD_ZERO, use the runtime's
version instead of having the binding define its own.  We've been using
FD_{SET,ISSET} in the runtime without issues for many years.  (On my system,
they and FD_CLR are not defined using inline assembler anyway.)

extras/posix/posix_workarounds.{ch}:
    Delete this files.

extras/posix/posix.select.m:
    Use MR_fd_zero in place of ME_fd_zero.

    Use FD_{SET,ISSET,CLR} directly.

extras/posix/Makefile:
extras/posix/Mercury.options:
extras/posix/Mmakefile:
    Conform to the above changes.
2019-03-22 10:17:15 +00:00
Julien Fischer
0b154978b6 Workaround a problem building the posix library.
extras/posix/Mmakefile:
    As above.
2019-03-22 06:59:52 +00:00
Julien Fischer
dcf7945280 Build the POSIX binding using mmc --make.
Building the POSIX binding using mmc --make by default and just have mmake
forward its work to that.  Using mmc --make means things like library grade
exclusions will work properly.

Exclude non-C grades from the grade set in which to install the POSIX binding.

Shift a POSIX binding sample into the samples subdirectory.

extras/posix/Makefile:
extras/posix/Mercury.options:
    Build the POSIX binding using mmc --make.

extras/posix/Mmakefile:
    Redirect mmake to use the normal Makefile.

extras/posix/hello.m:
    Shift this file into the samples subdirectory.

extras/samples/Makefile:
    Set up things to build the samples against a libposix in the
    parent directory.

extras/samples/Mmakefile:
    Delete this file.
2019-03-21 10:58:08 +00:00
Julien Fischer
c6d97df5ea Fix compilation of extras/posix with _FORTIFY_SOURCE.
extras/posix/posix.open.m:
    Avoid calling the two argument version of open.
2019-03-16 06:16:05 +00:00
Zoltan Somogyi
c4174e712b Fix redundant type declaration. 2019-03-15 04:47:55 +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
Paul Bone
fc4b3ff196 Remove .cvsignore files
Remove old .cvsignore files, moving their contents to .gitignore files.
There are now no .cvsignore files in the repository.

I've also sorted some .gitignore files and avoided repeating a pattern in a
subdirectory's .gitignore file when it is already mentioned in the parent
.gitignore file.
2017-04-04 12:05:56 +10:00
Julien Fischer
2dc59fefbe Fix compilation errors in samples, extras and benchmarks.
benchmarks/progs/quicksort/qs_always_par.m:
benchmarks/progs/quicksort/qs_utils.m:
extras/moose/check.m:
extras/posix/samples/mdprof_cgid.m:
extras/xml/parsing.m:
samples/muz/zparser.m:
samples/muz/ztype_op.m:
    As above -- the compiler now rejects determinism declarations on
    non-predmode predicate declarations.

    Replace a call to bitmap.new with bitmap.init.
2016-01-13 14:16:24 +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
Sebastian Godelet
fcee76f671 Update .gitignore files.
Update .gitignore files to ignore Unix executables and intermediate files.

extras/.gitignore:
    ignore *.beams

extras/cgi/.gitignore:
extras/gator/.gitignore:
extras/graphics/mercury_cairo/tutorial/.gitignore:
extras/logged_output/.gitignore:
extras/monte/.gitignore:
extras/odbc/.gitignore:
extras/posix/samples/.gitignore:
extras/quickcheck/.gitignore:
extras/quickcheck/tutes/.gitignore:
extras/references/samples/.gitignore:
    ignore executable(s)

extras/references/tests/.gitignore:
extras/trailed_update/tests/.gitignore:
    ignore test *.res and *.out files,
    ignore executable

extras/windows_installer_generator/sample/.gitignore:
samples/concurrency/dining_philosophers/.gitignore:
samples/concurrency/midimon/.gitignore:
    ignore executables

tests/hard_coded/.gitignore:
    ignore *.o and *.obj object files
2014-11-06 22:33:48 +11:00
Sebastian Godelet
f9899940b7 Add .gitignore files to the extras/ directory
extras/.gitignore:
    Mercury ignores the --use-{grade}-subdir dir
    Mercury/** for git 1.8+ this recursively ignores all build files
    ignoring *.mh and *.init files
    *.err output files
    lib*.{dll|so|a|dylib} ignores target compiler library output
    *.jar ignores the Java grade output
    *.exe for Windows executables

extras/dynamic_linking/.gitignore:
    ignoring the copy of dl.m, name_mangle.m
    ignoring hello lib and dl_test* executables

extras/moose/samples/.gitignore:
    ignoring cgram.m small.m alpha.m expr.m which are
    generated from the .moo grammar files

extras/graphics/mercury_cairo/samples/.gitignore:
    ignoring *.png output and all executables

extras/**/.gitignore:
    In each sample/test/example folder the linux executable/test
    output is ignored
2014-02-27 16:58:43 +11:00
Julien Fischer
452dd420ad Fix compilation errors in extras.
extras/curs/samples/demo.m:
extras/curs/samples/frogger.m:
extras/posix/hello.m:
	Update library calls where necessary.
2014-02-06 03:08:14 +11:00
Julien Fischer
df345f7258 Ignore generated files in the extras.
Branches: main, 11.07

extras/*/.cvsignore:
	Ignore generated files in the extras.
2011-11-18 03:03:26 +00:00
Peter Wang
b1af59cb29 Deprecate string.substring, string.foldl_substring, etc. in favour of
Branches: main

Deprecate string.substring, string.foldl_substring, etc. in favour of
new procedures named string.between, string.foldl_between, etc.
The "between" procedures take a pair of [Start, End) endpoints instead
of Start, Count arguments.  The reasons for this change are:

- the "between" procedures are more convenient

- "between" should be unambiguous.  You can guess that it takes an End
  argument instead of a Count argument without looking up the manual.

- Count arguments necessarily counted code units, but when working with
  non-ASCII strings, almost the only way that the values would be arrived at
  is by substracting one end point from another.

- it paves the way for a potential change to replace string offsets with an
  abstract type.  We cannot do that if users regularly have to perform a
  subtraction between two offsets.

library/string.m:
	Add string.foldl_between, string.foldl2_between,
	string.foldr_between, string.between.

	Deprecate the old substring names.

	Replace string.substring_by_codepoint by string.between_codepoints.

compiler/elds_to_erlang.m:
compiler/error_util.m:
compiler/rbmm.live_variable_analysis.m:
compiler/timestamp.m:
extras/posix/samples/mdprof_cgid.m:
library/bitmap.m:
library/integer.m:
library/lexer.m:
library/parsing_utils.m:
mdbcomp/trace_counts.m:
profiler/demangle.m:
	Conform to changes.

tests/general/Mercury.options:
tests/general/string_foldl_substring.exp:
tests/general/string_foldl_substring.m:
tests/general/string_foldr_substring.exp:
tests/general/string_foldr_substring.m:
tests/hard_coded/Mercury.options:
tests/hard_coded/string_substring.m:
	Test both between and substring procedures.

tests/hard_coded/string_codepoint.exp:
tests/hard_coded/string_codepoint.exp2:
tests/hard_coded/string_codepoint.m:
	Update names in test outputs.

NEWS:
	Announce the change.
2011-06-15 01:05:34 +00:00
Julien Fischer
f53181dff1 Replace a c_header_code pragma with a foreign_decl pragma
Branches: main

extras/posix/psoix.readdir.m:
	Replace a c_header_code pragma with a foreign_decl pragma
	for C.
2010-07-27 20:03:41 +00:00
Julien Fischer
a93d6c70d0 Convert the POSIX binding to use the standard library's bitmap module for
Estimated hours taken: 1
Branches: main

Convert the POSIX binding to use the standard library's bitmap module for
storing byte-oriented data rather than defining a separate module for doing
so.  (The standard library's facilities for dealing with such data are much
more extensive than what they were when the binding was originally written.)

extras/posix/posix.read.m:
extras/posix/posix.write.m:
	Use bitmaps in place of the text/0 type.

extras/posix/text.m:
extras/posix/text_header.h:
	Delete these modules; they are no longer needed.

extras/posix/Mmakefile:
	Don't install the extra header.

extras/posix/hello.m:
extras/posix/samples/mdprof_cgid.m:
	Conform to the above change.
2008-09-02 09:45:55 +00:00
Peter Wang
f886caca9d Retry interrupted system calls which return an error code and set `errno' to
Estimated hours taken: 1.5
Branches: main

Retry interrupted system calls which return an error code and set `errno' to
EINTR.

compiler/prog_event.m:
library/io.m:
runtime/mercury_context.c:
runtime/mercury_memory_handlers.c:
runtime/mercury_trace_base.c:
runtime/mercury_wrapper.c:
	As above.

extras/posix/posix.dup.m:
extras/posix/posix.exec.m:
extras/posix/posix.lseek.m:
extras/posix/posix.open.m:
extras/posix/posix.readdir.m:
extras/posix/posix.select.m:
extras/posix/posix.socket.m:
extras/posix/posix.stat.m:
extras/posix/posix.wait.m:
extras/posix/posix.write.m:
	As above.

	Use `pragma foreign_enum' in some places.

extras/posix/posix.read.m:
	Use `pragma foreign_proc' instead of `pragma c_code' in a spot.
2007-10-30 00:46:23 +00:00
Peter Wang
e41f5734de Add a minimal server program that accepts and passes through requests
Branches: main

extras/posix/samples/Mmakefile:
extras/posix/samples/mdprof_cgid.m:
extras/posix/samples/README:
	Add a minimal server program that accepts and passes through requests
	to mdprof.  It's useful when you want to view deep profiling data
	without configuring and running a proper web server.
2007-05-28 09:12:54 +00:00
Julien Fischer
1b35afa14b Fix an oversight in my last change: delete the old definition
Estimated hours taken: 0.1
Branches: main

extras/posix/posix.m:
	Fix an oversight in my last change: delete the old definition
	of the type posix.dir/0.

extras/posix/posix.socket.m:
	Define the type sockaddr_ptr/0 as as foreign type.
2007-04-23 09:21:00 +00:00
Julien Fischer
e9ddbd889d Further cleanups and updates for the posix binding.
Estimated hours taken: 2
Branches: main

Further cleanups and updates for the posix binding.

extras/posix/hello.m:
extras/posix/posix.exec.m:
extras/posix/posix.kill.m:
extras/posix/posix.lseek.m:
extras/posix/posix.mkdir.m:
extras/posix/posix.open.m:
extras/posix/posix.pipe.m:
extras/posix/posix.read.m:
extras/posix/posix.rmdir.m:
extras/posix/posix.select.m:
extras/posix/posix.socket.m:
extras/posix/posix.stat.m:
extras/posix/posix.wait.m:
extras/posix/posix.write.m:
 	Use 4-space indentation throughout.

 	Use the new foreign language interface throughout.

 	Use state variables for threading the I/O state.

 	Add missing `MR_' prefixes.

 	Use foreign_types rather than c_pointer in a number of places; the
 	former is more type safe.  (TODO: there are quite a few remaining uses
 	of c_pointer in these modules that could be replaced by foreign
 	types.)

 	Put no_inline pragmas on foreign_procs containing static data so we
 	don't end up duplicating that data.
 	(TODO: the static data should be shifted into foreign_code pragmas, but
 	that's a separate change.)

 	Rename posix.socket.(type)/0 to socket_type/0.  This avoids having to
 	parenthesise the name.  Redefine the former as an equivalence type for
 	the latter and add a comment mentioning that it is now obsolete.

 	Reformat code as per our current coding standard.
2007-04-23 09:08:15 +00:00
Julien Fischer
e128f20dce Add hello.m to this file.
extras/posix/.nocopyright:
	Add hello.m to this file.
2007-04-23 09:08:05 +00:00
Julien Fischer
8f4ce2ae10 Begin moving the posix binding over to the new foreign language interface
Estimated hours taken: 0.5
Branches: main

Begin moving the posix binding over to the new foreign language interface

Conform to our current coding standard in (some of) the posix binding.

extras/posix/posix.closedir.m:
extras/posix/posix.dup.m:
extras/posix/posix.fork.m:
extras/posix/posix.getpid.m:
extras/posix/posix.m:
extras/posix/posix.opendir.m:
	Use the new foreign language interface in these modules.

	Use predmode declarations where appropriate.

	Use 4-space indentation throughout.

	Define the type posix.dir/0 as a foreign type.
2007-04-23 04:32:38 +00:00
Peter Wang
0e8eaabfad Add dup2() system call.
Estimated hours taken: 0.1
Branches: main

extras/posix/posix.dup.m:
	Add dup2() system call.
2006-12-05 03:45:08 +00:00
Julien Fischer
d62dac6614 Fix compilation of the posix binding by conforming to
Estimated hours taken: 0
Branches: main, release

extras/posix/posix.exec.m:
	Fix compilation of the posix binding by conforming to
	recent changes in the stdlib.
2006-07-28 05:14:28 +00:00
Julien Fischer
86d492a744 Remove a use of ':' as a module qualifier.
Estimated hours taken: 0
Branches: main

extras/posix/posix.lseek.m:
	Remove a use of ':' as a module qualifier.
2005-10-20 05:01:44 +00:00
Julien Fischer
36afd24c29 Fix some minor problems with some of the libraries
Estimated hours taken: 0.1
Branches main.

Fix some minor problems with some of the libraries
in the extras distribution.

graphics/mercury_glut/glut.m:
graphics/mercury_glut/glut.overlay.m:
graphics/mercury_glut/glut.window.m:
graphics/mercury_opengl/mogl.m:
	Replace use of MR_bool_return_{yes,no} with the MR_YES
 	and MR_NO constants Ian added the other day.

	Make sure that the foreign procs in these module
 	don't promise will_not_call_mercury when they do.

	Reformat some C code so that it adheres to our
 	C coding standard.

posix/posix.select.m:
	Use symbolic constants for the values of yes and no
	instead of integers.
2004-11-30 14:54:39 +00:00
Fergus Henderson
67afe2c9fc Various changes to make it easier to build the extras.
Estimated hours taken: 0.5
Branches: main, release

Various changes to make it easier to build the extras.

extras/dynamic_linking/Mmakefile:
	Don't require the existence of "../../../mercury/browser".

extras/posix/README:
	Mention that it may be necessary to set MLLIBS.

extras/references/Mmakefile:
	Don't include the "asm_fast.tr" grade in LIBGRADES, since by
	default the Mercury standard library doesn't get installed in
	that grade.
2004-02-17 00:00:24 +00:00
Julien Fischer
4e098fa077 Change the Mmakefile for the POSIX binding so that it cleans
up posix_workarounds.pic_o.

extras/posix/Mmakefile:
	Make sure the clean target delete posix_workarounds.pic_o
2004-02-11 04:35:14 +00:00
Julien Fischer
0e18285339 Fix some compilation errors that were preventing the POSIX binding from
Estimated hours taken: 0.2
Branches: main.

Fix some compilation errors that were preventing the POSIX binding from
compiling successfully.

extras/posix/posix.stat.m:
	Module qualify the `file_type' type because of a type ambiguity
	between posix.stat.file_type and io.file_type.

extras/posix/posix.socket.m:
	Remove an unnecessary import.
2004-01-15 10:30:19 +00:00
Fergus Henderson
dced016cc1 Fix a problem where different packages in the `extras' distribution
Estimated hours taken: 3
Branches: main, release

Fix a problem where different packages in the `extras' distribution
were being installed in different directories when you specified
INSTALL_PREFIX in the Mmake.params file.  Some honoured the INSTALL_PREFIX
setting, some appended "/extras", and some ignored it completely.

Also, add `clean' and `realclean' targets for the extras directory hierarchy,
and fix a few other minor bugs.

extras/lazy_evaluation/Mmakefile:
	Include Mmake.params, which previously wasn't included at all
	in this file.

extras/logged_output/Mmakefile:
extras/odbc/Mmakefile:
extras/quickcheck/Mmakefile:
	Append "/extras" to INSTALL_PREFIX, which previously wasn't done
	at all in these directories.

extras/cgi/Mmakefile:
extras/complex_numbers/Mmakefile:
extras/concurrency/Mmakefile:
extras/curs/Mmakefile:
extras/curses/Mmakefile:
extras/dynamic_linking/Mmakefile:
extras/moose/Mmakefile:
extras/posix/Mmakefile:
	Move the line `INSTALL_PREFIX := $(INSTALL_PREFIX/extras)'
	to before the include of Mmake.params, so as not to override
	the user's setting (only override the default setting).

extras/Mmakefile:
extras/concurrency/Mmakefile:
	Add `clean' and `realclean' targets.

extras/posix/Mmakefile:
	Add MGNUCFLAGS = --no-ansi, since this is needed on some systems.

extras/quickcheck/Mmakefile:
	Add "depend", "all", and "install" targets.
	Ensure that the "check" target runs the test program.

extras/quickcheck/qcheck.m:
	Set the exit status to non-zero if a test fails.

extras/references/Mmakefile:
	Adjust the setting of LIBGRADES to account for the fact that
	$(GRADE) is no longer implicitly included in $(LIBGRADES).
2003-01-16 10:44:26 +00:00
Fergus Henderson
fb3686e7ce Install in the `extras' subdirectory of $(INSTALL_PREFIX),
Estimated hours taken: 0.25
Branches: main

extras/posix/Mmakefile:
	Install in the `extras' subdirectory of $(INSTALL_PREFIX),
	for consistency with what the other packages in `extras' do.
2002-04-02 09:45:31 +00:00
Michael Day
9674d03c4c Added waitpid predicate to posix.wait and added nlink_t, blkcnt_t and
Estimated hours taken: 1
Branches: main

Added waitpid predicate to posix.wait and added nlink_t, blkcnt_t and
blksize_t types for posix.stat.
2001-09-07 01:20:42 +00:00
Michael Day
0f0f99314a Add getpid and getppid predicates.
Estimated hours taken: 0.25
Branches: main

Add getpid and getppid predicates.
2001-08-24 03:02:37 +00:00
Michael Day
50358a58cf Adds support for the stat, pipe and kill system calls.
Estimated hours taken: 2
Branches: main

Adds support for the stat, pipe and kill system calls. Renames mode and
pid to mode_t and pid_t.
2001-07-25 08:37:24 +00:00
Michael Day
ee0c6b01dc This patch adds support for a number of POSIX system calls:
Estimated hours taken: 3
Branches: main

This patch adds support for a number of POSIX system calls:

    - opendir, readdir, closedir, mkdir, rmdir
    - fork, exec, wait
    - dup
2001-07-16 03:08:19 +00:00
Fergus Henderson
b52c17407c Various improvements to make it easier to use:
Estimated hours taken: 0.5

extras/posix/Mmakefile:
	Various improvements to make it easier to use:
	- Add an `install' target which installs the Posix library.
	- Add an `all' target that builds `libposix' and `hello',
	  and change the default target from `hello' to `all'.
	  Likewise change the rule for `depend' so that it builds
	  `posix.depend' as well as `hello.depend'.
	- Change the rule for `check' so that it runs `hello'.
	- Use $O and $(EXT_FOR_PIC_OBJECTS) rather than hard-coding `.o'.
2000-12-14 08:38:39 +00:00
Zoltan Somogyi
bdb4a83570 Add necessary MR_ prefixes.
Estimated hours taken: 0.5

extras/*/*.m:
	Add necessary MR_ prefixes.
2000-12-05 02:07:23 +00:00