Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Free Pascal
»
Unix
(Moderators:
FPK
,
Tomas Hajny
) »
Allocate memory pages
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Mapping Images Like Odome...
by
SandyG
[November 14, 2025, 11:53:01 pm]
This worries me about our...
by
dbannon
[November 14, 2025, 11:52:35 pm]
EditorMacroScript did not...
by
Martin_fr
[November 14, 2025, 11:48:31 pm]
Programmatic filtering in...
by
jamie
[November 14, 2025, 11:27:29 pm]
Form scaling aspect ratio
by
jamie
[November 14, 2025, 11:24:26 pm]
Problem with Qt5 on macOS
by
zeljko
[November 14, 2025, 10:39:24 pm]
Help with search and repa...
by
Thausand
[November 14, 2025, 08:37:03 pm]
Variable "xyz" doesn't no...
by
Thaddy
[November 14, 2025, 06:53:12 pm]
Incompatible type in MTPr...
by
LemonParty
[November 14, 2025, 06:36:59 pm]
In fpcsrc, many places ca...
by
AlexTP
[November 14, 2025, 06:15:35 pm]
Postgres, ZEOS and Visual...
by
wp
[November 14, 2025, 05:57:25 pm]
[Solved] Process exited w...
by
d7_2_laz
[November 14, 2025, 05:14:08 pm]
AVRPascal – free code edi...
by
ackarwow
[November 14, 2025, 04:21:44 pm]
Is there a "known good" c...
by
mischi
[November 14, 2025, 02:18:20 pm]
Lazarus Bugfix Release 4...
by
Martin_fr
[November 14, 2025, 12:24:59 pm]
Valgrind stops showing li...
by
Martin_fr
[November 14, 2025, 12:09:06 pm]
manufacturing sim (inc)
by
speter
[November 14, 2025, 11:38:56 am]
Can't I highlight part of...
by
Martin_fr
[November 14, 2025, 08:43:03 am]
Access Violation
by
Thaddy
[November 14, 2025, 06:23:59 am]
Problem Installing CHM He...
by
dbannon
[November 14, 2025, 01:53:29 am]
[SOLVED] Heaptrc reports ...
by
jamie
[November 14, 2025, 12:48:49 am]
New book on Object Pascal
by
TBMan
[November 14, 2025, 12:39:00 am]
Fpcupdeluxe
by
Cascade
[November 13, 2025, 10:46:00 pm]
line number when error ha...
by
Martin_fr
[November 13, 2025, 10:37:19 pm]
Unit Masks, matches funct...
by
Martin_fr
[November 13, 2025, 07:31:00 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Allocate memory pages (Read 2587 times)
LemonParty
Sr. Member
Posts: 373
Allocate memory pages
«
on:
February 27, 2025, 03:46:39 pm »
In Windows we have VirtualAlloc function for allocate memory pages. What is used in UNIX?
Logged
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11
Khrys
Sr. Member
Posts: 348
Re: Allocate memory pages
«
Reply #1 on:
February 27, 2025, 03:50:55 pm »
mmap
, and
mprotect
is analogous to
VirtualProtect
Logged
LemonParty
Sr. Member
Posts: 373
Re: Allocate memory pages
«
Reply #2 on:
February 27, 2025, 04:14:43 pm »
So if I want just memory I have to pass 0 to fd and offset arguments of mmap?
Logged
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11
MarkMLl
Hero Member
Posts: 8505
Re: Allocate memory pages
«
Reply #3 on:
February 27, 2025, 05:04:19 pm »
Quote from: LemonParty on February 27, 2025, 04:14:43 pm
So if I want just memory I have to pass 0 to fd and offset arguments of mmap?
There's an example at
https://www.freepascal.org/docs-html/current/rtl/baseunix/fpmmap.html
which suggests that it's not that simple. I've not used it ** , and suggest that you look for online examples- even if (shock! Horror!!) they're written in C etc.
** I've not used it
in Pascal
. I've used it in some C-based video stuff, but was doing so by rote based on existing code and there is absolutely no way I'd set myself up as an expert. I believe it's covered by POSIX, so examples should be fairly portable.
MarkMLl
Logged
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories:
https://github.com/MarkMLl?tab=repositories
LemonParty
Sr. Member
Posts: 373
Re: Allocate memory pages
«
Reply #4 on:
February 27, 2025, 05:52:38 pm »
Seems work.
Code: Pascal
[Select]
[+]
[-]
Fpmmap
(
nil
,
Size
,
PROT_EXEC
or
PROT_READ
or
PROT_WRITE
,
MAP_SHARED
or
MAP_ANONYMOUS
,
-
1
,
0
)
MAP_ANONYMOUS should be specified if no need to map to a file.
Logged
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Free Pascal
»
Unix
(Moderators:
FPK
,
Tomas Hajny
) »
Allocate memory pages
TinyPortal
© 2005-2018