Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 288918
b: refs/heads/master
c: 169c843
h: refs/heads/master
v: v3
  • Loading branch information
Tim Bird authored and Greg Kroah-Hartman committed Feb 9, 2012
1 parent 6892688 commit eacfc74
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 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: c76c7ca31f16c9556cad527bfa3504b0aafb3045
refs/heads/master: 169c843afffcb328390ef39ff95227596d6f63c4
28 changes: 20 additions & 8 deletions trunk/drivers/staging/android/logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,16 +242,28 @@ static size_t get_next_entry(struct logger_log *log, size_t off, size_t len)
}

/*
* clock_interval - is a < c < b in mod-space? Put another way, does the line
* from a to b cross c?
* is_between - is a < c < b, accounting for wrapping of a, b, and c
* positions in the buffer
*
* That is, if a<b, check for c between a and b
* and if a>b, check for c outside (not between) a and b
*
* |------- a xxxxxxxx b --------|
* c^
*
* |xxxxx b --------- a xxxxxxxxx|
* c^
* or c^
*/
static inline int clock_interval(size_t a, size_t b, size_t c)
static inline int is_between(size_t a, size_t b, size_t c)
{
if (b < a) {
if (a < c || b >= c)
if (a < b) {
/* is c between a and b? */
if (a < c && c <= b)
return 1;
} else {
if (a < c && b >= c)
/* is c outside of b through a? */
if (c <= b || a < c)
return 1;
}

Expand All @@ -272,11 +284,11 @@ static void fix_up_readers(struct logger_log *log, size_t len)
size_t new = logger_offset(log, old + len);
struct logger_reader *reader;

if (clock_interval(old, new, log->head))
if (is_between(old, new, log->head))
log->head = get_next_entry(log, log->head, len);

list_for_each_entry(reader, &log->readers, list)
if (clock_interval(old, new, reader->r_off))
if (is_between(old, new, reader->r_off))
reader->r_off = get_next_entry(log, reader->r_off, len);
}

Expand Down

0 comments on commit eacfc74

Please sign in to comment.