From 954aff700285588358df8a66d6ac9be1ef4f275b Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Mon, 21 Jan 2019 14:27:12 +0100 Subject: [PATCH] demo: avoid using deprecated APIs Issue #1987 Issue #3125 --- repos/demo/include/launchpad/launchpad.h | 24 +++--- repos/demo/include/scout/canvas.h | 1 + repos/demo/include/scout/printf.h | 21 ----- repos/demo/lib/mk/mini_c.mk | 3 +- repos/demo/recipes/src/demo/hash | 2 +- .../demo/src/app/launchpad/launchpad_window.h | 3 +- repos/demo/src/app/launchpad/loadbar.h | 39 +++++---- repos/demo/src/app/launchpad/main.cc | 17 ++-- repos/demo/src/app/scout/elements.h | 1 - repos/demo/src/app/scout/launcher.cc | 36 ++++---- repos/demo/src/app/scout/main.cc | 6 +- repos/demo/src/app/scout/png_image.cc | 2 +- repos/demo/src/app/scout/tick.cc | 7 +- repos/demo/src/lib/launchpad/launchpad.cc | 20 +++-- repos/demo/src/lib/libpng/main.cc | 8 +- repos/demo/src/lib/mini_c/mini_c.c | 84 ------------------- repos/demo/src/lib/mini_c/mini_c.cc | 81 ++++++++++++++++++ repos/demo/src/lib/mini_c/printf.cc | 24 ------ .../src/server/liquid_framebuffer/main.cc | 72 +++------------- .../src/server/liquid_framebuffer/services.cc | 8 +- .../src/server/liquid_framebuffer/services.h | 2 +- 21 files changed, 177 insertions(+), 284 deletions(-) delete mode 100644 repos/demo/include/scout/printf.h delete mode 100644 repos/demo/src/lib/mini_c/mini_c.c create mode 100644 repos/demo/src/lib/mini_c/mini_c.cc delete mode 100644 repos/demo/src/lib/mini_c/printf.cc diff --git a/repos/demo/include/launchpad/launchpad.h b/repos/demo/include/launchpad/launchpad.h index 297a92aa7..0629427df 100644 --- a/repos/demo/include/launchpad/launchpad.h +++ b/repos/demo/include/launchpad/launchpad.h @@ -152,25 +152,29 @@ class Launchpad_child : public Genode::Child_policy, Genode::Id_space &server_id_space() override { return _session_requester.id_space(); } - Genode::Service &resolve_session_request(Genode::Service::Name const &service_name, - Genode::Session_state::Args const &args) override + Genode::Child_policy::Route + resolve_session_request(Genode::Service::Name const &service_name, + Genode::Session_label const &label) override { + auto route = [&] (Genode::Service &service) { + return Genode::Child_policy::Route { .service = service, + .label = label, + .diag = Genode::Session::Diag() }; }; + Genode::Service *service = nullptr; /* check for config file request */ - if ((service = _config_policy - .resolve_session_request(service_name.string(), args.string()))) - return *service; + if ((service = _config_policy.resolve_session_request_with_label(service_name, label))) + return route(*service); /* check for "session_requests" ROM request */ - Genode::Session_label const label(Genode::label_from_args(args.string())); if (service_name == Genode::Rom_session::service_name() && label.last_element() == Genode::Session_requester::rom_name()) - return _session_requester.service(); + return route(_session_requester.service()); /* if service is provided by one of our children, use it */ if ((service = _find_service(_child_services, service_name))) - return *service; + return route(*service); /* * Handle special case of the demo scenario when the user uses @@ -189,7 +193,7 @@ class Launchpad_child : public Genode::Child_policy, if (service_name != "Input" && service_name != "Framebuffer" && ((service = _find_service(_parent_services, service_name)))) - return *service; + return route(*service); Genode::warning(name(), ": service ", service_name, " not available"); throw Genode::Service_denied(); @@ -206,7 +210,7 @@ class Launchpad_child : public Genode::Child_policy, Child_service(_child_services, service_name, _session_requester.id_space(), _child.session_factory(), *this, - _child.ram_session_cap(), + _child.pd_session_cap(), _child.pd_session_cap()); } }; diff --git a/repos/demo/include/scout/canvas.h b/repos/demo/include/scout/canvas.h index 695142781..a3383fbc3 100644 --- a/repos/demo/include/scout/canvas.h +++ b/repos/demo/include/scout/canvas.h @@ -14,6 +14,7 @@ #ifndef _INCLUDE__SCOUT__CANVAS_H_ #define _INCLUDE__SCOUT__CANVAS_H_ +#include #include #include #include diff --git a/repos/demo/include/scout/printf.h b/repos/demo/include/scout/printf.h deleted file mode 100644 index e2951bbbd..000000000 --- a/repos/demo/include/scout/printf.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * \brief Printf wrapper for Genode - * \date 2008-07-24 - * \author Norman Feske - */ - -/* - * Copyright (C) 2008-2017 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU Affero General Public License version 3. - */ - -#ifndef _INCLUDE__SCOUT__PRINTF_H_ -#define _INCLUDE__SCOUT__PRINTF_H_ - -#include - -namespace Scout { using Genode::printf; } - -#endif /* _INCLUDE__SCOUT__PRINTF_H_ */ diff --git a/repos/demo/lib/mk/mini_c.mk b/repos/demo/lib/mk/mini_c.mk index bd3f0a579..bebc27fa5 100644 --- a/repos/demo/lib/mk/mini_c.mk +++ b/repos/demo/lib/mk/mini_c.mk @@ -1,7 +1,6 @@ -SRC_C = mini_c.c SRC_CC = snprintf.cc vsnprintf.cc atol.cc strtol.cc strtod.cc \ malloc_free.cc memcmp.cc strlen.cc memset.cc abort.cc \ - printf.cc + mini_c.cc STDINC = yes diff --git a/repos/demo/recipes/src/demo/hash b/repos/demo/recipes/src/demo/hash index 42918e833..c49c62bdb 100644 --- a/repos/demo/recipes/src/demo/hash +++ b/repos/demo/recipes/src/demo/hash @@ -1 +1 @@ -2019-01-13 38882b356b93cc25f3e703714b588ac7530ec214 +2019-01-20 351e8fe91513154f62f015378e400386ffa07778 diff --git a/repos/demo/src/app/launchpad/launchpad_window.h b/repos/demo/src/app/launchpad/launchpad_window.h index 25db855aa..c5816ff1f 100644 --- a/repos/demo/src/app/launchpad/launchpad_window.h +++ b/repos/demo/src/app/launchpad/launchpad_window.h @@ -33,7 +33,6 @@ #include "section.h" #include -#include template class Launchpad_window : public Scout::Scrollbar_listener, @@ -170,7 +169,7 @@ class Launchpad_window : public Scout::Scrollbar_listener, break; if (!ce) { - PWRN("child entry lookup failed"); + Genode::warning("child entry lookup failed"); return; } diff --git a/repos/demo/src/app/launchpad/loadbar.h b/repos/demo/src/app/launchpad/loadbar.h index 978b70dc3..086a8e157 100644 --- a/repos/demo/src/app/launchpad/loadbar.h +++ b/repos/demo/src/app/launchpad/loadbar.h @@ -18,10 +18,6 @@ #include "styles.h" #include "fade_icon.h" -#include -#include - - #define LOADBAR_RGBA _binary_loadbar_rgba_start #define REDBAR_RGBA _binary_redbar_rgba_start #define WHITEBAR_RGBA _binary_whitebar_rgba_start @@ -226,27 +222,31 @@ class Kbyte_loadbar : public Loadbar { private: - char _label[32]; + typedef Genode::String<32> Label; - void _print_kbytes(int kbytes, char *dst, int dst_len) + Label _label { }; + + struct Kbytes { - if (kbytes >= 10*1024) - Genode::snprintf(dst, dst_len, "%d MByte", kbytes / 1024); - else - Genode::snprintf(dst, dst_len, "%d KByte", kbytes); - } + int const _value; + + Kbytes(int value) : _value(value) { } + + void print(Genode::Output &out) const + { + if (_value >= 10*1024) + Genode::print(out, _value/1024, " MByte"); + else + Genode::print(out, _value, " KByte"); + } + }; void _update_label() { - char value_buf[16]; - char max_buf[16]; + _label = Label(Kbytes(Loadbar::value()), " / ", + Kbytes(Loadbar::max_value())); - _print_kbytes(Loadbar::value(), value_buf, sizeof(value_buf)); - _print_kbytes(Loadbar::max_value(), max_buf, sizeof(max_buf)); - - Genode::snprintf(_label, sizeof(_label), "%s / %s", value_buf, max_buf); - - Loadbar::txt(_label); + Loadbar::txt(_label.string()); } public: @@ -254,7 +254,6 @@ class Kbyte_loadbar : public Loadbar Kbyte_loadbar(Loadbar_listener *listener, Scout::Font *font = 0): Loadbar(listener, font) { - _label[0] = 0; _update_label(); } diff --git a/repos/demo/src/app/launchpad/main.cc b/repos/demo/src/app/launchpad/main.cc index ca8678565..b3cc48e43 100644 --- a/repos/demo/src/app/launchpad/main.cc +++ b/repos/demo/src/app/launchpad/main.cc @@ -18,7 +18,6 @@ #include #include #include -#include #include #include "config.h" @@ -42,18 +41,18 @@ class Avail_quota_update : public Scout::Tick { private: - Ram_session &_ram; - Launchpad &_launchpad; - size_t _avail = 0; + Pd_session &_pd; + Launchpad &_launchpad; + size_t _avail = 0; public: /** * Constructor */ - Avail_quota_update(Ram_session &ram, Launchpad &launchpad) + Avail_quota_update(Pd_session &pd, Launchpad &launchpad) : - _ram(ram), _launchpad(launchpad) + _pd(pd), _launchpad(launchpad) { schedule(200); } @@ -63,7 +62,7 @@ class Avail_quota_update : public Scout::Tick */ int on_tick() { - size_t new_avail = _ram.avail_ram().value; + size_t new_avail = _pd.avail_ram().value; /* update launchpad window if needed */ if (new_avail != _avail) @@ -108,7 +107,7 @@ struct Main : Scout::Event_handler Launchpad_window _launchpad { _env, _graphics_backend, _initial_position, _initial_size, - _max_size, _env.ram().avail_ram().value }; + _max_size, _env.pd().avail_ram().value }; void _process_config() { @@ -117,7 +116,7 @@ struct Main : Scout::Event_handler bool const _config_processed = (_process_config(), true); - Avail_quota_update _avail_quota_update { _env.ram(), _launchpad }; + Avail_quota_update _avail_quota_update { _env.pd(), _launchpad }; User_state _user_state { &_launchpad, &_launchpad, _initial_position.x(), _initial_position.y() }; diff --git a/repos/demo/src/app/scout/elements.h b/repos/demo/src/app/scout/elements.h index 2fb120055..ed658f533 100644 --- a/repos/demo/src/app/scout/elements.h +++ b/repos/demo/src/app/scout/elements.h @@ -15,7 +15,6 @@ #define _ELEMENTS_H_ #include -#include #include #include #include diff --git a/repos/demo/src/app/scout/launcher.cc b/repos/demo/src/app/scout/launcher.cc index fe883ad96..d2225a7ee 100644 --- a/repos/demo/src/app/scout/launcher.cc +++ b/repos/demo/src/app/scout/launcher.cc @@ -12,10 +12,8 @@ */ #include +#include #include -#include -#include -#include #include "elements.h" using namespace Genode; @@ -54,25 +52,19 @@ class Config_registry struct Config_registry::Entry : List::Element { - Dataspace_capability _init_dataspace(char const *name) + String<128> const name; + + Constructible dataspace { }; + + Dataspace_capability ds_cap { }; + + Entry(char const *prg_name) : name(prg_name) { - char buf[256]; - snprintf(buf, sizeof(buf), "%s.config", name); - Rom_connection *config = 0; try { - config = new (*_alloc_ptr) Rom_connection(*_env_ptr, buf); - return config->dataspace(); + dataspace.construct(*_env_ptr, String<256>(name, ".config").string()); + ds_cap = dataspace->cap(); } catch (...) { } - return Dataspace_capability(); - } - - Dataspace_capability const dataspace; - char name[128]; - - Entry(char const *prg_name) : dataspace(_init_dataspace(prg_name)) - { - strncpy(name, prg_name, sizeof(name)); } }; @@ -81,14 +73,14 @@ Dataspace_capability Config_registry::config(char const *name) { /* lookup existing configuration */ for (Entry *e = _configs.first(); e; e = e->next()) - if (strcmp(name, e->name) == 0) - return e->dataspace; + if (e->name == name) + return e->ds_cap; /* if lookup failed, create and register new config */ Entry *entry = new (*_alloc_ptr) Entry(name); _configs.insert(entry); - return entry->dataspace; + return entry->ds_cap; } @@ -98,7 +90,7 @@ Dataspace_capability Config_registry::config(char const *name) void Launcher::init(Genode::Env &env, Allocator &alloc) { - static Launchpad launchpad(env, env.ram().avail_ram().value); + static Launchpad launchpad(env, env.pd().avail_ram().value); _launchpad_ptr = &launchpad; _alloc_ptr = &alloc; _env_ptr = &env; diff --git a/repos/demo/src/app/scout/main.cc b/repos/demo/src/app/scout/main.cc index b720b4cf7..9488deb19 100644 --- a/repos/demo/src/app/scout/main.cc +++ b/repos/demo/src/app/scout/main.cc @@ -69,9 +69,9 @@ struct Scout::Main : Scout::Event_handler bool const _event_handler_registered = (_platform.event_handler(*this), true); - Area const _max_size { 530, 620 }; - Point const _initial_position { 256, 80 }; - Area const _initial_size { 530, 400 }; + Area const _max_size { 530, 620 }; + Point const _initial_position { 256, 80 }; + Area const _initial_size { 530, 400 }; Config const _config { }; diff --git a/repos/demo/src/app/scout/png_image.cc b/repos/demo/src/app/scout/png_image.cc index be088341d..0040c52cb 100644 --- a/repos/demo/src/app/scout/png_image.cc +++ b/repos/demo/src/app/scout/png_image.cc @@ -104,7 +104,7 @@ void Png_image::fill_cache(Canvas_base &canvas) &interlace_type, int_p_NULL, int_p_NULL); _min_size = Scout::Area(w, h); - printf("png is %d x %d, depth=%d\n", _min_size.w(), _min_size.h(), bit_depth); + log("png is ", _min_size, " depth=", bit_depth); if (color_type == PNG_COLOR_TYPE_PALETTE) png_set_palette_to_rgb(png_ptr); diff --git a/repos/demo/src/app/scout/tick.cc b/repos/demo/src/app/scout/tick.cc index 37ccb9a93..115739236 100644 --- a/repos/demo/src/app/scout/tick.cc +++ b/repos/demo/src/app/scout/tick.cc @@ -12,7 +12,6 @@ */ #include -#include using namespace Scout; @@ -24,7 +23,6 @@ void Tick::_enqueue() { /* do not enqueue twice */ if (++_active > 1) { -// printf("enqueue twice? ticks scheduled=%d\n", ticks_scheduled()); _active--; return; } @@ -94,10 +92,7 @@ void Tick::schedule(time period) int Tick::ticks_scheduled() { int num_ticks = 0; - printf("now=%d\n", (int)now); - for (Tick *curr = head; curr; curr = curr->_next, num_ticks++) - printf("ticks_scheduled:\n %d: curr=%p, deadline=%d\n", - (int)num_ticks, curr, (int)curr->_deadline); + for (Tick *curr = head; curr; curr = curr->_next, num_ticks++); return num_ticks; } diff --git a/repos/demo/src/lib/launchpad/launchpad.cc b/repos/demo/src/lib/launchpad/launchpad.cc index 45eb4b3cd..aad6c5d6e 100644 --- a/repos/demo/src/lib/launchpad/launchpad.cc +++ b/repos/demo/src/lib/launchpad/launchpad.cc @@ -44,7 +44,7 @@ Launchpad::Launchpad(Env &env, unsigned long initial_quota) 0 /* null-termination */ }; for (unsigned i = 0; names[i]; i++) - new (_heap) Launchpad_child::Parent_service(_parent_services, names[i]); + new (_heap) Launchpad_child::Parent_service(_parent_services, env, names[i]); } @@ -129,13 +129,15 @@ void Launchpad::process_config(Genode::Xml_node config_node) Xml_node config_node = node.sub_node("config"); - /* allocate dataspace for config */ - size_t const size = config_node.size(); - config_ds = _env.ram().alloc(size); + config_node.with_raw_node([&] (char const *start, size_t length) { - /* copy configuration into new dataspace */ - Attached_dataspace attached(_env.rm(), config_ds); - memcpy(attached.local_addr(), config_node.addr(), size); + /* allocate dataspace for config */ + config_ds = _env.ram().alloc(length); + + /* copy configuration into new dataspace */ + Attached_dataspace attached(_env.rm(), config_ds); + memcpy(attached.local_addr(), start, length); + }); } /* add launchpad entry */ @@ -154,10 +156,10 @@ Launchpad_child *Launchpad::start_child(Launchpad_child::Name const &binary_name Launchpad_child::Name const unique_name = _get_unique_child_name(binary_name); log("using unique child name \"", unique_name, "\""); - if (ram_quota.value > _env.ram().avail_ram().value) { + if (ram_quota.value > _env.pd().avail_ram().value) { warning("child's ram quota is higher than our available quota, using available quota"); - size_t const avail = _env.ram().avail_ram().value; + size_t const avail = _env.pd().avail_ram().value; size_t const preserved = 256*1024; if (avail < preserved) { diff --git a/repos/demo/src/lib/libpng/main.cc b/repos/demo/src/lib/libpng/main.cc index fea8d467b..b53a67b7a 100644 --- a/repos/demo/src/lib/libpng/main.cc +++ b/repos/demo/src/lib/libpng/main.cc @@ -1,4 +1,4 @@ -#include +#include extern "C" { #include @@ -8,9 +8,7 @@ extern "C" { using namespace Genode; -static void user_read_data(png_structp, png_bytep, png_size_t) -{ -} +static void user_read_data(png_structp, png_bytep, png_size_t) { } int main(int, char **) { @@ -34,7 +32,7 @@ int main(int, char **) &interlace_type, int_p_NULL, int_p_NULL); int _min_w = w; int _min_h = h; - printf("png is %d x %d, depth=%d\n", _min_w, _min_h, bit_depth); + log("png is ", _min_w, " x ", _min_h, ", depth=", bit_depth); if (color_type == PNG_COLOR_TYPE_PALETTE) png_set_palette_to_rgb(png_ptr); diff --git a/repos/demo/src/lib/mini_c/mini_c.c b/repos/demo/src/lib/mini_c/mini_c.c deleted file mode 100644 index d6d6b4716..000000000 --- a/repos/demo/src/lib/mini_c/mini_c.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * \brief Mini C dummy functions - * \author Christian Helmuth - * \date 2008-07-24 - */ - -/* - * Copyright (C) 2008-2017 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU Affero General Public License version 3. - */ - -#include - -#ifdef GENODE_RELEASE -#define printf(...) -#endif /* GENODE_RELEASE */ - -int sprintf(char *str, const char *format, ...) - { printf("%s: not implemented\n", __func__); return 0; } -FILE *fopen(const char *path, const char *mode) - { printf("%s: not implemented\n", __func__); return 0; } -FILE *fdopen(int fildes, const char *mode) - { printf("%s: not implemented\n", __func__); return 0; } -int fclose(FILE *fp) - { printf("%s: not implemented\n", __func__); return 0; } -int fprintf(FILE *stream, const char *format, ...) - { printf("%s: not implemented\n", __func__); return 0; } -size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) - { printf("%s: not implemented\n", __func__); return 0; } -unsigned fread(void *ptr, unsigned size, unsigned nmemb, FILE *stream) - { printf("%s: not implemented\n", __func__); return 0; } -int fputc(int c, FILE *stream) - { printf("%s: not implemented\n", __func__); return 0; } -int fflush(FILE *stream) - { printf("%s: not implemented\n", __func__); return 0; } -int fseek(FILE *stream, long offset, int whence) - { printf("%s: not implemented\n", __func__); return 0; } -long ftell(FILE *stream) - { printf("%s: not implemented\n", __func__); return 0; } -void clearerr(FILE *stream) - { printf("%s: not implemented\n", __func__); } -int ferror(FILE *stream) - { printf("%s: not implemented\n", __func__); return 0; } -int puts(const char *s) - { printf("%s", s); return 1; } -int putchar(int c) - { printf("%c", c); return c; } - -#include - -int abs(int j) -{ - return j < 0 ? -j : j; -} - -/* in alloc_env_backend.cc -void *calloc(unsigned nmemb, unsigned size) - { printf("%s: not implemented\n", __func__); return 0; } -*/ - -#include - -/* in base/cxx -void *memcpy(void *dest, const void *src, unsigned n); -*/ -char *strcpy(char *dest, const char *src) - { return strncpy(dest, src, ~0); } -char *strcat(char *dest, const char *src) - { printf("%s: not implemented\n", __func__); return 0; } - -static inline size_t min(size_t v1, size_t v2) { return v1 < v2 ? v1 : v2; } - -char *strncpy(char *dst, const char *src, size_t n) -{ - n = min(n, strlen(src) + 1); - memcpy(dst, src, n); - if (n > 0) dst[n - 1] = 0; - return dst; -} - -char *strerror(int errnum) - { printf("%s: not implemented\n", __func__); return 0; } diff --git a/repos/demo/src/lib/mini_c/mini_c.cc b/repos/demo/src/lib/mini_c/mini_c.cc new file mode 100644 index 000000000..8c3ee4c58 --- /dev/null +++ b/repos/demo/src/lib/mini_c/mini_c.cc @@ -0,0 +1,81 @@ +/* + * \brief Mini C dummy functions + * \author Christian Helmuth + * \date 2008-07-24 + */ + +/* + * Copyright (C) 2008-2017 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU Affero General Public License version 3. + */ + +#include + +#define NOT_IMPLEMENTED Genode::log(__func__, " not implemented") + +extern "C" { + +#include + +int sprintf(char *, const char *, ...) + { NOT_IMPLEMENTED; return 0; } +int printf(const char *, ...) + { NOT_IMPLEMENTED; return 0; } +FILE *fopen(const char *, const char *) + { NOT_IMPLEMENTED; return 0; } +FILE *fdopen(int, const char *) + { NOT_IMPLEMENTED; return 0; } +int fclose(FILE *) + { NOT_IMPLEMENTED; return 0; } +int fprintf(FILE *, const char *, ...) + { NOT_IMPLEMENTED; return 0; } +size_t fwrite(const void *, size_t, size_t, FILE *) + { NOT_IMPLEMENTED; return 0; } +unsigned fread(void *, unsigned, unsigned, FILE *) + { NOT_IMPLEMENTED; return 0; } +int fputc(int, FILE *) + { NOT_IMPLEMENTED; return 0; } +int fflush(FILE *) + { NOT_IMPLEMENTED; return 0; } +int fseek(FILE *, long, int) + { NOT_IMPLEMENTED; return 0; } +long ftell(FILE *) + { NOT_IMPLEMENTED; return 0; } +void clearerr(FILE *) + { NOT_IMPLEMENTED; } +int ferror(FILE *) + { NOT_IMPLEMENTED; return 0; } +int puts(const char *s) + { Genode::log("%s", s); return 1; } +int putchar(int c) + { Genode::log("%c", c); return c; } + +#include + +int abs(int j) +{ + return j < 0 ? -j : j; +} + +#include + +char *strcpy(char *dest, const char *src) + { return strncpy(dest, src, ~0); } +char *strcat(char *, const char *) + { NOT_IMPLEMENTED; return 0; } + +static inline size_t min(size_t v1, size_t v2) { return v1 < v2 ? v1 : v2; } + +char *strncpy(char *dst, const char *src, size_t n) +{ + n = min(n, strlen(src) + 1); + memcpy(dst, src, n); + if (n > 0) dst[n - 1] = 0; + return dst; +} + +char *strerror(int) { NOT_IMPLEMENTED; return 0; } + +} /* extern "C" */ diff --git a/repos/demo/src/lib/mini_c/printf.cc b/repos/demo/src/lib/mini_c/printf.cc deleted file mode 100644 index 6f5d30203..000000000 --- a/repos/demo/src/lib/mini_c/printf.cc +++ /dev/null @@ -1,24 +0,0 @@ -/* - * \brief Mini C printf() - * \author Norman Feske - * \date 2008-10-23 - */ - -/* - * Copyright (C) 2008-2017 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU Affero General Public License version 3. - */ - -#include - -extern "C" void printf(const char *format, ...) -{ - va_list list; - va_start(list, format); - - Genode::vprintf(format, list); - - va_end(list); -} diff --git a/repos/demo/src/server/liquid_framebuffer/main.cc b/repos/demo/src/server/liquid_framebuffer/main.cc index 958d70f78..20916a126 100644 --- a/repos/demo/src/server/liquid_framebuffer/main.cc +++ b/repos/demo/src/server/liquid_framebuffer/main.cc @@ -79,7 +79,8 @@ static long config_fb_y = 260; /** * Window title */ -static const char *config_title = "Liquid Framebuffer"; +typedef Genode::String<128> Title; +static Title config_title { "Liquid Framebuffer" }; /** * Resize handle @@ -94,63 +95,16 @@ static bool config_decoration = true; /** * Parse configuration */ -static void read_config(Genode::Xml_node config_node) +static void read_config(Genode::Xml_node node) { - using namespace Genode; - - try { - char buf[16]; - config_node.attribute("animate").value(buf, sizeof(buf)); - - if (!strcmp("off", buf)) config_animate = false; - else if (!strcmp("on", buf)) config_animate = true; - else - Genode::printf("Warning: invalid value for animate declaration,\n" - " valid values are 'on', 'off.\n'"); - } catch (Xml_node::Nonexistent_attribute) { } - - config_alpha = config_animate; - - try { config_node.attribute("xpos").value(&config_fb_x); } - catch (Xml_node::Nonexistent_attribute) { } - - try { config_node.attribute("ypos").value(&config_fb_y); } - catch (Xml_node::Nonexistent_attribute) { } - - try { config_node.attribute("width").value(&config_fb_width); } - catch (Xml_node::Nonexistent_attribute) { } - - try { config_node.attribute("height").value(&config_fb_height); } - catch (Xml_node::Nonexistent_attribute) { } - - try { - static char buf[64]; - config_node.attribute("title").value(buf, sizeof(buf)); - config_title = buf; - } catch (Xml_node::Nonexistent_attribute) { } - - try { - char buf[16]; - config_node.attribute("decoration").value(buf, sizeof(buf)); - - if (!strcmp("off", buf)) config_decoration = false; - else if (!strcmp("on", buf)) config_decoration = true; - else - Genode::printf("Warning: invalid value for decoration declaration,\n" - " valid values are 'on', 'off.\n'"); - } catch (Xml_node::Nonexistent_attribute) { } - - try { - char buf[16]; - config_node.attribute("resize_handle").value(buf, sizeof(buf)); - - if (!strcmp("off", buf)) config_resize_handle = false; - else if (!strcmp("on", buf)) config_resize_handle = true; - else - Genode::printf("Warning: invalid value for resize_handle declaration,\n" - " valid values are 'on', 'off.\n'"); - } catch (Xml_node::Nonexistent_attribute) { } - + config_fb_x = node.attribute_value("xpos", config_fb_x); + config_fb_y = node.attribute_value("ypos", config_fb_y); + config_fb_width = node.attribute_value("width", config_fb_width); + config_fb_height = node.attribute_value("height", config_fb_height); + config_title = node.attribute_value("title", config_title); + config_animate = node.attribute_value("animate", true); + config_decoration = node.attribute_value("decoration", true); + config_resize_handle = node.attribute_value("resize_handle", true); } @@ -218,7 +172,7 @@ class Liquid_fb::Main : public Scout::Event_handler Framebuffer_window _fb_win { _graphics_backend, window_content(), _initial_position, _initial_size, _max_size, - config_title, config_alpha, + config_title.string(), config_alpha, config_resize_handle, config_decoration }; /* create background animator if configured */ @@ -260,7 +214,7 @@ class Liquid_fb::Main : public Scout::Event_handler try { read_config(_config.xml()); } catch (...) { } - _fb_win.name(config_title); + _fb_win.name(config_title.string()); _fb_win.config_alpha(config_alpha); _fb_win.config_resize_handle(config_resize_handle); _fb_win.config_decoration(config_decoration); diff --git a/repos/demo/src/server/liquid_framebuffer/services.cc b/repos/demo/src/server/liquid_framebuffer/services.cc index b887b5749..5df023a9b 100644 --- a/repos/demo/src/server/liquid_framebuffer/services.cc +++ b/repos/demo/src/server/liquid_framebuffer/services.cc @@ -85,7 +85,7 @@ class Window_content : public Scout::Element unsigned char *alpha; Genode::Texture texture; - Fb_texture(Genode::Ram_session &ram, Genode::Region_map &local_rm, + Fb_texture(Genode::Ram_allocator &ram, Genode::Region_map &local_rm, Genode::Allocator &alloc, unsigned w, unsigned h, bool config_alpha) : @@ -128,7 +128,7 @@ class Window_content : public Scout::Element }; - Genode::Ram_session &_ram; + Genode::Ram_allocator &_ram; Genode::Region_map &_rm; Genode::Allocator &_alloc; bool _config_alpha; @@ -157,7 +157,7 @@ class Window_content : public Scout::Element public: - Window_content(Genode::Ram_session &ram, Genode::Region_map &rm, + Window_content(Genode::Ram_allocator &ram, Genode::Region_map &rm, Genode::Allocator &alloc, unsigned fb_w, unsigned fb_h, Input::Session_component &input_session, bool config_alpha) @@ -270,7 +270,7 @@ class Framebuffer::Session_component : public Genode::Rpc_object }; -void init_window_content(Genode::Ram_session &ram, Genode::Region_map &rm, +void init_window_content(Genode::Ram_allocator &ram, Genode::Region_map &rm, Genode::Allocator &alloc, Input::Session_component &input_component, unsigned fb_w, unsigned fb_h, bool config_alpha) diff --git a/repos/demo/src/server/liquid_framebuffer/services.h b/repos/demo/src/server/liquid_framebuffer/services.h index 5ee96c4f7..64bf20dbe 100644 --- a/repos/demo/src/server/liquid_framebuffer/services.h +++ b/repos/demo/src/server/liquid_framebuffer/services.h @@ -21,7 +21,7 @@ #include "elements.h" extern Scout::Element *window_content(); -extern void init_window_content(Genode::Ram_session &, Genode::Region_map &, +extern void init_window_content(Genode::Ram_allocator &, Genode::Region_map &, Genode::Allocator &, Input::Session_component &, unsigned fb_w, unsigned fb_h, bool config_alpha); extern void init_services(Genode::Env &, Input::Session_component &);