comparison loader/ext.c @ 21248:2de480457872

Remove useless fd parameter for mmap_anon
author reimar
date Sun, 26 Nov 2006 13:09:46 +0000
parents 4fb09861b4eb
children 219d577285e1
comparison
equal deleted inserted replaced
21247:c0400a8091a8 21248:2de480457872
246 if (size_high || offset_high) 246 if (size_high || offset_high)
247 printf("offsets larger than 4Gb not supported\n"); 247 printf("offsets larger than 4Gb not supported\n");
248 248
249 if (unix_handle == -1) 249 if (unix_handle == -1)
250 { 250 {
251 ret = mmap_anon( start, size_low, prot, flags, &fd, offset_low ); 251 ret = mmap_anon( start, size_low, prot, flags, offset_low );
252 } 252 }
253 else 253 else
254 { 254 {
255 fd = unix_handle; 255 fd = unix_handle;
256 ret = mmap( start, size_low, prot, flags, fd, offset_low ); 256 ret = mmap( start, size_low, prot, flags, fd, offset_low );
363 mmap_access |=PROT_READ; 363 mmap_access |=PROT_READ;
364 else 364 else
365 mmap_access |=PROT_READ|PROT_WRITE; 365 mmap_access |=PROT_READ|PROT_WRITE;
366 366
367 if(anon) 367 if(anon)
368 answer=mmap_anon(NULL, len, mmap_access, MAP_PRIVATE, &hFile, 0); 368 answer=mmap_anon(NULL, len, mmap_access, MAP_PRIVATE, 0);
369 else 369 else
370 answer=mmap(NULL, len, mmap_access, MAP_PRIVATE, hFile, 0); 370 answer=mmap(NULL, len, mmap_access, MAP_PRIVATE, hFile, 0);
371 371
372 if(anon && hFile != -1)
373 close(hFile);
374 if(answer!=(LPVOID)-1) 372 if(answer!=(LPVOID)-1)
375 { 373 {
376 if(fm==0) 374 if(fm==0)
377 { 375 {
378 fm = (file_mapping*) malloc(sizeof(file_mapping)); 376 fm = (file_mapping*) malloc(sizeof(file_mapping));
393 } 391 }
394 else 392 else
395 fm->name=NULL; 393 fm->name=NULL;
396 fm->mapping_size=len; 394 fm->mapping_size=len;
397 395
398 if(anon && hFile != -1)
399 close(hFile);
400 return (HANDLE)answer; 396 return (HANDLE)answer;
401 } 397 }
402 return (HANDLE)0; 398 return (HANDLE)0;
403 } 399 }
404 WIN_BOOL WINAPI UnmapViewOfFile(LPVOID handle) 400 WIN_BOOL WINAPI UnmapViewOfFile(LPVOID handle)
493 return NULL; 489 return NULL;
494 } 490 }
495 } 491 }
496 492
497 answer=mmap_anon(address, size, PROT_READ | PROT_WRITE | PROT_EXEC, 493 answer=mmap_anon(address, size, PROT_READ | PROT_WRITE | PROT_EXEC,
498 MAP_PRIVATE, &fd, 0); 494 MAP_PRIVATE, 0);
499 // answer=FILE_dommap(-1, address, 0, size, 0, 0, 495 // answer=FILE_dommap(-1, address, 0, size, 0, 0,
500 // PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE); 496 // PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE);
501 if (fd != -1)
502 close(fd);
503 497
504 if (answer != (void *)-1 && address && answer != address) { 498 if (answer != (void *)-1 && address && answer != address) {
505 /* It is dangerous to try mmap() with MAP_FIXED since it does not 499 /* It is dangerous to try mmap() with MAP_FIXED since it does not
506 always detect conflicts or non-allocation and chaos ensues after 500 always detect conflicts or non-allocation and chaos ensues after
507 a successful call but an overlapping or non-allocated region. */ 501 a successful call but an overlapping or non-allocated region. */