this repo has no description
1
fork

Configure Feed

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

[mldr] Use __builtin_ctzl Instead Of log2 To Calculate The Page Shift

Thomas A ff59437f 29e49086

+4 -2
+1 -1
src/startup/mldr/CMakeLists.txt
··· 49 49 target_link_options(mldr32 PRIVATE -m32) 50 50 target_compile_options(mldr32 PRIVATE -pthread) 51 51 target_link_options(mldr32 PRIVATE -pthread) 52 - target_link_libraries(mldr32 PRIVATE -lrt -ldl mldr32_dserver_rpc -lm) 52 + target_link_libraries(mldr32 PRIVATE -lrt -ldl mldr32_dserver_rpc) 53 53 54 54 install(TARGETS mldr32 DESTINATION libexec/darling/usr/libexec/darling) 55 55 endif()
+3 -1
src/startup/mldr/commpage.c
··· 62 62 63 63 // I'm not sure if Linux has seperate page sizes for kernel and user space. 64 64 // Apple's code uses left shift logical (1 << user_page_shift) to get the page size value. 65 + // Since it's very unlikely that the page size won't be a power of 2, we can use __builtin_ctzl() 66 + // as a substitute for log2(). 65 67 user_page_shift = (uint8_t*)CGET(_64bit ? _COMM_PAGE_USER_PAGE_SHIFT_64 : _COMM_PAGE_USER_PAGE_SHIFT_32); 66 68 kernel_page_shift = (uint8_t*)CGET(_COMM_PAGE_KERNEL_PAGE_SHIFT); 67 - *kernel_page_shift = *user_page_shift = log2(sysconf(_SC_PAGESIZE)); 69 + *kernel_page_shift = *user_page_shift = (uint8_t)__builtin_ctzl(sysconf(_SC_PAGESIZE)); 68 70 69 71 my_caps = get_cpu_caps(); 70 72 if (*ncpus == 1)