| 73 | }; |
| 74 | |
| 75 | void |
| 76 | lock_init(struct lock_object *lock, struct lock_class *class, const char *name, |
| 77 | const char *type, int flags) |
| 78 | { |
| 79 | int i; |
| 80 | |
| 81 | /* Check for double-init and zero object. */ |
| 82 | KASSERT(flags & LO_NEW || !lock_initialized(lock), |
| 83 | ("lock \"%s\" %p already initialized", name, lock)); |
| 84 | |
| 85 | /* Look up lock class to find its index. */ |
| 86 | for (i = 0; i < LOCK_CLASS_MAX; i++) |
| 87 | if (lock_classes[i] == class) { |
| 88 | lock->lo_flags = i << LO_CLASSSHIFT; |
| 89 | break; |
| 90 | } |
| 91 | KASSERT(i < LOCK_CLASS_MAX, ("unknown lock class %p", class)); |
| 92 | |
| 93 | /* Initialize the lock object. */ |
| 94 | lock->lo_name = name; |
| 95 | lock->lo_flags |= flags | LO_INITIALIZED; |
| 96 | LOCK_LOG_INIT(lock, 0); |
| 97 | WITNESS_INIT(lock, (type != NULL) ? type : name); |
| 98 | } |
| 99 | |
| 100 | void |
| 101 | lock_destroy(struct lock_object *lock) |
no outgoing calls
no test coverage detected