Initial import from the monolithic Qt.

This is the beginning of revision history for this module. If you
want to look at revision history older than this, please refer to the
Qt Git wiki for how to use Git history grafting. At the time of
writing, this wiki is located here:

http://qt.gitorious.org/qt/pages/GitIntroductionWithQt

If you have already performed the grafting and you don't see any
history beyond this commit, try running "git log" with the "--follow"
argument.

Branched from the monolithic repo, Qt master branch, at commit
896db169ea224deb96c59ce8af800d019de63f12
This commit is contained in:
Qt by Nokia
2011-04-27 12:05:43 +02:00
committed by axis
commit 60941c2741
211 changed files with 87979 additions and 0 deletions

View File

@@ -0,0 +1,285 @@
/*****************************************************************************
ClockCycleCounter.cpp
Copyright (c) 2003 Laurent de Soras
--- Legal stuff ---
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*Tab=3***********************************************************************/
#if defined (_MSC_VER)
#pragma warning (1 : 4130) // "'operator' : logical operation on address of string constant"
#pragma warning (1 : 4223) // "nonstandard extension used : non-lvalue array converted to pointer"
#pragma warning (1 : 4705) // "statement has no effect"
#pragma warning (1 : 4706) // "assignment within conditional expression"
#pragma warning (4 : 4786) // "identifier was truncated to '255' characters in the debug information"
#pragma warning (4 : 4800) // "forcing value to bool 'true' or 'false' (performance warning)"
#pragma warning (4 : 4355) // "'this' : used in base member initializer list"
#endif
/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
#include "ClockCycleCounter.h"
#include <cassert>
namespace stopwatch
{
/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
/*
==============================================================================
Name: ctor
Description:
The first object constructed initialise global data. This first
construction may be a bit slow.
Throws: Nothing
==============================================================================
*/
ClockCycleCounter::ClockCycleCounter ()
: _start_time (0)
, _state (0)
, _best_score (-1)
{
if (! _init_flag)
{
// Should be executed in this order
compute_clk_mul ();
compute_measure_time_total ();
compute_measure_time_lap ();
// Restores object state
_start_time = 0;
_state = 0;
_best_score = -1;
_init_flag = true;
}
}
/*
==============================================================================
Name: get_time_total
Description:
Gives the time elapsed between the latest stop_lap() and start() calls.
Returns:
The duration, in clock cycles.
Throws: Nothing
==============================================================================
*/
Int64 ClockCycleCounter::get_time_total () const
{
const Int64 duration = _state - _start_time;
assert (duration >= 0);
const Int64 t = max (
duration - _measure_time_total,
static_cast <Int64> (0)
);
return (t * _clk_mul);
}
/*
==============================================================================
Name: get_time_best_lap
Description:
Gives the smallest time between two consecutive stop_lap() or between
the stop_lap() and start(). The value is reset by a call to start().
Call this function only after a stop_lap().
The time is amputed from the duration of the stop_lap() call itself.
Returns:
The smallest duration, in clock cycles.
Throws: Nothing
==============================================================================
*/
Int64 ClockCycleCounter::get_time_best_lap () const
{
assert (_best_score >= 0);
const Int64 t1 = max (
_best_score - _measure_time_lap,
static_cast <Int64> (0)
);
const Int64 t = min (t1, get_time_total ());
return (t * _clk_mul);
}
/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
#if defined (__MACOS__)
static inline double stopwatch_ClockCycleCounter_get_time_s ()
{
const Nanoseconds ns = AbsoluteToNanoseconds (UpTime ());
return (ns.hi * 4294967296e-9 + ns.lo * 1e-9);
}
#endif // __MACOS__
/*
==============================================================================
Name: compute_clk_mul
Description:
This function, only for PowerPC/MacOS computers, computes the multiplier
required to deduce clock cycles from the internal counter.
Throws: Nothing
==============================================================================
*/
void ClockCycleCounter::compute_clk_mul ()
{
assert (! _init_flag);
#if defined (__MACOS__)
long clk_speed_mhz = CurrentProcessorSpeed ();
const Int64 clk_speed =
static_cast <Int64> (clk_speed_mhz) * (1000L*1000L);
const double start_time_s = stopwatch_ClockCycleCounter_get_time_s ();
start ();
const double duration = 0.01; // Seconds
while (stopwatch_ClockCycleCounter_get_time_s () - start_time_s < duration)
{
continue;
}
const double stop_time_s = stopwatch_ClockCycleCounter_get_time_s ();
stop ();
const double diff_time_s = stop_time_s - start_time_s;
const double nbr_cycles = diff_time_s * static_cast <double> (clk_speed);
const Int64 diff_time_c = _state - _start_time;
const double clk_mul = nbr_cycles / static_cast <double> (diff_time_c);
_clk_mul = round_int (clk_mul);
#endif // __MACOS__
}
void ClockCycleCounter::compute_measure_time_total ()
{
start ();
spend_time ();
Int64 best_result = 0x7FFFFFFFL; // Should be enough
long nbr_tests = 100;
for (long cnt = 0; cnt < nbr_tests; ++cnt)
{
start ();
stop_lap ();
const Int64 duration = _state - _start_time;
best_result = min (best_result, duration);
}
_measure_time_total = best_result;
}
/*
==============================================================================
Name: compute_measure_time_lap
Description:
Computes the duration of one stop_lap() call and store it. It will be used
later to get the real duration of the measured operation (by substracting
the measurement duration).
Throws: Nothing
==============================================================================
*/
void ClockCycleCounter::compute_measure_time_lap ()
{
start ();
spend_time ();
long nbr_tests = 10;
for (long cnt = 0; cnt < nbr_tests; ++cnt)
{
stop_lap ();
stop_lap ();
stop_lap ();
stop_lap ();
}
_measure_time_lap = _best_score;
}
void ClockCycleCounter::spend_time ()
{
const Int64 nbr_clocks = 500; // Number of clock cycles to spend
const Int64 start = read_clock_counter ();
Int64 current;
do
{
current = read_clock_counter ();
}
while ((current - start) * _clk_mul < nbr_clocks);
}
Int64 ClockCycleCounter::_measure_time_total = 0;
Int64 ClockCycleCounter::_measure_time_lap = 0;
int ClockCycleCounter::_clk_mul = 1;
bool ClockCycleCounter::_init_flag = false;
} // namespace stopwatch
/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/

View File

@@ -0,0 +1,124 @@
/*****************************************************************************
ClockCycleCounter.h
Copyright (c) 2003 Laurent de Soras
Instrumentation class, for accurate time interval measurement. You may have
to modify the implementation to adapt it to your system and/or compiler.
--- Legal stuff ---
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*Tab=3***********************************************************************/
#if ! defined (stopwatch_ClockCycleCounter_HEADER_INCLUDED)
#define stopwatch_ClockCycleCounter_HEADER_INCLUDED
#if defined (_MSC_VER)
#pragma once
#pragma warning (4 : 4250) // "Inherits via dominance."
#endif
/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
#include "def.h"
#include "Int64.h"
namespace stopwatch
{
class ClockCycleCounter
{
/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
public:
ClockCycleCounter ();
stopwatch_FORCEINLINE void
start ();
stopwatch_FORCEINLINE void
stop_lap ();
Int64 get_time_total () const;
Int64 get_time_best_lap () const;
/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
protected:
/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
private:
void compute_clk_mul ();
void compute_measure_time_total ();
void compute_measure_time_lap ();
static void spend_time ();
static stopwatch_FORCEINLINE Int64
read_clock_counter ();
Int64 _start_time;
Int64 _state;
Int64 _best_score;
static Int64 _measure_time_total;
static Int64 _measure_time_lap;
static int _clk_mul;
static bool _init_flag;
/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
private:
ClockCycleCounter (const ClockCycleCounter &other);
ClockCycleCounter &
operator = (const ClockCycleCounter &other);
bool operator == (const ClockCycleCounter &other);
bool operator != (const ClockCycleCounter &other);
}; // class ClockCycleCounter
} // namespace stopwatch
#include "ClockCycleCounter.hpp"
#endif // stopwatch_ClockCycleCounter_HEADER_INCLUDED
/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/

View File

@@ -0,0 +1,150 @@
/*****************************************************************************
ClockCycleCounter.hpp
Copyright (c) 2003 Laurent de Soras
Please complete the definitions according to your compiler/architecture.
It's not a big deal if it's not possible to get the clock count...
--- Legal stuff ---
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*Tab=3***********************************************************************/
#if defined (stopwatch_ClockCycleCounter_CURRENT_CODEHEADER)
#error Recursive inclusion of ClockCycleCounter code header.
#endif
#define stopwatch_ClockCycleCounter_CURRENT_CODEHEADER
#if ! defined (stopwatch_ClockCycleCounter_CODEHEADER_INCLUDED)
#define stopwatch_ClockCycleCounter_CODEHEADER_INCLUDED
/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
#include "fnc.h"
#include <climits>
namespace stopwatch
{
/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
/*
==============================================================================
Name: start
Description:
Starts the counter.
Throws: Nothing
==============================================================================
*/
void ClockCycleCounter::start ()
{
_best_score = (static_cast <Int64> (1) << (sizeof (Int64) * CHAR_BIT - 2));
const Int64 start_clock = read_clock_counter ();
_start_time = start_clock;
_state = start_clock - _best_score;
}
/*
==============================================================================
Name: stop_lap
Description:
Captures the current time and updates the smallest duration between two
consecutive calls to stop_lap() or the latest start().
start() must have been called at least once before calling this function.
Throws: Nothing
==============================================================================
*/
void ClockCycleCounter::stop_lap ()
{
const Int64 end_clock = read_clock_counter ();
_best_score = min (end_clock - _state, _best_score);
_state = end_clock;
}
/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
Int64 ClockCycleCounter::read_clock_counter ()
{
register Int64 clock_cnt;
#if defined (_MSC_VER)
__asm
{
lea edi, clock_cnt
rdtsc
mov [edi ], eax
mov [edi + 4], edx
}
#elif defined (__GNUC__) && defined (__i386__)
__asm__ __volatile__ ("rdtsc" : "=A" (clock_cnt));
#elif (__MWERKS__) && defined (__POWERPC__)
asm
{
loop:
mftbu clock_cnt@hiword
mftb clock_cnt@loword
mftbu r5
cmpw clock_cnt@hiword,r5
bne loop
}
#endif
return (clock_cnt);
}
} // namespace stopwatch
#endif // stopwatch_ClockCycleCounter_CODEHEADER_INCLUDED
#undef stopwatch_ClockCycleCounter_CURRENT_CODEHEADER
/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/

View File

@@ -0,0 +1,71 @@
/*****************************************************************************
Int64.h
Copyright (c) 2003 Laurent de Soras
--- Legal stuff ---
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*Tab=3***********************************************************************/
#if ! defined (stopwatch_Int64_HEADER_INCLUDED)
#define stopwatch_Int64_HEADER_INCLUDED
#if defined (_MSC_VER)
#pragma once
#pragma warning (4 : 4250) // "Inherits via dominance."
#endif
/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
namespace stopwatch
{
#if defined (_MSC_VER)
typedef __int64 Int64;
#elif defined (__MWERKS__) || defined (__GNUC__)
typedef long long Int64;
#elif defined (__BEOS__)
typedef int64 Int64;
#else
#error No 64-bit integer type defined for this compiler !
#endif
} // namespace stopwatch
#endif // stopwatch_Int64_HEADER_INCLUDED
/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/

View File

@@ -0,0 +1,101 @@
/*****************************************************************************
StopWatch.cpp
Copyright (c) 2005 Laurent de Soras
--- Legal stuff ---
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*Tab=3***********************************************************************/
#if defined (_MSC_VER)
#pragma warning (1 : 4130) // "'operator' : logical operation on address of string constant"
#pragma warning (1 : 4223) // "nonstandard extension used : non-lvalue array converted to pointer"
#pragma warning (1 : 4705) // "statement has no effect"
#pragma warning (1 : 4706) // "assignment within conditional expression"
#pragma warning (4 : 4786) // "identifier was truncated to '255' characters in the debug information"
#pragma warning (4 : 4800) // "forcing value to bool 'true' or 'false' (performance warning)"
#pragma warning (4 : 4355) // "'this' : used in base member initializer list"
#endif
/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
#include "StopWatch.h"
#include <cassert>
namespace stopwatch
{
/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
StopWatch::StopWatch ()
: _ccc ()
, _nbr_laps (0)
{
// Nothing
}
double StopWatch::get_time_total (Int64 nbr_op) const
{
assert (_nbr_laps > 0);
assert (nbr_op > 0);
return (
static_cast <double> (_ccc.get_time_total ())
/ (static_cast <double> (nbr_op) * static_cast <double> (_nbr_laps))
);
}
double StopWatch::get_time_best_lap (Int64 nbr_op) const
{
assert (nbr_op > 0);
return (
static_cast <double> (_ccc.get_time_best_lap ())
/ static_cast <double> (nbr_op)
);
}
/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
} // namespace stopwatch
/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/

View File

@@ -0,0 +1,110 @@
/*****************************************************************************
StopWatch.h
Copyright (c) 2005 Laurent de Soras
Utility class based on ClockCycleCounter to measure the unit time of a
repeated operation.
--- Legal stuff ---
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*Tab=3***********************************************************************/
#if ! defined (stopwatch_StopWatch_HEADER_INCLUDED)
#define stopwatch_StopWatch_HEADER_INCLUDED
#if defined (_MSC_VER)
#pragma once
#pragma warning (4 : 4250) // "Inherits via dominance."
#endif
/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
#include "ClockCycleCounter.h"
namespace stopwatch
{
class StopWatch
{
/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
public:
StopWatch ();
stopwatch_FORCEINLINE void
start ();
stopwatch_FORCEINLINE void
stop_lap ();
double get_time_total (Int64 nbr_op) const;
double get_time_best_lap (Int64 nbr_op) const;
/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
protected:
/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
private:
ClockCycleCounter
_ccc;
Int64 _nbr_laps;
/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
private:
StopWatch (const StopWatch &other);
StopWatch & operator = (const StopWatch &other);
bool operator == (const StopWatch &other);
bool operator != (const StopWatch &other);
}; // class StopWatch
} // namespace stopwatch
#include "StopWatch.hpp"
#endif // stopwatch_StopWatch_HEADER_INCLUDED
/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/

View File

@@ -0,0 +1,83 @@
/*****************************************************************************
StopWatch.hpp
Copyright (c) 2005 Laurent de Soras
--- Legal stuff ---
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*Tab=3***********************************************************************/
#if defined (stopwatch_StopWatch_CURRENT_CODEHEADER)
#error Recursive inclusion of StopWatch code header.
#endif
#define stopwatch_StopWatch_CURRENT_CODEHEADER
#if ! defined (stopwatch_StopWatch_CODEHEADER_INCLUDED)
#define stopwatch_StopWatch_CODEHEADER_INCLUDED
/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
namespace stopwatch
{
/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
void StopWatch::start ()
{
_nbr_laps = 0;
_ccc.start ();
}
void StopWatch::stop_lap ()
{
_ccc.stop_lap ();
++ _nbr_laps;
}
/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
} // namespace stopwatch
#endif // stopwatch_StopWatch_CODEHEADER_INCLUDED
#undef stopwatch_StopWatch_CURRENT_CODEHEADER
/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/

View File

@@ -0,0 +1,65 @@
/*****************************************************************************
def.h
Copyright (c) 2003 Laurent de Soras
--- Legal stuff ---
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*Tab=3***********************************************************************/
#if ! defined (stopwatch_def_HEADER_INCLUDED)
#define stopwatch_def_HEADER_INCLUDED
#if defined (_MSC_VER)
#pragma once
#pragma warning (4 : 4250) // "Inherits via dominance."
#endif
/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
namespace stopwatch
{
#if defined (_MSC_VER)
#define stopwatch_FORCEINLINE __forceinline
#else
#define stopwatch_FORCEINLINE inline
#endif
} // namespace stopwatch
#endif // stopwatch_def_HEADER_INCLUDED
/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/

View File

@@ -0,0 +1,67 @@
/*****************************************************************************
fnc.h
Copyright (c) 2003 Laurent de Soras
--- Legal stuff ---
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*Tab=3***********************************************************************/
#if ! defined (stopwatch_fnc_HEADER_INCLUDED)
#define stopwatch_fnc_HEADER_INCLUDED
#if defined (_MSC_VER)
#pragma once
#pragma warning (4 : 4250) // "Inherits via dominance."
#endif
/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
namespace stopwatch
{
template <typename T>
inline T min (T a, T b);
template <typename T>
inline T max (T a, T b);
inline int round_int (double x);
} // namespace rsp
#include "fnc.hpp"
#endif // stopwatch_fnc_HEADER_INCLUDED
/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/

View File

@@ -0,0 +1,85 @@
/*****************************************************************************
fnc.hpp
Copyright (c) 2003 Laurent de Soras
--- Legal stuff ---
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*Tab=3***********************************************************************/
#if defined (stopwatch_fnc_CURRENT_CODEHEADER)
#error Recursive inclusion of fnc code header.
#endif
#define stopwatch_fnc_CURRENT_CODEHEADER
#if ! defined (stopwatch_fnc_CODEHEADER_INCLUDED)
#define stopwatch_fnc_CODEHEADER_INCLUDED
/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
#include <cassert>
#include <cmath>
namespace std {}
namespace stopwatch
{
template <typename T>
inline T min (T a, T b)
{
return ((a < b) ? a : b);
}
template <typename T>
inline T max (T a, T b)
{
return ((b < a) ? a : b);
}
int round_int (double x)
{
using namespace std;
return (static_cast <int> (floor (x + 0.5)));
}
} // namespace stopwatch
#endif // stopwatch_fnc_CODEHEADER_INCLUDED
#undef stopwatch_fnc_CURRENT_CODEHEADER
/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/