word-at-a-time.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef _ASM_WORD_AT_A_TIME_H
  2. #define _ASM_WORD_AT_A_TIME_H
  3. #include <asm/compiler.h>
  4. /*
  5. * word-at-a-time interface for Alpha.
  6. */
  7. /*
  8. * We do not use the word_at_a_time struct on Alpha, but it needs to be
  9. * implemented to humour the generic code.
  10. */
  11. struct word_at_a_time {
  12. const unsigned long unused;
  13. };
  14. #define WORD_AT_A_TIME_CONSTANTS { 0 }
  15. /* Return nonzero if val has a zero */
  16. static inline unsigned long has_zero(unsigned long val, unsigned long *bits, const struct word_at_a_time *c)
  17. {
  18. unsigned long zero_locations = __kernel_cmpbge(0, val);
  19. *bits = zero_locations;
  20. return zero_locations;
  21. }
  22. static inline unsigned long prep_zero_mask(unsigned long val, unsigned long bits, const struct word_at_a_time *c)
  23. {
  24. return bits;
  25. }
  26. #define create_zero_mask(bits) (bits)
  27. static inline unsigned long find_zero(unsigned long bits)
  28. {
  29. #if defined(CONFIG_ALPHA_EV6) && defined(CONFIG_ALPHA_EV67)
  30. /* Simple if have CIX instructions */
  31. return __kernel_cttz(bits);
  32. #else
  33. unsigned long t1, t2, t3;
  34. /* Retain lowest set bit only */
  35. bits &= -bits;
  36. /* Binary search for lowest set bit */
  37. t1 = bits & 0xf0;
  38. t2 = bits & 0xcc;
  39. t3 = bits & 0xaa;
  40. if (t1) t1 = 4;
  41. if (t2) t2 = 2;
  42. if (t3) t3 = 1;
  43. return t1 + t2 + t3;
  44. #endif
  45. }
  46. #define zero_bytemask(mask) ((2ul << (find_zero(mask) * 8)) - 1)
  47. #endif /* _ASM_WORD_AT_A_TIME_H */