4 #include <linux/config.h>
7 #include <asm/atomic.h>
10 #define MREMAP_MAYMOVE 1
11 #define MREMAP_FIXED 2
13 extern int sysctl_overcommit_memory;
14 extern int sysctl_overcommit_ratio;
15 extern atomic_t vm_committed_space;
18 extern void vm_acct_memory(long pages);
20 static inline void vm_acct_memory(long pages)
22 atomic_add(pages, &vm_committed_space);
26 static inline void vm_unacct_memory(long pages)
28 vm_acct_memory(-pages);
32 * Optimisation macro. It is equivalent to:
33 * (x & bit1) ? bit2 : 0
34 * but this version is faster.
35 * ("bit1" and "bit2" must be single bits)
37 #define _calc_vm_trans(x, bit1, bit2) \
38 ((bit1) <= (bit2) ? ((x) & (bit1)) * ((bit2) / (bit1)) \
39 : ((x) & (bit1)) / ((bit1) / (bit2)))
42 * Combine the mmap "prot" argument into "vm_flags" used internally.
44 static inline unsigned long
45 calc_vm_prot_bits(unsigned long prot)
47 return _calc_vm_trans(prot, PROT_READ, VM_READ ) |
48 _calc_vm_trans(prot, PROT_WRITE, VM_WRITE) |
49 _calc_vm_trans(prot, PROT_EXEC, VM_EXEC );
53 * Combine the mmap "flags" argument into "vm_flags" used internally.
55 static inline unsigned long
56 calc_vm_flag_bits(unsigned long flags)
58 return _calc_vm_trans(flags, MAP_GROWSDOWN, VM_GROWSDOWN ) |
59 _calc_vm_trans(flags, MAP_DENYWRITE, VM_DENYWRITE ) |
60 _calc_vm_trans(flags, MAP_EXECUTABLE, VM_EXECUTABLE) |
61 _calc_vm_trans(flags, MAP_LOCKED, VM_LOCKED );
64 #endif /* _LINUX_MMAN_H */