I was going through the manual of the mmap function and came across this line:
pa_offset = offset & ~(sysconf(_SC_PAGE_SIZE) - 1);
/* offset for mmap() must be page aligned */
I think I understand what this line does. It gets the page size and makes sure that pa_offset is either zero or a multiple of the page size (4096 here). But I do not understand how. I know what the bitwise operators do, but is it possible to explain how exactly this is being achieved?