| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_MMAN_H | 
 | 2 | #define _LINUX_MMAN_H | 
 | 3 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | #include <asm/mman.h> | 
 | 5 |  | 
 | 6 | #define MREMAP_MAYMOVE	1 | 
 | 7 | #define MREMAP_FIXED	2 | 
 | 8 |  | 
 | 9 | #define OVERCOMMIT_GUESS		0 | 
 | 10 | #define OVERCOMMIT_ALWAYS		1 | 
 | 11 | #define OVERCOMMIT_NEVER		2 | 
| David Woodhouse | 9cdcb56 | 2006-04-25 14:18:07 +0100 | [diff] [blame] | 12 |  | 
 | 13 | #ifdef __KERNEL__ | 
| David Woodhouse | 9cdcb56 | 2006-04-25 14:18:07 +0100 | [diff] [blame] | 14 | #include <linux/mm.h> | 
 | 15 |  | 
 | 16 | #include <asm/atomic.h> | 
 | 17 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | extern int sysctl_overcommit_memory; | 
 | 19 | extern int sysctl_overcommit_ratio; | 
 | 20 | extern atomic_t vm_committed_space; | 
 | 21 |  | 
 | 22 | #ifdef CONFIG_SMP | 
 | 23 | extern void vm_acct_memory(long pages); | 
 | 24 | #else | 
 | 25 | static inline void vm_acct_memory(long pages) | 
 | 26 | { | 
 | 27 | 	atomic_add(pages, &vm_committed_space); | 
 | 28 | } | 
 | 29 | #endif | 
 | 30 |  | 
 | 31 | static inline void vm_unacct_memory(long pages) | 
 | 32 | { | 
 | 33 | 	vm_acct_memory(-pages); | 
 | 34 | } | 
 | 35 |  | 
 | 36 | /* | 
 | 37 |  * Optimisation macro.  It is equivalent to: | 
 | 38 |  *      (x & bit1) ? bit2 : 0 | 
 | 39 |  * but this version is faster. | 
 | 40 |  * ("bit1" and "bit2" must be single bits) | 
 | 41 |  */ | 
 | 42 | #define _calc_vm_trans(x, bit1, bit2) \ | 
 | 43 |   ((bit1) <= (bit2) ? ((x) & (bit1)) * ((bit2) / (bit1)) \ | 
 | 44 |    : ((x) & (bit1)) / ((bit1) / (bit2))) | 
 | 45 |  | 
 | 46 | /* | 
 | 47 |  * Combine the mmap "prot" argument into "vm_flags" used internally. | 
 | 48 |  */ | 
 | 49 | static inline unsigned long | 
 | 50 | calc_vm_prot_bits(unsigned long prot) | 
 | 51 | { | 
 | 52 | 	return _calc_vm_trans(prot, PROT_READ,  VM_READ ) | | 
 | 53 | 	       _calc_vm_trans(prot, PROT_WRITE, VM_WRITE) | | 
 | 54 | 	       _calc_vm_trans(prot, PROT_EXEC,  VM_EXEC ); | 
 | 55 | } | 
 | 56 |  | 
 | 57 | /* | 
 | 58 |  * Combine the mmap "flags" argument into "vm_flags" used internally. | 
 | 59 |  */ | 
 | 60 | static inline unsigned long | 
 | 61 | calc_vm_flag_bits(unsigned long flags) | 
 | 62 | { | 
 | 63 | 	return _calc_vm_trans(flags, MAP_GROWSDOWN,  VM_GROWSDOWN ) | | 
 | 64 | 	       _calc_vm_trans(flags, MAP_DENYWRITE,  VM_DENYWRITE ) | | 
 | 65 | 	       _calc_vm_trans(flags, MAP_EXECUTABLE, VM_EXECUTABLE) | | 
 | 66 | 	       _calc_vm_trans(flags, MAP_LOCKED,     VM_LOCKED    ); | 
 | 67 | } | 
| David Woodhouse | 9cdcb56 | 2006-04-25 14:18:07 +0100 | [diff] [blame] | 68 | #endif /* __KERNEL__ */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | #endif /* _LINUX_MMAN_H */ |