.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * lib/clz_ctz.c |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2013 Chanho Min <chanho.min@lge.com> |
---|
5 | 6 | * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify |
---|
7 | | - * it under the terms of the GNU General Public License version 2 as |
---|
8 | | - * published by the Free Software Foundation. |
---|
9 | 7 | * The functions in this file aren't called directly, but are required by |
---|
10 | 8 | * GCC builtins such as __builtin_ctz, and therefore they can't be removed |
---|
11 | 9 | * despite appearing unreferenced in kernel source. |
---|
.. | .. |
---|
30 | 28 | } |
---|
31 | 29 | EXPORT_SYMBOL(__clzsi2); |
---|
32 | 30 | |
---|
33 | | -int __weak __clzdi2(long val); |
---|
34 | | -int __weak __ctzdi2(long val); |
---|
35 | | -#if BITS_PER_LONG == 32 |
---|
36 | | - |
---|
37 | | -int __weak __clzdi2(long val) |
---|
| 31 | +int __weak __clzdi2(u64 val); |
---|
| 32 | +int __weak __clzdi2(u64 val) |
---|
38 | 33 | { |
---|
39 | | - return 32 - fls((int)val); |
---|
| 34 | + return 64 - fls64(val); |
---|
40 | 35 | } |
---|
41 | 36 | EXPORT_SYMBOL(__clzdi2); |
---|
42 | 37 | |
---|
43 | | -int __weak __ctzdi2(long val) |
---|
| 38 | +int __weak __ctzdi2(u64 val); |
---|
| 39 | +int __weak __ctzdi2(u64 val) |
---|
44 | 40 | { |
---|
45 | | - return __ffs((u32)val); |
---|
| 41 | + return __ffs64(val); |
---|
46 | 42 | } |
---|
47 | 43 | EXPORT_SYMBOL(__ctzdi2); |
---|
48 | | - |
---|
49 | | -#elif BITS_PER_LONG == 64 |
---|
50 | | - |
---|
51 | | -int __weak __clzdi2(long val) |
---|
52 | | -{ |
---|
53 | | - return 64 - fls64((u64)val); |
---|
54 | | -} |
---|
55 | | -EXPORT_SYMBOL(__clzdi2); |
---|
56 | | - |
---|
57 | | -int __weak __ctzdi2(long val) |
---|
58 | | -{ |
---|
59 | | - return __ffs64((u64)val); |
---|
60 | | -} |
---|
61 | | -EXPORT_SYMBOL(__ctzdi2); |
---|
62 | | - |
---|
63 | | -#else |
---|
64 | | -#error BITS_PER_LONG not 32 or 64 |
---|
65 | | -#endif |
---|