* more fixes. Linux specific cases ifdef linuxed

This commit is contained in:
marco 2004-07-18 17:06:28 +00:00
parent d43436e1cd
commit e7b88006d2
7 changed files with 31 additions and 31 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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