mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-02 04:49:43 +01:00
+ Added example 66
This commit is contained in:
parent
a63c76249a
commit
0cc02b454e
@ -36,8 +36,7 @@ OBJECTS=ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 ex9 ex10 ex11 ex12 ex13 ex14 \
|
||||
ex15 ex16 ex17 ex18 ex19 ex20 ex21 ex22 ex23 ex24 ex25 ex26 ex27 \
|
||||
ex28 ex29 ex30 ex31 ex32 ex33 ex34 ex35 ex36 ex37 ex38 ex39 ex40 \
|
||||
ex41 ex42 ex43 ex44 ex45 ex46 ex47 ex48 ex49 ex51 ex52 ex53 ex54 ex55 \
|
||||
ex56 ex57 ex58 ex59 ex60 ex61 ex62 ex63 ex64 ex65
|
||||
# ex66 \
|
||||
ex56 ex57 ex58 ex59 ex60 ex61 ex62 ex63 ex64 ex65 ex66
|
||||
# ex67 ex68 ex69 ex70 ex71 ex72 ex73 ex74 ex75 ex76 ex77
|
||||
|
||||
TEXOBJECTS=$(addsuffix .tex, $(OBJECTS))
|
||||
|
||||
@ -61,9 +61,10 @@ ex57.pp contains an example of the SigAction function.
|
||||
ex58.pp contains an example of the Signal function.
|
||||
ex59.pp contains an example of the Alarm function.
|
||||
ex60.pp contains an example of the GetDateTime function.
|
||||
serial.pp contains an example of serial port programming in FPC.
|
||||
ex61.pp contains an example of the CreateShellArgV function.
|
||||
ex62.pp contains an example of the ReadLink function.
|
||||
ex63.pp contains an example of the FRename function.
|
||||
ex64.pp contains an example of the SysInfo function.
|
||||
ex64.pp contains an example of the SigRaise function.
|
||||
ex66.pp contains an example of the MMap function.
|
||||
serial.pp contains an example of serial port programming in FPC.
|
||||
|
||||
37
docs/linuxex/ex66.pp
Normal file
37
docs/linuxex/ex66.pp
Normal file
@ -0,0 +1,37 @@
|
||||
Program Example66;
|
||||
|
||||
{ Program to demonstrate the MMap function. }
|
||||
|
||||
Uses linux;
|
||||
|
||||
Var S : String;
|
||||
fd,Len : Longint;
|
||||
args : tmmapargs;
|
||||
P : PChar;
|
||||
|
||||
begin
|
||||
S:='This is a string'#0;
|
||||
Len:=Length(S);
|
||||
fd:=fdOpen('testfile.txt',Open_wrOnly or open_creat);
|
||||
If fd=-1 then
|
||||
Halt(1);
|
||||
If fdWrite(fd,S[1],Len)=-1 then
|
||||
Halt(2);
|
||||
fdClose(fd);
|
||||
fdOpen('testfile.txt',Open_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));
|
||||
If longint(P)=-1 then
|
||||
Halt(4);
|
||||
Writeln('Read in memory :',P);
|
||||
fdclose(fd);
|
||||
if Not MUnMap(P,Len) Then
|
||||
Halt(LinuxError);
|
||||
end.
|
||||
Loading…
Reference in New Issue
Block a user