mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-29 21:33:00 +01:00
While the GCC and Clang compilers already define __ASSEMBLER__ automatically when compiling assembly code, __ASSEMBLY__ is a macro that only gets defined by the Makefiles in the kernel. This can be very confusing when switching between userspace and kernelspace coding, or when dealing with uapi headers that rather should use __ASSEMBLER__ instead. So let's standardize now on the __ASSEMBLER__ macro that is provided by the compilers. This is a completely mechanical patch (done with a simple "sed -i" statement). Link: https://lore.kernel.org/[email protected] Signed-off-by: Thomas Huth <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Axel Rasmussen <[email protected]> Cc: Barry Song <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Kairui Song <[email protected]> Cc: Liam R. Howlett <[email protected]> Cc: Lorenzo Stoakes <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Mike Rapoport <[email protected]> Cc: Shakeel Butt <[email protected]> Cc: Suren Baghdasaryan <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: Wei Xu <[email protected]> Cc: Yuanchu Xie <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
53 lines
1.2 KiB
C
53 lines
1.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __ASM_GENERIC_GETORDER_H
|
|
#define __ASM_GENERIC_GETORDER_H
|
|
|
|
#ifndef __ASSEMBLER__
|
|
|
|
#include <linux/compiler.h>
|
|
#include <linux/log2.h>
|
|
|
|
/**
|
|
* get_order - Determine the allocation order of a memory size
|
|
* @size: The size for which to get the order
|
|
*
|
|
* Determine the allocation order of a particular sized block of memory. This
|
|
* is on a logarithmic scale, where:
|
|
*
|
|
* 0 -> 2^0 * PAGE_SIZE and below
|
|
* 1 -> 2^1 * PAGE_SIZE to 2^0 * PAGE_SIZE + 1
|
|
* 2 -> 2^2 * PAGE_SIZE to 2^1 * PAGE_SIZE + 1
|
|
* 3 -> 2^3 * PAGE_SIZE to 2^2 * PAGE_SIZE + 1
|
|
* 4 -> 2^4 * PAGE_SIZE to 2^3 * PAGE_SIZE + 1
|
|
* ...
|
|
*
|
|
* The order returned is used to find the smallest allocation granule required
|
|
* to hold an object of the specified size.
|
|
*
|
|
* The result is undefined if the size is 0.
|
|
*/
|
|
static __always_inline __attribute_const__ int get_order(unsigned long size)
|
|
{
|
|
if (__builtin_constant_p(size)) {
|
|
if (!size)
|
|
return BITS_PER_LONG - PAGE_SHIFT;
|
|
|
|
if (size < (1UL << PAGE_SHIFT))
|
|
return 0;
|
|
|
|
return ilog2((size) - 1) - PAGE_SHIFT + 1;
|
|
}
|
|
|
|
size--;
|
|
size >>= PAGE_SHIFT;
|
|
#if BITS_PER_LONG == 32
|
|
return fls(size);
|
|
#else
|
|
return fls64(size);
|
|
#endif
|
|
}
|
|
|
|
#endif /* __ASSEMBLER__ */
|
|
|
|
#endif /* __ASM_GENERIC_GETORDER_H */
|