mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-18 18:56:29 +00:00
libc: make 'mmap()' address alignment configurable
With this commit, the alignment of anonymous 'mmap()' allocations can be configured like this: <config> <libc> <mmap align_log2="21"/> </libc> </config> Fixes #3907
This commit is contained in:
parent
7d21335ac9
commit
058f2e687c
@ -63,11 +63,20 @@ Libc::Mmap_registry *Libc::mmap_registry()
|
||||
}
|
||||
|
||||
|
||||
static Cwd *_cwd_ptr;
|
||||
static Cwd *_cwd_ptr;
|
||||
static unsigned int _mmap_align_log2 { PAGE_SHIFT };
|
||||
|
||||
void Libc::init_file_operations(Cwd &cwd)
|
||||
void Libc::init_file_operations(Cwd &cwd,
|
||||
Config_accessor const &config_accessor)
|
||||
{
|
||||
_cwd_ptr = &cwd;
|
||||
|
||||
config_accessor.config().with_sub_node("libc", [&] (Xml_node libc) {
|
||||
libc.with_sub_node("mmap", [&] (Xml_node mmap) {
|
||||
_mmap_align_log2 = mmap.attribute_value("align_log2",
|
||||
(unsigned int)PAGE_SHIFT);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -423,7 +432,7 @@ __SYS_(void *, mmap, (void *addr, ::size_t length,
|
||||
}
|
||||
|
||||
bool const executable = prot & PROT_EXEC;
|
||||
void *start = mem_alloc(executable)->alloc(length, PAGE_SHIFT);
|
||||
void *start = mem_alloc(executable)->alloc(length, _mmap_align_log2);
|
||||
if (!start) {
|
||||
errno = ENOMEM;
|
||||
return MAP_FAILED;
|
||||
|
@ -41,6 +41,7 @@ namespace Libc {
|
||||
struct Timer_accessor;
|
||||
struct Cwd;
|
||||
struct Atexit;
|
||||
struct Config_accessor;
|
||||
|
||||
/**
|
||||
* Support for shared libraries
|
||||
@ -66,7 +67,7 @@ namespace Libc {
|
||||
* Virtual file system
|
||||
*/
|
||||
void init_vfs_plugin(Monitor &, Genode::Region_map &);
|
||||
void init_file_operations(Cwd &);
|
||||
void init_file_operations(Cwd &, Config_accessor const &);
|
||||
|
||||
/**
|
||||
* Select support
|
||||
|
@ -474,7 +474,7 @@ Libc::Kernel::Kernel(Genode::Env &env, Genode::Allocator &heap)
|
||||
init_plugin(*this);
|
||||
init_sleep(*this);
|
||||
init_vfs_plugin(*this, _env.rm());
|
||||
init_file_operations(*this);
|
||||
init_file_operations(*this, _libc_env);
|
||||
init_time(*this, *this);
|
||||
init_select(*this, _signal, *this);
|
||||
init_socket_fs(*this);
|
||||
|
Loading…
Reference in New Issue
Block a user