diff --git a/makefile b/makefile index 32b9c1ae..0119f235 100644 --- a/makefile +++ b/makefile @@ -152,6 +152,7 @@ stage6: $(VOCSTATIC) -sP oocwrapperlibc.Mod #Ulm's Oberon system libs + $(VOCSTATIC) -sP ulmSys.Mod $(VOCSTATIC) -sP ulmSYSTEM.Mod $(VOCSTATIC) -sP ulmASCII.Mod ulmSets.Mod $(VOCSTATIC) -sP ulmObjects.Mod ulmDisciplines.Mod @@ -161,15 +162,16 @@ stage6: $(VOCSTATIC) -sP ulmIndirectDisciplines.Mod ulmStreamDisciplines.Mod $(VOCSTATIC) -sP ulmIEEE.Mod ulmMC68881.Mod ulmReals.Mod $(VOCSTATIC) -sP ulmPrint.Mod + $(VOCSTATIC) -sP ulmWrite.Mod $(VOCSTATIC) -sP ulmTexts.Mod $(VOCSTATIC) -sP ulmStrings.Mod ulmConstStrings.Mod $(VOCSTATIC) -sP ulmConstStrings.Mod $(VOCSTATIC) -sP ulmPlotters.Mod $(VOCSTATIC) -sP ulmSysTypes.Mod - $(VOCSTATIC) -sP ulmSys.Mod $(VOCSTATIC) -sP ulmSysConversions.Mod $(VOCSTATIC) -sP ulmErrors.Mod $(VOCSTATIC) -sP ulmSysErrors.Mod + $(VOCSTATIC) -sP ulmSysIO.Mod #pow32 libs diff --git a/ocat b/ocat index 07389ef1..277a42b4 100755 Binary files a/ocat and b/ocat differ diff --git a/showdef.REMOVED.git-id b/showdef.REMOVED.git-id index 5dbb067a..c6e0719c 100644 --- a/showdef.REMOVED.git-id +++ b/showdef.REMOVED.git-id @@ -1 +1 @@ -29d896a275b93de22ad542e451c4fd63e78b393e \ No newline at end of file +af2514a8aa2a2c1b4d24cf77214f36265162340c \ No newline at end of file diff --git a/src/lib/system/gnuc/armv6j/Unix.Mod b/src/lib/system/gnuc/armv6j/Unix.Mod index 21bb53d3..19d1c019 100644 --- a/src/lib/system/gnuc/armv6j/Unix.Mod +++ b/src/lib/system/gnuc/armv6j/Unix.Mod @@ -275,6 +275,9 @@ TYPE PROCEDURE -Dup2*(fd1, fd2: LONGINT): LONGINT "dup(fd1, fd2)"; + PROCEDURE -Pipe*(fds : LONGINT): LONGINT + "pipe(fds)"; + PROCEDURE -Getpid*(): LONGINT "getpid()"; diff --git a/src/lib/system/gnuc/armv6j_hardfp/Unix.Mod b/src/lib/system/gnuc/armv6j_hardfp/Unix.Mod index 21bb53d3..19d1c019 100644 --- a/src/lib/system/gnuc/armv6j_hardfp/Unix.Mod +++ b/src/lib/system/gnuc/armv6j_hardfp/Unix.Mod @@ -275,6 +275,9 @@ TYPE PROCEDURE -Dup2*(fd1, fd2: LONGINT): LONGINT "dup(fd1, fd2)"; + PROCEDURE -Pipe*(fds : LONGINT): LONGINT + "pipe(fds)"; + PROCEDURE -Getpid*(): LONGINT "getpid()"; diff --git a/src/lib/system/gnuc/armv7a_hardfp/Unix.Mod b/src/lib/system/gnuc/armv7a_hardfp/Unix.Mod index 21bb53d3..19d1c019 100644 --- a/src/lib/system/gnuc/armv7a_hardfp/Unix.Mod +++ b/src/lib/system/gnuc/armv7a_hardfp/Unix.Mod @@ -275,6 +275,9 @@ TYPE PROCEDURE -Dup2*(fd1, fd2: LONGINT): LONGINT "dup(fd1, fd2)"; + PROCEDURE -Pipe*(fds : LONGINT): LONGINT + "pipe(fds)"; + PROCEDURE -Getpid*(): LONGINT "getpid()"; diff --git a/src/lib/system/gnuc/x86/Unix.Mod b/src/lib/system/gnuc/x86/Unix.Mod index 21bb53d3..19d1c019 100644 --- a/src/lib/system/gnuc/x86/Unix.Mod +++ b/src/lib/system/gnuc/x86/Unix.Mod @@ -275,6 +275,9 @@ TYPE PROCEDURE -Dup2*(fd1, fd2: LONGINT): LONGINT "dup(fd1, fd2)"; + PROCEDURE -Pipe*(fds : LONGINT): LONGINT + "pipe(fds)"; + PROCEDURE -Getpid*(): LONGINT "getpid()"; diff --git a/src/lib/system/gnuc/x86_64/Unix.Mod b/src/lib/system/gnuc/x86_64/Unix.Mod index 09351c06..7bf77533 100644 --- a/src/lib/system/gnuc/x86_64/Unix.Mod +++ b/src/lib/system/gnuc/x86_64/Unix.Mod @@ -353,6 +353,9 @@ from man gettimeofday PROCEDURE -Dup2*(fd1, fd2: LONGINT): LONGINT "dup(fd1, fd2)"; + PROCEDURE -Pipe*(fds : LONGINT): LONGINT + "pipe(fds)"; + PROCEDURE -Getpid*(): LONGINT "getpid()"; diff --git a/src/lib/ulm/gnuc/ulmSYSTEM.Mod b/src/lib/ulm/gnuc/ulmSYSTEM.Mod deleted file mode 100644 index 56ca7703..00000000 --- a/src/lib/ulm/gnuc/ulmSYSTEM.Mod +++ /dev/null @@ -1,67 +0,0 @@ -MODULE ulmSYSTEM; -IMPORT SYSTEM; - -CONST - READ = 3; - WRITE = 4; - -TYPE pchar = POINTER TO ARRAY 1 OF CHAR; - - PROCEDURE -Write(adr, n: LONGINT): LONGINT - "write(1/*stdout*/, adr, n)"; - - PROCEDURE -read(VAR ch: CHAR): LONGINT - "read(0/*stdin*/, ch, 1)"; - - - PROCEDURE TAS*(VAR flag:BOOLEAN): BOOLEAN; (* added for compatibility with ulmSYSTEM module; noch *) - VAR oldflag : BOOLEAN; - BEGIN - oldflag := flag; - flag := TRUE; - RETURN oldflag; - END TAS; - - PROCEDURE UNIXCALL*(syscall: LONGINT; VAR d0, d1: LONGINT; (* in ulm version both LONGINT and INTEGER are 4 byte size *) - arg1, arg2, arg3: LONGINT) : BOOLEAN; - VAR - n : LONGINT; - ch : CHAR; - pch : pchar; - BEGIN - - IF syscall = READ THEN - NEW(pch); - pch := SYSTEM.VAL(pchar, arg2); - ch := pch^[0]; - n := read(ch); - IF n # 1 THEN - ch := 0X; - RETURN FALSE - ELSE - pch^[0] := ch; - RETURN TRUE - END; - ELSIF syscall = WRITE THEN - NEW(pch); - pch := SYSTEM.VAL(pchar, arg2); - n := Write(SYSTEM.VAL(LONGINT, pch), 1); - IF n # 1 THEN RETURN FALSE ELSE RETURN TRUE END - END - - END UNIXCALL; - - - PROCEDURE UNIXFORK(VAR pid: LONGINT) : BOOLEAN; - BEGIN - - END UNIXFORK; - - PROCEDURE UNIXSIGNAL(signo: INTEGER; p: PROCEDURE; - VAR old: PROCEDURE; VAR error: INTEGER) : BOOLEAN; - BEGIN - - END UNIXSIGNAL; - - -END ulmSYSTEM. diff --git a/src/lib/ulm/ulmSYSTEM.Mod b/src/lib/ulm/ulmSYSTEM.Mod new file mode 100644 index 00000000..2f2eb2f2 --- /dev/null +++ b/src/lib/ulm/ulmSYSTEM.Mod @@ -0,0 +1,97 @@ +MODULE ulmSYSTEM; +IMPORT SYSTEM, Unix, Sys := ulmSys; + +TYPE pchar = POINTER TO ARRAY 1 OF CHAR; + pstring = POINTER TO ARRAY 1024 OF CHAR; +(* + PROCEDURE -Write(adr, n: LONGINT): LONGINT + "write(1/*stdout*/, adr, n)"; + + PROCEDURE -read(VAR ch: CHAR): LONGINT + "read(0/*stdin*/, ch, 1)"; +*) + + PROCEDURE TAS*(VAR flag:BOOLEAN): BOOLEAN; (* added for compatibility with ulmSYSTEM module; noch *) + VAR oldflag : BOOLEAN; + BEGIN + oldflag := flag; + flag := TRUE; + RETURN oldflag; + END TAS; + + PROCEDURE UNIXCALL*(syscall: LONGINT; VAR d0, d1: LONGINT; (* in ulm version both LONGINT and INTEGER are 4 byte size *) + arg1, arg2, arg3: LONGINT) : BOOLEAN; + VAR + n : LONGINT; + ch : CHAR; + pch : pchar; + pstr : pstring; + BEGIN + + IF syscall = Sys.read THEN + d0 := Unix.Read(arg1, arg2, arg3); + IF d0 >= 0 THEN RETURN TRUE ELSE RETURN FALSE END + (*NEW(pch); + pch := SYSTEM.VAL(pchar, arg2); + ch := pch^[0]; + n := read(ch); + IF n # 1 THEN + ch := 0X; + RETURN FALSE + ELSE + pch^[0] := ch; + RETURN TRUE + END; + *) + ELSIF syscall = Sys.write THEN + d0 := Unix.Write(arg1, arg2, arg3); + IF d0 >= 0 THEN RETURN TRUE ELSE RETURN FALSE END + (*NEW(pch); + pch := SYSTEM.VAL(pchar, arg2); + n := Write(SYSTEM.VAL(LONGINT, pch), 1); + IF n # 1 THEN RETURN FALSE ELSE RETURN TRUE END + *) + ELSIF syscall = Sys.open THEN + pstr := SYSTEM.VAL(pstring, arg1); + d0 := Unix.Open(pstr^, SYSTEM.VAL(SET, arg3), SYSTEM.VAL(SET, arg2)); + IF d0 >= 0 THEN RETURN TRUE ELSE RETURN FALSE END + ELSIF syscall = Sys.close THEN + d0 := Unix.Close(arg1); + IF d0 = 0 THEN RETURN TRUE ELSE RETURN FALSE END + ELSIF syscall = Sys.lseek THEN + d0 := Unix.Lseek(arg1, arg2, arg3); + IF d0 >= 0 THEN RETURN TRUE ELSE RETURN FALSE END + ELSIF syscall = Sys.ioctl THEN + d0 := Unix.Ioctl(arg1, arg2, arg3); + RETURN d0 >= 0; + ELSIF syscall = Sys.fcntl THEN + d0 := Unix.Fcntl (arg1, arg2, arg3); + RETURN d0 >= 0; + ELSIF syscall = Sys.dup THEN + d0 := Unix.Dup(arg1); + RETURN d0 > 0; + ELSIF syscall = Sys.pipe THEN + d0 := Unix.Pipe(arg1); + RETURN d0 >= 0; + END + + END UNIXCALL; + + + PROCEDURE UNIXFORK(VAR pid: LONGINT) : BOOLEAN; + BEGIN + + END UNIXFORK; + + PROCEDURE UNIXSIGNAL(signo: INTEGER; p: PROCEDURE; + VAR old: PROCEDURE; VAR error: INTEGER) : BOOLEAN; + BEGIN + + END UNIXSIGNAL; + + PROCEDURE WMOVE*(from, to, n : LONGINT); + VAR l : LONGINT; + BEGIN + SYSTEM.MOVE(from, to, n); + END WMOVE; +END ulmSYSTEM. diff --git a/src/lib/ulm/ulmSysErrors.Mod b/src/lib/ulm/ulmSysErrors.Mod index 9f33df30..0e81818d 100644 --- a/src/lib/ulm/ulmSysErrors.Mod +++ b/src/lib/ulm/ulmSysErrors.Mod @@ -138,8 +138,8 @@ MODULE ulmSysErrors; EventRec* = RECORD (Events.EventRec) - errno*: INTEGER; - syscall*: INTEGER; (* number of system call *) + errno*: (*INTEGER*)LONGINT; + syscall*: (*INTEGER*)LONGINT; (* number of system call *) text*: ARRAY textlen OF CHAR; END; @@ -150,7 +150,7 @@ MODULE ulmSysErrors; syserror*: ARRAY ncodes OF Events.EventType; PROCEDURE Raise*(errors: RelatedEvents.Object; - errno, syscall: INTEGER; text: ARRAY OF CHAR); + errno, syscall: (*INTEGER*)LONGINT; text: ARRAY OF CHAR); (* in ulm's system INTEGER and LONGINT have the same size *) (* raises the events syserrors and syserrors[syscall]; `text' contains additional information (e.g. filenames); further, the syserrors[syscall] event is passed to @@ -192,9 +192,9 @@ MODULE ulmSysErrors; IF ~Streams.WriteByte(s, ch) THEN END; END Write; - PROCEDURE WriteInt(intval: INTEGER); + PROCEDURE WriteInt(intval: LONGINT); VAR - rest: INTEGER; + rest: LONGINT; BEGIN rest := intval DIV 10; IF rest > 0 THEN diff --git a/src/lib/ulm/ulmSysIO.Mod b/src/lib/ulm/ulmSysIO.Mod new file mode 100644 index 00000000..33959006 --- /dev/null +++ b/src/lib/ulm/ulmSysIO.Mod @@ -0,0 +1,343 @@ +(* Ulm's Oberon Library + Copyright (C) 1989-1994 by University of Ulm, SAI, D-89069 Ulm, Germany + ---------------------------------------------------------------------------- + Ulm's Oberon Library is free software; you can redistribute it + and/or modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either version + 2 of the License, or (at your option) any later version. + + Ulm's Oberon Library is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied warranty + of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + ---------------------------------------------------------------------------- + E-mail contact: oberon@mathematik.uni-ulm.de + ---------------------------------------------------------------------------- + $Id: SysIO.om,v 1.1 1994/02/23 07:59:15 borchert Exp $ + ---------------------------------------------------------------------------- + $Log: SysIO.om,v $ + Revision 1.1 1994/02/23 07:59:15 borchert + Initial revision + + ---------------------------------------------------------------------------- + AFB 6/89 + ---------------------------------------------------------------------------- +*) + +MODULE ulmSysIO; + + IMPORT RelatedEvents := ulmRelatedEvents, Sys := ulmSys, SYS := SYSTEM, ulmSYSTEM, SysErrors := ulmSysErrors, SysTypes := ulmSysTypes; + + CONST + (* file control options: arguments of Fcntl and Open *) + rdonly* = {}; + wronly* = { 0 }; + rdwr* = { 1 }; + append* = { 10 }; + ndelay* = { 11 }; (* O_NONBLOCK that works like former O_NDELAY *) + creat* = { 6 }; + trunc* = { 9 }; + excl* = { 7 }; + noctty* = { 8 }; + sync* = { 12 }; + fasync* = { 13 }; + direct* = { 14 }; + largefile* = { 15 }; + directory* = { 16 }; + nofollow* = { 17 }; + + (* Whence = (fromStart, fromPos, fromEnd); *) + fromStart* = 0; + fromPos* = 1; + fromEnd* = 2; + + (* file descriptor flags *) + closeonexec* = { 0 }; + + (* Fcntl requests *) + dupfd* = 0; (* duplicate file descriptor *) + getfd* = 1; (* get file desc flags (close-on-exec) *) + setfd* = 2; (* set file desc flags (close-on-exec) *) + getfl* = 3; (* get file flags *) + setfl* = 4; (* set file flags (ndelay, append) *) + getlk* = 5; (* get file lock *) + setlk* = 6; (* set file lock *) + setlkw* = 7; (* set file lock and wait *) + setown* = 8; (* set owner (async IO) *) + getown* = 9; (* get owner (async IO) *) + setsig* = 10; (* set SIGIO replacement *) + getsig* = 11; (* get SIGIO replacement *) + + TYPE + File* = SysTypes.File; (* file descriptor *) + Address* = SysTypes.Address; + Count* = SysTypes.Count; + Protection* = LONGINT; + Whence* = LONGINT; + + PROCEDURE OpenCreat*(VAR fd: File; + filename: ARRAY OF CHAR; options: SET; + protection: Protection; + errors: RelatedEvents.Object; + retry: BOOLEAN; VAR interrupted: BOOLEAN) : BOOLEAN; + (* the filename must be 0X-terminated *) + VAR + d0, d1: (*INTEGER*)LONGINT; + BEGIN + interrupted := FALSE; + LOOP + IF ulmSYSTEM.UNIXCALL(Sys.open, d0, d1, + SYS.ADR(filename), SYS.VAL(LONGINT, options), protection) THEN + fd := d0; + RETURN TRUE + ELSE + IF d0 = SysErrors.intr THEN + interrupted := TRUE; + END; + IF (d0 # SysErrors.intr) OR ~retry THEN + SysErrors.Raise(errors, d0, Sys.open, filename); + RETURN FALSE + END; + END; + END; + END OpenCreat; + + PROCEDURE Open*(VAR fd: File; + filename: ARRAY OF CHAR; options: SET; + errors: RelatedEvents.Object; + retry: BOOLEAN; VAR interrupted: BOOLEAN) : BOOLEAN; + (* the filename must be 0X-terminated *) + BEGIN + RETURN OpenCreat(fd, filename, options, 0, errors, retry, interrupted) + END Open; + + PROCEDURE Close*(fd: File; + errors: RelatedEvents.Object; + retry: BOOLEAN; VAR interrupted: BOOLEAN) : BOOLEAN; + VAR + d0, d1: LONGINT; + a0, a1 : LONGINT; (* just to match UNIXCALL interface *) + BEGIN + interrupted := FALSE; + LOOP + IF ulmSYSTEM.UNIXCALL(Sys.close, d0, d1, fd, a0, a1) THEN + (*IF ulmSYSTEM.UNIXCALL(Sys.close, d0, d1, fd) THEN*) + RETURN TRUE + ELSE + IF d0 = SysErrors.intr THEN + interrupted := TRUE; + END; + IF (d0 # SysErrors.intr) OR ~retry THEN + SysErrors.Raise(errors, d0, Sys.close, ""); + RETURN FALSE + END; + END; + END; + END Close; + + PROCEDURE Read*(fd: File; buf: Address; cnt: Count; + errors: RelatedEvents.Object; + retry: BOOLEAN; VAR interrupted: BOOLEAN) : Count; + (* return value of 0: EOF + -1: I/O error + >0: number of bytes read + *) + VAR + d0, d1: LONGINT; + BEGIN + interrupted := FALSE; + LOOP + IF ulmSYSTEM.UNIXCALL(Sys.read, d0, d1, fd, buf, cnt) THEN + RETURN d0 + ELSE + IF d0 = SysErrors.intr THEN + interrupted := TRUE; + END; + IF (d0 # SysErrors.intr) OR ~retry THEN + SysErrors.Raise(errors, d0, Sys.read, ""); + RETURN -1 + END; + END; + END; + END Read; + + PROCEDURE Write*(fd: File; buf: Address; cnt: Count; + errors: RelatedEvents.Object; + retry: BOOLEAN; VAR interrupted: BOOLEAN) : Count; + (* return value of -1: I/O error + >=0: number of bytes written + *) + VAR + d0, d1: LONGINT; + BEGIN + interrupted := FALSE; + LOOP + IF ulmSYSTEM.UNIXCALL(Sys.write, d0, d1, fd, buf, cnt) THEN + RETURN d0 + ELSE + IF d0 = SysErrors.intr THEN + interrupted := TRUE; + END; + IF (d0 # SysErrors.intr) OR ~retry THEN + SysErrors.Raise(errors, d0, Sys.write, ""); + RETURN -1 + END; + END; + END; + END Write; + + PROCEDURE Seek*(fd: File; offset: Count; whence: Whence; + errors: RelatedEvents.Object) : BOOLEAN; + VAR + d0, d1: LONGINT; + BEGIN + IF ulmSYSTEM.UNIXCALL(Sys.lseek, d0, d1, fd, offset, whence) THEN + RETURN TRUE + ELSE + SysErrors.Raise(errors, d0, Sys.lseek, ""); + RETURN FALSE + END; + END Seek; + + PROCEDURE Tell*(fd: File; VAR offset: Count; + errors: RelatedEvents.Object) : BOOLEAN; + VAR + d0, d1: LONGINT; + BEGIN + IF ulmSYSTEM.UNIXCALL(Sys.lseek, d0, d1, fd, 0, fromPos) THEN + offset := d0; + RETURN TRUE + ELSE + SysErrors.Raise(errors, d0, Sys.lseek, ""); + RETURN FALSE + END; + END Tell; + + PROCEDURE Isatty*(fd: File) : BOOLEAN; + CONST + sizeofStructTermIO = 18; + tcgeta = 00005405H; + VAR + d0, d1: LONGINT; + buf: ARRAY 32 OF SYS.BYTE; (* Should be more than sufficient *) + BEGIN + (* following system call fails for non-tty's *) + RETURN ulmSYSTEM.UNIXCALL(Sys.ioctl, d0, d1, fd, tcgeta, SYS.ADR(buf)) + END Isatty; + + PROCEDURE Fcntl*(fd: File; request: INTEGER; VAR arg: LONGINT; + errors: RelatedEvents.Object; + retry: BOOLEAN; VAR interrupted: BOOLEAN) : BOOLEAN; + VAR + d0, d1: LONGINT; + BEGIN + interrupted := FALSE; + LOOP + IF ulmSYSTEM.UNIXCALL(Sys.fcntl, d0, d1, fd, request, arg) THEN + arg := d0; + RETURN TRUE + ELSE + IF d0 = SysErrors.intr THEN + interrupted := TRUE; + END; + IF (d0 # SysErrors.intr) OR ~retry THEN + SysErrors.Raise(errors, d0, Sys.fcntl, ""); + RETURN FALSE + END; + END; + END; + END Fcntl; + + PROCEDURE FcntlSet*(fd: File; request: INTEGER; flags: SET; + errors: RelatedEvents.Object; + retry: BOOLEAN; VAR interrupted: BOOLEAN) : BOOLEAN; + VAR + d0, d1: LONGINT; + BEGIN + interrupted := FALSE; + LOOP + IF ulmSYSTEM.UNIXCALL(Sys.fcntl, d0, d1, fd, request, SYS.VAL(LONGINT, flags)) THEN + RETURN TRUE + ELSE + IF d0 = SysErrors.intr THEN + interrupted := TRUE; + END; + IF (d0 # SysErrors.intr) OR ~retry THEN + SysErrors.Raise(errors, d0, Sys.fcntl, ""); + RETURN FALSE + END; + END; + END; + END FcntlSet; + + PROCEDURE FcntlGet*(fd: File; request: INTEGER; VAR flags: SET; + errors: RelatedEvents.Object) : BOOLEAN; + VAR + d0, d1: LONGINT; + BEGIN + IF ulmSYSTEM.UNIXCALL(Sys.fcntl, d0, d1, fd, request, 0) THEN + ulmSYSTEM.WMOVE(SYS.ADR(d0), SYS.ADR(flags), 1); + RETURN TRUE + ELSE + SysErrors.Raise(errors, d0, Sys.fcntl, ""); + RETURN FALSE + END; + END FcntlGet; + + PROCEDURE Dup*(fd: File; VAR newfd: File; + errors: RelatedEvents.Object) : BOOLEAN; + VAR + d0, d1: LONGINT; + a0, a1: LONGINT; + BEGIN + IF ulmSYSTEM.UNIXCALL(Sys.dup, d0, d1, fd, a0, a1) THEN + newfd := d0; + RETURN TRUE + ELSE + SysErrors.Raise(errors, d0, Sys.dup, ""); + RETURN FALSE + END; + END Dup; + + PROCEDURE Dup2*(fd, newfd: File; errors: RelatedEvents.Object) : BOOLEAN; + VAR + d0, d1: LONGINT; + a0, a1: LONGINT; + fd2: File; + interrupted: BOOLEAN; + BEGIN + fd2 := newfd; + (* handmade close to avoid unnecessary events *) + IF ~ulmSYSTEM.UNIXCALL(Sys.close, d0, d1, newfd, a0, a1) THEN END; + IF Fcntl(fd, dupfd, fd2, errors, TRUE, interrupted) THEN + IF fd2 = newfd THEN + RETURN TRUE + ELSE + RETURN Close(fd2, errors, TRUE, interrupted) & FALSE + END; + ELSE + RETURN FALSE + END; + END Dup2; + + PROCEDURE Pipe*(VAR readfd, writefd: File; + errors: RelatedEvents.Object) : BOOLEAN; + VAR + d0, d1: LONGINT; + a0, a1: LONGINT; + fds : ARRAY 2 OF (*File*)INTEGER; (* it needs int pipefd[2], and int is 4 bytes long on x86_64 -- noch *) + BEGIN + IF ulmSYSTEM.UNIXCALL(Sys.pipe, d0, d1, SYS.ADR (fds), a0, a1) THEN + readfd := fds[0]; writefd := fds[1]; + RETURN TRUE + ELSE + SysErrors.Raise(errors, d0, Sys.pipe, ""); + RETURN FALSE + END; + END Pipe; + +END ulmSysIO. diff --git a/src/lib/ulm/ulmSysTypes.Mod b/src/lib/ulm/ulmSysTypes.Mod index b7a0fedf..a614c67b 100644 --- a/src/lib/ulm/ulmSysTypes.Mod +++ b/src/lib/ulm/ulmSysTypes.Mod @@ -39,7 +39,7 @@ MODULE ulmSysTypes; Size* = Types.Size; Byte* = Types.Byte; - File* = INTEGER; + File* = (*INTEGER*)LONGINT; (* in ulm's system both INTEGER and LONGINT are 4 bytes long *) Offset* = LONGINT; Device* = INTEGER; Inode* = LONGINT; diff --git a/voc.REMOVED.git-id b/voc.REMOVED.git-id index 4b49d3ed..e952ef08 100644 --- a/voc.REMOVED.git-id +++ b/voc.REMOVED.git-id @@ -1 +1 @@ -5a61e0f70e28eb3c5eb604cf506a2f9a18c3355c \ No newline at end of file +781786d67da699b419a4f4ae42b31c6cd1506ee8 \ No newline at end of file