mirror of
https://github.com/FWGS/xash3d-fwgs
synced 2024-11-23 18:30:50 +01:00
engine: server: support MAP_ANON synonym for MAP_ANONYMOUS, disable allocating string pool near server library for OSX
This commit is contained in:
parent
a520d245a6
commit
5678d9a253
@ -3092,12 +3092,10 @@ void SV_SetStringArrayMode( qboolean dynamic )
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef XASH_64BIT
|
||||
#if !XASH_WIN32
|
||||
#if XASH_64BIT && !XASH_WIN32 && !XASH_APPLE
|
||||
#define USE_MMAP
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
==================
|
||||
@ -3128,14 +3126,21 @@ void SV_AllocStringPool( void )
|
||||
|
||||
#ifdef USE_MMAP
|
||||
{
|
||||
uint flags;
|
||||
size_t pagesize = sysconf( _SC_PAGESIZE );
|
||||
int arrlen = (str64.maxstringarray * 2) & ~(pagesize - 1);
|
||||
void *base = svgame.dllFuncs.pfnGameInit;
|
||||
void *start = svgame.hInstance - arrlen;
|
||||
|
||||
#if defined(MAP_ANON)
|
||||
flags = MAP_ANON | MAP_PRIVATE;
|
||||
#elif defined(MAP_ANONYMOUS)
|
||||
flags = MAP_ANONYMOUS | MAP_PRIVATE;
|
||||
#endif
|
||||
|
||||
while( start - base > INT_MIN )
|
||||
{
|
||||
void *mapptr = mmap((void*)((unsigned long)start & ~(pagesize - 1)), arrlen, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0 );
|
||||
void *mapptr = mmap((void*)((unsigned long)start & ~(pagesize - 1)), arrlen, PROT_READ | PROT_WRITE, flags, 0, 0 );
|
||||
if( mapptr && mapptr != (void*)-1 && mapptr - base > INT_MIN && mapptr - base < INT_MAX )
|
||||
{
|
||||
ptr = mapptr;
|
||||
@ -3150,7 +3155,7 @@ void SV_AllocStringPool( void )
|
||||
start = base;
|
||||
while( start - base < INT_MAX )
|
||||
{
|
||||
void *mapptr = mmap((void*)((unsigned long)start & ~(pagesize - 1)), arrlen, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0 );
|
||||
void *mapptr = mmap((void*)((unsigned long)start & ~(pagesize - 1)), arrlen, PROT_READ | PROT_WRITE, flags, 0, 0 );
|
||||
if( mapptr && mapptr != (void*)-1 && mapptr - base > INT_MIN && mapptr - base < INT_MAX )
|
||||
{
|
||||
ptr = mapptr;
|
||||
|
Loading…
Reference in New Issue
Block a user