Fix compilation warnings and a couple of errors due to GCC -pedantic flags

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1329 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2008-11-08 21:17:11 +00:00
parent 61df7cd551
commit 99135b1237
39 changed files with 77 additions and 188 deletions

View file

@ -307,9 +307,9 @@ ConcreteHistory::clear()
ConcreteHistory::ResourcePair
ConcreteHistory::add_resource(const Glib::ustring& name,
bool preemptable,
bool /*preemptable*/,
size_t places,
size_t availability)
size_t /*availability*/)
{
typedef ConcreteEnvironment::Resources Resources;
typedef ConcreteEnvironment::SubRequestQueue SubRequestQueue;
@ -341,9 +341,9 @@ ConcreteHistory::add_resource(const Glib::ustring& name,
void
ConcreteHistory::edit_resource(Resource& resource,
const Glib::ustring& name,
bool preemptable,
bool /*preemptable*/,
size_t places,
size_t availability)
size_t /*availability*/)
{
// And preemptable and availability?? FIXME!

View file

@ -37,7 +37,7 @@ namespace sgpem
This class is a direct subclass of the abstract class ProcessStatistics.
For the documentation af all methods refere to it.
*/
class ConcreteProcessStatistics : public ProcessStatistics
class SG_DLLLOCAL ConcreteProcessStatistics : public ProcessStatistics
{
public:
friend class ConcreteStatistics;

View file

@ -167,11 +167,13 @@ ConcreteSimulation::step()
{
// step forward
bool yet_to_finish = true;
if (_history.get_front() == _history.get_size() - 1)
if(!_history.is_sealed())
yet_to_finish = Scheduler::get_instance().step_forward(_history, *get_policy(), *get_resource_policy());
else
yet_to_finish = false;
if (_history.get_front() == _history.get_size() - 1)
{
if(!_history.is_sealed())
yet_to_finish = Scheduler::get_instance().step_forward(_history, *get_policy(), *get_resource_policy());
else
yet_to_finish = false;
}
if (!yet_to_finish) _history.seal();

View file

@ -22,7 +22,6 @@
#define CONCRETE_SIMULATION_HH 1
#include <sgpemv2/simulation.hh>
#include "concrete_history.hh"
@ -35,7 +34,7 @@ namespace sgpem
{
class ConcreteSimulation;
class ConcreteSimulation : public Simulation
class SG_DLLLOCAL ConcreteSimulation : public Simulation
{
public:
ConcreteSimulation();

View file

@ -36,7 +36,7 @@ namespace sgpem
This class is a direct subclass of the abstract class SimulationStatistics.
For the documentation af all methods refere to it.
*/
class ConcreteSimulationStatistics : public SimulationStatistics
class SG_DLLLOCAL ConcreteSimulationStatistics : public SimulationStatistics
{
public:
friend class ConcreteStatistics;

View file

@ -38,7 +38,7 @@ namespace sgpem
This class is a direct subclass of the abstract class Statistics.
For the documentation af all methods refere to it.
*/
class ConcreteStatistics : public Statistics
class SG_DLLLOCAL ConcreteStatistics : public Statistics
{
public:
ConcreteStatistics();

View file

@ -38,7 +38,7 @@ namespace sgpem
This class is a direct subclass of the abstract class ThreadStatistics.
For the documentation af all methods refere to it.
*/
class ConcreteThreadStatistics : public ThreadStatistics
class SG_DLLLOCAL ConcreteThreadStatistics : public ThreadStatistics
{
public:
friend class ConcreteProcessStatistics;

View file

@ -37,7 +37,7 @@ namespace sgpem
/**
ResourcePolicyManager is the Abstract Factory for \ref ResourcePolicy objects.
*/
class CppResourcePolicyManager : public ResourcePolicyManager
class SG_DLLLOCAL CppResourcePolicyManager : public ResourcePolicyManager
{
public:
/** \brief CppResourcePolicyManager constructor

View file

@ -41,7 +41,7 @@ using std::runtime_error;
using namespace sgpem;
// Explicit template instantiation to allow to export symbols from the DSO.
template class SG_DLLEXPORT Singleton<CPUPoliciesGatekeeper>;
template class Singleton<CPUPoliciesGatekeeper>;
typedef vector<CPUPolicyManager*>::iterator ManagerIterator;
typedef map<History*, CPUPolicy*>::iterator ActiveIterator;

View file

@ -40,7 +40,7 @@
using namespace sgpem;
// Explicit template instantiation to allow to export symbols from the DSO.
template class SG_DLLEXPORT Singleton<GlobalPreferences>;
template class Singleton<GlobalPreferences>;
GlobalPreferences::GlobalPreferences()
: _mod_dirs(1, PLUGDIR), _pol_dirs(1, POLDIR), _speed(1000)

View file

@ -1,4 +1,4 @@
// src/backend/key_file.hh - Copyright 2005, 2006, University
// src/backend/global_preferences_serializer.hh - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
@ -36,7 +36,7 @@ namespace sgpem
* in the form of: key=value rows.
*
*/
class SG_DLLEXPORT GlobalPreferencesSerializer : public KeyFile
class SG_DLLLOCAL GlobalPreferencesSerializer : public KeyFile
{
public:

View file

@ -35,7 +35,7 @@
using namespace sgpem;
template class SG_DLLEXPORT Singleton<PluginManager>;
template class Singleton<PluginManager>;
std::vector<Module*>

View file

@ -40,7 +40,7 @@ using std::runtime_error;
using namespace sgpem;
// Explicit template instantiation to allow to export symbols from the DSO.
template class SG_DLLEXPORT Singleton<ResourcePoliciesGatekeeper>;
template class Singleton<ResourcePoliciesGatekeeper>;
typedef vector<ResourcePolicyManager*>::iterator ManagerIterator;
typedef map<History*, ResourcePolicy*>::iterator PolicyIterator;

View file

@ -35,7 +35,7 @@ ResourcePolicyFiFo::configure()
}
void
ResourcePolicyFiFo::enforce(Environment& environment, Environment::SubRequestQueue& queue, SubRequest& sr)
ResourcePolicyFiFo::enforce(Environment& /*environment*/, Environment::SubRequestQueue& queue, SubRequest& sr)
throw(UserInterruptException)
{
typedef Environment::SubRequestQueue SubRequestQueue;

View file

@ -36,7 +36,7 @@ namespace sgpem
It's a Strategy wich stay for a resource allocating algorithm.
It implements the related resource allocation policy.
*/
class ResourcePolicyFiFo : public ResourcePolicy
class SG_DLLLOCAL ResourcePolicyFiFo : public ResourcePolicy
{
public:
virtual ~ResourcePolicyFiFo();

View file

@ -34,7 +34,7 @@ ResourcePolicyLiFo::configure()
}
void
ResourcePolicyLiFo::enforce(Environment& environment, Environment::SubRequestQueue& queue, SubRequest& sr)
ResourcePolicyLiFo::enforce(Environment& /*environment*/, Environment::SubRequestQueue& queue, SubRequest& sr)
throw(UserInterruptException)
{
typedef Environment::SubRequestQueue SubRequestQueue;

View file

@ -37,7 +37,7 @@ namespace sgpem
It's a Strategy wich stay for a resource allocating algorithm.
It implements the related resource allocation policy.
*/
class ResourcePolicyLiFo : public ResourcePolicy
class SG_DLLLOCAL ResourcePolicyLiFo : public ResourcePolicy
{
public:
virtual ~ResourcePolicyLiFo();

View file

@ -36,7 +36,7 @@ ResourcePolicyPriority::configure()
}
void
ResourcePolicyPriority::enforce(Environment& environment, Environment::SubRequestQueue& queue, SubRequest& sr)
ResourcePolicyPriority::enforce(Environment& /*environment*/, Environment::SubRequestQueue& queue, SubRequest& sr)
throw(UserInterruptException)
{
typedef Environment::SubRequestQueue SubRequestQueue;

View file

@ -40,7 +40,7 @@ namespace sgpem
/// following the priority of the owners of the requests.
class ResourcePolicyPriority;
class ResourcePolicyPriority : public ResourcePolicy
class SG_DLLLOCAL ResourcePolicyPriority : public ResourcePolicy
{
public:

View file

@ -35,7 +35,7 @@ ResourcePolicyPriorityInheritance::configure()
}
void
ResourcePolicyPriorityInheritance::enforce(Environment& environment, Environment::SubRequestQueue& queue, SubRequest& sr)
ResourcePolicyPriorityInheritance::enforce(Environment& /*environment*/, Environment::SubRequestQueue& queue, SubRequest& sr)
throw(UserInterruptException)
{
typedef Environment::SubRequestQueue SubRequestQueue;

View file

@ -34,7 +34,7 @@ namespace sgpem
* \brief It's a Strategy wich stay for a resource allocating algorithm.
* It implements the related resource allocation policy.
*/
class ResourcePolicyPriorityInheritance : public ResourcePolicy
class SG_DLLLOCAL ResourcePolicyPriorityInheritance : public ResourcePolicy
{
public:

View file

@ -49,7 +49,7 @@ using namespace std;
using namespace sgpem;
// Explicit template instantiation to allow to export symbols from the DSO.
template class SG_DLLEXPORT Singleton<Scheduler>;
template class Singleton<Scheduler>;
typedef std::vector<DynamicProcess*> Processes;
@ -69,8 +69,6 @@ static void terminate_all_requests_of(DynamicThread& thread, ConcreteEnvironment
static void update_allocated_requests(DynamicThread& running_thread, ConcreteEnvironment& environment);
static void raise_new_requests(DynamicThread& running_thread, ConcreteEnvironment& environment, ResourcePolicy& resource_policy);
static void look_for_mutant_request_states(ConcreteEnvironment& environment, unsigned int& alive_threads);
static void determine_subr_allocable_status(const DynamicRequest& req, DynamicSubRequest& subr,
const Resource& res, SubRequestQueue& queue);
static void determine_subr_allocable_status(const Resource& res, const SubRequestQueue& queue);
@ -268,69 +266,6 @@ raise_new_requests(DynamicThread& running_thread, ConcreteEnvironment& environme
}
// The following loop determines how many places in the resource are
// really available for a thread, and how many places for a specific
// resource a thread really needs. Admittedly, it's a bit of a hack (in
// the way it's written, not conceptually!)
void
determine_subr_allocable_status(const DynamicRequest& req, DynamicSubRequest& subr,
const Resource& res, SubRequestQueue& queue)
{
unsigned int total_places = res.get_places();
unsigned int free_places = total_places;
unsigned int needed_places = 0;
unsigned int position_in_queue = 0;
bool too_far_in_the_queue = false;
const SubRequestQueue& const_queue = queue;
for(Iseq<SubRequestQueue::const_iterator> queue_it = iseq(const_queue);
queue_it && free_places >= needed_places; queue_it++, position_in_queue++)
{
SubRequest& sr = **queue_it;
if(sr.get_state() == Request::state_allocated)
{
assert(free_places > 0); // Just to be sure...
free_places--;
}
// Okay, this won't win a beauty contest...
if(&sr.get_request() == &req)
needed_places++;
// Well, and what about this, then?
if(&sr == &subr && position_in_queue + 1 > total_places)
too_far_in_the_queue = true;
} //~ for(over subrequest queue)
// If the number of places this thread need for a resource are
// less or equal the places left free, it's allocable.
if(needed_places <= free_places && !too_far_in_the_queue)
subr.set_state(Request::state_allocable);
else
{
subr.set_state(Request::state_unallocable);
/*
// Okay, this is difficult to understand, so read carefully:
// when we make a subrequest unallocable, it means that the
// whole request is unallocable. However, it may happen that
// there are other subrequests just marked allocable for
// a given resource. Since a request is atomic, either we're
// given *all* the places we asked for in a resource, or none.
// This doesn't affect the state for other subrequests on other
// resources, which may stay (atomically) allocable.
// (Maybe it was better to implement the number of "places"
// needed directly into subrequests, after all...)
for(Iseq<SubRequestQueue::iterator> queue_it = iseq(queue); queue_it; queue_it++)
{
DynamicSubRequest& x = static_cast<DynamicSubRequest&>(**queue_it);
if(&x.get_request() == &req && x.get_state() == Request::state_allocable)
x.set_state(Request::state_unallocable);
}
*/
}
}
// The following loop updates the states of the subrequests depending
// on their position in the queue
void

View file

@ -24,6 +24,7 @@
#include <sgpemv2/sgpemv2-visibility.hh>
#include <map>
#include <string>
#include <stdexcept>
#include "glibmm/ustring.h"
@ -34,7 +35,7 @@ namespace sgpem
class SG_DLLEXPORT PolicyParametersException : public std::runtime_error
{
public:
PolicyParametersException(char* msg): std::runtime_error(msg) {}
PolicyParametersException(std::string msg): std::runtime_error(msg) {}
};

View file

@ -33,7 +33,7 @@
using namespace sgpem;
// Explicit template instantiation to allow to export symbols from the DSO.
template class SG_DLLEXPORT Singleton<ConcreteSimulation>;
template class Singleton<ConcreteSimulation>;
Simulation::Simulation()
: _notify(true)

View file

@ -38,7 +38,7 @@ namespace sgpem
It IS a Schedulable object.
*/
class StaticProcess : public StaticSchedulable
class SG_DLLLOCAL StaticProcess : public StaticSchedulable
{
public:
/** \brief Creates a new object with the given parameters. */

View file

@ -31,7 +31,7 @@ namespace sgpem
class StaticRequest;
class SerializeVisitor;
class StaticRequest
class SG_DLLLOCAL StaticRequest
{
public:
StaticRequest(StaticThread* thread, unsigned int instant);

View file

@ -21,6 +21,7 @@
#ifndef STATIC_RESOURCE_HH
#define STATIC_RESOURCE_HH 1
#include <sgpemv2/sgpemv2-visibility.hh>
#include "glibmm/ustring.h"
@ -39,7 +40,7 @@ namespace sgpem
/// copy constructor private. This makes clear that if you want to edit a
/// static entity, you should reset the ::History, remove the old static
/// entity, and create a new dynamic entity for the new static one.
class StaticResource
class SG_DLLLOCAL StaticResource
{
public:
/// \brief Constructor taking a defined name and a number of places.

View file

@ -21,6 +21,7 @@
#ifndef STATIC_SCHEDULABLE_HH
#define STATIC_SCHEDULABLE_HH 1
#include <sgpemv2/sgpemv2-visibility.hh>
#include "glibmm/ustring.h"
@ -38,7 +39,7 @@ namespace sgpem
*
* \see DynamicSchedulable
*/
class StaticSchedulable
class SG_DLLLOCAL StaticSchedulable
{
public:
/** \brief Create a new object with the given parameters */

View file

@ -45,7 +45,7 @@ namespace sgpem
class StaticRequest;
class StaticResource;
class StaticSubRequest
class SG_DLLLOCAL StaticSubRequest
{
public:
typedef SubRequest::resource_key_t resource_key_t;

View file

@ -65,7 +65,7 @@ namespace sgpem
/// at which its creation in the operating system is simulated.
class StaticThread;
class StaticThread : public StaticSchedulable
class SG_DLLLOCAL StaticThread : public StaticSchedulable
{
public:

View file

@ -25,7 +25,7 @@
#include <gdkmm/window.h>
#include <cstring>
#include <cassert>
#include <memory>
@ -110,8 +110,10 @@ CairoWidget::on_realize()
set_window(window);
window->set_user_data(gobj());
gtk_style_attach(get_style()->gobj(), window->gobj());
get_style()->set_background(window, Gtk::STATE_ACTIVE);
Glib::RefPtr<Gtk::Style> style = get_style ();
style = style->attach (window);
style->set_background(window, Gtk::STATE_ACTIVE);
}
/*

View file

@ -25,6 +25,7 @@
#include <glibmm/ustring.h>
#include <cstdlib>
#include <iostream>
int

View file

@ -45,6 +45,7 @@
#include <glibmm/timer.h>
#include <cassert>
#include <cstdlib>
#include <ios>
#include <iomanip>
#include <sstream>