/* SPDX-License-Identifier: GPL-2.0-only */ /* * Bit operations for the Hexagon architecture * * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
*/
/* * The offset calculations for these are based on BITS_PER_LONG == 32 * (i.e. I get to shift by #5-2 (32 bits per long, 4 bytes per access), * mask by 0x0000001F) * * Typically, R10 is clobbered for address, R11 bit nr, and R12 is temp
*/
/** * test_and_clear_bit - clear a bit and return its old value * @nr: bit number to clear * @addr: pointer to memory
*/ staticinlineint test_and_clear_bit(int nr, volatilevoid *addr)
{ int oldval;
/** * test_and_set_bit - set a bit and return its old value * @nr: bit number to set * @addr: pointer to memory
*/ staticinlineint test_and_set_bit(int nr, volatilevoid *addr)
{ int oldval;
/** * test_and_change_bit - toggle a bit and return its old value * @nr: bit number to set * @addr: pointer to memory
*/ staticinlineint test_and_change_bit(int nr, volatilevoid *addr)
{ int oldval;
/* * These are allowed to be non-atomic. In fact the generic flavors are * in non-atomic.h. Would it be better to use intrinsics for this? * * OK, writes in our architecture do not invalidate LL/SC, so this has to * be atomic, particularly for things like slab_lock and slab_unlock. *
*/ static __always_inline void
arch___clear_bit(unsignedlong nr, volatileunsignedlong *addr)
{
test_and_clear_bit(nr, addr);
}
/* Apparently, at least some of these are allowed to be non-atomic */ static __always_inline bool
arch___test_and_clear_bit(unsignedlong nr, volatileunsignedlong *addr)
{ return test_and_clear_bit(nr, addr);
}
/* * ffz - find first zero in word. * @word: The word to search * * Undefined if no zero exists, so code should check against ~0UL first.
*/ staticinlinelong ffz(int x)
{ int r;
/* * fls - find last (most-significant) bit set * @x: the word to search * * This is defined the same way as ffs. * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
*/ staticinlineint fls(unsignedint x)
{ int r;
/* * ffs - find first bit set * @x: the word to search * * This is defined the same way as * the libc and compiler builtin ffs routines, therefore * differs in spirit from the above ffz (man ffs).
*/ staticinlineint ffs(int x)
{ int r;
/* * __ffs - find first bit in word. * @word: The word to search * * Undefined if no bit exists, so code should check against 0 first. * * bits_per_long assumed to be 32 * numbering starts at 0 I think (instead of 1 like ffs)
*/ staticinlineunsignedlong __ffs(unsignedlong word)
{ int num;
/* * __fls - find last (most-significant) set bit in a long word * @word: the word to search * * Undefined if no set bit exists, so code should check against 0 first. * bits_per_long assumed to be 32
*/ staticinlineunsignedlong __fls(unsignedlong word)
{ int num;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.