parent
d6a92e956a
commit
a79f7d234b
|
@ -73,7 +73,7 @@ namespace Libc {
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
File_descriptor_allocator();
|
File_descriptor_allocator(Genode::Allocator &md_alloc);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate file descriptor
|
* Allocate file descriptor
|
||||||
|
|
|
@ -16,32 +16,32 @@
|
||||||
#include <util/construct_at.h>
|
#include <util/construct_at.h>
|
||||||
#include <base/env.h>
|
#include <base/env.h>
|
||||||
#include <base/log.h>
|
#include <base/log.h>
|
||||||
|
#include <libc/allocator.h>
|
||||||
|
|
||||||
/* libc plugin interface */
|
/* libc plugin interface */
|
||||||
#include <libc-plugin/fd_alloc.h>
|
#include <libc-plugin/fd_alloc.h>
|
||||||
|
|
||||||
namespace Libc {
|
|
||||||
|
|
||||||
File_descriptor_allocator *file_descriptor_allocator()
|
|
||||||
{
|
|
||||||
static bool constructed = 0;
|
|
||||||
static char placeholder[sizeof(File_descriptor_allocator)];
|
|
||||||
if (!constructed) {
|
|
||||||
Genode::construct_at<File_descriptor_allocator>(placeholder);
|
|
||||||
constructed = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return reinterpret_cast<File_descriptor_allocator *>(placeholder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
using namespace Libc;
|
using namespace Libc;
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
|
|
||||||
File_descriptor_allocator::File_descriptor_allocator()
|
File_descriptor_allocator *Libc::file_descriptor_allocator()
|
||||||
: Allocator_avl_tpl<File_descriptor>(Genode::env()->heap())
|
{
|
||||||
|
static bool constructed = false;
|
||||||
|
static char placeholder[sizeof(File_descriptor_allocator)];
|
||||||
|
static Libc::Allocator md_alloc;
|
||||||
|
|
||||||
|
if (!constructed) {
|
||||||
|
Genode::construct_at<File_descriptor_allocator>(placeholder, md_alloc);
|
||||||
|
constructed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return reinterpret_cast<File_descriptor_allocator *>(placeholder);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
File_descriptor_allocator::File_descriptor_allocator(Genode::Allocator &md_alloc)
|
||||||
|
: Allocator_avl_tpl<File_descriptor>(&md_alloc)
|
||||||
{
|
{
|
||||||
add_range(0, MAX_NUM_FDS);
|
add_range(0, MAX_NUM_FDS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,9 @@
|
||||||
#include <base/env.h>
|
#include <base/env.h>
|
||||||
#include <base/log.h>
|
#include <base/log.h>
|
||||||
|
|
||||||
|
/* Genode libc includes */
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
/* libc-internal includes */
|
/* libc-internal includes */
|
||||||
#include <libc-plugin/plugin.h>
|
#include <libc-plugin/plugin.h>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user