Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 255309
b: refs/heads/master
c: f5d33d3
h: refs/heads/master
i:
  255307: bf1dcca
v: v3
  • Loading branch information
Antonio Quartulli authored and Sven Eckelmann committed May 30, 2011
1 parent ff4d07a commit fc28f86
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 728cbc6ac1eef89660875c70a602c1a0ba8df4ff
refs/heads/master: f5d33d37786af139cecde5af831d64a671bb756b
16 changes: 16 additions & 0 deletions trunk/net/batman-adv/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,20 @@ static inline int compare_eth(const void *data1, const void *data2)

#define atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0)

/* Returns the smallest signed integer in two's complement with the sizeof x */
#define smallest_signed_int(x) (1u << (7u + 8u * (sizeof(x) - 1u)))

/* Checks if a sequence number x is a predecessor/successor of y.
* they handle overflows/underflows and can correctly check for a
* predecessor/successor unless the variable sequence number has grown by
* more then 2**(bitwidth(x)-1)-1.
* This means that for a uint8_t with the maximum value 255, it would think:
* - when adding nothing - it is neither a predecessor nor a successor
* - before adding more than 127 to the starting value - it is a predecessor,
* - when adding 128 - it is neither a predecessor nor a successor,
* - after adding more than 127 to the starting value - it is a successor */
#define seq_before(x, y) ({typeof(x) _dummy = (x - y); \
_dummy > smallest_signed_int(_dummy); })
#define seq_after(x, y) seq_before(y, x)

#endif /* _NET_BATMAN_ADV_MAIN_H_ */
16 changes: 0 additions & 16 deletions trunk/net/batman-adv/vis.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,6 @@

#define MAX_VIS_PACKET_SIZE 1000

/* Returns the smallest signed integer in two's complement with the sizeof x */
#define smallest_signed_int(x) (1u << (7u + 8u * (sizeof(x) - 1u)))

/* Checks if a sequence number x is a predecessor/successor of y.
* they handle overflows/underflows and can correctly check for a
* predecessor/successor unless the variable sequence number has grown by
* more then 2**(bitwidth(x)-1)-1.
* This means that for a uint8_t with the maximum value 255, it would think:
* - when adding nothing - it is neither a predecessor nor a successor
* - before adding more than 127 to the starting value - it is a predecessor,
* - when adding 128 - it is neither a predecessor nor a successor,
* - after adding more than 127 to the starting value - it is a successor */
#define seq_before(x, y) ({typeof(x) _dummy = (x - y); \
_dummy > smallest_signed_int(_dummy); })
#define seq_after(x, y) seq_before(y, x)

static void start_vis_timer(struct bat_priv *bat_priv);

/* free the info */
Expand Down

0 comments on commit fc28f86

Please sign in to comment.