word-at-a-time.h 1.3 KB

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