1
mirror of https://github.com/mpv-player/mpv synced 2024-12-24 07:33:46 +01:00

Remove useless fd parameter for mmap_anon

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@21264 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2006-11-26 13:09:46 +00:00
parent c95db8d583
commit 7142e36d1f
5 changed files with 7 additions and 21 deletions

View File

@ -248,7 +248,7 @@ LPVOID FILE_dommap( int unix_handle, LPVOID start,
if (unix_handle == -1)
{
ret = mmap_anon( start, size_low, prot, flags, &fd, offset_low );
ret = mmap_anon( start, size_low, prot, flags, offset_low );
}
else
{
@ -365,12 +365,10 @@ HANDLE WINAPI CreateFileMappingA(HANDLE handle, LPSECURITY_ATTRIBUTES lpAttr,
mmap_access |=PROT_READ|PROT_WRITE;
if(anon)
answer=mmap_anon(NULL, len, mmap_access, MAP_PRIVATE, &hFile, 0);
answer=mmap_anon(NULL, len, mmap_access, MAP_PRIVATE, 0);
else
answer=mmap(NULL, len, mmap_access, MAP_PRIVATE, hFile, 0);
if(anon && hFile != -1)
close(hFile);
if(answer!=(LPVOID)-1)
{
if(fm==0)
@ -395,8 +393,6 @@ HANDLE WINAPI CreateFileMappingA(HANDLE handle, LPSECURITY_ATTRIBUTES lpAttr,
fm->name=NULL;
fm->mapping_size=len;
if(anon && hFile != -1)
close(hFile);
return (HANDLE)answer;
}
return (HANDLE)0;
@ -495,11 +491,9 @@ LPVOID WINAPI VirtualAlloc(LPVOID address, DWORD size, DWORD type, DWORD protec
}
answer=mmap_anon(address, size, PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_PRIVATE, &fd, 0);
MAP_PRIVATE, 0);
// answer=FILE_dommap(-1, address, 0, size, 0, 0,
// PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE);
if (fd != -1)
close(fd);
if (answer != (void *)-1 && address && answer != address) {
/* It is dangerous to try mmap() with MAP_FIXED since it does not

View File

@ -196,12 +196,10 @@ ldt_fs_t* Setup_LDT_Keeper(void)
return NULL;
fs_seg=
ldt_fs->fs_seg = mmap_anon(NULL, getpagesize(), PROT_READ | PROT_WRITE, MAP_PRIVATE, &ldt_fs->fd,
0);
ldt_fs->fs_seg = mmap_anon(NULL, getpagesize(), PROT_READ | PROT_WRITE, MAP_PRIVATE, 0);
if (ldt_fs->fs_seg == (void*)-1)
{
perror("ERROR: Couldn't allocate memory for fs segment");
close(ldt_fs->fd);
free(ldt_fs);
return NULL;
}
@ -282,7 +280,5 @@ void Restore_LDT_Keeper(ldt_fs_t* ldt_fs)
free(ldt_fs->prev_struct);
munmap((char*)ldt_fs->fs_seg, getpagesize());
ldt_fs->fs_seg = 0;
if (ldt_fs->fd != -1)
close(ldt_fs->fd);
free(ldt_fs);
}

View File

@ -9,7 +9,6 @@ extern "C"
typedef struct {
void* fs_seg;
char* prev_struct;
int fd;
} ldt_fs_t;
void Setup_FS_Segment(void);

View File

@ -31,7 +31,7 @@
* \param zerofd
* \return a pointer to the mapped region upon successful completion, -1 otherwise.
*/
void *mmap_anon(void *addr, size_t len, int prot, int flags, int *zerofd, off_t offset)
void *mmap_anon(void *addr, size_t len, int prot, int flags, off_t offset)
{
int fd;
void *result;
@ -46,7 +46,6 @@ void *mmap_anon(void *addr, size_t len, int prot, int flags, int *zerofd, off_t
#ifdef MAP_ANONYMOUS
/* BSD-style anonymous mapping */
fd = -1;
result = mmap(addr, len, prot, flags | MAP_ANONYMOUS, -1, offset);
#else
/* SysV-style anonymous mapping */
@ -57,11 +56,9 @@ void *mmap_anon(void *addr, size_t len, int prot, int flags, int *zerofd, off_t
}
result = mmap(addr, len, prot, flags, fd, offset);
close(fd);
#endif /* MAP_ANONYMOUS */
if (zerofd)
*zerofd = fd;
return result;
}

View File

@ -3,6 +3,6 @@
#include <sys/types.h>
void *mmap_anon(void *, size_t, int, int, int *, off_t);
void *mmap_anon(void *, size_t, int, int, off_t);
#endif /* _OSDEP_MMAP_ANON_H_ */