spinlock_types.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright 2010 Tilera Corporation. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation, version 2.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  11. * NON INFRINGEMENT. See the GNU General Public License for
  12. * more details.
  13. */
  14. #ifndef _ASM_TILE_SPINLOCK_TYPES_H
  15. #define _ASM_TILE_SPINLOCK_TYPES_H
  16. #ifndef __LINUX_SPINLOCK_TYPES_H
  17. # error "please don't include this file directly"
  18. #endif
  19. #ifdef __tilegx__
  20. /* Low 15 bits are "next"; high 15 bits are "current". */
  21. typedef struct arch_spinlock {
  22. unsigned int lock;
  23. } arch_spinlock_t;
  24. #define __ARCH_SPIN_LOCK_UNLOCKED { 0 }
  25. /* High bit is "writer owns"; low 31 bits are a count of readers. */
  26. typedef struct arch_rwlock {
  27. unsigned int lock;
  28. } arch_rwlock_t;
  29. #define __ARCH_RW_LOCK_UNLOCKED { 0 }
  30. #else
  31. typedef struct arch_spinlock {
  32. /* Next ticket number to hand out. */
  33. int next_ticket;
  34. /* The ticket number that currently owns this lock. */
  35. int current_ticket;
  36. } arch_spinlock_t;
  37. #define __ARCH_SPIN_LOCK_UNLOCKED { 0, 0 }
  38. /*
  39. * Byte 0 for tns (only the low bit is used), byte 1 for ticket-lock "next",
  40. * byte 2 for ticket-lock "current", byte 3 for reader count.
  41. */
  42. typedef struct arch_rwlock {
  43. unsigned int lock;
  44. } arch_rwlock_t;
  45. #define __ARCH_RW_LOCK_UNLOCKED { 0 }
  46. #endif
  47. #endif /* _ASM_TILE_SPINLOCK_TYPES_H */