Use base/log.h instead of deprecated base/printf.h

- Remove use of PLOG, PINF, PWRN, PERR, and printf.
  Only a single use of printf in fesrv remains for now.
- Whitespace and style fixes
- Fix build of server/synergy_input
- Add missing include of base/heap.h (previously, this header
  was implicitly included by root/component.h)
This commit is contained in:
Norman Feske
2016-07-15 13:14:35 +02:00
parent 3405eb2853
commit 1cf653d548
18 changed files with 230 additions and 199 deletions

View File

@@ -374,7 +374,7 @@ Just add the following two lines to hold the program when the second
message appears:
! if (strcmp("basic_string::substr", s) == 0) {
! PERR("stop!");
! Genode::error("stop!");
! for (;;);
! }
@@ -414,7 +414,7 @@ in a new _getenv.cc_ file that we link to the target:
! extern "C" char *getenv(const char *name)
! {
! PINF("environment variable \"%s\" requested", name);
! Genode::log("environment variable \"", name, "\" requested");
! return (char *)"";
! };

View File

@@ -1 +1 @@
f3880fddb60b77e7af5bc03abfef751db0e1faf6
e8c92ca78721ec791f0780481ca12aa31c3fdc50

View File

@@ -127,15 +127,15 @@ int main()
{
auto image = image_name();
Htif_zedboard_genode htif( image );
PINF( "Initialized Htif_zedboard with %s", image.c_str() );
Genode::log( "Initialized Htif_zedboard with ", image.c_str() );
htif.run();
}
catch ( const std::runtime_error &e )
{
PERR( "Caught runtime error: %s", e.what() );
Genode::error( "Caught runtime error: ", e.what() );
}
catch ( ... )
{
PERR( "Unknown error occured" );
Genode::error( "Unknown error occured" );
}
}

View File

@@ -1,29 +1,30 @@
FESRV_SRC = $(call select_from_ports,fesrv)/src/app/fesrv/fesvr/
SRC_CC = main.cc \
linux_syscalls.cc \
context.cc \
device.cc \
dummy.cc \
elfloader.cc \
htif.cc \
htif_eth.cc \
htif_hexwriter.cc \
htif_rs232.cc \
htif_zedboard.cc \
memif.cc \
option_parser.cc \
packet.cc \
rfb.cc \
syscall.cc \
term.cc
SRC_CC = main.cc \
linux_syscalls.cc \
context.cc \
device.cc \
dummy.cc \
elfloader.cc \
htif.cc \
htif_eth.cc \
htif_hexwriter.cc \
htif_rs232.cc \
htif_zedboard.cc \
memif.cc \
option_parser.cc \
packet.cc \
rfb.cc \
syscall.cc \
term.cc
TARGET = fesrv
LIBS = stdcxx
TARGET = fesrv
LIBS = stdcxx
INC_DIR += $(FESRV_SRC)
# Some defines to keep the fesrv compilation process happy
CC_OPT += -DPREFIX=\"\" -DTARGET_ARCH=\"\" -DTARGET_DIR=\"\"
CC_OPT += -DTARGET_ARCH=\"\" -DTARGET_DIR=\"\"
CC_OPT_htif += -DPREFIX=\"\"
vpath %.cc $(FESRV_SRC)

View File

@@ -8,12 +8,12 @@
#include <stdlib.h>
/* Genode includes */
#include <base/printf.h>
#include <base/log.h>
extern "C" char *getenv(const char *name)
{
PINF("environment variable \"%s\" requested", name);
Genode::log("environment variable \"", name, "\" requested");
return (char *)"";
};

View File

@@ -14,8 +14,9 @@
#include <gpio_session/zynq/gpio_session.h>
#include <cap_session/connection.h>
#include <dataspace/client.h>
#include <base/printf.h>
#include <base/log.h>
#include <base/sleep.h>
#include <base/heap.h>
#include <root/component.h>
#include <os/static_root.h>
#include <os/config.h>
@@ -28,28 +29,31 @@ namespace Gpio {
class Root;
};
class Gpio::Session_component : public Genode::Rpc_object<Gpio::Session>
{
private:
Driver &_driver;
unsigned _number;
unsigned _number;
public:
Session_component(Driver &driver, unsigned gpio_number) : _driver(driver), _number(gpio_number) {}
Session_component(Driver &driver, unsigned gpio_number)
: _driver(driver), _number(gpio_number) {}
virtual Genode::uint32_t read(bool isChannel2)
virtual Genode::uint32_t read(bool isChannel2)
{
return _driver.read(_number, isChannel2);
return _driver.read(_number, isChannel2);
}
virtual bool write(Genode::uint32_t data, bool isChannel2)
virtual bool write(Genode::uint32_t data, bool isChannel2)
{
return _driver.write(_number, data, isChannel2);
return _driver.write(_number, data, isChannel2);
}
};
class Gpio::Root : public Genode::Root_component<Gpio::Session_component>
{
private:
@@ -60,72 +64,75 @@ class Gpio::Root : public Genode::Root_component<Gpio::Session_component>
Session_component *_create_session(const char *args)
{
unsigned number = Genode::Arg_string::find_arg(args, "gpio").ulong_value(0);
Genode::size_t ram_quota = Genode::Arg_string::find_arg(args, "ram_quota").ulong_value(0);
unsigned number = Genode::Arg_string::find_arg(args, "gpio").ulong_value(0);
Genode::size_t ram_quota = Genode::Arg_string::find_arg(args, "ram_quota").ulong_value(0);
if (ram_quota < sizeof(Session_component)) {
PWRN("Insufficient dontated ram_quota (%zd bytes), require %zd bytes",
ram_quota, sizeof(Session_component));
throw Genode::Root::Quota_exceeded();
}
if (ram_quota < sizeof(Session_component)) {
Genode::warning("Insufficient dontated ram_quota (", ram_quota, " bytes), "
"require ", sizeof(Session_component), " bytes");
throw Genode::Root::Quota_exceeded();
}
return new (md_alloc()) Session_component(_driver, number);
return new (md_alloc()) Session_component(_driver, number);
}
public:
Root(Genode::Rpc_entrypoint *session_ep,
Genode::Allocator *md_alloc, Driver &driver)
: Genode::Root_component<Gpio::Session_component>(session_ep, md_alloc),
_driver(driver) { }
:
Genode::Root_component<Gpio::Session_component>(session_ep, md_alloc),
_driver(driver)
{ }
};
int main(int, char **)
{
using namespace Gpio;
using namespace Gpio;
PINF("Zynq Gpio driver");
Genode::log("Zynq Gpio driver");
/*
* Read config
*/
std::vector<Genode::addr_t> addr;
/*
* Read config
*/
std::vector<Genode::addr_t> addr;
try {
Genode::Xml_node gpio_node = Genode::config()->xml_node().sub_node("gpio");
try {
Genode::Xml_node gpio_node = Genode::config()->xml_node().sub_node("gpio");
for (unsigned i = 0; ;i++, gpio_node = gpio_node.next("gpio"))
{
addr.push_back(0);
gpio_node.attribute("addr").value(&addr[i]);
PINF("Gpio with mio address 0x%x added.", (unsigned int)addr[i]);
for (unsigned i = 0; ;i++, gpio_node = gpio_node.next("gpio"))
{
addr.push_back(0);
gpio_node.attribute("addr").value(&addr[i]);
Genode::log("Gpio with mio address ", Genode::Hex(addr[i]), " added.");
if (gpio_node.is_last("gpio")) break;
}
}
catch (Genode::Xml_node::Nonexistent_sub_node) {
PWRN("No Gpio config");
}
if (gpio_node.is_last("gpio")) break;
}
}
catch (Genode::Xml_node::Nonexistent_sub_node) {
Genode::warning("No Gpio config");
}
/*
* Create Driver
*/
Driver &driver = Driver::factory(addr);
addr.clear();
/*
* Create Driver
*/
Driver &driver = Driver::factory(addr);
addr.clear();
/*
* Initialize server entry point
*/
enum { STACK_SIZE = 4096 };
enum { STACK_SIZE = 4096 };
static Cap_connection cap;
Sliced_heap sliced_heap(env()->ram_session(), env()->rm_session());
static Rpc_entrypoint ep(&cap, STACK_SIZE, "gpio_ep");
static Gpio::Root gpio_root(&ep, &sliced_heap, driver);
static Rpc_entrypoint ep(&cap, STACK_SIZE, "gpio_ep");
static Gpio::Root gpio_root(&ep, &sliced_heap, driver);
/*
* Announce service
*/
env()->parent()->announce(ep.manage(&gpio_root));
*/
env()->parent()->announce(ep.manage(&gpio_root));
Genode::sleep_forever();
return 0;

View File

@@ -58,12 +58,12 @@ class I2C::Driver
buf[1]=reg;
if (i2c_reg->i2c_write(adr, buf, 2) != 0)
{
PERR("Zynq i2c: read failed");
Genode::error("Zynq i2c: read failed");
return false;
}
if (i2c_reg->i2c_read_byte(adr, data) != 0)
{
PERR("Zynq i2c: read failed");
Genode::error("Zynq i2c: read failed");
return false;
}
return true;
@@ -79,7 +79,7 @@ class I2C::Driver
buf[2]=data;
if (i2c_reg->i2c_write(adr, buf, 3) != 0)
{
PERR("Zynq i2c: write failed");
Genode::error("Zynq i2c: write failed");
return false;
}
return true;

View File

@@ -14,7 +14,8 @@
#include <i2c_session/i2c_session.h>
#include <cap_session/connection.h>
#include <dataspace/client.h>
#include <base/printf.h>
#include <base/log.h>
#include <base/heap.h>
#include <base/sleep.h>
#include <root/component.h>
@@ -78,7 +79,7 @@ int main(int, char **)
{
using namespace I2C;
PINF("Zynq I2C driver");
Genode::log("Zynq I2C driver");
Driver &driver = Driver::factory();

View File

@@ -13,7 +13,7 @@
*/
/* Genode includes */
#include <base/printf.h>
#include <base/log.h>
#include <os/server.h>
/* local includes */
@@ -24,7 +24,6 @@ struct Main
{
Server::Entrypoint &ep;
struct Factory : Block::Driver_factory
{
Block::Driver *create() {
@@ -40,7 +39,7 @@ struct Main
Main(Server::Entrypoint &ep)
: ep(ep), root(ep, Genode::env()->heap(), factory)
{
Genode::printf("--- SD card driver ---\n");
Genode::log("--- SD card driver ---");
Genode::env()->parent()->announce(ep.manage(root));
}

View File

@@ -14,7 +14,8 @@
#include <vdma_session/vdma_session.h>
#include <cap_session/connection.h>
#include <dataspace/client.h>
#include <base/printf.h>
#include <base/log.h>
#include <base/heap.h>
#include <base/sleep.h>
#include <root/component.h>
#include <os/static_root.h>
@@ -28,43 +29,46 @@ namespace Vdma {
class Root;
};
class Vdma::Session_component : public Genode::Rpc_object<Vdma::Session>
{
private:
Driver &_driver;
unsigned _number;
unsigned _number;
public:
Session_component(Driver &driver, unsigned vdma_number) : _driver(driver), _number(vdma_number) {}
Session_component(Driver &driver, unsigned vdma_number)
: _driver(driver), _number(vdma_number) {}
virtual bool setConfig(Genode::uint32_t data, bool isMM2S)
{
return _driver.setConfig(_number, data, isMM2S);
}
virtual bool setConfig(Genode::uint32_t data, bool isMM2S)
{
return _driver.setConfig(_number, data, isMM2S);
}
virtual bool setStride(Genode::uint16_t data, bool isMM2S)
{
return _driver.setStride(_number, data, isMM2S);
}
virtual bool setStride(Genode::uint16_t data, bool isMM2S)
{
return _driver.setStride(_number, data, isMM2S);
}
virtual bool setWidth(Genode::uint16_t data, bool isMM2S)
{
return _driver.setWidth(_number, data, isMM2S);
}
virtual bool setWidth(Genode::uint16_t data, bool isMM2S)
{
return _driver.setWidth(_number, data, isMM2S);
}
virtual bool setHeight(Genode::uint16_t data, bool isMM2S)
{
return _driver.setHeight(_number, data, isMM2S);
}
virtual bool setHeight(Genode::uint16_t data, bool isMM2S)
{
return _driver.setHeight(_number, data, isMM2S);
}
virtual bool setAddr(Genode::uint32_t data, bool isMM2S)
{
return _driver.setAddr(_number, data, isMM2S);
}
virtual bool setAddr(Genode::uint32_t data, bool isMM2S)
{
return _driver.setAddr(_number, data, isMM2S);
}
};
class Vdma::Root : public Genode::Root_component<Vdma::Session_component>
{
private:
@@ -75,16 +79,16 @@ class Vdma::Root : public Genode::Root_component<Vdma::Session_component>
Session_component *_create_session(const char *args)
{
unsigned number = Genode::Arg_string::find_arg(args, "vdma").ulong_value(0);
Genode::size_t ram_quota = Genode::Arg_string::find_arg(args, "ram_quota").ulong_value(0);
unsigned number = Genode::Arg_string::find_arg(args, "vdma").ulong_value(0);
Genode::size_t ram_quota = Genode::Arg_string::find_arg(args, "ram_quota").ulong_value(0);
if (ram_quota < sizeof(Session_component)) {
PWRN("Insufficient dontated ram_quota (%zd bytes), require %zd bytes",
ram_quota, sizeof(Session_component));
throw Genode::Root::Quota_exceeded();
}
if (ram_quota < sizeof(Session_component)) {
PWRN("Insufficient dontated ram_quota (%zd bytes), require %zd bytes",
ram_quota, sizeof(Session_component));
throw Genode::Root::Quota_exceeded();
}
return new (md_alloc()) Session_component(_driver, number);
return new (md_alloc()) Session_component(_driver, number);
}
public:
@@ -95,38 +99,39 @@ class Vdma::Root : public Genode::Root_component<Vdma::Session_component>
_driver(driver) { }
};
int main(int, char **)
{
using namespace Vdma;
using namespace Vdma;
PINF("Zynq VDMA driver");
Genode::log("Zynq VDMA driver");
/*
* Read config
*/
std::vector<Genode::addr_t> addr;
/*
* Read config
*/
std::vector<Genode::addr_t> addr;
try {
Genode::Xml_node vdma_node = Genode::config()->xml_node().sub_node("vdma");
try {
Genode::Xml_node vdma_node = Genode::config()->xml_node().sub_node("vdma");
for (unsigned i = 0; ;i++, vdma_node = vdma_node.next("vdma"))
{
addr.push_back(0);
vdma_node.attribute("addr").value(&addr[i]);
PINF("VDMA with mio address 0x%x added.", (unsigned int)addr[i]);
for (unsigned i = 0; ;i++, vdma_node = vdma_node.next("vdma"))
{
addr.push_back(0);
vdma_node.attribute("addr").value(&addr[i]);
Genode::log("VDMA with mio address ", Genode::Hex(addr[i]), " added.");
if (vdma_node.is_last("vdma")) break;
}
}
catch (Genode::Xml_node::Nonexistent_sub_node) {
PWRN("No VDMA config");
}
if (vdma_node.is_last("vdma")) break;
}
}
catch (Genode::Xml_node::Nonexistent_sub_node) {
Genode::warning("No VDMA config");
}
/*
* Create Driver
*/
Driver &driver = Driver::factory(addr);
addr.clear();
/*
* Create Driver
*/
Driver &driver = Driver::factory(addr);
addr.clear();
/*
* Initialize server entry point
@@ -134,13 +139,13 @@ int main(int, char **)
enum { STACK_SIZE = 4096 };
static Cap_connection cap;
Sliced_heap sliced_heap(env()->ram_session(), env()->rm_session());
static Rpc_entrypoint ep(&cap, STACK_SIZE, "vdma_ep");
static Vdma::Root vdma_root(&ep, &sliced_heap, driver);
static Rpc_entrypoint ep(&cap, STACK_SIZE, "vdma_ep");
static Vdma::Root vdma_root(&ep, &sliced_heap, driver);
/*
* Announce service
*/
env()->parent()->announce(ep.manage(&vdma_root));
*/
env()->parent()->announce(ep.manage(&vdma_root));
Genode::sleep_forever();
return 0;

View File

@@ -6,6 +6,7 @@
#include <base/env.h>
#include <base/exception.h>
#include <base/log.h>
#include <backend_base.h>
@@ -56,9 +57,9 @@ class Remote_rom::Packet_base : public Ethernet_frame, public Ipv4_packet
protected:
char _module_name[MAX_NAME_LEN]; /* the ROM module name */
Type _type; /* packet type */
uint32_t _content_size; /* ROM content size in bytes */
uint16_t _offset; /* offset in bytes */
uint16_t _payload_size; /* payload size in bytes */
uint32_t _content_size; /* ROM content size in bytes */
uint16_t _offset; /* offset in bytes */
uint16_t _payload_size; /* payload size in bytes */
/*****************************************************
** 'payload' must be the last member of this class **
@@ -68,7 +69,12 @@ class Remote_rom::Packet_base : public Ethernet_frame, public Ipv4_packet
public:
Packet_base(size_t size) : Ethernet_frame(sizeof(Packet_base) + size), Ipv4_packet(sizeof(Packet_base) + size - sizeof(Ethernet_frame)), _payload_size(size) { }
Packet_base(size_t size)
:
Ethernet_frame(sizeof(Packet_base) + size),
Ipv4_packet(sizeof(Packet_base) + size - sizeof(Ethernet_frame)),
_payload_size(size)
{ }
void const * base() const { return &payload; }
@@ -235,12 +241,12 @@ class Remote_rom::Backend_base
_nic.rx()->acknowledge_packet(_rx_packet);
}
}
void _handle_rx_ready_to_ack(unsigned) { _handle_rx_packet_avail(0); }
void _handle_link_state(unsigned)
{
PINF("link state changed");
Genode::log("link state changed");
}
public:
@@ -291,7 +297,10 @@ class Remote_rom::Backend_base
}
public:
explicit Backend_base(Genode::Allocator &alloc, HANDLER &handler) : _tx_block_alloc(&alloc), _nic(&_tx_block_alloc, BUF_SIZE, BUF_SIZE), _rx_thread(_nic, handler, _accept_ip)
explicit Backend_base(Genode::Allocator &alloc, HANDLER &handler)
:
_tx_block_alloc(&alloc), _nic(&_tx_block_alloc, BUF_SIZE, BUF_SIZE),
_rx_thread(_nic, handler, _accept_ip)
{
/* start dispatcher thread */
_rx_thread.start();
@@ -316,7 +325,7 @@ class Remote_rom::Backend_base
_accept_ip = _src_ip;
} catch (...) {
PWRN("No IP configured, falling back to broadcast mode!");
Genode::warning("No IP configured, falling back to broadcast mode!");
_src_ip = Ipv4_packet::CURRENT;
_dst_ip = Ipv4_packet::BROADCAST;
_accept_ip = Ipv4_packet::BROADCAST;
@@ -417,7 +426,8 @@ class Remote_rom::Backend_server : public Backend_server_base, public Backend_ba
switch (packet.type())
{
case Packet_base::UPDATE:
if (verbose) PINF("receiving UPDATE (%s) packet", packet.module_name());
if (verbose)
Genode::log("receiving UPDATE (", packet.module_name(), ") packet");
if (!_forwarder)
return;
@@ -508,14 +518,16 @@ class Remote_rom::Backend_client : public Backend_client_base, public Backend_ba
switch (packet.type())
{
case Packet_base::SIGNAL:
if (verbose) PINF("receiving SIGNAL(%s) packet", packet.module_name());
if (verbose)
Genode::log("receiving SIGNAL(", packet.module_name(), ") packet");
/* send update request */
update(packet.module_name());
break;
case Packet_base::DATA:
if (verbose) PINF("receiving DATA(%s) packet", packet.module_name());
if (verbose)
Genode::log("receiving DATA(", packet.module_name(), ") packet");
/* write into buffer */
if (!_receiver) return;
@@ -531,7 +543,8 @@ class Remote_rom::Backend_client : public Backend_client_base, public Backend_ba
break;
case Packet_base::DATA_CONT:
if (verbose) PINF("receiving DATA_CONT(%s) packet", packet.module_name());
if (verbose)
Genode::log("receiving DATA_CONT(", packet.module_name(), ") packet");
if (!_receiver) return;

View File

@@ -351,6 +351,7 @@ static int genode_file_size(sqlite3_file *pFile, sqlite_int64 *pSize)
typedef Vfs::Directory_service::Stat_result Result;
switch(p->vfs->stat(p->path, stat)) {
case Result::STAT_ERR_NO_ENTRY: return SQLITE_IOERR_FSTAT;
case Result::STAT_ERR_NO_PERM: return SQLITE_IOERR_ACCESS;
case Result::STAT_OK: break;
}
*pSize = stat.size;
@@ -510,17 +511,17 @@ static int genode_open(
int sqlite3_os_init(void)
{
PINF("initializing native SQLite OS interface");
Genode::log("initializing native SQLite OS interface");
int ret = Jitter::jent_entropy_init();
if(ret) {
PERR("Jitter entropy initialization failed with error code %d", ret);
Genode::error("Jitter entropy initialization failed with error code ", ret);
return SQLITE_ERROR;
}
_jitter = Jitter::jent_entropy_collector_alloc(0, 0);
if (!_jitter) {
PERR("Jitter entropy collector initialization failed");
Genode::error("Jitter entropy collector initialization failed");
return SQLITE_ERROR;
}
@@ -538,11 +539,11 @@ int sqlite3_os_init(void)
PWRN("additional VFS created for SQLite");
} catch (Genode::Xml_node::Nonexistent_sub_node) {
PERR("no VFS defined for SQLite library");
Genode::error("no VFS defined for SQLite library");
return SQLITE_ERROR;
}
} catch (...) {
PERR("error loading VFS definition for SQLite library");
Genode::error("error loading VFS definition for SQLite library");
return SQLITE_ERROR;
}

View File

@@ -17,8 +17,9 @@
* under the terms of the GNU General Public License version 2.
*/
#include <base/printf.h>
#include <base/env.h>
#include <base/heap.h>
#include <base/log.h>
#include <util/volatile_object.h>
#include <util/list.h>
@@ -200,7 +201,7 @@ struct Remote_rom::Main : public Remote_rom::Read_buffer, public Remote_rom::Rom
void commit_new_content(bool abort=false)
{
if (abort)
PERR("abort not supported");
Genode::error("abort not supported");
// TODO release write lock
@@ -251,7 +252,7 @@ namespace Component {
Genode::Xml_node remote_rom = Genode::config()->xml_node().sub_node("remote_rom");
remote_rom.attribute("name").value(Remote_rom::remotename, sizeof(Remote_rom::remotename));
} catch (...) {
PERR("No ROM module configured!");
Genode::error("No ROM module configured!");
}
static Remote_rom::Main main(env);

View File

@@ -17,7 +17,7 @@
* under the terms of the GNU General Public License version 2.
*/
#include <base/printf.h>
#include <base/log.h>
#include <base/env.h>
#include <backend_base.h>
@@ -133,7 +133,7 @@ namespace Component {
remote_rom.attribute("binary").value(&Remote_rom::binary);
} catch (...) { }
} catch (...) {
PERR("No ROM module configured!");
Genode::error("No ROM module configured!");
}
static Remote_rom::Main main(env.ep());

View File

@@ -148,11 +148,11 @@ struct Proxy : Rpc_object<Typed_root<File_system::Session>>
catch (No_space) { errstr = "no space"; }
catch (...) { errstr = "unknown error"; }
PERR("%s: %s", new_root, errstr);
Genode::error(new_root, ": ", errstr);
throw Root::Unavailable();
}
void upgrade(Session_capability cap,
void upgrade(Session_capability cap,
Root::Upgrade_args const &args) override {
_parent_service.upgrade(cap, args.string()); }

View File

@@ -14,6 +14,7 @@
*/
/* Genode includes */
#include <base/log.h>
#include <input/component.h>
#include <framebuffer_session/connection.h>
#include <nitpicker_session/connection.h>
@@ -94,7 +95,7 @@ static uSynergyBool connect(uSynergyCookie cookie)
try {
config_node.attribute("addr").value(addr, sizeof(addr));
} catch (Xml_node::Nonexistent_attribute) {
PERR("server address not set in config");
Genode::error("server address not set in config");
return USYNERGY_FALSE;
}
@@ -111,7 +112,7 @@ static uSynergyBool connect(uSynergyCookie cookie)
sockaddr.sin_family = AF_INET;
sockaddr.sin_port = htons(port);
if (inet_pton(AF_INET, addr, &sockaddr.sin_addr.s_addr) == 0) {
PERR("bad IPv4 address %s for server", addr);
Genode::error("bad IPv4 address ", addr, " for server");
return USYNERGY_FALSE;
}
@@ -149,7 +150,7 @@ void sleep(uSynergyCookie, int timeMs) { timer()->msleep(timeMs); }
uint32_t get_time() { return timer()->elapsed_ms(); }
void trace_callback(uSynergyCookie cookie, const char *text) { PLOG("%s", text); }
void trace_callback(uSynergyCookie cookie, const char *text) { Genode::log(text); }
void screen_active_callback(uSynergyCookie cookie, uSynergyBool active)
{
@@ -227,12 +228,12 @@ void keyboard_callback(uSynergyCookie cookie,
** Network processing thread **
*******************************/
struct Synergy_thread : Thread_base
struct Synergy_thread : Thread
{
enum {
MAX_NAME_LEN = 256,
WEIGHT = Cpu_session::DEFAULT_WEIGHT,
WEIGHT = Cpu_session::Weight::DEFAULT_WEIGHT,
STACK_SIZE = 1024*sizeof(long)
};
@@ -242,7 +243,7 @@ struct Synergy_thread : Thread_base
Signal_context config_ctx;
Synergy_thread(Session_component &session)
: Thread_base(WEIGHT, "synergy_ep", STACK_SIZE)
: Thread(WEIGHT, "synergy_ep", STACK_SIZE)
{
*screen_name = 0;
uSynergyInit(&context);
@@ -282,14 +283,14 @@ struct Synergy_thread : Thread_base
try {
config_node.attribute("addr");;
} catch (Xml_node::Nonexistent_attribute) {
PERR("server address not set in config");
Genode::error("server address not set in config");
return false;
}
try {
config_node.attribute("name").value(screen_name, sizeof(screen_name));
} catch (Xml_node::Nonexistent_attribute) {
PERR("client screen name not set in config, waiting for update");
Genode::error("client screen name not set in config, waiting for update");
return false;
}
@@ -399,4 +400,4 @@ namespace Server {
size_t stack_size() { return 1; }
void construct(Entrypoint &ep) { static Main inst(ep); }
}
}

View File

@@ -19,6 +19,7 @@
#include <os/session_policy.h>
#include <os/path.h>
#include <base/attached_rom_dataspace.h>
#include <base/heap.h>
#include <root/component.h>
#include <base/component.h>
#include <util/list.h>

View File

@@ -1,4 +1,3 @@
#include <base/printf.h>
#include <timer_session/connection.h>
#include <glucose/core/Solver.h>
@@ -6,6 +5,8 @@
#include <trace/timestamp.h>
#include <stdio.h>
// this value is for the Raspberry Pi
#define TICKS_PER_USEC (700.0/64.0)
@@ -19,27 +20,27 @@ inline double cpuTime()
void printStats(Solver& solver, double initial_time, Genode::Trace::Timestamp start_ts)
{
Genode::Trace::Timestamp ts_ticks = Genode::Trace::timestamp() - start_ts;
double cpu_time = cpuTime() - initial_time;
double mem_used = 0;//memUsedPeak();
printf("c restarts : %lld (%lld conflicts in avg)\n", solver.starts,(solver.starts>0 ?solver.conflicts/solver.starts : 0));
printf("c blocked restarts : %lld (multiple: %lld) \n", solver.nbstopsrestarts,solver.nbstopsrestartssame);
printf("c last block at restart : %lld\n",solver.lastblockatrestart);
printf("c nb ReduceDB : %lld\n", solver.nbReduceDB);
printf("c nb removed Clauses : %lld\n",solver.nbRemovedClauses);
printf("c nb learnts DL2 : %lld\n", solver.nbDL2);
printf("c nb learnts size 2 : %lld\n", solver.nbBin);
printf("c nb learnts size 1 : %lld\n", solver.nbUn);
Genode::Trace::Timestamp ts_ticks = Genode::Trace::timestamp() - start_ts;
double cpu_time = cpuTime() - initial_time;
double mem_used = 0;//memUsedPeak();
printf("c restarts : %lld (%lld conflicts in avg)\n", solver.starts,(solver.starts>0 ?solver.conflicts/solver.starts : 0));
printf("c blocked restarts : %lld (multiple: %lld) \n", solver.nbstopsrestarts,solver.nbstopsrestartssame);
printf("c last block at restart : %lld\n",solver.lastblockatrestart);
printf("c nb ReduceDB : %lld\n", solver.nbReduceDB);
printf("c nb removed Clauses : %lld\n",solver.nbRemovedClauses);
printf("c nb learnts DL2 : %lld\n", solver.nbDL2);
printf("c nb learnts size 2 : %lld\n", solver.nbBin);
printf("c nb learnts size 1 : %lld\n", solver.nbUn);
printf("c conflicts : %-12lld (%.0f /sec)\n", solver.conflicts , solver.conflicts /cpu_time);
printf("c decisions : %-12lld (%4.2f %% random) (%.0f /sec)\n", solver.decisions, (float)solver.rnd_decisions*100 / (float)solver.decisions, solver.decisions /cpu_time);
printf("c propagations : %-12lld (%.0f /sec)\n", solver.propagations, solver.propagations/cpu_time);
printf("c conflict literals : %-12lld (%4.2f %% deleted)\n", solver.tot_literals, (solver.max_literals - solver.tot_literals)*100 / (double)solver.max_literals);
printf("c nb reduced Clauses : %lld\n",solver.nbReducedClauses);
if (mem_used != 0) printf("Memory used : %.2f MB\n", mem_used);
printf("c CPU time : %.2f ms\n", cpu_time);
printf("c TS ticks : %d (%.1f µs)\n", ts_ticks, (double)ts_ticks/TICKS_PER_USEC);
printf("c conflicts : %-12lld (%.0f /sec)\n", solver.conflicts , solver.conflicts /cpu_time);
printf("c decisions : %-12lld (%4.2f %% random) (%.0f /sec)\n", solver.decisions, (float)solver.rnd_decisions*100 / (float)solver.decisions, solver.decisions /cpu_time);
printf("c propagations : %-12lld (%.0f /sec)\n", solver.propagations, solver.propagations/cpu_time);
printf("c conflict literals : %-12lld (%4.2f %% deleted)\n", solver.tot_literals, (solver.max_literals - solver.tot_literals)*100 / (double)solver.max_literals);
printf("c nb reduced Clauses : %lld\n",solver.nbReducedClauses);
if (mem_used != 0) printf("Memory used : %.2f MB\n", mem_used);
printf("c CPU time : %.2f ms\n", cpu_time);
printf("c TS ticks : %u (%.1f µs)\n", (unsigned)ts_ticks, (double)ts_ticks/TICKS_PER_USEC);
}
int main()
@@ -63,7 +64,7 @@ int main()
printf("c | Number of clauses: %12d |\n", S.nClauses());
printf("c | Parse time: %12.2f ms |\n", parsed_time - initial_time);
printf("c | Parse ticks: %d (%.1f µs) |\n", parse_ticks - start_ts, (double)(parse_ticks-start_ts)/TICKS_PER_USEC);
printf("c | Parse ticks: %u (%.1f µs) |\n", (unsigned)parse_ticks - start_ts, (double)(parse_ticks-start_ts)/TICKS_PER_USEC);
printf("c | |\n");
if (!S.simplify()){
@@ -92,10 +93,10 @@ int main()
/* solver finished */
PINF("Okay");
Genode::log("Okay");
}
else {
PERR("Unable to open file \"Test.cnf\"");
Genode::error("Unable to open file \"Test.cnf\"");
return 1;
}