| 764 | } |
| 765 | |
| 766 | void * |
| 767 | malloc_domainset_aligned(size_t size, size_t align, |
| 768 | struct malloc_type *mtp, struct domainset *ds, int flags) |
| 769 | { |
| 770 | void *res; |
| 771 | size_t asize; |
| 772 | |
| 773 | KASSERT(align != 0 && powerof2(align), |
| 774 | ("malloc_domainset_aligned: wrong align %#zx size %#zx", |
| 775 | align, size)); |
| 776 | KASSERT(align <= PAGE_SIZE, |
| 777 | ("malloc_domainset_aligned: align %#zx (size %#zx) too large", |
| 778 | align, size)); |
| 779 | |
| 780 | /* |
| 781 | * Round the allocation size up to the next power of 2, |
| 782 | * because we can only guarantee alignment for |
| 783 | * power-of-2-sized allocations. Further increase the |
| 784 | * allocation size to align if the rounded size is less than |
| 785 | * align, since malloc zones provide alignment equal to their |
| 786 | * size. |
| 787 | */ |
| 788 | asize = size <= align ? align : 1UL << flsl(size - 1); |
| 789 | |
| 790 | res = malloc_domainset(asize, mtp, ds, flags); |
| 791 | KASSERT(res == NULL || ((uintptr_t)res & (align - 1)) == 0, |
| 792 | ("malloc_domainset_aligned: result not aligned %p size %#zx " |
| 793 | "allocsize %#zx align %#zx", res, size, asize, align)); |
| 794 | return (res); |
| 795 | } |
| 796 | |
| 797 | void * |
| 798 | mallocarray(size_t nmemb, size_t size, struct malloc_type *type, int flags) |
no test coverage detected