home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue4 / SDL / gcc346 / !gcc / include / unixlib / sys / h / mman < prev    next >
Encoding:
Text File  |  2006-09-17  |  4.7 KB  |  114 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /usr/local/cvsroot/gccsdk/unixlib/source/clib/sys/mman.h,v $
  4.  * $Date: 2004/04/17 10:51:15 $
  5.  * $Revision: 1.4 $
  6.  * $State: Exp $
  7.  * $Author: nick $
  8.  *
  9.  ***************************************************************************/
  10.  
  11. /* Definitions for BSD-style memory management.  Generic/4.4 BSD version.
  12.    sys/mman.h: Written by Peter Burwood, 1 November 1996, June 1997 */
  13.  
  14. /* These are the bits used by 4.4 BSD and its derivatives.  On systems
  15.    (such as GNU) where these facilities are not system services but can be
  16.    emulated in the C library, these are the definitions we emulate.  */
  17.  
  18. #ifndef    __SYS_MMAN_H
  19. #define    __SYS_MMAN_H
  20.  
  21. #ifndef __UNIXLIB_FEATURES_H
  22. #include <features.h>
  23. #endif
  24.  
  25. #include <sys/types.h>
  26.  
  27. __BEGIN_DECLS
  28.  
  29. /* Protections are chosen from these bits, OR'd together.  The
  30.    implementation does not necessarily support PROT_EXEC or PROT_WRITE
  31.    without PROT_READ.  The only guarantees are that no writing will be
  32.    allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
  33.  
  34. #define    PROT_NONE    0x00    /* No access.  */
  35. #define    PROT_READ    0x04    /* Pages can be read.  */
  36. #define    PROT_WRITE    0x02    /* Pages can be written.  */
  37. #define    PROT_EXEC    0x01    /* Pages can be executed.  */
  38.  
  39. /* Return value of mmap in case of errors.  */
  40. #define MAP_FAILED ((void *) -1)
  41.  
  42. /* Flags contain mapping type, sharing type and options.  */
  43.  
  44. /* Mapping type (must choose one and only one of these).  */
  45. #define    MAP_FILE    0x0001    /* Mapped from a file or device.  */
  46. #define    MAP_ANON    0x0002    /* Allocated from anonymous virtual memory.  */
  47. #define    MAP_TYPE    0x000f    /* Mask for type field.  */
  48.  
  49. /* Sharing types (must choose one and only one of these).  */
  50. #define    MAP_COPY    0x0020    /* Virtual copy of region at mapping time.  */
  51. #define    MAP_SHARED    0x0010    /* Share changes.  */
  52. #define    MAP_PRIVATE    0x0000    /* Changes private; copy pages on write.  */
  53.  
  54. /* Other flags.  */
  55. #define    MAP_FIXED    0x0100    /* Map address must be exactly as requested. */
  56. #define    MAP_NOEXTEND    0x0200    /* For MAP_FILE, don't change file size.  */
  57. #define    MAP_HASSEMPHORE    0x0400    /* Region may contain semaphores.  */
  58. #define    MAP_INHERIT    0x0800    /* Region is retained after exec.  */
  59.  
  60. /* Advice to `madvise'.  */
  61. #define    MADV_NORMAL    0    /* No further special treatment.  */
  62. #define    MADV_RANDOM    1    /* Expect random page references.  */
  63. #define    MADV_SEQUENTIAL    2    /* Expect sequential page references.  */
  64. #define    MADV_WILLNEED    3    /* Will need these pages.  */
  65. #define    MADV_DONTNEED    4    /* Don't need these pages.  */
  66.  
  67. /* Flags for `mremap'.  */
  68. #define MREMAP_MAYMOVE    1    /* May move the pages when remapping.  */
  69.  
  70. /* Map addresses starting near ADDR and extending for LEN bytes.  from
  71.    OFFSET into the file FD describes according to PROT and FLAGS.  If ADDR
  72.    is nonzero, it is the desired mapping address.  If the MAP_FIXED bit is
  73.    set in FLAGS, the mapping will be at ADDR exactly (which must be
  74.    page-aligned); otherwise the system chooses a convenient nearby address.
  75.    The return value is the actual mapping address chosen or (caddr_t) -1
  76.    for errors (in which case `errno' is set).  A successful `mmap' call
  77.    deallocates any previous mapping for the affected region.  */
  78.  
  79. extern __caddr_t mmap (__caddr_t __addr, size_t __len,
  80.                int __prot, int __flags, int __fd,
  81.                off_t __offset) __THROW;
  82.  
  83. /* Deallocate any mapping for the region starting at ADDR and extending LEN
  84.    bytes.  Returns 0 if successful, -1 for errors (and sets errno).  */
  85. extern int munmap (__caddr_t __addr, size_t __len) __THROW;
  86.  
  87. /* Change the memory protection of the region starting at ADDR and
  88.    extending LEN bytes to PROT.  Returns 0 if successful, -1 for errors
  89.    (and sets errno).  */
  90. /* Not supported.  */
  91. extern int mprotect (__caddr_t __addr, size_t __len, int __prot) __THROW;
  92.  
  93. /* Synchronize the region starting at ADDR and extending LEN bytes with the
  94.    file it maps.  Filesystem operations on a file being mapped are
  95.    unpredictable before this is done.  */
  96. /* Not supported.  */
  97. extern int msync (__caddr_t __addr, size_t __len) __THROW;
  98.  
  99. /* Advise the system about particular usage patterns the program follows
  100.    for the region starting at ADDR and extending LEN bytes.  */
  101. /* Not supported.  */
  102. extern int madvise (__caddr_t __addr, size_t __len, int __advice) __THROW;
  103.  
  104. /* Remap addresses mapped by the range [ADDR,ADDR+OLD_LEN) to new length
  105.    NEW_LEN.  If MAY_MOVE is MREMAP_MAYMOVE the returned address may differ
  106.    from ADDR.  The return value is the actual mapping address chosen or
  107.    (caddr_t) -1 for errors (in which case `errno' is set).  */
  108. extern __caddr_t mremap (__caddr_t __addr, size_t __old_len,
  109.              size_t __new_len, int __may_move) __THROW;
  110.  
  111. __END_DECLS
  112.  
  113. #endif    /* sys/mman.h */
  114.