[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
|
|
Subscribe / Log in / New account

Implementing alignment guarantees for kmalloc()

Implementing alignment guarantees for kmalloc()

Posted Oct 22, 2019 19:55 UTC (Tue) by wilevers (subscriber, #110407)
In reply to: Implementing alignment guarantees for kmalloc() by jreiser
Parent article: Implementing alignment guarantees for kmalloc()

Try parsing this. Then again. Any questions?


to post comments

Implementing alignment guarantees for kmalloc()

Posted Oct 23, 2019 14:20 UTC (Wed) by rweikusat2 (subscriber, #117920) [Link]

The expression was n & ~(-1 + n). That's a slightly steganographically obscured version of n & ~(n - 1). Assuming that n is some non-zero binary number, subtracting one from that causes the lowest set 1 bit to change to 0 and all 0 bits below it to 1. All other 1 bits of n are also 1 in n - 1. Hence n & ~(n - 1) leaves only the lowest bit of n set.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds