getorder.h 421 B

12345678910111213141516171819202122232425
  1. #ifndef __ASM_GENERIC_GETORDER_H
  2. #define __ASM_GENERIC_GETORDER_H
  3. #ifndef __ASSEMBLY__
  4. #include <linux/compiler.h>
  5. /* Pure 2^n version of get_order */
  6. static inline __attribute_const__ int get_order(unsigned long size)
  7. {
  8. int order;
  9. size = (size - 1) >> (PAGE_SHIFT - 1);
  10. order = -1;
  11. do {
  12. size >>= 1;
  13. order++;
  14. } while (size);
  15. return order;
  16. }
  17. #endif /* __ASSEMBLY__ */
  18. #endif /* __ASM_GENERIC_GETORDER_H */