comparison src/dumper.c @ 410:de805c49cfc1 r21-2-35

Import from CVS: tag r21-2-35
author cvs
date Mon, 13 Aug 2007 11:19:21 +0200
parents b8cc9ab3f761
children
comparison
equal deleted inserted replaced
409:301b9ebbdf3b 410:de805c49cfc1
20 20
21 /* Synched up with: Not in FSF. */ 21 /* Synched up with: Not in FSF. */
22 22
23 #include <config.h> 23 #include <config.h>
24 #include "lisp.h" 24 #include "lisp.h"
25
25 #include "dump-id.h" 26 #include "dump-id.h"
26 #include "specifier.h" 27 #include "specifier.h"
27 #include "alloc.h" 28 #include "alloc.h"
28 #include "elhash.h" 29 #include "elhash.h"
29 #include "sysfile.h" 30 #include "sysfile.h"
30 #include "console-stream.h" 31 #include "console-stream.h"
31 #include "dumper.h" 32 #include "dumper.h"
32 33
33 #ifdef WINDOWSNT 34 #ifdef WIN32_NATIVE
34 #define WINDOWS_LEAN_AND_MEAN 35 #include "nt.h"
35 #include <windows.h>
36 #define PATH_MAX MAXPATHLEN
37 #else 36 #else
38 #ifdef HAVE_MMAP 37 #ifdef HAVE_MMAP
39 #include <sys/mman.h> 38 #include <sys/mman.h>
40 #endif 39 #endif
41 #endif 40 #endif
105 } dump_header; 104 } dump_header;
106 105
107 char *pdump_start, *pdump_end; 106 char *pdump_start, *pdump_end;
108 static size_t pdump_length; 107 static size_t pdump_length;
109 108
110 #ifdef WINDOWSNT 109 #ifdef WIN32_NATIVE
111 // Handle for the dump file 110 // Handle for the dump file
112 HANDLE pdump_hFile = INVALID_HANDLE_VALUE; 111 HANDLE pdump_hFile = INVALID_HANDLE_VALUE;
113 // Handle for the file mapping object for the dump file 112 // Handle for the file mapping object for the dump file
114 HANDLE pdump_hMap = INVALID_HANDLE_VALUE; 113 HANDLE pdump_hMap = INVALID_HANDLE_VALUE;
115 #endif 114 #endif
1108 noninteractive1 = noninteractive; 1107 noninteractive1 = noninteractive;
1109 1108
1110 return 1; 1109 return 1;
1111 } 1110 }
1112 1111
1113 #ifdef WINDOWSNT 1112 #ifdef WIN32_NATIVE
1114 /* Free the mapped file if we decide we don't want it after all */ 1113 /* Free the mapped file if we decide we don't want it after all */
1115 static void pdump_file_unmap(void) 1114 static void pdump_file_unmap(void)
1116 { 1115 {
1117 UnmapViewOfFile (pdump_start); 1116 UnmapViewOfFile (pdump_start);
1118 CloseHandle (pdump_hFile); 1117 CloseHandle (pdump_hFile);
1196 } 1195 }
1197 1196
1198 return 1; 1197 return 1;
1199 } 1198 }
1200 1199
1201 #else /* !WINDOWSNT */ 1200 #else /* !WIN32_NATIVE */
1202 1201
1203 static void *pdump_mallocadr; 1202 static void *pdump_mallocadr;
1204 1203
1205 static void pdump_file_free(void) 1204 static void pdump_file_free(void)
1206 { 1205 {
1245 read (pdump_fd, pdump_start, pdump_length); 1244 read (pdump_fd, pdump_start, pdump_length);
1246 1245
1247 close (pdump_fd); 1246 close (pdump_fd);
1248 return 1; 1247 return 1;
1249 } 1248 }
1250 #endif /* !WINDOWSNT */ 1249 #endif /* !WIN32_NATIVE */
1251 1250
1252 1251
1253 static int pdump_file_try(char *exe_path) 1252 static int pdump_file_try(char *exe_path)
1254 { 1253 {
1255 char *w; 1254 char *w;
1290 } 1289 }
1291 1290
1292 int pdump_load(const char *argv0) 1291 int pdump_load(const char *argv0)
1293 { 1292 {
1294 char exe_path[PATH_MAX]; 1293 char exe_path[PATH_MAX];
1295 #ifdef WINDOWSNT 1294 #ifdef WIN32_NATIVE
1296 GetModuleFileName (NULL, exe_path, PATH_MAX); 1295 GetModuleFileName (NULL, exe_path, PATH_MAX);
1297 #else /* !WINDOWSNT */ 1296 #else /* !WIN32_NATIVE */
1298 char *w; 1297 char *w;
1299 const char *dir, *p; 1298 const char *dir, *p;
1300 1299
1301 dir = argv0; 1300 dir = argv0;
1302 if (dir[0] == '-') 1301 if (dir[0] == '-')
1353 break; 1352 break;
1354 } 1353 }
1355 path = p+1; 1354 path = p+1;
1356 } 1355 }
1357 } 1356 }
1358 #endif /* WINDOWSNT */ 1357 #endif /* WIN32_NATIVE */
1359 1358
1360 if (pdump_file_try (exe_path)) 1359 if (pdump_file_try (exe_path))
1361 { 1360 {
1362 pdump_load_finish (); 1361 pdump_load_finish ();
1363 return 1; 1362 return 1;
1364 } 1363 }
1365 1364
1366 #ifdef WINDOWSNT 1365 #ifdef WIN32_NATIVE
1367 if (pdump_resource_get ()) 1366 if (pdump_resource_get ())
1368 { 1367 {
1369 if (pdump_load_check ()) 1368 if (pdump_load_check ())
1370 { 1369 {
1371 pdump_load_finish (); 1370 pdump_load_finish ();