changeset 21248:2de480457872

Remove useless fd parameter for mmap_anon
author reimar
date Sun, 26 Nov 2006 13:09:46 +0000
parents c0400a8091a8
children e181136346c8
files loader/ext.c loader/ldt_keeper.c loader/ldt_keeper.h osdep/mmap_anon.c osdep/mmap_anon.h
diffstat 5 files changed, 7 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/loader/ext.c	Sun Nov 26 13:04:14 2006 +0000
+++ b/loader/ext.c	Sun Nov 26 13:09:46 2006 +0000
@@ -248,7 +248,7 @@
 
     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 @@
 	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 @@
 	    fm->name=NULL;
 	fm->mapping_size=len;
 
-	if(anon && hFile != -1)
-	    close(hFile);
 	return (HANDLE)answer;
     }
     return (HANDLE)0;
@@ -495,11 +491,9 @@
     }
 
     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
--- a/loader/ldt_keeper.c	Sun Nov 26 13:04:14 2006 +0000
+++ b/loader/ldt_keeper.c	Sun Nov 26 13:09:46 2006 +0000
@@ -196,12 +196,10 @@
 	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 @@
 	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);
 }
--- a/loader/ldt_keeper.h	Sun Nov 26 13:04:14 2006 +0000
+++ b/loader/ldt_keeper.h	Sun Nov 26 13:09:46 2006 +0000
@@ -9,7 +9,6 @@
 typedef struct {
   void* fs_seg;
   char* prev_struct;
-  int fd;
 } ldt_fs_t;
 
 void Setup_FS_Segment(void);
--- a/osdep/mmap_anon.c	Sun Nov 26 13:04:14 2006 +0000
+++ b/osdep/mmap_anon.c	Sun Nov 26 13:09:46 2006 +0000
@@ -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 @@
 
 #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 @@
     }
 
     result = mmap(addr, len, prot, flags, fd, offset);
+    close(fd);
 #endif /* MAP_ANONYMOUS */
 
-    if (zerofd)
-        *zerofd = fd;
-
     return result;
 }
 
--- a/osdep/mmap_anon.h	Sun Nov 26 13:04:14 2006 +0000
+++ b/osdep/mmap_anon.h	Sun Nov 26 13:09:46 2006 +0000
@@ -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_ */