Mercurial > mplayer.hg
comparison osdep/mmap_anon.c @ 21248:2de480457872
Remove useless fd parameter for mmap_anon
author | reimar |
---|---|
date | Sun, 26 Nov 2006 13:09:46 +0000 |
parents | d9cedf7b8069 |
children | f2ddea0632d4 |
comparison
equal
deleted
inserted
replaced
21247:c0400a8091a8 | 21248:2de480457872 |
---|---|
29 * \param flags specifies the type of the mapped object. | 29 * \param flags specifies the type of the mapped object. |
30 * \param offset start mapping at byte offset. | 30 * \param offset start mapping at byte offset. |
31 * \param zerofd | 31 * \param zerofd |
32 * \return a pointer to the mapped region upon successful completion, -1 otherwise. | 32 * \return a pointer to the mapped region upon successful completion, -1 otherwise. |
33 */ | 33 */ |
34 void *mmap_anon(void *addr, size_t len, int prot, int flags, int *zerofd, off_t offset) | 34 void *mmap_anon(void *addr, size_t len, int prot, int flags, off_t offset) |
35 { | 35 { |
36 int fd; | 36 int fd; |
37 void *result; | 37 void *result; |
38 | 38 |
39 /* From loader/ext.c: | 39 /* From loader/ext.c: |
44 flags = (flags & ~MAP_SHARED) | MAP_PRIVATE; | 44 flags = (flags & ~MAP_SHARED) | MAP_PRIVATE; |
45 #endif /* defined(MAP_SHARED) && defined(MAP_PRIVATE) */ | 45 #endif /* defined(MAP_SHARED) && defined(MAP_PRIVATE) */ |
46 | 46 |
47 #ifdef MAP_ANONYMOUS | 47 #ifdef MAP_ANONYMOUS |
48 /* BSD-style anonymous mapping */ | 48 /* BSD-style anonymous mapping */ |
49 fd = -1; | |
50 result = mmap(addr, len, prot, flags | MAP_ANONYMOUS, -1, offset); | 49 result = mmap(addr, len, prot, flags | MAP_ANONYMOUS, -1, offset); |
51 #else | 50 #else |
52 /* SysV-style anonymous mapping */ | 51 /* SysV-style anonymous mapping */ |
53 fd = open("/dev/zero", O_RDWR); | 52 fd = open("/dev/zero", O_RDWR); |
54 if(fd < 0){ | 53 if(fd < 0){ |
55 perror( "Cannot open /dev/zero for READ+WRITE. Check permissions! error: "); | 54 perror( "Cannot open /dev/zero for READ+WRITE. Check permissions! error: "); |
56 return NULL; | 55 return NULL; |
57 } | 56 } |
58 | 57 |
59 result = mmap(addr, len, prot, flags, fd, offset); | 58 result = mmap(addr, len, prot, flags, fd, offset); |
59 close(fd); | |
60 #endif /* MAP_ANONYMOUS */ | 60 #endif /* MAP_ANONYMOUS */ |
61 | |
62 if (zerofd) | |
63 *zerofd = fd; | |
64 | 61 |
65 return result; | 62 return result; |
66 } | 63 } |
67 | 64 |