- 论坛徽章:
- 0
|
用MAP_ANON是正确的啊:
APUE2上也写了:
The anonymous memory-mapping facility is supported by all four platforms discussed in this text. Note, however, that Linux defines the MAP_ANONYMOUS flag for this facility, but defines the MAP_ANON flag to be the same value for improved application portability.
four platforms: 指的是System V/386 Rel 4.2, 4.3+BSD, BSD/386 和 SunOS 4.1.1/4.1.2
Linux(Linux 2.6.23.1-42.fc8 i686)下的/usr/include/bits/mman.h
/* Other flags. */
#define MAP_FIXED 0x10 /* Interpret addr exactly. */
#ifdef __USE_MISC
# define MAP_FILE 0
# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
# define MAP_ANON MAP_ANONYMOUS
#endif
Solaris 10 的/usr/include/sys/mman.h
#define MAP_FIXED 0x10 /* user assigns address */
#define MAP_NORESERVE 0x40 /* don't reserve needed swap area */
#define MAP_ANON 0x100 /* map anonymous pages directly */
#define MAP_ANONYMOUS MAP_ANON /* (source compatibility) */
#define MAP_ALIGN 0x200 /* addr specifies alignment */
#define MAP_TEXT 0x400 /* map code segment */
#define MAP_INITDATA 0x800 /* map data segment */
FreeBSD 6.2 /usr/include/sys/mman.h
/*
* Mapping type
*/
#define MAP_FILE 0x0000 /* map from file (default) */
#define MAP_ANON 0x1000 /* allocated from memory, swap space */ |
|