mman.h
上传用户:szlgq88
上传日期:2009-04-28
资源大小:48287k
文件大小:2k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

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