| 4916 | } |
| 4917 | |
| 4918 | static inline void |
| 4919 | vm_page_bits_clear(vm_page_t m, vm_page_bits_t *bits, vm_page_bits_t clear) |
| 4920 | { |
| 4921 | |
| 4922 | #if PAGE_SIZE == 32768 |
| 4923 | atomic_clear_64((uint64_t *)bits, clear); |
| 4924 | #elif PAGE_SIZE == 16384 |
| 4925 | atomic_clear_32((uint32_t *)bits, clear); |
| 4926 | #elif (PAGE_SIZE == 8192) && defined(atomic_clear_16) |
| 4927 | atomic_clear_16((uint16_t *)bits, clear); |
| 4928 | #elif (PAGE_SIZE == 4096) && defined(atomic_clear_8) |
| 4929 | atomic_clear_8((uint8_t *)bits, clear); |
| 4930 | #else /* PAGE_SIZE <= 8192 */ |
| 4931 | uintptr_t addr; |
| 4932 | int shift; |
| 4933 | |
| 4934 | addr = (uintptr_t)bits; |
| 4935 | /* |
| 4936 | * Use a trick to perform a 32-bit atomic on the |
| 4937 | * containing aligned word, to not depend on the existence |
| 4938 | * of atomic_{set, clear}_{8, 16}. |
| 4939 | */ |
| 4940 | shift = addr & (sizeof(uint32_t) - 1); |
| 4941 | #if BYTE_ORDER == BIG_ENDIAN |
| 4942 | shift = (sizeof(uint32_t) - sizeof(vm_page_bits_t) - shift) * NBBY; |
| 4943 | #else |
| 4944 | shift *= NBBY; |
| 4945 | #endif |
| 4946 | addr &= ~(sizeof(uint32_t) - 1); |
| 4947 | atomic_clear_32((uint32_t *)addr, clear << shift); |
| 4948 | #endif /* PAGE_SIZE */ |
| 4949 | } |
| 4950 | |
| 4951 | static inline vm_page_bits_t |
| 4952 | vm_page_bits_swap(vm_page_t m, vm_page_bits_t *bits, vm_page_bits_t newbits) |
no test coverage detected