Skip to content

Commit

Permalink
tux3: Update libklib/libklib.h for v4.19
Browse files Browse the repository at this point in the history
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
  • Loading branch information
OGAWAHirofumi committed Nov 14, 2018
1 parent abd20dd commit 0ef4dde
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions fs/tux3/user/libklib/libklib.h
Expand Up @@ -70,7 +70,23 @@
* arguments just once each.
*/
#define __round_mask(x, y) ((__typeof__(x))((y)-1))
/**
* round_up - round up to next specified power of 2
* @x: the value to round
* @y: multiple to round up to (must be a power of 2)
*
* Rounds @x up to next multiple of @y (which must be a power of 2).
* To perform arbitrary rounding up, use roundup() below.
*/
#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
/**
* round_down - round down to next specified power of 2
* @x: the value to round
* @y: multiple to round down to (must be a power of 2)
*
* Rounds @x down to next multiple of @y (which must be a power of 2).
* To perform arbitrary rounding down, use rounddown() below.
*/
#define round_down(x, y) ((x) & ~__round_mask(x, y))

/**
Expand All @@ -84,6 +100,37 @@

#define DIV_ROUND_UP __KERNEL_DIV_ROUND_UP

/**
* roundup - round up to the next specified multiple
* @x: the value to up
* @y: multiple to round up to
*
* Rounds @x up to next multiple of @y. If @y will always be a power
* of 2, consider using the faster round_up().
*
* The `const' here prevents gcc-3.3 from calling __divdi3
*/
#define roundup(x, y) ( \
{ \
const typeof(y) __y = y; \
(((x) + (__y - 1)) / __y) * __y; \
} \
)
/**
* rounddown - round down to next specified multiple
* @x: the value to round
* @y: multiple to round down to
*
* Rounds @x down to next multiple of @y. If @y will always be a power
* of 2, consider using the faster round_down().
*/
#define rounddown(x, y) ( \
{ \
typeof(x) __x = (x); \
__x - (__x % (y)); \
} \
)

/*
* min()/max()/clamp() macros must accomplish three things:
*
Expand Down

0 comments on commit 0ef4dde

Please sign in to comment.