diff options
| author | Tvrtko Ursulin <tvrtko.ursulin@intel.com> | 2022-01-18 10:54:02 +0000 |
|---|---|---|
| committer | Tvrtko Ursulin <tvrtko.ursulin@intel.com> | 2022-01-18 10:54:02 +0000 |
| commit | 647bfd26bf054313305ea9c2c4a1c71f3bbfee63 (patch) | |
| tree | 49abfde459ef32c9811d06ae59dfbaf0000762ab /tools/include/linux/math.h | |
| parent | 3a5d604f90f90a09e35ccfdeeedbadfd06b606db (diff) | |
| parent | 4efdddbce7c1329f00c458e85dcaf105aebdc0ed (diff) | |
| download | lwn-647bfd26bf054313305ea9c2c4a1c71f3bbfee63.tar.gz lwn-647bfd26bf054313305ea9c2c4a1c71f3bbfee63.zip | |
Merge drm/drm-next into drm-intel-gt-next
Maarten needs backmerge to account for header file renames/changes which
landed via drm-intel-next and are interfering with his pinning work.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Diffstat (limited to 'tools/include/linux/math.h')
| -rw-r--r-- | tools/include/linux/math.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tools/include/linux/math.h b/tools/include/linux/math.h new file mode 100644 index 000000000000..4e7af99ec9eb --- /dev/null +++ b/tools/include/linux/math.h @@ -0,0 +1,25 @@ +#ifndef _TOOLS_MATH_H +#define _TOOLS_MATH_H + +/* + * This looks more complex than it should be. But we need to + * get the type for the ~ right in round_down (it needs to be + * as wide as the result!), and we want to evaluate the macro + * arguments just once each. + */ +#define __round_mask(x, y) ((__typeof__(x))((y)-1)) +#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1) +#define round_down(x, y) ((x) & ~__round_mask(x, y)) + +#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) + +#ifndef roundup +#define roundup(x, y) ( \ +{ \ + const typeof(y) __y = y; \ + (((x) + (__y - 1)) / __y) * __y; \ +} \ +) +#endif + +#endif |
