Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
422 giacomo 1
#ifndef _LINUX_MMAN_H
2
#define _LINUX_MMAN_H
3
 
4
#include <linux/config.h>
5
#include <linux/mm.h>
6
 
7
#include <asm/atomic.h>
8
#include <asm/mman.h>
9
 
10
#define MREMAP_MAYMOVE  1
11
#define MREMAP_FIXED    2
12
 
13
extern int sysctl_overcommit_memory;
14
extern int sysctl_overcommit_ratio;
15
extern atomic_t vm_committed_space;
16
 
17
#ifdef CONFIG_SMP
18
extern void vm_acct_memory(long pages);
19
#else
20
static inline void vm_acct_memory(long pages)
21
{
22
        atomic_add(pages, &vm_committed_space);
23
}
24
#endif
25
 
26
static inline void vm_unacct_memory(long pages)
27
{
28
        vm_acct_memory(-pages);
29
}
30
 
31
/*
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)
36
 */
37
#define _calc_vm_trans(x, bit1, bit2) \
38
  ((bit1) <= (bit2) ? ((x) & (bit1)) * ((bit2) / (bit1)) \
39
   : ((x) & (bit1)) / ((bit1) / (bit2)))
40
 
41
/*
42
 * Combine the mmap "prot" argument into "vm_flags" used internally.
43
 */
44
static inline unsigned long
45
calc_vm_prot_bits(unsigned long prot)
46
{
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 );
50
}
51
 
52
/*
53
 * Combine the mmap "flags" argument into "vm_flags" used internally.
54
 */
55
static inline unsigned long
56
calc_vm_flag_bits(unsigned long flags)
57
{
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    );
62
}
63
 
64
#endif /* _LINUX_MMAN_H */