mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
[sys] Add a function to lock a region of memory
Locked memory is needed for real-time threads (which the sound mixer is when using JACK).
This commit is contained in:
parent
5fd9098e05
commit
0c65d294ed
2 changed files with 14 additions and 0 deletions
|
@ -130,6 +130,7 @@ void Sys_PageIn (void *ptr, size_t size);
|
|||
size_t Sys_PageSize (void);
|
||||
void *Sys_Alloc (size_t size);
|
||||
void Sys_Free (void *mem, size_t size);
|
||||
int Sys_LockMemory (void *mem, size_t size);
|
||||
|
||||
int Sys_ProcessorCount (void);
|
||||
|
||||
|
|
|
@ -758,6 +758,19 @@ Sys_Free (void *mem, size_t size)
|
|||
#endif
|
||||
}
|
||||
|
||||
VISIBLE int
|
||||
Sys_LockMemory (void *mem, size_t size)
|
||||
{
|
||||
size_t page_size = Sys_PageSize ();
|
||||
size_t page_mask = page_size - 1;
|
||||
size = (size + page_mask) & ~page_mask;
|
||||
#ifdef _WIN32
|
||||
return VirtualLock (mem, size) != 0;
|
||||
#else
|
||||
return mlock (mem, size) == 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
VISIBLE int
|
||||
Sys_ProcessorCount (void)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue