VM Maker: VMMaker-dtl.413.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

VM Maker: VMMaker-dtl.413.mcz

commits-2
 
David T. Lewis uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker-dtl.413.mcz

==================== Summary ====================

Name: VMMaker-dtl.413
Author: dtl
Time: 1 March 2020, 12:00:40.233 pm
UUID: b2a46b0f-6fd6-4809-b466-a2e230f5e387
Ancestors: VMMaker-dtl.412

Revert one change accidentally included in the previous commit. This is a separate update for checking file system space on image save, and may be included in a future commit along with platform changes.

=============== Diff against VMMaker-dtl.412 ===============

Item was changed:
  ----- Method: ContextInterpreter>>writeImageFileIO:embedded: (in category 'image save/restore') -----
  writeImageFileIO: imageBytes embedded: embedded
 
  | headerStart headerSize f bytesWritten sCWIfn okToWrite |
  <var: #f type: 'sqImageFile'>
  <var: #headerStart type: 'squeakFileOffsetType '>
  <var: #sCWIfn type: 'void *'>
 
  "If the security plugin can be loaded, use it to check for write permission.
  If not, assume it's ok"
  sCWIfn := self ioLoadFunction: 'secCanWriteImage' From: 'SecurityPlugin'.
  sCWIfn ~= 0 ifTrue:[okToWrite := self cCode: '((sqInt (*)(void))sCWIfn)()'.
  okToWrite ifFalse:[^self primitiveFail]].
 
  "local constants"
  headerStart := 0.  
  headerSize := 16 * objectMemory bytesPerWord.  "header size in bytes; do not change!!"
 
- "self sqSpaceForImage: imageName OfSize: imageBytes + 100000"
- (self cCode: 'sqImageFileSpaceToSave(imageName, imageBytes + 100000)')
- ifFalse: ["file system full"
- self success: false.
- ^ nil].
-
  f := self cCode: 'sqImageFileOpen(imageName, "wb")'.
  f = nil ifTrue: [
  "could not open the image file for writing"
  self success: false.
  ^ nil].
 
  headerStart := self cCode: 'sqImageFileStartLocation(f,imageName,headerSize+imageBytes)'.
  self cCode: '/* Note: on Unix systems one could put an exec command here, padded to 512 bytes */'.
  "position file to start of header"
  self sqImageFile: f Seek: headerStart.
 
  self putLong: (self imageFormatVersion) toFile: f.
  self putLong: headerSize toFile: f.
  self putLong: imageBytes toFile: f.
  self putLong: (objectMemory startOfMemory) toFile: f.
  self putLong: objectMemory getSpecialObjectsOop toFile: f.
  self putLong: objectMemory getLastHash toFile: f.
  self putLong: (self ioScreenSize) toFile: f.
  self putLong: fullScreenFlag toFile: f.
  self putLong: extraVMMemory toFile: f.
  1 to: 7 do: [:i | self putLong: 0 toFile: f].  "fill remaining header words with zeros"
  self successful ifFalse: [
  "file write or seek failure"
  self cCode: 'sqImageFileClose(f)'.
  ^ nil].
 
  "position file after the header"
  self sqImageFile: f Seek: headerStart + headerSize.
 
  "write the image data"
  bytesWritten := self
  sqImage: (objectMemory pointerForOop: objectMemory getMemory)
  write: f
  size: (self cCode: 'sizeof(unsigned char)')
  length: imageBytes.
  self success: bytesWritten = imageBytes.
  embedded ifFalse: [self setMacFileTypeForImageFile].
+ self cCode: 'sqImageFileClose(f)'.
- self sqImageFileClose: f.
 
  !