Browse Source

* more fixes. Linux specific cases ifdef linuxed

marco 21 years ago
parent
commit
e7b88006d2
7 changed files with 31 additions and 31 deletions
  1. 16 20
      docs/linuxex/ex66.pp
  2. 1 1
      docs/linuxex/ex67.pp
  3. 3 5
      docs/linuxex/ex68.pp
  4. 1 1
      docs/linuxex/ex69.pp
  5. 2 2
      docs/linuxex/ex70.pp
  6. 6 0
      docs/linuxex/ex71.pp
  7. 2 2
      docs/linuxex/ex72.pp

+ 16 - 20
docs/linuxex/ex66.pp

@@ -2,36 +2,32 @@ Program Example66;
 
 { Program to demonstrate the MMap function. }
 
-Uses linux;
+Uses BaseUnix,Unix;
 
-Var S : String;
-    fd,Len : Longint;
-    args : tmmapargs;
-    P : PChar;
+Var S    : String;
+    fd   : cint;
+    Len  : longint;
+//    args : tmmapargs;
+    P    : PChar;
         
 begin
-  S:='This is a string'#0;
+  s:='This is the string';
   Len:=Length(S);
-  fd:=fdOpen('testfile.txt',Open_wrOnly or open_creat);
+  fd:=fpOpen('testfile.txt',O_wrOnly or o_creat);
   If fd=-1 then 
     Halt(1);
-  If fdWrite(fd,S[1],Len)=-1 then
+  If fpWrite(fd,S[1],Len)=-1 then
     Halt(2);
-  fdClose(fd);
-  fdOpen('testfile.txt',Open_rdOnly);
+  fpClose(fd);
+  fd:=fpOpen('testfile.txt',O_rdOnly);
   if fd=-1 then
     Halt(3);
-  args.address:=0;
-  args.offset:=0;
-  args.size:=Len+1;
-  args.fd:=Fd;
-  args.flags:=MAP_PRIVATE;
-  args.prot:=PROT_READ or PROT_WRITE;
-  P:=Pchar(mmap(args));
+  P:=Pchar(fpmmap(nil,len+1 ,PROT_READ or PROT_WRITE,MAP_PRIVATE,fd,0));
+
   If longint(P)=-1 then
     Halt(4);
   Writeln('Read in memory  :',P);
-  fdclose(fd);
-  if Not MUnMap(P,Len) Then
-    Halt(LinuxError);
+  fpclose(fd);
+  if fpMUnMap(P,Len)<>0 Then
+    Halt(fpgeterrno);
 end.

+ 1 - 1
docs/linuxex/ex67.pp

@@ -1,6 +1,6 @@
 Program Example67;
 
-uses Linux;
+uses UnixUtil;
 
 { Program to demonstrate the FSplit function. }
 

+ 3 - 5
docs/linuxex/ex68.pp

@@ -2,10 +2,8 @@ Program Example68;
 
 { Program to demonstrate the Octal function. }
 
-Uses linux;
-
 begin
-  Writeln('Mode 777 : ', Octal(777));
-  Writeln('Mode 644 : ', Octal(644));
-  Writeln('Mode 755 : ', Octal(755));
+  Writeln('Mode 777 : ', &777);
+  Writeln('Mode 644 : ', &544);
+  Writeln('Mode 755 : ', &755);
 end.

+ 1 - 1
docs/linuxex/ex69.pp

@@ -2,7 +2,7 @@ Program Example69;
 
 { Program to demonstrate the FNMatch function. }
 
-Uses linux;
+Uses unixutil;
 
   Procedure TestMatch(Pattern,Name : String);
   

+ 2 - 2
docs/linuxex/ex70.pp

@@ -2,7 +2,7 @@ Program Example70;
 
 { Program to demonstrate the StringToPPchar function. }
 
-Uses linux;
+Uses UnixUtil;
 
 Var S : String;
     P : PPChar;
@@ -11,7 +11,7 @@ Var S : String;
 begin
   // remark whitespace at end.
   S:='This is a string with words. ';
-  P:=StringToPPChar(S);
+  P:=StringToPPChar(S,0);
   I:=0;
   While P[i]<>Nil do
     begin

+ 6 - 0
docs/linuxex/ex71.pp

@@ -1,5 +1,8 @@
 program TestC{lone};
 
+{$ifdef Linux}
+// close is very Linux specific. 1.9.x threading is done via pthreads.
+
 uses
   Linux, Errors, crt;
 
@@ -68,4 +71,7 @@ begin
     end;
     end;
   FreeMem( theStack, StackSze );
+{$else}
+begin
+{$endif}
 end.

+ 2 - 2
docs/linuxex/ex72.pp

@@ -2,7 +2,7 @@ program example72;
 
 { Program to demonstrate the NanoSleep function. } 
 
-uses Linux;
+uses BaseUnix;
 
 Var
   Req,Rem : TimeSpec;
@@ -16,7 +16,7 @@ begin
     end;
   Write('NanoSleep returned : ');
   Flush(Output);
-  Res:=(NanoSleep(Req,rem);
+  Res:=(fpNanoSleep(@Req,@rem));
   Writeln(res);
   If (res<>0) then
     With rem do