Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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.
  • Loading branch information...
commit f635cc4a192544499d16ec23dbff51f4f1655aaf 1 parent b624928
@cproc cproc authored nfeske committed
View
3  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 = \
View
2  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
}
View
109 libports/src/lib/python/libc_plugin.cc
@@ -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 <base/env.h>
-#include <base/printf.h>
-#include <rom_session/connection.h>
-#include <dataspace/client.h>
-#include <libc-plugin/fd_alloc.h>
-
-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<Plugin_context *>(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;
-}
-
View
18 libports/src/lib/python/libc_plugin_init.cc
@@ -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();
-}
View
2  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
Please sign in to comment.
Something went wrong with that request. Please try again.