common.h 1.3 KB

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