From f635cc4a192544499d16ec23dbff51f4f1655aaf Mon Sep 17 00:00:00 2001 From: Christian Prochaska Date: Mon, 8 Oct 2012 14:39:34 +0200 Subject: [PATCH] Python: use 'libc-rom' plugin This patch removes the libc plugin of the Python port. The Python test uses the 'libc_rom' plugin instead. Fixes #392. --- libports/lib/mk/python.inc | 3 - libports/run/python.run | 2 +- libports/src/lib/python/libc_plugin.cc | 109 -------------------- libports/src/lib/python/libc_plugin_init.cc | 18 ---- libports/src/test/python/target.mk | 2 +- 5 files changed, 2 insertions(+), 132 deletions(-) delete mode 100644 libports/src/lib/python/libc_plugin.cc delete mode 100644 libports/src/lib/python/libc_plugin_init.cc diff --git a/libports/lib/mk/python.inc b/libports/lib/mk/python.inc index 4cc365c851..f97a1a021a 100644 --- a/libports/lib/mk/python.inc +++ b/libports/lib/mk/python.inc @@ -15,9 +15,6 @@ D_OPTS := $(addprefix -D,$(D_OPTS)) F_OPTS := $(addprefix -f,$(F_OPTS)) CC_DEF += $(F_OPTS) $(D_OPTS) -# libc back-end -SRC_CC = libc_plugin.cc libc_plugin_init.cc - # python.c # SRC_C = \ diff --git a/libports/run/python.run b/libports/run/python.run index 118c20ac1c..2607167096 100644 --- a/libports/run/python.run +++ b/libports/run/python.run @@ -57,7 +57,7 @@ exec cp [genode_dir]/libports/src/test/python/hello.py bin/ # generic modules set boot_modules { core init - ld.lib.so libc.lib.so libc_log.lib.so libm.lib.so python.lib.so + ld.lib.so libc.lib.so libc_log.lib.so libc_rom.lib.so libm.lib.so python.lib.so test-python hello.py } diff --git a/libports/src/lib/python/libc_plugin.cc b/libports/src/lib/python/libc_plugin.cc deleted file mode 100644 index 901dadbb0a..0000000000 --- a/libports/src/lib/python/libc_plugin.cc +++ /dev/null @@ -1,109 +0,0 @@ -/** - * \brief Libc back-end for Python - * \author Sebastian Sumpf - * \date 2010-02-17 - */ - -/* - * Copyright (C) 2010-2012 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU General Public License version 2. - */ - -#include -#include -#include -#include -#include - -namespace { - - class Plugin_context : public Libc::Plugin_context - { - private: - - Genode::Dataspace_capability _ds_cap; - ::size_t _ds_size; - ::off_t _offs; - Genode::addr_t _base; - - public: - - Plugin_context(Genode::Dataspace_capability ds_cap) - : _ds_cap(ds_cap), _offs(0) - { - _ds_size = Genode::Dataspace_client(ds_cap).size(); - _base = Genode::env()->rm_session()->attach(ds_cap); - } - - ssize_t read(void *buf, ::size_t count) - { - if (_offs >= (::off_t)_ds_size) - return -1; - - if (_offs + count > _ds_size) - count = _ds_size - _offs; - - Genode::memcpy(buf, (void *)(_base + _offs), count); - _offs += count; - return count; - } - }; - - - static inline Plugin_context *context(Libc::File_descriptor *fd) - { - return static_cast(fd->context); - } - - - struct Plugin : Libc::Plugin - { - Plugin() - { - PDBG("Python libc plugin"); - } - - bool supports_open(const char*, int) { return true; } - - Libc::File_descriptor *open(const char *pathname, int flags) - { - using namespace Genode; - - Dataspace_capability ds_cap; - const char *_pathname = (pathname[0] == '/') ? pathname + 1 : pathname; - - try { - /* Open the file dataspace */ - Rom_connection rom(_pathname); - rom.on_destruction(Rom_connection::KEEP_OPEN); - ds_cap = rom.dataspace(); - } - catch (...) { - PERR("could not open file: %s", pathname); - return 0; - } - - Plugin_context *context = new (env()->heap()) Plugin_context(ds_cap); - return Libc::file_descriptor_allocator()->alloc(this, context); - } - - ssize_t read(Libc::File_descriptor *fdo, void *buf, ::size_t count) - { - return context(fdo)->read(buf, count); - } - - ssize_t _read(Libc::File_descriptor *fdo, void *buf, ::size_t count) - { - return read(fdo, buf, count); - } - }; -} - - -void create_libc_plugin() -{ - static Plugin plugin; -} - diff --git a/libports/src/lib/python/libc_plugin_init.cc b/libports/src/lib/python/libc_plugin_init.cc deleted file mode 100644 index f9586e8716..0000000000 --- a/libports/src/lib/python/libc_plugin_init.cc +++ /dev/null @@ -1,18 +0,0 @@ -/** - * \brief Constructor for libc plugin - * \author Sebastian Sumpf - * \date 2010-02-17 - */ - -/* - * Copyright (C) 2010-2012 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU General Public License version 2. - */ - -void __attribute__((constructor)) init_libc_plugin(void) -{ - extern void create_libc_plugin(); - create_libc_plugin(); -} diff --git a/libports/src/test/python/target.mk b/libports/src/test/python/target.mk index 75607edd46..be438f573c 100644 --- a/libports/src/test/python/target.mk +++ b/libports/src/test/python/target.mk @@ -1,4 +1,4 @@ TARGET = test-python -LIBS = cxx env python libc libc_log libm +LIBS = cxx env python libc libc_log libc_rom libm REQUIRES = x86 SRC_CC = main.cc