Mercurial > hg > xemacs-beta
comparison src/dumper.c @ 5923:61d7d7bcbe76 cygwin
merged heads after pull -u
author | Henry Thompson <ht@markup.co.uk> |
---|---|
date | Thu, 05 Feb 2015 17:19:05 +0000 |
parents | 93a18dbcfd8c |
children | e2fae7783046 |
comparison
equal
deleted
inserted
replaced
5921:68639fb08af8 | 5923:61d7d7bcbe76 |
---|---|
204 pdump_align_stream (FILE *stream, Bytecount alignment) | 204 pdump_align_stream (FILE *stream, Bytecount alignment) |
205 { | 205 { |
206 OFF_T offset = FTELL (stream); | 206 OFF_T offset = FTELL (stream); |
207 OFF_T adjustment = ALIGN_SIZE (offset, alignment) - offset; | 207 OFF_T adjustment = ALIGN_SIZE (offset, alignment) - offset; |
208 if (adjustment) | 208 if (adjustment) |
209 FSEEK (stream, adjustment, SEEK_CUR); | 209 { |
210 if (FSEEK (stream, adjustment, SEEK_CUR) == -1) | |
211 { | |
212 report_file_error ("Unable to fseek dump file", | |
213 build_ascstring (EMACS_PROGNAME ".dmp")); | |
214 } | |
215 } | |
210 } | 216 } |
211 | 217 |
212 #define PDUMP_ALIGN_OUTPUT(type) pdump_align_stream (pdump_out, ALIGNOF (type)) | 218 #define PDUMP_ALIGN_OUTPUT(type) pdump_align_stream (pdump_out, ALIGNOF (type)) |
213 | 219 |
214 #define PDUMP_WRITE(type, object) \ | 220 #define PDUMP_WRITE(type, object) \ |
842 break; | 848 break; |
843 case XD_OPAQUE_PTR_CONVERTIBLE: | 849 case XD_OPAQUE_PTR_CONVERTIBLE: |
844 { | 850 { |
845 pdump_cv_ptr_info info; | 851 pdump_cv_ptr_info info; |
846 info.object = *(void **)rdata; | 852 info.object = *(void **)rdata; |
853 info.index = 0; | |
854 info.save_offset = 0; | |
847 info.fcts = desc1->data2.funcs; | 855 info.fcts = desc1->data2.funcs; |
848 if (!pdump_find_in_cv_ptr_dynarr (info.object)) | 856 if (!pdump_find_in_cv_ptr_dynarr (info.object)) |
849 { | 857 { |
850 info.fcts->convert(info.object, &info.data, &info.size); | 858 info.fcts->convert(info.object, &info.data, &info.size); |
851 Dynarr_add (pdump_cv_ptr, info); | 859 Dynarr_add (pdump_cv_ptr, info); |
855 case XD_OPAQUE_DATA_CONVERTIBLE: | 863 case XD_OPAQUE_DATA_CONVERTIBLE: |
856 { | 864 { |
857 pdump_cv_data_info info; | 865 pdump_cv_data_info info; |
858 info.object = data; | 866 info.object = data; |
859 info.offset = offset; | 867 info.offset = offset; |
868 info.dest_offset = 0; | |
869 info.save_offset = 0; | |
860 info.fcts = desc1->data2.funcs; | 870 info.fcts = desc1->data2.funcs; |
861 | 871 |
862 info.fcts->convert(rdata, &info.data, &info.size); | 872 info.fcts->convert(rdata, &info.data, &info.size); |
863 Dynarr_add (pdump_cv_data, info); | 873 Dynarr_add (pdump_cv_data, info); |
864 break; | 874 break; |
2133 O_WRONLY | O_CREAT | O_TRUNC | OPEN_BINARY, 0666); | 2143 O_WRONLY | O_CREAT | O_TRUNC | OPEN_BINARY, 0666); |
2134 if (pdump_fd < 0) | 2144 if (pdump_fd < 0) |
2135 report_file_error ("Unable to open dump file", | 2145 report_file_error ("Unable to open dump file", |
2136 build_ascstring (EMACS_PROGNAME ".dmp")); | 2146 build_ascstring (EMACS_PROGNAME ".dmp")); |
2137 pdump_out = fdopen (pdump_fd, "w"); | 2147 pdump_out = fdopen (pdump_fd, "w"); |
2138 if (pdump_out < 0) | 2148 if (pdump_out == NULL) |
2139 report_file_error ("Unable to open dump file for writing", | 2149 report_file_error ("Unable to open dump file for writing", |
2140 build_ascstring (EMACS_PROGNAME ".dmp")); | 2150 build_ascstring (EMACS_PROGNAME ".dmp")); |
2141 | 2151 |
2142 retry_fwrite (&header, sizeof (header), 1, pdump_out); | 2152 retry_fwrite (&header, sizeof (header), 1, pdump_out); |
2143 PDUMP_ALIGN_OUTPUT (max_align_t); | 2153 PDUMP_ALIGN_OUTPUT (max_align_t); |
2166 pdump_cv_ptr_info *elt = Dynarr_atp (pdump_cv_ptr, i); | 2176 pdump_cv_ptr_info *elt = Dynarr_atp (pdump_cv_ptr, i); |
2167 if(elt->fcts->convert_free) | 2177 if(elt->fcts->convert_free) |
2168 elt->fcts->convert_free(elt->object, elt->data, elt->size); | 2178 elt->fcts->convert_free(elt->object, elt->data, elt->size); |
2169 } | 2179 } |
2170 | 2180 |
2171 FSEEK (pdump_out, header.stab_offset, SEEK_SET); | 2181 if (FSEEK (pdump_out, header.stab_offset, SEEK_SET) == -1) |
2182 { | |
2183 report_file_error ("Unable to fseek dump file", | |
2184 build_ascstring (EMACS_PROGNAME ".dmp")); | |
2185 } | |
2172 | 2186 |
2173 #ifdef NEW_GC | 2187 #ifdef NEW_GC |
2174 { | 2188 { |
2175 EMACS_INT zero = 0; | 2189 EMACS_INT zero = 0; |
2176 pdump_scan_lisp_objects_by_alignment (pdump_dump_mc_data); | 2190 pdump_scan_lisp_objects_by_alignment (pdump_dump_mc_data); |
2551 { | 2565 { |
2552 retry_close (fd); | 2566 retry_close (fd); |
2553 return 0; | 2567 return 0; |
2554 } | 2568 } |
2555 | 2569 |
2556 lseek (fd, 0, SEEK_SET); | 2570 if (lseek (fd, 0, SEEK_SET) == -1) |
2571 { | |
2572 retry_close (fd); | |
2573 return 0; | |
2574 } | |
2557 | 2575 |
2558 #ifdef HAVE_MMAP | 2576 #ifdef HAVE_MMAP |
2559 /* Unix 98 requires that sys/mman.h define MAP_FAILED, | 2577 /* Unix 98 requires that sys/mman.h define MAP_FAILED, |
2560 but many earlier implementations don't. */ | 2578 but many earlier implementations don't. */ |
2561 # ifndef MAP_FAILED | 2579 # ifndef MAP_FAILED |