mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-28 16:43:09 +00:00
Use a macro wrapper over printf along with KASSERT to reduce the amount
of code here.
This commit is contained in:
parent
ebce6f8a5c
commit
7d26b6a450
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=75462
@ -212,65 +212,44 @@ struct vmspace {
|
||||
(map)->timestamp++; \
|
||||
} while(0)
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
/* #define MAP_LOCK_DIAGNOSTIC 1 */
|
||||
#ifdef MAP_LOCK_DIAGNOSTIC
|
||||
#define vm_map_lock(map) \
|
||||
do { \
|
||||
printf ("locking map LK_EXCLUSIVE: 0x%x\n", map); \
|
||||
if (lockmgr(&(map)->lock, LK_EXCLUSIVE, (void *)0, curproc) != 0) { \
|
||||
panic("vm_map_lock: failed to get lock"); \
|
||||
} \
|
||||
(map)->timestamp++; \
|
||||
} while(0)
|
||||
#define vm_map_printf(str, arg) printf(str,arg)
|
||||
#else
|
||||
#define vm_map_lock(map) \
|
||||
do { \
|
||||
if (lockmgr(&(map)->lock, LK_EXCLUSIVE, (void *)0, curproc) != 0) { \
|
||||
panic("vm_map_lock: failed to get lock"); \
|
||||
} \
|
||||
(map)->timestamp++; \
|
||||
} while(0)
|
||||
#define vm_map_printf(str, arg)
|
||||
#endif
|
||||
#else
|
||||
|
||||
#define vm_map_lock(map) \
|
||||
do { \
|
||||
lockmgr(&(map)->lock, LK_EXCLUSIVE, (void *)0, curproc); \
|
||||
vm_map_printf("locking map LK_EXCLUSIVE: 0x%x\n", map); \
|
||||
KASSERT(lockmgr(&(map)->lock, LK_EXCLUSIVE, (void *)0, curproc) == 0, \
|
||||
("vm_map_lock: failed to get lock")); \
|
||||
(map)->timestamp++; \
|
||||
} while(0)
|
||||
#endif /* DIAGNOSTIC */
|
||||
|
||||
#if defined(MAP_LOCK_DIAGNOSTIC)
|
||||
#define vm_map_unlock(map) \
|
||||
do { \
|
||||
printf ("locking map LK_RELEASE: 0x%x\n", map); \
|
||||
vm_map_printf("locking map LK_RELEASE: 0x%x\n", map); \
|
||||
lockmgr(&(map)->lock, LK_RELEASE, (void *)0, curproc); \
|
||||
} while (0)
|
||||
|
||||
#define vm_map_lock_read(map) \
|
||||
do { \
|
||||
printf ("locking map LK_SHARED: 0x%x\n", map); \
|
||||
vm_map_printf("locking map LK_SHARED: 0x%x\n", map); \
|
||||
lockmgr(&(map)->lock, LK_SHARED, (void *)0, curproc); \
|
||||
} while (0)
|
||||
|
||||
#define vm_map_unlock_read(map) \
|
||||
do { \
|
||||
printf ("locking map LK_RELEASE: 0x%x\n", map); \
|
||||
vm_map_printf("locking map LK_RELEASE: 0x%x\n", map); \
|
||||
lockmgr(&(map)->lock, LK_RELEASE, (void *)0, curproc); \
|
||||
} while (0)
|
||||
#else
|
||||
#define vm_map_unlock(map) \
|
||||
lockmgr(&(map)->lock, LK_RELEASE, (void *)0, curproc)
|
||||
#define vm_map_lock_read(map) \
|
||||
lockmgr(&(map)->lock, LK_SHARED, (void *)0, curproc)
|
||||
#define vm_map_unlock_read(map) \
|
||||
lockmgr(&(map)->lock, LK_RELEASE, (void *)0, curproc)
|
||||
#endif
|
||||
|
||||
static __inline__ int
|
||||
_vm_map_lock_upgrade(vm_map_t map, struct proc *p) {
|
||||
int error;
|
||||
#if defined(MAP_LOCK_DIAGNOSTIC)
|
||||
printf("locking map LK_EXCLUPGRADE: 0x%x\n", map);
|
||||
#endif
|
||||
|
||||
vm_map_printf("locking map LK_EXCLUPGRADE: 0x%x\n", map);
|
||||
error = lockmgr(&map->lock, LK_EXCLUPGRADE, (void *)0, p);
|
||||
if (error == 0)
|
||||
map->timestamp++;
|
||||
@ -279,16 +258,11 @@ _vm_map_lock_upgrade(vm_map_t map, struct proc *p) {
|
||||
|
||||
#define vm_map_lock_upgrade(map) _vm_map_lock_upgrade(map, curproc)
|
||||
|
||||
#if defined(MAP_LOCK_DIAGNOSTIC)
|
||||
#define vm_map_lock_downgrade(map) \
|
||||
do { \
|
||||
printf ("locking map LK_DOWNGRADE: 0x%x\n", map); \
|
||||
vm_map_printf("locking map LK_DOWNGRADE: 0x%x\n", map); \
|
||||
lockmgr(&(map)->lock, LK_DOWNGRADE, (void *)0, curproc); \
|
||||
} while (0)
|
||||
#else
|
||||
#define vm_map_lock_downgrade(map) \
|
||||
lockmgr(&(map)->lock, LK_DOWNGRADE, (void *)0, curproc)
|
||||
#endif
|
||||
|
||||
#define vm_map_set_recursive(map) \
|
||||
do { \
|
||||
@ -296,6 +270,7 @@ _vm_map_lock_upgrade(vm_map_t map, struct proc *p) {
|
||||
(map)->lock.lk_flags |= LK_CANRECURSE; \
|
||||
mtx_unlock((map)->lock.lk_interlock); \
|
||||
} while(0)
|
||||
|
||||
#define vm_map_clear_recursive(map) \
|
||||
do { \
|
||||
mtx_lock((map)->lock.lk_interlock); \
|
||||
|
Loading…
Reference in New Issue
Block a user