From 6727e543c7d81a6828e89729887d2ceb561f5960 Mon Sep 17 00:00:00 2001 From: riastradh Date: Wed, 6 Aug 2014 14:05:08 +0000 Subject: [PATCH] Add rounddown_pow_of_two. --- sys/external/bsd/drm2/include/linux/log2.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sys/external/bsd/drm2/include/linux/log2.h b/sys/external/bsd/drm2/include/linux/log2.h index cf328b54c42f..0c2ee4085d7a 100644 --- a/sys/external/bsd/drm2/include/linux/log2.h +++ b/sys/external/bsd/drm2/include/linux/log2.h @@ -1,4 +1,4 @@ -/* $NetBSD: log2.h,v 1.4 2014/07/16 20:59:58 riastradh Exp $ */ +/* $NetBSD: log2.h,v 1.5 2014/08/06 14:05:08 riastradh Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -58,6 +58,14 @@ roundup_pow_of_two(unsigned long n) return (n + 1); } +static inline unsigned long +rounddown_pow_of_two(unsigned long n) +{ + + /* XXX fls64 is not fls_ulong, but it'll do for now. */ + return (1UL << (fls64(n) - 1)); +} + static inline unsigned order_base_2(unsigned long n) {