committed by
Norman Feske
parent
7370cc7410
commit
800c3e940f
@@ -1,12 +1,24 @@
|
||||
#include <timer_session/connection.h>
|
||||
#include <genode_init.h>
|
||||
#include <base/printf.h>
|
||||
|
||||
Genode::Allocator *_heap = nullptr;
|
||||
Timer::Connection *_timer = nullptr;
|
||||
|
||||
|
||||
void testu01_init(Genode::Allocator &heap, Timer::Connection &timer)
|
||||
{
|
||||
_heap = &heap;
|
||||
_timer = &timer;
|
||||
}
|
||||
|
||||
|
||||
/* XXX: should be the CPU session time, but the timer works for now */
|
||||
static void Heure (unsigned long *tsec, unsigned long *tusec)
|
||||
{
|
||||
static Timer::Connection timer;
|
||||
if (!_timer)
|
||||
Genode::error("library not initialized with 'testu01_init'!");
|
||||
|
||||
unsigned long ms = timer.elapsed_ms();
|
||||
unsigned long ms = _timer->elapsed_ms();
|
||||
|
||||
*tsec = ms / 1000;
|
||||
*tusec = ms * 1000;
|
||||
@@ -25,13 +37,16 @@ void chrono_Init (chrono_Chrono *C) {
|
||||
|
||||
chrono_Chrono * chrono_Create (void)
|
||||
{
|
||||
chrono_Chrono *C = new (Genode::env()->heap()) chrono_Chrono;
|
||||
if (!_heap)
|
||||
Genode::error("library not initialized with 'testu01_init'!");
|
||||
|
||||
chrono_Chrono *C = new (*_heap) chrono_Chrono;
|
||||
Heure(&C->second, &C->microsec);
|
||||
return C;
|
||||
}
|
||||
|
||||
|
||||
void chrono_Delete (chrono_Chrono *C) { destroy(Genode::env()->heap(), C); }
|
||||
void chrono_Delete (chrono_Chrono *C) { destroy(*_heap, C); }
|
||||
|
||||
|
||||
double chrono_Val (chrono_Chrono *C, chrono_TimeFormat Unit)
|
||||
|
||||
@@ -7,9 +7,7 @@ extern "C" {
|
||||
|
||||
void gdef_GetHostName (char machine[], int n)
|
||||
{
|
||||
Genode::Attached_rom_dataspace config("config");
|
||||
try { config.xml().attribute("hostname").value(machine, n); }
|
||||
catch (...) { Genode::strncpy(machine, "genode", n); }
|
||||
if (n) *machine = '\0';
|
||||
}
|
||||
|
||||
void gdef_WriteHostName (void) { }
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#include <testu01/genode_init.h>
|
||||
|
||||
#include <base/attached_rom_dataspace.h>
|
||||
#include <libc/component.h>
|
||||
#include <base/heap.h>
|
||||
#include <base/log.h>
|
||||
|
||||
extern "C" {
|
||||
@@ -30,7 +33,13 @@ void Libc::Component::construct(Libc::Env &env)
|
||||
return;
|
||||
}
|
||||
|
||||
bbattery_AlphabitFile((char *)file.string(), nbits);
|
||||
Heap heap(env.pd(), env.rm());
|
||||
Timer::Connection timer(env);
|
||||
|
||||
testu01_init(heap, timer);
|
||||
|
||||
Libc::with_libc([&] () {
|
||||
bbattery_AlphabitFile((char *)file.string(), nbits); });
|
||||
|
||||
env.parent().exit(0);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
TARGET = testu01_alphabet
|
||||
TARGET = testu01_alphabit
|
||||
LIBS += testu01 libc libm
|
||||
SRC_CC = main.cc
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#include <testu01/genode_init.h>
|
||||
|
||||
#include <base/attached_rom_dataspace.h>
|
||||
#include <libc/component.h>
|
||||
#include <base/heap.h>
|
||||
#include <base/log.h>
|
||||
|
||||
extern "C" {
|
||||
@@ -36,7 +39,13 @@ void Libc::Component::construct(Libc::Env &env)
|
||||
return;
|
||||
}
|
||||
|
||||
bbattery_RabbitFile((char *)file.string(), nbits);
|
||||
Heap heap(env.pd(), env.rm());
|
||||
Timer::Connection timer(env);
|
||||
|
||||
testu01_init(heap, timer);
|
||||
|
||||
Libc::with_libc([&] () {
|
||||
bbattery_RabbitFile((char *)file.string(), nbits); });
|
||||
|
||||
env.parent().exit(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user