mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-15 04:32:24 +00:00
vmalloc: better detect default region size on Linux
This is a Linux-specific fix for vmalloc from OpenSUSE, for what that's still worth; we're not going to keep using vmalloc long term. https://build.opensuse.org/package/view_file/shells/ksh/ksh93-vm.dif
This commit is contained in:
parent
e2c2753ee8
commit
3002c4113e
2 changed files with 14 additions and 0 deletions
|
@ -152,6 +152,9 @@ extern void _vmmessage _ARG_((const char*, long, const char*, long));
|
|||
#endif /*DEBUG*/
|
||||
|
||||
#define VMPAGESIZE 8192
|
||||
#if defined(__linux__) && !defined(_lib_getpagesize)
|
||||
#define _lib_getpagesize 1
|
||||
#endif
|
||||
#if _lib_getpagesize
|
||||
#define GETPAGESIZE(x) ((x) ? (x) : ((x)=getpagesize()) )
|
||||
#else
|
||||
|
|
|
@ -63,8 +63,10 @@ void _STUB_vmmapopen(){}
|
|||
/* magic word signaling file/segment is ready */
|
||||
#define MM_MAGIC ((unsigned int)(('P'<<24) | ('&'<<16) | ('N'<<8) | ('8')) )
|
||||
|
||||
#ifndef __linux__
|
||||
/* default minimum region size */
|
||||
#define MM_MINSIZE (64*_Vmpagesize)
|
||||
#endif
|
||||
|
||||
/* macros to get the data section and size */
|
||||
#define MMHEAD(file) ROUND(sizeof(Mmvm_t)+strlen(file), ALIGN)
|
||||
|
@ -167,9 +169,18 @@ static int mminit(Mmdisc_t* mmdc)
|
|||
if(mmdc->mmvm) /* already done this */
|
||||
return 0;
|
||||
|
||||
#ifndef __linux__
|
||||
/* fixed size region so make it reasonably large */
|
||||
if((size = mmdc->size) < MM_MINSIZE )
|
||||
size = MM_MINSIZE;
|
||||
#else /* on Linux */
|
||||
if (sizeof(void*) > 32)
|
||||
extent = ROUND(0x80000,_Vmpagesize);
|
||||
else
|
||||
extent = ROUND(0x40000,_Vmpagesize);
|
||||
if((size = mmdc->size) < extent)
|
||||
size = extent;
|
||||
#endif
|
||||
size += MMHEAD(mmdc->file) + ALIGN;
|
||||
size = ROUND(size, _Vmpagesize);
|
||||
|
||||
|
|
Loading…
Reference in a new issue