Skip to content

Commit

Permalink
Use click_jiffies_t where appropriate.
Browse files Browse the repository at this point in the history
That is, not click_jiffies_type.  Also fix a misbehavior in
click_get_cycles() for i386 without 64-bit integers.
  • Loading branch information
Eddie Kohler committed May 23, 2008
1 parent a4afeda commit 0d9f144
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 47 deletions.
4 changes: 2 additions & 2 deletions elements/aqm/red.cc
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ RED::should_drop()
} else {
// do timing stuff for when the queue was empty
#if CLICK_HZ < 50
int j = click_jiffies();
click_jiffies_t j = click_jiffies();
#else
int j = click_jiffies() / (CLICK_HZ / 50);
click_jiffies_t j = click_jiffies() / (CLICK_HZ / 50);
#endif
_size.update_n(0, _last_jiffies ? j - _last_jiffies : 1);
_last_jiffies = j;
Expand Down
2 changes: 1 addition & 1 deletion elements/aqm/red.hh
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class RED : public Element { public:
unsigned _G2;
int _count;
int _random_value;
int _last_jiffies;
click_jiffies_t _last_jiffies;

int _drops;
Vector<Element *> _queue_elements;
Expand Down
8 changes: 4 additions & 4 deletions elements/bsdmodule/fastudpsrc.hh
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ class FastUDPSource : public Element {
unsigned int _interval;
bool _cksum;
struct mbuf *_m;
unsigned long _first; // jiffies
unsigned long _last;
click_jiffies_t _first;
click_jiffies_t _last;

void incr_ports();

Expand Down Expand Up @@ -101,8 +101,8 @@ class FastUDPSource : public Element {
void add_handlers();
void reset();
unsigned count() { return _count; }
unsigned long first() { return _first; }
unsigned long last() { return _last; }
click_jiffies_t first() { return _first; }
click_jiffies_t last() { return _last; }

#if 0
friend int FastUDPSource_limit_write_handler
Expand Down
4 changes: 2 additions & 2 deletions elements/ethernet/arpquerier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ ARPQuerier::expire_hook(Timer *timer, void *thunk)
// packet.
ARPQuerier *arpq = (ARPQuerier *)thunk;
arpq->_lock.acquire_write();
int jiff = click_jiffies();
click_jiffies_t jiff = click_jiffies();
ARPEntry *ae;

// Delete old entries.
Expand Down Expand Up @@ -364,7 +364,7 @@ ARPQuerier::handle_ip(Packet *p)
}

// Send a query for any given address at most 10 times a second.
click_jiffies_type jiff = click_jiffies();
click_jiffies_t jiff = click_jiffies();
if ((jiff - ae->last_response_jiffies) >= CLICK_HZ / 10) {
ae->last_response_jiffies = jiff;
_lock.release_write();
Expand Down
2 changes: 1 addition & 1 deletion elements/ethernet/arpquerier.hh
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class ARPQuerier : public Element { public:
EtherAddress en; // Deleting head and pprev could get it down to
bool ok; // 32B, with some time cost.
bool polling; // It used to be 24B... :|
int last_response_jiffies;
click_jiffies_t last_response_jiffies;
Packet *head;
Packet *tail;
ARPEntry *next;
Expand Down
2 changes: 1 addition & 1 deletion elements/ethernet/ip6ndsolicitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void
IP6NDSolicitor::expire_hook(Timer *, void *thunk)
{
IP6NDSolicitor *arpq = (IP6NDSolicitor *)thunk;
int jiff = click_jiffies();
click_jiffies_t jiff = click_jiffies();
for (int i = 0; i < NMAP; i++) {
NDEntry *prev = 0;
while (1) {
Expand Down
2 changes: 1 addition & 1 deletion elements/ethernet/ip6ndsolicitor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class IP6NDSolicitor : public Element {
struct NDEntry {
IP6Address ip6;
EtherAddress en;
int last_response_jiffies;
click_jiffies_t last_response_jiffies;
unsigned ok: 1;
unsigned polling: 1;
Packet *p;
Expand Down
8 changes: 4 additions & 4 deletions elements/linuxmodule/fasttcpflows.hh
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ class FastTCPFlows : public Element {
unsigned int _last_flow;
unsigned int _flowsize;
bool _cksum;
unsigned long _first; // jiffies
unsigned long _last;
click_jiffies_t _first;
click_jiffies_t _last;

struct flow_t {
WritablePacket *syn_packet;
Expand Down Expand Up @@ -106,8 +106,8 @@ class FastTCPFlows : public Element {
void add_handlers();
void reset();
unsigned count() { return _count; }
unsigned long first() { return _first; }
unsigned long last() { return _last; }
click_jiffies_t first() { return _first; }
click_jiffies_t last() { return _last; }
};


Expand Down
8 changes: 4 additions & 4 deletions elements/linuxmodule/fastudpflows.hh
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class FastUDPFlows : public Element {
unsigned int _last_flow;
unsigned int _flowsize;
bool _cksum;
unsigned long _first; // jiffies
unsigned long _last;
click_jiffies_t _first;
click_jiffies_t _last;

struct flow_t {
WritablePacket *packet;
Expand Down Expand Up @@ -102,8 +102,8 @@ class FastUDPFlows : public Element {
void add_handlers();
void reset();
unsigned count() { return _count; }
unsigned long first() { return _first; }
unsigned long last() { return _last; }
click_jiffies_t first() { return _first; }
click_jiffies_t last() { return _last; }
};


Expand Down
8 changes: 4 additions & 4 deletions elements/linuxmodule/fastudpsrc.hh
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ class FastUDPSource : public Element {
bool _cksum;
WritablePacket *_packet;
struct sk_buff *_skb;
unsigned long _first; // jiffies
unsigned long _last;
click_jiffies_t _first;
click_jiffies_t _last;

void incr_ports();

Expand Down Expand Up @@ -100,8 +100,8 @@ class FastUDPSource : public Element {
void add_handlers();
void reset();
unsigned count() { return _count; }
unsigned long first() { return _first; }
unsigned long last() { return _last; }
click_jiffies_t first() { return _first; }
click_jiffies_t last() { return _last; }

#if 0
friend int FastUDPSource_limit_write_handler
Expand Down
8 changes: 4 additions & 4 deletions elements/linuxmodule/fastudpsrcip6.hh
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ class FastUDPSourceIP6 : public Element {
bool _cksum;
WritablePacket *_packet;
struct sk_buff *_skb;
unsigned long _first; // jiffies
unsigned long _last;
click_jiffies_t _first;
click_jiffies_t _last;

void incr_ports();

Expand Down Expand Up @@ -101,8 +101,8 @@ class FastUDPSourceIP6 : public Element {
void add_handlers();
void reset();
unsigned count() { return _count; }
unsigned long first() { return _first; }
unsigned long last() { return _last; }
click_jiffies_t first() { return _first; }
click_jiffies_t last() { return _last; }

#if 0
friend int FastUDPSourceIP6_limit_write_handler
Expand Down
4 changes: 2 additions & 2 deletions elements/linuxmodule/sortedsched.cc
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ BalancedThreadSched::run_timer(Timer *)
#if DEBUG > 1
if (high >= 500) {
print = 1;
unsigned now = click_jiffies();
click_jiffies_t now = click_jiffies();
for(int i=0; i<sorted.size(); i++) {
Element *e = sorted[i]->element();
if (e)
Expand Down Expand Up @@ -254,7 +254,7 @@ BalancedThreadSched::run_timer(Timer *)

#if DEBUG > 1
if (print) {
unsigned now = click_jiffies();
click_jiffies_t now = click_jiffies();
for(int i=0; i<sorted.size(); i++) {
Element *e = sorted[i]->element();
if (e)
Expand Down
2 changes: 1 addition & 1 deletion elements/linuxmodule/threadmonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ThreadMonitor::run_timer(Timer *)
{
Master *m = router()->master();
StringAccum sa;
unsigned now_jiffies = click_jiffies();
click_jiffies_t now_jiffies = click_jiffies();

// report currently scheduled tasks (ignore pending list)
for (int tid = 0; tid < m->nthreads(); tid++) {
Expand Down
15 changes: 8 additions & 7 deletions elements/standard/averagecounter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,14 @@ AverageCounter::initialize(ErrorHandler *)
Packet *
AverageCounter::simple_action(Packet *p)
{
_first.compare_and_swap(0, click_jiffies());
if (click_jiffies() - _first >= _ignore) {
_count++;
_byte_count += p->length();
}
_last = click_jiffies();
return p;
uint32_t jpart = click_jiffies();
_first.compare_and_swap(0, jpart);
if (jpart - _first >= _ignore) {
_count++;
_byte_count += p->length();
}
_last = jpart;
return p;
}

static String
Expand Down
16 changes: 8 additions & 8 deletions include/click/glue.hh
Original file line number Diff line number Diff line change
Expand Up @@ -209,27 +209,27 @@ typedef struct device net_device;
// TIMEVALS AND JIFFIES

#if CLICK_LINUXMODULE
typedef unsigned long click_jiffies_type;
typedef long click_jiffies_difference_type;
typedef unsigned long click_jiffies_t;
typedef long click_jiffies_difference_t;
# define click_gettimeofday(tvp) (do_gettimeofday(tvp))
# define click_jiffies() (jiffies)
# define CLICK_HZ HZ
#elif CLICK_BSDMODULE
typedef int click_jiffies_type;
typedef int click_jiffies_difference_type;
typedef int click_jiffies_t;
typedef int click_jiffies_difference_t;
# define click_gettimeofday(tvp) (getmicrotime(tvp))
# define click_jiffies() ((unsigned)ticks)
# define CLICK_HZ hz
#else
typedef unsigned click_jiffies_type;
typedef int click_jiffies_difference_type;
typedef unsigned click_jiffies_t;
typedef int click_jiffies_difference_t;
#if !CLICK_NS
# define click_gettimeofday(tvp) (gettimeofday(tvp, (struct timezone *)0))
#else
# define click_gettimeofday(tvp) (simclick_gettimeofday(tvp))
#endif
CLICK_DECLS
click_jiffies_type click_jiffies();
click_jiffies_t click_jiffies();
CLICK_ENDDECLS
# define CLICK_HZ 1000
#endif
Expand Down Expand Up @@ -412,7 +412,7 @@ click_get_cycles()
#elif CLICK_LINUXMODULE && __i386__
uint32_t xlo, xhi;
__asm__ __volatile__ ("rdtsc" : "=a" (xlo), "=d" (xhi));
return xhi ? 0xFFFFFFFF : xlo;
return xlo;
#elif CLICK_BSDMODULE
return rdtsc();
#else
Expand Down
2 changes: 1 addition & 1 deletion lib/glue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ click_qsort(void *base, size_t n, size_t size, int (*compar)(const void *, const
# endif
CLICK_DECLS

click_jiffies_type
click_jiffies_t
click_jiffies()
{
struct timeval tv;
Expand Down

0 comments on commit 0d9f144

Please sign in to comment.