[m-rev.] for review: library changes for `mmc --make' on Windows
Fergus Henderson
fjh at cs.mu.OZ.AU
Thu Jul 24 02:42:45 AEST 2003
On 15-Jun-2003, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
>
> Library changes required to make the compiler work on Windows
> without Cygwin. (Compiler changes to come separately).
...
> library/io.m:
...
> Add io.file_id for use by dir.foldl2 to detect
> symlink loops. This is a bit low level, so it's
> not included in the user documentation.
...
> +% Can we retrieve inodes on this system.
> +:- type file_id
> + ---> file_id(device :: int, inode :: int).
> +
> +io__file_id(FileName, Result) -->
> + ( { have_file_ids } ->
> + io__file_id_2(FileName, Status, Msg, Device, Inode),
> + ( { Status = 1 } ->
> + { Result = ok(file_id(Device, Inode)) }
> + ;
> + { Result = error(io_error(Msg)) }
> + )
> + ;
> + { Result = error(
> + make_io_error("io.file_id not implemented on this platform")) }
> + ).
> +
> +:- pred io__file_id_2(string, int, string, int, int,
> + io__state, io__state).
> +:- mode io__file_id_2(in, out, out, out, out, di, uo) is det.
> +
> +:- pragma foreign_proc("C",
> + io__file_id_2(FileName::in, Status::out, Msg::out,
> + Device::out, Inode::out, IO0::di, IO::uo),
> + [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
> +"{
> +#ifdef MR_HAVE_STAT
> + struct stat s;
> + if (stat(FileName, &s) == 0) {
> + Device = s.st_dev;
> + Inode = s.st_ino;
This code assumes that a dev_t and an ino_t are integral types
that will fit into a Mercury int. This assumption is false,
and results in a compilation error on mars with lcc, where
dev_t is a struct type (because it is 64 bits and lcc has no
64-bit integral type).
Probably the best fix is to use a foreign_type instead.
The foreign type would have to be defined carefully using appropriate
#ifdefs, because on non-Posix systems dev_t and ino_t might not exist.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list