this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Support aligned memory allocation

+25
+25
src/kernel/mach_server/client/mach_traps.c
··· 274 274 { 275 275 return KERN_FAILURE; 276 276 } 277 + 278 + if (mask && ( ((uintptr_t)addr) & mask) != 0) 279 + { 280 + uintptr_t boundary, q, diff, iaddr; 281 + 282 + // Alignment was requested, but we couldn't get it the easy way 283 + munmap(addr, size); 284 + 285 + // This may not work for some crazy masks. Consider using __builtin_clz(). 286 + boundary = mask + 1; 287 + 288 + iaddr = mmap(*address, size + boundary, prot, posix_flags, -1, 0); 289 + if (iaddr == (uintptr_t) MAP_FAILED) 290 + return KERN_FAILURE; 291 + 292 + q = (iaddr + (boundary-1)) / boundary * boundary; 293 + diff = q - iaddr; 294 + 295 + if (diff > 0) 296 + munmap(iaddr, diff); 297 + if (boundary - diff > 0) 298 + munmap((void*) (q + size), boundary - diff); 299 + 300 + addr = (void*) q; 301 + } 277 302 278 303 *address = addr; 279 304 return KERN_SUCCESS;