common.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef _LIBLOCKDEP_COMMON_H
  2. #define _LIBLOCKDEP_COMMON_H
  3. #include <pthread.h>
  4. #define NR_LOCKDEP_CACHING_CLASSES 2
  5. #define MAX_LOCKDEP_SUBCLASSES 8UL
  6. #ifndef CALLER_ADDR0
  7. #define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
  8. #endif
  9. #ifndef _RET_IP_
  10. #define _RET_IP_ CALLER_ADDR0
  11. #endif
  12. #ifndef _THIS_IP_
  13. #define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
  14. #endif
  15. struct lockdep_subclass_key {
  16. char __one_byte;
  17. };
  18. struct lock_class_key {
  19. struct lockdep_subclass_key subkeys[MAX_LOCKDEP_SUBCLASSES];
  20. };
  21. struct lockdep_map {
  22. struct lock_class_key *key;
  23. struct lock_class *class_cache[NR_LOCKDEP_CACHING_CLASSES];
  24. const char *name;
  25. #ifdef CONFIG_LOCK_STAT
  26. int cpu;
  27. unsigned long ip;
  28. #endif
  29. };
  30. void lockdep_init_map(struct lockdep_map *lock, const char *name,
  31. struct lock_class_key *key, int subclass);
  32. void lock_acquire(struct lockdep_map *lock, unsigned int subclass,
  33. int trylock, int read, int check,
  34. struct lockdep_map *nest_lock, unsigned long ip);
  35. void lock_release(struct lockdep_map *lock, int nested,
  36. unsigned long ip);
  37. extern void debug_check_no_locks_freed(const void *from, unsigned long len);
  38. #define STATIC_LOCKDEP_MAP_INIT(_name, _key) \
  39. { .name = (_name), .key = (void *)(_key), }
  40. #endif