P&S router: some missing files

parent db62d672
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* This program 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.
*
* This program 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 this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file profile.h:
* @brief Simple profiling functions for measuring code execution time.
*/
#ifndef __TPROFILE_H
#define __TPROFILE_H
#include <sys/time.h>
#include <stdint.h>
/**
* Function rdtsc
* Returns processor's time-stamp counter. Main purpose is precise time measuring of code
* execution time.
* @return unsigned long long - Value of time-stamp counter.
*/
#if defined(__i386__)
static __inline__ unsigned long long rdtsc()
{
unsigned long long int x;
__asm__ volatile ( ".byte 0x0f, 0x31" : "=A" ( x ) );
return x;
}
#elif defined(__x86_64__)
static __inline__ unsigned long long rdtsc()
{
unsigned hi, lo;
__asm__ __volatile__ ( "rdtsc" : "=a" ( lo ), "=d" ( hi ) );
return ( (unsigned long long) lo ) | ( ( (unsigned long long) hi ) << 32 );
}
#elif defined(__powerpc__)
static __inline__ unsigned long long rdtsc()
{
unsigned long long int result = 0;
unsigned long int upper, lower, tmp;
__asm__ volatile (
"0: \n"
"\tmftbu %0 \n"
"\tmftb %1 \n"
"\tmftbu %2 \n"
"\tcmpw %2,%0 \n"
"\tbne 0b \n"
: "=r" ( upper ), "=r" ( lower ), "=r" ( tmp )
);
result = upper;
result = result << 32;
result = result | lower;
return result;
}
#endif /* __powerpc__ */
// Fixme: OS X version
/**
* Function get_tics
* Returns the number of microseconds that have elapsed since the system was started.
* @return uint64_t Number of microseconds.
*/
static inline uint64_t get_tics()
{
struct timeval tv;
gettimeofday( &tv, NULL );
return (uint64_t) tv.tv_sec * 1000000ULL + (uint64_t) tv.tv_usec;
}
/**
* Structure for storing data related to profiling counters.
*/
struct prof_counter
{
uint64_t value; /// Stored timer value
bool use_rdtsc; /// Method of time measuring (rdtsc or tics)
};
/**
* Function prof_start
* Begins code execution time counting for a given profiling counter.
* @param cnt is the counter which should be started.
* @param use_rdtsc tells if processor's time-stamp counter should be used for time counting.
* Otherwise is system tics method will be used. IMPORTANT: time-stamp counter should not
* be used on multicore machines executing threaded code.
*/
static inline void prof_start( prof_counter* cnt, bool use_rdtsc )
{
cnt->use_rdtsc = use_rdtsc;
if( use_rdtsc )
{
cnt->value = rdtsc();
}
else
{
cnt->value = get_tics();
}
}
/**
* Function prof_stop
* Ends code execution time counting for a given profiling counter.
* @param cnt is the counter which should be stopped.
*/
static inline void prof_end( prof_counter* cnt )
{
if( cnt->use_rdtsc )
cnt->value = rdtsc() - cnt->value;
else
cnt->value = get_tics() - cnt->value;
}
#endif
#ifndef __TOOL_ACTION_H
#define __TOOL_ACTION_H
#include <string>
#include <wx/wx.h>
#include <tool/tool_base.h>
///> Scope of tool actions
enum TOOL_ActionScope {
SCOPE_CONTEXT = 1, ///> Action belongs to a particular tool (i.e. a part of a pop-up menu)
SCOPE_GLOBAL ///> Global action (toolbar/main menu event, global shortcut)
};
// TOOL_ACTION - represents a single action. For instance:
// - changing layer to top by pressing PgUp
// - running the DRC from the menu
// and so on, and so forth....
class TOOL_ACTION
{
public:
TOOL_ACTION
(
const std::string& name,
TOOL_ActionScope scope = SCOPE_GLOBAL,
int aDefaultHotKey = 0,
const wxString& menuItem = wxT(""),
const wxString& menuDesc = wxT("")
) :
m_name(name),
m_scope(scope),
m_defaultHotKey(aDefaultHotKey),
m_currentHotKey(aDefaultHotKey),
m_menuItem(menuItem),
m_menuDescription(menuDesc) {}
bool operator == ( const TOOL_ACTION& rhs ) const
{
return m_id == rhs.m_id;
}
bool operator != ( const TOOL_ACTION& rhs ) const
{
return m_id != rhs.m_id;
}
bool hasHotKey() const
{
return m_currentHotKey > 0;
}
private:
friend class TOOL_MANAGER;
void setId ( int aId )
{
m_id = aId;
}
// name of the action (convention is: app.[tool.]action.name)
std::string m_name;
TOOL_ActionScope m_scope;
int m_defaultHotKey;
int m_currentHotKey;
// Menu item text
wxString m_menuItem;
// Pop-up help
wxString m_menuDescription;
//KiBitmap m_bitmap;
// Unique ID for fast matching. Assigned by TOOL_MANAGER
int m_id;
// Origin of the action
TOOL_BASE *m_origin;
// Originating UI object
wxWindow *m_uiOrigin;
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment