/* Mask value to the correct size. */
mask = GENMASK((size * BITS_PER_BYTE) - 1, 0);
val &= mask;
/* * Calculate a shift & mask that correspond to the value we wish to * exchange within the naturally aligned 4 byte integerthat includes * it.
*/
shift = (unsignedlong)ptr & 0x3;
shift *= BITS_PER_BYTE;
mask <<= shift;
/* * Calculate a pointer to the naturally aligned 4 byte integer that * includes our byte of interest, and load its value.
*/
ptr32 = (volatile u32 *)((unsignedlong)ptr & ~0x3);
/* Mask inputs to the correct size. */
mask = GENMASK((size * BITS_PER_BYTE) - 1, 0);
old &= mask; new &= mask;
/* * Calculate a shift & mask that correspond to the value we wish to * compare & exchange within the naturally aligned 4 byte integer * that includes it.
*/
shift = (unsignedlong)ptr & 0x3;
shift *= BITS_PER_BYTE;
old <<= shift; new <<= shift;
mask <<= shift;
/* * Calculate a pointer to the naturally aligned 4 byte integer that * includes our byte of interest, and load its value.
*/
ptr32 = (volatile u32 *)((unsignedlong)ptr & ~0x3);
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.