Skip to content
Snippets Groups Projects
Commit f0406bb2 authored by g0dil's avatar g0dil
Browse files

Better SENF configuration support (local_config.hh)

Packets: Fix PacketImpl::updateIterators implemantation (don't access invalidated iterators)
Scheduler: Remove access to invalidated timerMap_ iterator
Socket: BUGFIX: Fix generic WriteRange implementation
parent 2376c04d
No related branches found
No related tags found
No related merge requests found
Showing
with 105 additions and 89 deletions
......@@ -57,7 +57,7 @@ prefix_ void senf::detail::PacketImpl::clear(PacketData * self)
truncateInterpreters(n);
iterator first (boost::next(begin(),self->begin_));
data_.erase(first, boost::next(begin(),self->end_));
updateIterators(self,first,-self->size());
updateIterators(self,self->begin_,-self->size());
}
// private members
......@@ -73,7 +73,7 @@ prefix_ void senf::detail::PacketImpl::eraseInterpreters(interpreter_list::itera
}
}
prefix_ void senf::detail::PacketImpl::updateIterators(PacketData * self, iterator pos,
prefix_ void senf::detail::PacketImpl::updateIterators(PacketData * self, difference_type pos,
difference_type n)
{
// I hate to change the PacketData representation from here, I would have preferred to let
......@@ -101,7 +101,7 @@ prefix_ void senf::detail::PacketImpl::updateIterators(PacketData * self, iterat
// c)
interpreter_list::iterator const i_end (interpreters_.end());
if (++i != i_end)
if (std::distance(begin(), pos) < difference_type(i->begin_))
if (pos <= difference_type(i->begin_))
// pos is before the packet, it must then be before all futher packets ...
for (; i != i_end; ++i) {
i->begin_ += n;
......
......@@ -148,27 +148,32 @@ prefix_ senf::detail::PacketImpl::size_type senf::detail::PacketImpl::size()
prefix_ void senf::detail::PacketImpl::insert(PacketData * self, iterator pos, byte v)
{
difference_type ix (std::distance(begin(),pos));
data_.insert(pos,v);
updateIterators(self,pos,1);
updateIterators(self,ix,1);
}
prefix_ void senf::detail::PacketImpl::insert(PacketData * self, iterator pos, size_type n,
byte v)
{
difference_type ix (std::distance(begin(),pos));
data_.insert(pos,n,v);
updateIterators(self,pos,n);
updateIterators(self,ix,n);
}
prefix_ void senf::detail::PacketImpl::erase(PacketData * self, iterator pos)
{
difference_type ix (std::distance(begin(),pos));
data_.erase(pos);
updateIterators(self,pos,-1);
updateIterators(self,ix,-1);
}
prefix_ void senf::detail::PacketImpl::erase(PacketData * self, iterator first, iterator last)
{
difference_type ix (std::distance(begin(),first));
difference_type delta (std::distance(first,last));
data_.erase(first,last);
updateIterators(self,first,-std::distance(first,last));
updateIterators(self,ix,-delta);
}
///////////////////////////////////////////////////////////////////////////
......
......@@ -37,8 +37,9 @@ template <class ForwardIterator>
prefix_ void senf::detail::PacketImpl::insert(PacketData * self, iterator pos, ForwardIterator f,
ForwardIterator l)
{
difference_type ix (std::distance(begin(),pos));
data_.insert(pos,f,l);
updateIterators(self,pos,std::distance(f,l));
updateIterators(self,ix,std::distance(f,l));
}
template <class InputIterator>
......
......@@ -121,7 +121,7 @@ namespace detail {
interpreter_list interpreters_;
void eraseInterpreters(interpreter_list::iterator b, interpreter_list::iterator e);
void updateIterators(PacketData * self, iterator pos, difference_type n);
void updateIterators(PacketData * self, difference_type pos, difference_type n);
};
}}
......
......@@ -26,13 +26,6 @@
#include "ParseArray.ih"
// Custom includes
#include <algorithm>
#if defined(_STLP_ALGORITHM) || (__GNUC__<4 && __GNUC_MINOR__<4)
#define copy_n std::copy_n
#else
#include <ext/algorithm>
#define copy_n __gnu_cxx::copy_n
#endif
#define prefix_ inline
///////////////////////////////cti.p///////////////////////////////////////
......@@ -154,7 +147,6 @@ prefix_ void senf::detail::Parse_Array_iterator<ElementParser>::advance(int n)
i_ += n*ElementParser::fixed_bytes;
}
#undef copy_n
///////////////////////////////cti.e///////////////////////////////////////
#undef prefix_
......
......@@ -33,7 +33,7 @@ def nonemptyFile(f):
except OSError: return False
def checkLocalConf(target, source, env):
if nonemptyFile('SConfig') or nonemptyFile('Doxyfile.local'):
if [ True for f in env['CONFIG_FILES'] if nonemptyFile(f) ]:
print
print "You have made local modifications to 'SConfig' and/or 'Doxyfile.local'."
print "Building a debian package would remove those files."
......@@ -73,8 +73,11 @@ logname = os.environ.get('LOGNAME')
if not logname:
logname = pwd.getpwuid(os.getuid()).pw_name
def configFilesOpts(target, source, env, for_signature):
return [ '-I%s' % os.path.split(f)[1] for f in env['CONFIG_FILES'] ]
env.Append(
CPPPATH = [ ],
CPPPATH = [ '#' ],
LIBS = [ 'iberty', '$BOOSTREGEXLIB' ],
DOXY_XREF_TYPES = [ 'bug', 'fixme', 'todo', 'idea' ],
DOXY_HTML_XSL = '#/doclib/html-munge.xsl',
......@@ -83,8 +86,10 @@ env.Append(
'LOGNAME' : logname, # needed by the debian build scripts
'CONCURRENCY_LEVEL' : env.GetOption('num_jobs') or "1"
},
CONFIG_FILES = [ 'Doxyfile.local', 'SConfig', 'local_config.hh' ],
CONFIG_FILES_OPTS = configFilesOpts,
CLEAN_PATTERNS = [ '*.pyc', 'semantic.cache', '.sconsign', '.sconsign.dblite' ],
BUILDPACKAGE_COMMAND = "dpkg-buildpackage -us -uc -rfakeroot -I.svn -IDoxyfile.local -ISConfig",
BUILDPACKAGE_COMMAND = "dpkg-buildpackage -us -uc -rfakeroot -I.svn $CONFIG_FILES_OPTS",
)
Export('env')
......@@ -94,15 +99,9 @@ Export('env')
if not env.GetOption('clean') and not os.path.exists("Doxyfile.local"):
Execute(Touch("Doxyfile.local"))
# Create config.h
file("config.h","w").write(
"""#ifndef H_config_
#define H_config_ 1
// This looks stupid. However, we need this since the debian packaged Version
// of SENF is installed in a 'senf' subdirectory which the source Version is not
#define SENF_ABSOLUTE_INCLUDE_PATH(senf_relative_include_file_path) <%s/senf_relative_include_file_path>
#endif
""" % env.Dir('#').abspath)
# Create local_config.h
if not env.GetOption('clean') and not os.path.exists("local_config.hh"):
Execute(Touch("local_config.hh"))
###########################################################################
# Define build targets
......@@ -116,6 +115,8 @@ SENFSCons.DoxyXRef(env,
HTML_HEADER = '#/doclib/doxy-header-overview.html',
HTML_FOOTER = '#/doclib/doxy-footer.html')
SENFSCons.InstallIncludeFiles(env, [ 'config.hh' ])
# Build combined library 'libsenf'
libsenf = env.Library(
SENFSCons.LibPath('senf'),
......@@ -141,5 +142,3 @@ env.Clean('all', [ os.path.join(path,f)
for path, subdirs, files in os.walk('.')
for pattern in env['CLEAN_PATTERNS']
for f in fnmatch.filter(files,pattern) ])
env.Clean('all', 'config.h')
......@@ -201,8 +201,8 @@ prefix_ void senf::Scheduler::process()
i->second.cb();
else
break;
timerMap_.erase(i);
timerQueue_.pop();
timerMap_.erase(i);
}
if (events <= 0)
......
......@@ -60,25 +60,29 @@ readfrom(Handle & handle, ForwardWritableRange & range, typename Handle::Address
// senf::detail::WriteRange<Handle,ForwardReadableRange,IsContiguous>
template <class Handle, class ForwardReadableRange, bool IsContiguous>
prefix_ typename boost::range_iterator<ForwardReadableRange>::type
prefix_ typename boost::range_const_iterator<ForwardReadableRange>::type
senf::detail::WriteRange<Handle,ForwardReadableRange,IsContiguous>::
write(Handle & handle, ForwardReadableRange & range)
{
typename boost::range_size<ForwardReadableRange>::type nwrite (boost::size(range));
typename boost::range_const_iterator<ForwardReadableRange>::type i (boost::begin(range));
SENF_SCOPED_BUFFER(char, buffer, nwrite);
std::copy(boost::begin(range), boost::end(range), buffer);
return handle.write(std::make_pair(buffer, buffer+nwrite));
std::copy(i, boost::end(range), buffer);
std::advance(i, handle.write(std::make_pair(buffer, buffer+nwrite)) - buffer);
return i;
}
template <class Handle, class ForwardReadableRange, bool IsContiguous>
prefix_ typename boost::range_iterator<ForwardReadableRange>::type
prefix_ typename boost::range_const_iterator<ForwardReadableRange>::type
senf::detail::WriteRange<Handle,ForwardReadableRange,IsContiguous>::
writeto(Handle & handle, ForwardReadableRange & range, typename Handle::Address const & addr)
{
typename boost::range_size<ForwardReadableRange>::type nwrite (boost::size(range));
typename boost::range_const_iterator<ForwardReadableRange>::type i (boost::begin(range));
SENF_SCOPED_BUFFER(char, buffer, nwrite);
std::copy(boost::begin(range), boost::end(range), buffer);
return handle.writeto(std::make_pair(buffer, buffer+nwrite), addr);
std::copy(i, boost::end(range), buffer);
std::advance(i, handle.writeto(std::make_pair(buffer, buffer+nwrite), addr) - buffer);
return i;
}
///////////////////////////////////////////////////////////////////////////
......
......@@ -68,13 +68,13 @@ prefix_ typename boost::range_const_iterator<ForwardReadableRange>::type
senf::detail::WriteRange<Handle, ForwardReadableRange, true>::
write(Handle & handle, ForwardReadableRange & range)
{
typename boost::range_const_iterator<ForwardReadableRange>::type const i
typename boost::range_const_iterator<ForwardReadableRange>::type i
(boost::const_begin(range));
char const * const ic (reinterpret_cast<char const *>(storage_iterator(i)));
return i + (handle.write(ic,
reinterpret_cast<char const *>(
storage_iterator(boost::const_end(range))))
- ic);
std::advance(i, handle.write(ic,
reinterpret_cast<char const *>(
storage_iterator(boost::const_end(range)))) - ic);
return i;
}
template <class Handle, class ForwardReadableRange>
......@@ -82,14 +82,13 @@ prefix_ typename boost::range_const_iterator<ForwardReadableRange>::type
senf::detail::WriteRange<Handle, ForwardReadableRange, true>::
writeto(Handle & handle, ForwardReadableRange & range, typename Handle::Address const & addr)
{
typename boost::range_const_iterator<ForwardReadableRange>::type const i
typename boost::range_const_iterator<ForwardReadableRange>::type i
(boost::const_begin(range));
char const * const ic (reinterpret_cast<char const *>(storage_iterator(i)));
return i + (handle.writeto(addr,
ic,
reinterpret_cast<char const *>(
storage_iterator(boost::const_end(range))))
- ic);
std::advance(i, handle.writeto(addr, ic,
reinterpret_cast<char const *>(
storage_iterator(boost::const_end(range)))) - ic);
return i;
}
///////////////////////////////////////////////////////////////////////////
......
......@@ -79,10 +79,10 @@ namespace detail {
template <class Handle, class ForwardReadableRange, bool IsContiguous>
struct WriteRange
{
static typename boost::range_iterator<ForwardReadableRange>::type
static typename boost::range_const_iterator<ForwardReadableRange>::type
write(Handle & handle, ForwardReadableRange & range);
static typename boost::range_iterator<ForwardReadableRange>::type
static typename boost::range_const_iterator<ForwardReadableRange>::type
writeto(Handle & handle, ForwardReadableRange & range,
typename Handle::Address const & addr);
};
......
......@@ -29,7 +29,7 @@
// Custom includes
#include "ClientSocketHandle.hh"
#include "../config.h"
#include "../config.hh"
#include "ProtocolClientSocketHandle.mpp"
///////////////////////////////hh.p////////////////////////////////////////
......
......@@ -29,6 +29,7 @@
// Custom includes
#include "ServerSocketHandle.hh"
#include "../config.hh"
#include "ProtocolServerSocketHandle.mpp"
///////////////////////////////hh.p////////////////////////////////////////
......
......@@ -27,31 +27,11 @@
#define HH_Buffer_ 1
// Custom includes
#include "../config.hh"
//#include "Buffer.mpp"
///////////////////////////////hh.p////////////////////////////////////////
#if !defined(SENF_BUFFER_USE_LOCALS) && !defined(SENF_BUFFER_USE_ALLOCA) && !defined(SENF_BUFFER_USE_NEW)
#
#
# if defined(__GNUC__)
# define SENF_BUFFER_USE_LOCALS 1
#
# // Add other compilers here ...
#
# // dynamic arrays are part of C99. Which is NOT part of C++
# // but lets try nonetheless ...
# elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
# define SENF_BUFFER_USE_LOCALS 1
#
# endif
#
# if !defined(SENF_BUFFER_USE_LOCALS) && !defined(SENF_BUFFER_USE_ALLOCA)
# define SENF_BUFFER_USE_NEW 1
# endif
#
#endif
#if defined(SENF_BUFFER_USE_LOCALS)
# define SENF_SCOPED_BUFFER(type, sym, size) \
......
......@@ -32,21 +32,20 @@
namespace senf {
// It is not very nice that we need to specialize on the exact iterator names.
// The preprocessor guard will need to be expanded by also giving the correct
// version numbers. We need to disable it when using stlport and so on ...
// The problem is, that typedefs are not expanded when specializing ...
// It is not very nice that we need to specialize on the exact iterator names. The preprocessor
// guard will need to be expanded by also giving the correct version numbers. The problem is,
// that typedefs are not expanded when specializing ...
#if defined(__GNUG__)
template <class T, class Alloc>
struct contiguous_storage_iterator<
__gnu_cxx::__normal_iterator<T*, std::vector<T,Alloc> > >
::__gnu_cxx::__normal_iterator<T*, std::vector<T,Alloc> > >
: public boost::true_type
{};
template <class CharT, class Traits, class Alloc>
struct contiguous_storage_iterator<
__gnu_cxx::__normal_iterator<CharT*, std::basic_string<CharT, Traits, Alloc> > >
::__gnu_cxx::__normal_iterator<CharT*, std::basic_string<CharT, Traits, Alloc> > >
: public boost::true_type
{};
#endif
......
......@@ -41,7 +41,7 @@ BOOST_AUTO_UNIT_TEST(iteratorTraits)
{
BOOST_CHECK_EQUAL( senf::contiguous_storage_iterator<int*>::value, true );
BOOST_CHECK_EQUAL( senf::contiguous_storage_iterator<void>::value, false );
#ifdef __GNUG__
#if defined(__GNUG__) && ! defined(_GLIBCXX_DEBUG)
BOOST_CHECK_EQUAL( senf::contiguous_storage_iterator<std::vector<int>::iterator>::value, true);
BOOST_CHECK_EQUAL( senf::contiguous_storage_iterator<std::string::iterator>::value, true);
#endif
......
......@@ -27,7 +27,7 @@
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/repetition/enum_shifted.hpp>
#include <boost/preprocessor/iteration/iterate.hpp>
#include "../../config.h"
#include "../../config.hh"
template <typename R, typename T>
boost::function<R()> membind(R (T::* fn)(),scOBTYPE ob)
......
......@@ -27,6 +27,7 @@
#define HH_mpl_ 1
// Custom includes
#include "../config.hh"
//#include "mpl.mpp"
#include "mpl.ih"
......@@ -38,10 +39,6 @@ namespace mpl {
/** \defgroup senfmpl Low-level template meta programming helpers
*/
# ifndef SENF_MPL_RV_ALIGNMENT
# define SENF_MPL_RV_ALIGNMENT 16
# endif
/** \brief Return-value type used to implement overload selection
The senf::mpl::rv type is used together with \ref SENF_MPL_RV() to select template
......
......@@ -23,15 +23,52 @@
/** \file
\brief config public header */
#ifndef H_config_
#define H_config_ 1
#ifndef HH_config_
#define HH_config_ 1
// Custom includes
//#include "config.mpp"
///////////////////////////////hh.p////////////////////////////////////////
#define SENF_ABSOLUTE_INCLUDE_PATH(senf_relative_include_file_path) <senf/senf_relative_include_file_path>
# include "local_config.hh"
# ifndef SENF_ABSOLUTE_INCLUDE_PATH
# define SENF_ABSOLUTE_INCLUDE_PATH(senf_relative_include_file_path) <senf_relative_include_file_path>
# endif
# ifndef SENF_copy_n
# include <algorithm>
# if defined(__GNUC__) && ! defined(_STLP_ALGORITHM) && (__GNUC__>=4 || (__GNUC__==3 && __GNUC_MINOR__>=4))
# include <ext/algorithm>
# define SENF_copy_n __gnu_cxx::copy_n
# else
# define SENF_copy_n std::copy_n
# endif
# endif
# ifndef SENF_MPL_RV_ALIGNMENT
# define SENF_MPL_RV_ALIGNMENT 16
# endif
# if !defined(SENF_BUFFER_USE_LOCALS) && !defined(SENF_BUFFER_USE_ALLOCA) && !defined(SENF_BUFFER_USE_NEW)
#
# if defined(__GNUC__)
# define SENF_BUFFER_USE_LOCALS 1
#
# // Add other compilers here ...
#
# // dynamic arrays are part of C99. Which is NOT part of C++
# // but lets try nonetheless ...
# elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
# define SENF_BUFFER_USE_LOCALS 1
# endif
#
# if !defined(SENF_BUFFER_USE_LOCALS) && !defined(SENF_BUFFER_USE_ALLOCA)
# define SENF_BUFFER_USE_NEW 1
# endif
#
# endif
///////////////////////////////hh.e////////////////////////////////////////
//#include "config.cci"
......
......@@ -6,7 +6,7 @@ debian/tmp/usr/include/Scheduler usr/include/senf
debian/tmp/usr/include/Socket usr/include/senf
debian/tmp/usr/include/Utils usr/include/senf
boost usr/include/senf
debian/config.h usr/include/senf
debian/local_config.hh usr/include/senf
debian/Socket.hh usr/include/senf
debian/Packets.hh usr/include/senf
debian/PPI.hh usr/include/senf
......
#define SENF_ABSOLUTE_INCLUDE_PATH(senf_relative_include_file_path) <senf/senf_relative_include_file_path>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment