diff options
author | alc <alc@FreeBSD.org> | 1999-08-16 18:21:09 +0000 |
---|---|---|
committer | alc <alc@FreeBSD.org> | 1999-08-16 18:21:09 +0000 |
commit | 708e372c9ab369fa7e8c9021bb6f4df67b9fd475 (patch) | |
tree | 2c29cf6e63194c1af14933472ec4a549e2e63126 /sys/vm | |
parent | 722a2243a9ff0d9ad6f64c63d87e68a3536d4d73 (diff) | |
download | FreeBSD-src-708e372c9ab369fa7e8c9021bb6f4df67b9fd475.zip FreeBSD-src-708e372c9ab369fa7e8c9021bb6f4df67b9fd475.tar.gz |
vm_map_lock*:
Remove semicolons or add "do { } while (0)" as necessary
to enable the use of these macros in arbitrary statements.
(There are no functional changes.)
Submitted by: dillon
Diffstat (limited to 'sys/vm')
-rw-r--r-- | sys/vm/vm_map.h | 93 |
1 files changed, 52 insertions, 41 deletions
diff --git a/sys/vm/vm_map.h b/sys/vm/vm_map.h index 2c22801..d9a3e43 100644 --- a/sys/vm/vm_map.h +++ b/sys/vm/vm_map.h @@ -61,7 +61,7 @@ * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. * - * $Id: vm_map.h,v 1.43 1999/07/10 18:16:08 alc Exp $ + * $Id: vm_map.h,v 1.44 1999/08/01 06:05:08 alc Exp $ */ /* @@ -184,38 +184,47 @@ struct vmspace { /* * Macros: vm_map_lock, etc. * Function: - * Perform locking on the data portion of a map. + * Perform locking on the data portion of a map. Note that + * these macros mimic procedure calls returning void. The + * semicolon is supplied by the user of these macros, not + * by the macros themselves. The macros can safely be used + * as unbraced elements in a higher level statement. */ -#define vm_map_lock_drain_interlock(map) { \ - lockmgr(&(map)->lock, LK_DRAIN|LK_INTERLOCK, \ - &(map)->ref_lock, curproc); \ - (map)->timestamp++; \ -} +#define vm_map_lock_drain_interlock(map) \ + do { \ + lockmgr(&(map)->lock, LK_DRAIN|LK_INTERLOCK, \ + &(map)->ref_lock, curproc); \ + (map)->timestamp++; \ + } while(0) #ifdef DIAGNOSTIC /* #define MAP_LOCK_DIAGNOSTIC 1 */ #ifdef MAP_LOCK_DIAGNOSTIC -#define vm_map_lock(map) { \ - 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++; \ -} +#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) #else -#define vm_map_lock(map) { \ - if (lockmgr(&(map)->lock, LK_EXCLUSIVE, (void *)0, curproc) != 0) { \ - panic("vm_map_lock: failed to get lock"); \ - } \ - (map)->timestamp++; \ +#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) } #endif #else -#define vm_map_lock(map) { \ - lockmgr(&(map)->lock, LK_EXCLUSIVE, (void *)0, curproc); \ - (map)->timestamp++; \ -} +#define vm_map_lock(map) \ + do { \ + lockmgr(&(map)->lock, LK_EXCLUSIVE, (void *)0, curproc); \ + (map)->timestamp++; \ + } while(0) #endif /* DIAGNOSTIC */ #if defined(MAP_LOCK_DIAGNOSTIC) @@ -223,24 +232,24 @@ struct vmspace { do { \ printf ("locking map LK_RELEASE: 0x%x\n", map); \ lockmgr(&(map)->lock, LK_RELEASE, (void *)0, curproc); \ - } while (0); + } while (0) #define vm_map_lock_read(map) \ do { \ printf ("locking map LK_SHARED: 0x%x\n", map); \ lockmgr(&(map)->lock, LK_SHARED, (void *)0, curproc); \ - } while (0); + } while (0) #define vm_map_unlock_read(map) \ do { \ printf ("locking map LK_RELEASE: 0x%x\n", map); \ lockmgr(&(map)->lock, LK_RELEASE, (void *)0, curproc); \ - } while (0); + } while (0) #else #define vm_map_unlock(map) \ - lockmgr(&(map)->lock, LK_RELEASE, (void *)0, curproc); + lockmgr(&(map)->lock, LK_RELEASE, (void *)0, curproc) #define vm_map_lock_read(map) \ - lockmgr(&(map)->lock, LK_SHARED, (void *)0, curproc); + lockmgr(&(map)->lock, LK_SHARED, (void *)0, curproc) #define vm_map_unlock_read(map) \ - lockmgr(&(map)->lock, LK_RELEASE, (void *)0, curproc); + lockmgr(&(map)->lock, LK_RELEASE, (void *)0, curproc) #endif static __inline__ int @@ -262,22 +271,24 @@ _vm_map_lock_upgrade(vm_map_t map, struct proc *p) { do { \ printf ("locking map LK_DOWNGRADE: 0x%x\n", map); \ lockmgr(&(map)->lock, LK_DOWNGRADE, (void *)0, curproc); \ - } while (0); + } while (0) #else #define vm_map_lock_downgrade(map) \ - lockmgr(&(map)->lock, LK_DOWNGRADE, (void *)0, curproc); + lockmgr(&(map)->lock, LK_DOWNGRADE, (void *)0, curproc) #endif -#define vm_map_set_recursive(map) { \ - simple_lock(&(map)->lock.lk_interlock); \ - (map)->lock.lk_flags |= LK_CANRECURSE; \ - simple_unlock(&(map)->lock.lk_interlock); \ -} -#define vm_map_clear_recursive(map) { \ - simple_lock(&(map)->lock.lk_interlock); \ - (map)->lock.lk_flags &= ~LK_CANRECURSE; \ - simple_unlock(&(map)->lock.lk_interlock); \ -} +#define vm_map_set_recursive(map) \ + do { \ + simple_lock(&(map)->lock.lk_interlock); \ + (map)->lock.lk_flags |= LK_CANRECURSE; \ + simple_unlock(&(map)->lock.lk_interlock); \ + } while(0) +#define vm_map_clear_recursive(map) \ + do { \ + simple_lock(&(map)->lock.lk_interlock); \ + (map)->lock.lk_flags &= ~LK_CANRECURSE; \ + simple_unlock(&(map)->lock.lk_interlock); \ + } while(0) /* * Functions implemented as macros |