[M3devel] unix - unknown qualification

Daniel Alejandro Benavides D. dabenavidesd at yahoo.es
Fri Jul 13 16:44:55 CEST 2012


Hi all:
indeed but I'm afraid that using C API level specification programming doesn't make the bulk sense of the language, the core is about machine programming, that so many believe is better in C. But UNSAFE in my way of think is just better than C because you still have some check not bullet proof, but with appropriate module isolation you can control it doesn't propagate by using Modula-3 keen Modules in RTMachinery stopped appropriately and where the machine allows safety manageable execution you can recover from that (trapped error, like arithmetic overflow e.g to dump it in disk) or update your data and finish with an expectancy of following rules to stop execution, this is my point Jay. Now quality of current machines is going more bad than before, so who cares if we use DEC stuff.
I wanted to say, that here the language designers tried hard to make easier to optimize itself the language and for this purpose in mind, with that objective makes sense to believe that the application itself must be compiled with Modula-3, so at some degree I'm being hypocritical about Gcc use, but sometimes using Gcc gives more time to develop the rest of the system.
Thanks in advance

--- El vie, 13/7/12, Rodney M. Bates <rodney_bates at lcwb.coop> escribió:

De: Rodney M. Bates <rodney_bates at lcwb.coop>
Asunto: Re: [M3devel] unix - unknown qualification
Para: m3devel at elegosoft.com
Fecha: viernes, 13 de julio, 2012 07:54

Sounds like a good idea to me.  IT moves the M3/C boundary back just
enough to pick up all the #ifdef stuff, etc.
but not the application-specific code.

On 07/13/2012 04:33 AM, Jay K wrote:
> Hey, how about I just provide copying wrappers here, like we do for stat?
> Where we define an idealized portable struct flock and copy it back and forth in C to the real struct flock?
>
> It is a little strange -- the wrapper is fnctl.
> It must check the first parameter, and know/assume its meaning.
>
>
>   - Jay
>
>
 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------
 --
> From: jay.krell at cornell.edu
> To: pgoltzsch at gmail.com; m3devel at elegosoft.com
> Date: Thu, 12 Jul 2012 22:12:49 +0000
> Subject: Re: [M3devel] unix - unknown qualification
>
> Unix.i3 has always been a maintenance and portability problem.
> As such, it has been dramatically reduced.
> This stuff was probably removed, esp. struct_flock.
> The constants can exposed easily enough, portably, but aren't useful without the struct, prpbably.
>
>
> You REALLY REALLY REALLY want to write this in C.
> Writing it in Modula-3 has many downsides. You lose safety. You losestatic checking. You loseportability.
> You gain infinitely small efficiency.
> Something like:
>
>
> jbook2:libm3 jay$ pwd
> /dev2/cm3/m3-libs/libm3
> jbook2:libm3 jay$ find . | xargs grep flock
> ./src/os/POSIX/FilePosixC.c:saves us from having to declare struct flock, which is gnarled up in #ifdefs.
> ./src/os/POSIX/FilePosixC.c:    struct flock lock;
> ./src/os/POSIX/FilePosixC.c:    struct flock lock;
> ./tests/os/src/locktest.c:  struct flock param;
>
>
> ./src/os/POSIX/FilePosixC.c:
>
> /* Copyright (C) 1993, Digital Equipment Corporation           */
> /* All rights reserved.                                        */
> /* See the file COPYRIGHT for a full description.              */
>
> /*
> Writing part of libm3/os/POSIX/FilePosix.m3/RegularFileLock, RegularFileUnlock in C
> saves us from having to declare struct flock, which is gnarled up in #ifdefs.
>
> see http://www.opengroup.org/onlinepubs/009695399/functions/fcntl.html
> */
>
> #include "m3core.h"
> #include <string.h>
>
> #ifdef __cplusplus
> extern "C" {
> #endif
>
> #define FALSE 0
> #define TRUE 1
>
> INTEGER FilePosixC__RegularFileLock(int fd)
> {
>      struct flock lock;
>      int err;
>
>      ZeroMemory(&lock, sizeof(lock));
>      lock.l_type = F_WRLCK;
>      lock.l_whence = SEEK_SET;
>
>      if (fcntl(fd, F_SETLK, &lock) < 0)
>      {
>          err = errno;
>          if (err == EACCES || err == EAGAIN)
>              return FALSE;
>          return -1;
>      }
>      return TRUE;
> }
>
> INTEGER FilePosixC__RegularFileUnlock(int fd)
> {
>      struct flock lock;
>
>      ZeroMemory(&lock, sizeof(lock));
>      lock.l_type = F_UNLCK;
>      lock.l_whence = SEEK_SET;
>
>      return fcntl(fd, F_SETLK, &lock);
> }
>
> #ifdef __cplusplus
> } /* extern "C" */
> #endif
>
>
>
> We can add this to libm3 probably.
>
>
>   - Jay
>
>
>  > Date: Thu, 12 Jul 2012 14:58:11 +0200
>  > From: pgoltzsch at gmail.com
>  > To: m3devel at elegosoft.com
>  > Subject: Re: [M3devel] unix - unknown qualification
>  >
>  > >>>>> Rodney M. Bates wrote:
>  >
>  > > I think we need to see some source code for ClsShare.m3.
>  > > particularly to see what is before the dot on these lines. I
>  > > don't see any of the failing qualifications in Unix.i3 in my
>  > > cm3 directory.
>  >
>  > The first errors are caused by the following procedure,
>  > which seems to copied from old DEC example code as I found
>  > out while looking for a solution:
>  >
>  > PROCEDURE FilePartLock( h : INTEGER; start, len : INTEGER ) : BOOLEAN RAISES {OSError.E} =
>  > VAR flock := Unix.struct_flock {
>  > l_type := Unix.F_WRLCK,
>  > l_whence := Unix.L_SET,
>  > l_start := 0,
>  > l_len := 0, (* i.e., whole file *)
>  > l_pid := 0 }; (* don't care *)
>  > BEGIN
>  > flock.l_start := start;
>  > flock.l_len := len;
>  > IF Unix.fcntl( h, Unix.F_SETLK, LOOPHOLE( ADR( flock ), Ctypes.long ) ) < 0
>  > THEN
>  > IF Uerror.errno = Uerror.EACCES OR
>  > Uerror.errno = Uerror.EAGAIN THEN
>  > RETURN FALSE
>  > END;
>  > OSErrorPosix.Raise()
>  > END;
>  > RETURN TRUE
>  > END FilePartLock;
>  >
>  >
>  >
>  > Regards,
>  >
>  > Patrick

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20120713/b61b00d7/attachment-0002.html>


More information about the M3devel mailing list