From 4cad356657bae389021188598a10701fc8785a16 Mon Sep 17 00:00:00 2001 From: tchernobog Date: Sat, 28 Jan 2006 20:39:29 +0000 Subject: [PATCH] - Get DSO visibility check right in configure.ac. Now it should work correctly with GCC >= 4.0, while doing nothing for GCC < 4.0 - Add class sgpem::schedulable to test for DSO visibility export. Methods may need to be reordered to conform to coding style guidelines git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@244 3ecf2c5c-341e-0410-92b4-d18e462d057c --- configure.ac | 46 ++++++++++---------------- distro/gentoo/sgpemv2-0.00.ebuild | 16 +++++++++ src/backend/Makefile.am | 12 +++---- src/backend/schedulable.cc | 55 +++++++++++++++++++++++++++++++ src/backend/schedulable.hh | 55 +++++++++++++++++++++++++++++++ src/main.hh | 5 +-- src/startgui.cc | 3 +- 7 files changed, 149 insertions(+), 43 deletions(-) create mode 100644 distro/gentoo/sgpemv2-0.00.ebuild create mode 100644 src/backend/schedulable.cc create mode 100644 src/backend/schedulable.hh diff --git a/configure.ac b/configure.ac index d576083..5ae5eca 100644 --- a/configure.ac +++ b/configure.ac @@ -91,48 +91,36 @@ PKG_CHECK_MODULES([GTKMM], dnl use DSO visibility tags for systems that supports it correctly dnl (for example, GCC 4.0 and above) dnl see http://gcc.gnu.org/wiki/Visibility for more informations -AC_MSG_CHECKING([whether the compiler supports DSO visibility attributes]) +AH_TEMPLATE([DLLEXPORT],[Attribute for objects to be exported from DSOs]) +AH_TEMPLATE([DLLIMPORT],[Attribute for objects to be imported from DSOs]) +AH_TEMPLATE([DLLLOCAL], [Attribute for objects local to current DSO]) +AH_TEMPLATE([DLLPUBLIC],[Attribute for DSO public objects]) + +dnl for now it works only with GCC >= 4.0.0 +AC_MSG_CHECKING([whether GCC supports DSO visibility attributes]) AC_LANG_PUSH([C++]) AC_COMPILE_IFELSE( AC_LANG_PROGRAM([], [ - #if defined (GCC_HASCLASSVISIBILITY) || defined (WIN32) + #if defined __GNUC__ && (__GNUC__) >= 4 return 0; #else bails out with a compilation error. #endif ]),[ AC_MSG_RESULT([yes]) - AH_VERBATIM([DLLEXPORT],[ -// DSO visibility support enabled by configure -#ifdef WIN32 - #define DLLIMPORT __declspec(dllimport) - #define DLLEXPORT __declspec(dllexport) - #define DLLLOCAL - #define DLLPUBLIC -#else - #define DLLIMPORT - #ifdef GCC_HASCLASSVISIBILITY - #define DLLEXPORT __attribute__ ((visibility("default"))) - #define DLLLOCAL __attribute__ ((visibility("hidden"))) - #define DLLPUBLIC __attribute__ ((visibility("default"))) - #else - #define DLLEXPORT - #define DLLLOCAL - #define DLLPUBLIC - #endif -#endif - ]) + AC_DEFINE([DLLIMPORT],[/* intentionally left with no value */]) + AC_DEFINE([DLLEXPORT],[__attribute__ ((visibility("default")))]) + AC_DEFINE([DLLLOCAL],[__attribute__ ((visibility("hidden")))]) + AC_DEFINE([DLLPUBLIC],[__attribute__ ((visibility("default")))]) + AC_CHECK_CXXFLAG([fvisibility=hidden]) AC_CHECK_CXXFLAG([fvisibility-inlines-hidden]) ],[ AC_MSG_RESULT([no]) - AH_VERBATIM([DLLEXPORT],[ -// Proper DSO visibility is unsupported -#define DLLIMPORT -#define DLLEXPORT -#define DLLLOCAL -#define DLLPUBLIC - ]) + AC_DEFINE([DLLIMPORT],[/* unsupported */]) + AC_DEFINE([DLLEXPORT],[/* unsupported */]) + AC_DEFINE([DLLLOCAL],[/* unsupported */]) + AC_DEFINE([DLLPUBLIC],[/* unsupported */]) ]) AC_LANG_POP diff --git a/distro/gentoo/sgpemv2-0.00.ebuild b/distro/gentoo/sgpemv2-0.00.ebuild new file mode 100644 index 0000000..ce6022e --- /dev/null +++ b/distro/gentoo/sgpemv2-0.00.ebuild @@ -0,0 +1,16 @@ +# Copyright 1999-2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +DESCRIPTION="" +HOMEPAGE="" +SRC_URI="" + +LICENSE="" +SLOT="0" +KEYWORDS="~x86" +IUSE="" + +DEPEND="" +RDEPEND="" + diff --git a/src/backend/Makefile.am b/src/backend/Makefile.am index 0cbec0f..36d6377 100644 --- a/src/backend/Makefile.am +++ b/src/backend/Makefile.am @@ -44,12 +44,8 @@ libbackend_la_LIBADD = $(PYTHON_LDFLAGS) \ libbackend_la_LDFLAGS = $(PYTHON_EXTRA_LDFLAGS) # Please keep this in sorted order: -libbackend_la_SOURCES = empty.cc - -noinst_HEADERS = - -# !! temp file for debug, will be deleted as soon as -# !! source's in place -empty.cc : - echo "int main() {}" > @builddir@/$@ +libbackend_la_SOURCES = \ + schedulable.cc +noinst_HEADERS = \ + schedulable.hh diff --git a/src/backend/schedulable.cc b/src/backend/schedulable.cc new file mode 100644 index 0000000..a9095e7 --- /dev/null +++ b/src/backend/schedulable.cc @@ -0,0 +1,55 @@ +// src/backend/schedulable.cc - Copyright 2005, 2006, University +// of Padova, dept. of Pure and Applied +// Mathematics +// +// This file is part of SGPEMv2. +// +// This is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// SGPEMv2 is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with SGPEMv2; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +#include "schedulable.hh" +using namespace sgpem; + + +Schedulable::Schedulable(unsigned int arrival, + unsigned int total, + int priority) : + _arrival_time(arrival), _total_time(total), _priority(priority) +{} + + +Schedulable::~Schedulable() +{} + + +unsigned int +Schedulable::getArrivalTime() const +{ + return _arrival_time; +} + + +unsigned int +Schedulable::getTotalCPUTime() const +{ + return _total_time; +} + + +int +Schedulable::getPriority() const +{ + return _priority; +} + diff --git a/src/backend/schedulable.hh b/src/backend/schedulable.hh new file mode 100644 index 0000000..5960d84 --- /dev/null +++ b/src/backend/schedulable.hh @@ -0,0 +1,55 @@ +// src/backend/schedulable.hh - Copyright 2005, 2006, University +// of Padova, dept. of Pure and Applied +// Mathematics +// +// This file is part of SGPEMv2. +// +// This is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// SGPEMv2 is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with SGPEMv2; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +#ifndef SCHEDULABLE_HH +#define SCHEDULABLE_HH 1 + +#include "config.h" + +namespace sgpem +{ + class Schedulable; + + /** \brief An entity that can use the processor + * This abstract class describes an entity that can use the + * processor. It describes the parameters that don't change + * during a simulation. + * All subclasses are ... (FIXME: teach Luca and Marco what's + * the Italian language for, damn them! -- they must have + * *smoked* mushrooms! :-) ) */ + class DLLEXPORT Schedulable + { + public: + Schedulable(unsigned int arrival, unsigned int total, int priority); + virtual ~Schedulable() = 0; + + virtual unsigned int getArrivalTime() const; + unsigned int getTotalCPUTime() const; + int getPriority() const; + + private: + unsigned int _arrival_time; + unsigned int _total_time; + int _priority; + }; + +} + +#endif diff --git a/src/main.hh b/src/main.hh index 438acd7..afa26fd 100644 --- a/src/main.hh +++ b/src/main.hh @@ -1,4 +1,4 @@ -// src/main.cc - Copyright 2005, 2006, University +// src/main.hh - Copyright 2005, 2006, University // of Padova, dept. of Pure and Applied // Mathematics // @@ -21,7 +21,4 @@ #ifndef MAIN_HH #define MAIN_HH 1 -// found in mainwindow.hh -extern void build_gui(int argc, char** argv); - #endif diff --git a/src/startgui.cc b/src/startgui.cc index df75b3b..d153b55 100644 --- a/src/startgui.cc +++ b/src/startgui.cc @@ -26,11 +26,10 @@ #include -void DLLEXPORT +void start_gui(int argc, char** argv) { Gtk::Main gtk_main(argc,argv); MainWindow main_window; Gtk::Main::run(main_window); } -