<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
<div>Unix.i3 has always been a maintenance and portability problem.</div><div>As such, it has been dramatically reduced.</div><div>This stuff was probably removed, esp. struct_flock.</div><div>The constants can exposed easily enough, portably, but aren't useful without the struct, prpbably.</div><div><br></div><div><br></div><div>You REALLY REALLY REALLY want to write this in C.</div><div>Writing it in Modula-3 has many downsides. <span style="font-size: 10pt; ">You lose safety. You lose</span><span style="font-size: 10pt; "> </span><span style="font-size: 10pt; ">static checking. You lose</span><span style="font-size: 10pt; "> </span><span style="font-size: 10pt; ">portability.</span></div><div><span style="font-size: 10pt; ">You gain infinitely small efficiency.</span></div><div><span style="font-size: 10pt; ">Something like:</span></div><div><br></div><div><br></div><div>jbook2:libm3 jay$ pwd</div><div>/dev2/cm3/m3-libs/libm3</div><div>jbook2:libm3 jay$ find . | xargs grep flock</div><div>./src/os/POSIX/FilePosixC.c:saves us from having to declare struct flock, which is gnarled up in #ifdefs.</div><div>./src/os/POSIX/FilePosixC.c: struct flock lock;</div><div>./src/os/POSIX/FilePosixC.c: struct flock lock;</div><div>./tests/os/src/locktest.c: struct flock param;</div><div><br></div><div><br></div><div>./src/os/POSIX/FilePosixC.c:</div><div><br></div><div>/* Copyright (C) 1993, Digital Equipment Corporation */</div><div>/* All rights reserved. */</div><div>/* See the file COPYRIGHT for a full description. */</div><div><br></div><div>/*</div><div>Writing part of libm3/os/POSIX/FilePosix.m3/RegularFileLock, RegularFileUnlock in C</div><div>saves us from having to declare struct flock, which is gnarled up in #ifdefs.</div><div><br></div><div>see http://www.opengroup.org/onlinepubs/009695399/functions/fcntl.html</div><div>*/</div><div><br></div><div>#include "m3core.h"</div><div>#include <string.h></div><div><br></div><div>#ifdef __cplusplus</div><div>extern "C" {</div><div>#endif</div><div><br></div><div>#define FALSE 0</div><div>#define TRUE 1</div><div><br></div><div>INTEGER FilePosixC__RegularFileLock(int fd)</div><div>{</div><div> struct flock lock;</div><div> int err;</div><div><br></div><div> ZeroMemory(&lock, sizeof(lock));</div><div> lock.l_type = F_WRLCK;</div><div> lock.l_whence = SEEK_SET;</div><div><br></div><div> if (fcntl(fd, F_SETLK, &lock) < 0)</div><div> {</div><div> err = errno;</div><div> if (err == EACCES || err == EAGAIN)</div><div> return FALSE;</div><div> return -1;</div><div> }</div><div> return TRUE;</div><div>}</div><div><br></div><div>INTEGER FilePosixC__RegularFileUnlock(int fd)</div><div>{</div><div> struct flock lock;</div><div><br></div><div> ZeroMemory(&lock, sizeof(lock));</div><div> lock.l_type = F_UNLCK;</div><div> lock.l_whence = SEEK_SET;</div><div><br></div><div> return fcntl(fd, F_SETLK, &lock);</div><div>}</div><div><br></div><div>#ifdef __cplusplus</div><div>} /* extern "C" */</div><div>#endif</div><div><br></div><div><br></div><div><br></div><div>We can add this to libm3 probably.</div><div><br></div><div><br></div><div> - Jay</div><div><div><br><br><div><div id="SkyDrivePlaceholder"></div>> Date: Thu, 12 Jul 2012 14:58:11 +0200<br>> From: pgoltzsch@gmail.com<br>> To: m3devel@elegosoft.com<br>> Subject: Re: [M3devel] unix - unknown qualification<br>> <br>> >>>>> Rodney M. Bates wrote:<br>> <br>> > I think we need to see some source code for ClsShare.m3.<br>> > particularly to see what is before the dot on these lines. I<br>> > don't see any of the failing qualifications in Unix.i3 in my<br>> > cm3 directory.<br>> <br>> The first errors are caused by the following procedure,<br>> which seems to copied from old DEC example code as I found<br>> out while looking for a solution:<br>> <br>> PROCEDURE FilePartLock( h : INTEGER; start, len : INTEGER ) : BOOLEAN RAISES {OSError.E} =<br>> VAR flock := Unix.struct_flock {<br>> l_type := Unix.F_WRLCK,<br>> l_whence := Unix.L_SET,<br>> l_start := 0,<br>> l_len := 0, (* i.e., whole file *)<br>> l_pid := 0 }; (* don't care *)<br>> BEGIN<br>> flock.l_start := start;<br>> flock.l_len := len;<br>> IF Unix.fcntl( h, Unix.F_SETLK, LOOPHOLE( ADR( flock ), Ctypes.long ) ) < 0<br>> THEN<br>> IF Uerror.errno = Uerror.EACCES OR<br>> Uerror.errno = Uerror.EAGAIN THEN <br>> RETURN FALSE <br>> END;<br>> OSErrorPosix.Raise()<br>> END;<br>> RETURN TRUE<br>> END FilePartLock;<br>> <br>> <br>> <br>> Regards,<br>> <br>> Patrick<br></div></div></div> </div></body>
</html>