Merge branch 'm1_dynamic_pagesize' into 'master'

ntdll/unix: Don't hardcode page_size, page_shift and page_mask

See merge request wine/wine!4738
This commit is contained in:
Fabian Maurer 2024-11-18 10:27:25 +00:00
commit 3df65661f4
2 changed files with 15 additions and 3 deletions

View file

@ -131,7 +131,7 @@ struct async_fileio
HANDLE handle;
};
static const SIZE_T page_size = 0x1000;
extern SIZE_T page_size;
static const SIZE_T teb_size = 0x3800; /* TEB64 + TEB32 + debug info */
static const SIZE_T signal_stack_mask = 0xffff;
static const SIZE_T signal_stack_size = 0x10000 - 0x3800;

View file

@ -152,8 +152,9 @@ static const BYTE VIRTUAL_Win32Flags[16] =
static struct wine_rb_tree views_tree;
static pthread_mutex_t virtual_mutex;
static const UINT page_shift = 12;
static const UINT_PTR page_mask = 0xfff;
SIZE_T page_size;
static UINT page_shift;
static UINT_PTR page_mask;
static const UINT_PTR granularity_mask = 0xffff;
/* Note: these are Windows limits, you cannot change them. */
@ -3312,6 +3313,13 @@ static void *alloc_virtual_heap( SIZE_T size )
return anon_mmap_alloc( size, PROT_READ | PROT_WRITE );
}
static UINT get_page_shift(SIZE_T page_size)
{
UINT ret = 0;
while (page_size >>= 1) ret++;
return ret;
}
/***********************************************************************
* virtual_init
*/
@ -3323,6 +3331,10 @@ void virtual_init(void)
int i;
pthread_mutexattr_t attr;
page_size = getpagesize();
page_shift = get_page_shift(page_size);
page_mask = page_size - 1;
pthread_mutexattr_init( &attr );
pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_RECURSIVE );
pthread_mutex_init( &virtual_mutex, &attr );