[m-rev.] Updated posix patch

Fergus Henderson fjh at cs.mu.OZ.AU
Sun Jul 15 03:34:29 AEST 2001


On 14-Jul-2001, Michael Day <mikeday at corplink.com.au> wrote:
> 
> This patch now includes wrappers for:
> 
> 	- opendir, closedir, readdir
> 	- fork, wait, exec
> 	- dup
> 	- mkdir, rmdir
> 	- stat

Thanks.

> It probably needs some review (It Works For Me) and a kindly soul to place
> it in cvs.

I've fixed the problem that you reported with your cvs write access.

> :- module posix__opendir.
...
> :- pragma c_code(opendir0(Path::in, Dir::out, Res::out, IO0::di, IO::uo),
> 		[will_not_call_mercury, thread_safe], "
> 	Dir = (MR_Word) opendir(Path);
> 	Res = Dir == 0;

I suggest using parentheses here for clarity:
 	Res = (Dir == 0);

> :- module posix__stat.
> 
> :- interface.
> 
> :- import_module int, string.
> 
> :- type file_type
>     --->    file
>     ;	    directory
>     ;	    symbolic_link
>     ;	    character_device
>     ;	    block_device
>     ;	    fifo
>     ;	    unknown
>     .
> 
> :- type stat.
> 
> :- func device(stat) = int.
> :- func inode(stat) = int.
> :- func mode(stat) = (mode).
> :- func file_type(stat) = file_type.
> :- func nlink(stat) = int.
> :- func uid(stat) = int.
> :- func gid(stat) = int.
> :- func rdev(stat) = int.
> :- func size(stat) = int.
> :- func blksize(stat) = int.
> :- func blocks(stat) = int.
> :- func atime(stat) = int.
> :- func mtime(stat) = int.
> :- func ctime(stat) = int.

Rather than just using `int' here, you should use abstract types, or
equivalence types, for dev_t, ino_t, mode_t, nlink_t, uid_t, gid_t,
dev_t, off_t, and time_t.

Note that time_t is defined in library/time.m.

> :- pragma c_code(readdir0(Dir::in, Entry::out, Result::out, IO0::di, IO::uo),
> 		[will_not_call_mercury, thread_safe], "
> 	struct dirent *ent = readdir((DIR *)Dir);
> 	if (ent != NULL) {
> 		MR_save_transient_hp();
> 		MR_make_aligned_string_copy(Entry, ent->d_name);
> 		MR_restore_transient_hp();

The save/restore_transient_hp calls here aren't needed.

> :- module posix__exec.
...
> exec(Command, Args, Env, Result) -->
> 	exec0(Command,
> 	    array(Args ++ [null]),
> 	    array(map(variable, to_assoc_list(Env)) ++ [null])

Please s/map/list__map/
and s/to_assoc_list/map__to_assoc_list/

Could you please address the issues with using `int' rather than
abstract types for `stat' and then post the posix__stat module again?

-- 
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