word-at-a-time.h 997 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef _ASM_WORD_AT_A_TIME_H
  2. #define _ASM_WORD_AT_A_TIME_H
  3. /*
  4. * Word-at-a-time interfaces for PowerPC.
  5. */
  6. #include <linux/kernel.h>
  7. #include <asm/asm-compat.h>
  8. struct word_at_a_time {
  9. const unsigned long high_bits, low_bits;
  10. };
  11. #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0xfe) + 1, REPEAT_BYTE(0x7f) }
  12. /* Bit set in the bytes that have a zero */
  13. static inline long prep_zero_mask(unsigned long val, unsigned long rhs, const struct word_at_a_time *c)
  14. {
  15. unsigned long mask = (val & c->low_bits) + c->low_bits;
  16. return ~(mask | rhs);
  17. }
  18. #define create_zero_mask(mask) (mask)
  19. static inline long find_zero(unsigned long mask)
  20. {
  21. long leading_zero_bits;
  22. asm (PPC_CNTLZL "%0,%1" : "=r" (leading_zero_bits) : "r" (mask));
  23. return leading_zero_bits >> 3;
  24. }
  25. static inline bool has_zero(unsigned long val, unsigned long *data, const struct word_at_a_time *c)
  26. {
  27. unsigned long rhs = val | c->low_bits;
  28. *data = rhs;
  29. return (val + c->high_bits) & ~rhs;
  30. }
  31. #endif /* _ASM_WORD_AT_A_TIME_H */