[Vm-dev] VM Maker: VMMaker.oscog-eem.2471.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Oct 22 23:07:04 UTC 2018


Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.2471.mcz

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

Name: VMMaker.oscog-eem.2471
Author: eem
Time: 22 October 2018, 4:06:22.886297 pm
UUID: 1d2b46b2-adf0-4b97-8422-59b4f078dfe3
Ancestors: VMMaker.oscog-eem.2470

Simulation:
Fix a regression in memcpy:_:_: in VMMaker.oscog-eem.2467.  Make malloc: simuulate a la alloca:.

=============== Diff against VMMaker.oscog-eem.2470 ===============

Item was removed:
- ----- Method: BitBltSimulation>>lockSurfaceFn: (in category 'surface support') -----
- lockSurfaceFn: sourceHandle _: pitchPtr _: x _: y _: w _: h
- 	"Simulate the lockSurfaceFn function call as a failure to load the surface."
- 	<doNotGenerate>
- 	^0!

Item was added:
+ ----- Method: BitBltSimulation>>lockSurfaceFn:_:_:_:_:_: (in category 'surface support') -----
+ lockSurfaceFn: sourceHandle _: pitchPtr _: x _: y _: w _: h
+ 	"Simulate the lockSurfaceFn function call as a failure to load the surface."
+ 	<doNotGenerate>
+ 	^0!

Item was removed:
- ----- Method: BitBltSimulation>>querySurfaceFn: (in category 'surface support') -----
- querySurfaceFn: handle _: widthPtr _: heightPtr _: depthPtr _: endianPtr
- 	"Query the dimension of an OS surface.
- 	This method is provided so that in case the inst vars of the
- 	source form are broken, *actual* values of the OS surface
- 	can be obtained. This might, for instance, happen if the user
- 	resizes the main window.
- 	This is a simulation of the querySurfaceFn function call; simulate as a failure."
- 	<doNotGenerate>
- 	^false!

Item was added:
+ ----- Method: BitBltSimulation>>querySurfaceFn:_:_:_:_: (in category 'surface support') -----
+ querySurfaceFn: handle _: widthPtr _: heightPtr _: depthPtr _: endianPtr
+ 	"Query the dimension of an OS surface.
+ 	This method is provided so that in case the inst vars of the
+ 	source form are broken, *actual* values of the OS surface
+ 	can be obtained. This might, for instance, happen if the user
+ 	resizes the main window.
+ 	This is a simulation of the querySurfaceFn function call; simulate as a failure."
+ 	<doNotGenerate>
+ 	^false!

Item was removed:
- ----- Method: FilePluginSimulator>>dir_Create: (in category 'simulation') -----
- dir_Create: dirNameIndex _: dirNameSize
- 	^[FileDirectory default
- 		primCreateDirectory: (interpreterProxy interpreter
- 								asString: dirNameIndex
- 								size: dirNameSize).
- 	   true]
- 		on: Error
- 		do: [:ex| false]!

Item was added:
+ ----- Method: FilePluginSimulator>>dir_Create:_: (in category 'simulation') -----
+ dir_Create: dirNameIndex _: dirNameSize
+ 	^[FileDirectory default
+ 		primCreateDirectory: (interpreterProxy interpreter
+ 								asString: dirNameIndex
+ 								size: dirNameSize).
+ 	   true]
+ 		on: Error
+ 		do: [:ex| false]!

Item was removed:
- ----- Method: FilePluginSimulator>>dir_EntryLookup: (in category 'simulation') -----
- dir_EntryLookup: pathString _: pathStringLength _: entryNameString _: entryNameStringLength _: name _: nameLength _: creationDate _: modificationDate _: isDirectory _: sizeIfFile _: posixPermissions _: isSymlink
- 	"sqInt dir_EntryLookup(char *pathString, sqInt pathStringLength, char *nameString, sqInt nameStringLength,
- 		/* outputs: */		char *name, sqInt *nameLength, sqInt *creationDate, sqInt *modificationDate,
-   						      sqInt *isDirectory, squeakFileOffsetType *sizeIfFile, sqInt *posixPermissions, sqInt *isSymlink)"
- 	| result pathName entryName |
- 	pathName := ((0 to: pathStringLength - 1) collect: [:i| (pathString at: i) asCharacter]) as: ByteString.
- 	entryName := ((0 to: entryNameStringLength - 1) collect: [:i| (entryNameString at: i) asCharacter]) as: ByteString.
- 	result := self primLookupEntryIn: pathName name: entryName.
- 	result ifNil: [^DirNoMoreEntries].
- 	result isInteger ifTrue:
- 		[result > 1 ifTrue:
- 			[interpreterProxy primitiveFailFor: result].
- 		 ^DirBadPath].
- 	name replaceFrom: 1 to: result first size with: result first startingAt: 1.
- 	nameLength at: 0 put: result first size.
- 	creationDate at: 0 put: (result at: 2).
- 	modificationDate at: 0 put: (result at: 3).
- 	isDirectory at: 0 put: (result at: 4).
- 	sizeIfFile at: 0 put: (result at: 5).
- 	posixPermissions at: 0 put: (result at: 6 ifAbsent: [(result at: 4) ifTrue: [8r755] ifFalse: [8r644]]).
- 	isSymlink at: 0 put: (result at: 7 ifAbsent: [false]).
- 	^DirEntryFound!

Item was added:
+ ----- Method: FilePluginSimulator>>dir_EntryLookup:_:_:_:_:_:_:_:_:_:_:_: (in category 'simulation') -----
+ dir_EntryLookup: pathString _: pathStringLength _: entryNameString _: entryNameStringLength _: name _: nameLength _: creationDate _: modificationDate _: isDirectory _: sizeIfFile _: posixPermissions _: isSymlink
+ 	"sqInt dir_EntryLookup(char *pathString, sqInt pathStringLength, char *nameString, sqInt nameStringLength,
+ 		/* outputs: */		char *name, sqInt *nameLength, sqInt *creationDate, sqInt *modificationDate,
+   						      sqInt *isDirectory, squeakFileOffsetType *sizeIfFile, sqInt *posixPermissions, sqInt *isSymlink)"
+ 	| result pathName entryName |
+ 	pathName := ((0 to: pathStringLength - 1) collect: [:i| (pathString at: i) asCharacter]) as: ByteString.
+ 	entryName := ((0 to: entryNameStringLength - 1) collect: [:i| (entryNameString at: i) asCharacter]) as: ByteString.
+ 	result := self primLookupEntryIn: pathName name: entryName.
+ 	result ifNil: [^DirNoMoreEntries].
+ 	result isInteger ifTrue:
+ 		[result > 1 ifTrue:
+ 			[interpreterProxy primitiveFailFor: result].
+ 		 ^DirBadPath].
+ 	name replaceFrom: 1 to: result first size with: result first startingAt: 1.
+ 	nameLength at: 0 put: result first size.
+ 	creationDate at: 0 put: (result at: 2).
+ 	modificationDate at: 0 put: (result at: 3).
+ 	isDirectory at: 0 put: (result at: 4).
+ 	sizeIfFile at: 0 put: (result at: 5).
+ 	posixPermissions at: 0 put: (result at: 6 ifAbsent: [(result at: 4) ifTrue: [8r755] ifFalse: [8r644]]).
+ 	isSymlink at: 0 put: (result at: 7 ifAbsent: [false]).
+ 	^DirEntryFound!

Item was removed:
- ----- Method: FilePluginSimulator>>dir_Lookup: (in category 'simulation') -----
- dir_Lookup: pathString _: pathStringLength _: index _: name _: nameLength _: creationDate _: modificationDate _: isDirectory _: sizeIfFile _: posixPermissions _: isSymlink
- 	"sqInt dir_Lookup(	char *pathString, sqInt pathStringLength, sqInt index,
- 		/* outputs: */	char *name, sqInt *nameLength, sqInt *creationDate, sqInt *modificationDate,
- 		   				sqInt *isDirectory, squeakFileOffsetType *sizeIfFile, sqInt * posixPermissions, sqInt *isSymlink)"
- 	| result pathName |
- 	pathName := ((0 to: pathStringLength - 1) collect: [:i| (pathString at: i) asCharacter]) as: ByteString.
- 	result := self primLookupEntryIn: pathName index: index.
- 	result ifNil: [^DirNoMoreEntries].
- 	result isInteger ifTrue:
- 		[result > 1 ifTrue:
- 			[interpreterProxy primitiveFailFor: result].
- 		 ^DirBadPath].
- 	name replaceFrom: 1 to: result first size with: result first startingAt: 1.
- 	nameLength at: 0 put: result first size.
- 	creationDate at: 0 put: (result at: 2).
- 	modificationDate at: 0 put: (result at: 3).
- 	isDirectory at: 0 put: (result at: 4).
- 	sizeIfFile at: 0 put: (result at: 5).
- 	posixPermissions at: 0 put: (result at: 6 ifAbsent: [(result at: 4) ifTrue: [8r755] ifFalse: [8r644]]).
- 	isSymlink at: 0 put: (result at: 7 ifAbsent: [false]).
- 	^DirEntryFound!

Item was added:
+ ----- Method: FilePluginSimulator>>dir_Lookup:_:_:_:_:_:_:_:_:_:_: (in category 'simulation') -----
+ dir_Lookup: pathString _: pathStringLength _: index _: name _: nameLength _: creationDate _: modificationDate _: isDirectory _: sizeIfFile _: posixPermissions _: isSymlink
+ 	"sqInt dir_Lookup(	char *pathString, sqInt pathStringLength, sqInt index,
+ 		/* outputs: */	char *name, sqInt *nameLength, sqInt *creationDate, sqInt *modificationDate,
+ 		   				sqInt *isDirectory, squeakFileOffsetType *sizeIfFile, sqInt * posixPermissions, sqInt *isSymlink)"
+ 	| result pathName |
+ 	pathName := ((0 to: pathStringLength - 1) collect: [:i| (pathString at: i) asCharacter]) as: ByteString.
+ 	result := self primLookupEntryIn: pathName index: index.
+ 	result ifNil: [^DirNoMoreEntries].
+ 	result isInteger ifTrue:
+ 		[result > 1 ifTrue:
+ 			[interpreterProxy primitiveFailFor: result].
+ 		 ^DirBadPath].
+ 	name replaceFrom: 1 to: result first size with: result first startingAt: 1.
+ 	nameLength at: 0 put: result first size.
+ 	creationDate at: 0 put: (result at: 2).
+ 	modificationDate at: 0 put: (result at: 3).
+ 	isDirectory at: 0 put: (result at: 4).
+ 	sizeIfFile at: 0 put: (result at: 5).
+ 	posixPermissions at: 0 put: (result at: 6 ifAbsent: [(result at: 4) ifTrue: [8r755] ifFalse: [8r644]]).
+ 	isSymlink at: 0 put: (result at: 7 ifAbsent: [false]).
+ 	^DirEntryFound!

Item was removed:
- ----- Method: InterpreterPlugin>>strncpy: (in category 'simulation support') -----
- strncpy: aString _: bString _: n
- 	<doNotGenerate>
- 	^interpreterProxy strncpy: aString _: bString _: n!

Item was added:
+ ----- Method: InterpreterPlugin>>strncpy:_:_: (in category 'simulation support') -----
+ strncpy: aString _: bString _: n
+ 	<doNotGenerate>
+ 	^interpreterProxy strncpy: aString _: bString _: n!

Item was removed:
- ----- Method: JPEGReadWriter2Plugin>>primJPEGReadImagefromByteArrayonFormdoDitheringerrorMgrReadScanlines: (in category 'simulation') -----
- primJPEGReadImagefromByteArrayonFormdoDitheringerrorMgrReadScanlines: jpegDecompressStruct _: jpegErrorMgr2Struct _: source _: sourceSize _: ditherFlag _: formBitmap _: pixelsPerWord _: wordsPerRow _: formNativeDepth
- 	"void primJPEGReadImagefromByteArrayonFormdoDitheringerrorMgrReadScanlines(
- 		    char* jpegDecompressStruct,
- 		    char* jpegErrorMgr2Struct,
- 		    char* source,
- 		    unsigned int sourceSize,
- 		    int ditherFlag,
- 		    unsigned int* bitmap,
- 		    unsigned int pixelsPerWord,
- 		    unsigned int wordsPerRow,
- 		    int nativeDepth)"
- 	<doNotGenerate>
- 	| sourceBytes decompressStruct errorStruct form |
- 	sourceBytes := source asByteArray.
- 	decompressStruct := jpegDecompressStruct asByteArray.
- 	errorStruct := jpegErrorMgr2Struct asByteArray.
- 	(self evaluateIfFailed:
- 		[| slave height |
- 		 slave := JPEGReadWriter2 new.
- 		 height := slave primImageWidth: decompressStruct. "cheating ;-)"
- 		 form := Form extent: wordsPerRow * pixelsPerWord @ height depth: formNativeDepth.
- 		 slave
- 			primJPEGReadImage: decompressStruct
- 			fromByteArray: sourceBytes
- 			onForm: form
- 			doDithering: true
- 			errorMgr: errorStruct]) ifTrue: [^nil].
- 	jpegDecompressStruct overwriteContentsWith: decompressStruct.
- 	jpegErrorMgr2Struct overwriteContentsWith: errorStruct.
- 	source overwriteContentsWith: sourceBytes. "could happen..."
- 	ByteArray adoptInstance: form bits.
- 	formBitmap overwriteContentsWith: form bits.
- 	^nil!

Item was added:
+ ----- Method: JPEGReadWriter2Plugin>>primJPEGReadImagefromByteArrayonFormdoDitheringerrorMgrReadScanlines:_:_:_:_:_:_:_:_: (in category 'simulation') -----
+ primJPEGReadImagefromByteArrayonFormdoDitheringerrorMgrReadScanlines: jpegDecompressStruct _: jpegErrorMgr2Struct _: source _: sourceSize _: ditherFlag _: formBitmap _: pixelsPerWord _: wordsPerRow _: formNativeDepth
+ 	"void primJPEGReadImagefromByteArrayonFormdoDitheringerrorMgrReadScanlines(
+ 		    char* jpegDecompressStruct,
+ 		    char* jpegErrorMgr2Struct,
+ 		    char* source,
+ 		    unsigned int sourceSize,
+ 		    int ditherFlag,
+ 		    unsigned int* bitmap,
+ 		    unsigned int pixelsPerWord,
+ 		    unsigned int wordsPerRow,
+ 		    int nativeDepth)"
+ 	<doNotGenerate>
+ 	| sourceBytes decompressStruct errorStruct form |
+ 	sourceBytes := source asByteArray.
+ 	decompressStruct := jpegDecompressStruct asByteArray.
+ 	errorStruct := jpegErrorMgr2Struct asByteArray.
+ 	(self evaluateIfFailed:
+ 		[| slave height |
+ 		 slave := JPEGReadWriter2 new.
+ 		 height := slave primImageWidth: decompressStruct. "cheating ;-)"
+ 		 form := Form extent: wordsPerRow * pixelsPerWord @ height depth: formNativeDepth.
+ 		 slave
+ 			primJPEGReadImage: decompressStruct
+ 			fromByteArray: sourceBytes
+ 			onForm: form
+ 			doDithering: true
+ 			errorMgr: errorStruct]) ifTrue: [^nil].
+ 	jpegDecompressStruct overwriteContentsWith: decompressStruct.
+ 	jpegErrorMgr2Struct overwriteContentsWith: errorStruct.
+ 	source overwriteContentsWith: sourceBytes. "could happen..."
+ 	ByteArray adoptInstance: form bits.
+ 	formBitmap overwriteContentsWith: form bits.
+ 	^nil!

Item was removed:
- ----- Method: JPEGReadWriter2Plugin>>primJPEGWriteImageonByteArrayformqualityprogressiveJPEGerrorMgrWriteScanlines: (in category 'simulation') -----
- primJPEGWriteImageonByteArrayformqualityprogressiveJPEGerrorMgrWriteScanlines: width _: height _: nativeDepth _: bitmap _: jpegCompressStruct _: jpegErrorMgr2Struct _: quality _: progressiveFlag _: pixelsPerWord _: wordsPerRow _: destination _: destinationSizePtr
- 	"void primJPEGWriteImageonByteArrayformqualityprogressiveJPEGerrorMgrWriteScanlines(
- 			unsigned int width,
- 			unsigned int height,
- 			int nativeDepth,
- 			unsigned int* bitmap,
- 			char* jpegCompressStruct,
- 			char* jpegErrorMgr2Struct,
- 			int quality,
- 			int progressiveFlag,
- 			unsigned int pixelsPerWord,
- 			unsigned int wordsPerRow,
- 			char* destination,
- 			unsigned int* destinationSizePtr)"
- 	<doNotGenerate>
- 	| bits form compressStruct errorStruct destinationBytes destinationSize |
- 	bits := bitmap asByteArray.
- 	Bitmap adoptInstance: bits.
- 	form := Form extent: width @ height depth: nativeDepth bits: bits.
- 	compressStruct := jpegCompressStruct asByteArray.
- 	errorStruct := jpegErrorMgr2Struct asByteArray.
- 	destinationBytes := destination asByteArray.
- 	(self evaluateIfFailed:
- 		[destinationSize :=JPEGReadWriter2 new
- 			primJPEGWriteImage: compressStruct
- 			onByteArray: destinationBytes
- 			form: form
- 			quality: quality
- 			progressiveJPEG: progressiveFlag
- 			errorMgr: errorStruct]) ifTrue: [^nil].
- 	jpegCompressStruct overwriteContentsWith: compressStruct.
- 	jpegErrorMgr2Struct overwriteContentsWith: errorStruct.
- 	destination overwriteContentsWith: destinationBytes.
- 	destinationSizePtr at: 0 put: destinationSize.
- 	^nil!

Item was added:
+ ----- Method: JPEGReadWriter2Plugin>>primJPEGWriteImageonByteArrayformqualityprogressiveJPEGerrorMgrWriteScanlines:_:_:_:_:_:_:_:_:_:_:_: (in category 'simulation') -----
+ primJPEGWriteImageonByteArrayformqualityprogressiveJPEGerrorMgrWriteScanlines: width _: height _: nativeDepth _: bitmap _: jpegCompressStruct _: jpegErrorMgr2Struct _: quality _: progressiveFlag _: pixelsPerWord _: wordsPerRow _: destination _: destinationSizePtr
+ 	"void primJPEGWriteImageonByteArrayformqualityprogressiveJPEGerrorMgrWriteScanlines(
+ 			unsigned int width,
+ 			unsigned int height,
+ 			int nativeDepth,
+ 			unsigned int* bitmap,
+ 			char* jpegCompressStruct,
+ 			char* jpegErrorMgr2Struct,
+ 			int quality,
+ 			int progressiveFlag,
+ 			unsigned int pixelsPerWord,
+ 			unsigned int wordsPerRow,
+ 			char* destination,
+ 			unsigned int* destinationSizePtr)"
+ 	<doNotGenerate>
+ 	| bits form compressStruct errorStruct destinationBytes destinationSize |
+ 	bits := bitmap asByteArray.
+ 	Bitmap adoptInstance: bits.
+ 	form := Form extent: width @ height depth: nativeDepth bits: bits.
+ 	compressStruct := jpegCompressStruct asByteArray.
+ 	errorStruct := jpegErrorMgr2Struct asByteArray.
+ 	destinationBytes := destination asByteArray.
+ 	(self evaluateIfFailed:
+ 		[destinationSize :=JPEGReadWriter2 new
+ 			primJPEGWriteImage: compressStruct
+ 			onByteArray: destinationBytes
+ 			form: form
+ 			quality: quality
+ 			progressiveJPEG: progressiveFlag
+ 			errorMgr: errorStruct]) ifTrue: [^nil].
+ 	jpegCompressStruct overwriteContentsWith: compressStruct.
+ 	jpegErrorMgr2Struct overwriteContentsWith: errorStruct.
+ 	destination overwriteContentsWith: destinationBytes.
+ 	destinationSizePtr at: 0 put: destinationSize.
+ 	^nil!

Item was removed:
- ----- Method: Spur64BitMemoryManager>>memmove: (in category 'simulation only') -----
- memmove: destAddress _: sourceAddress _: bytes
- 	<doNotGenerate>
- 	| dst src  |
- 	dst := destAddress asInteger.
- 	src := sourceAddress asInteger.
- 	"Emulate the c library memmove function"
- 	self assert: bytes \\ 4 = 0.
- 	destAddress > sourceAddress
- 		ifTrue:
- 			[bytes - 4 to: 0 by: -4 do:
- 				[:i| self long32At: dst + i put: (self long32At: src + i)]]
- 		ifFalse:
- 			[0 to: bytes - 4 by: 4 do:
- 				[:i| self long32At: dst + i put: (self long32At: src + i)]]!

Item was added:
+ ----- Method: Spur64BitMemoryManager>>memmove:_:_: (in category 'simulation only') -----
+ memmove: destAddress _: sourceAddress _: bytes
+ 	<doNotGenerate>
+ 	| dst src  |
+ 	dst := destAddress asInteger.
+ 	src := sourceAddress asInteger.
+ 	"Emulate the c library memmove function"
+ 	self assert: bytes \\ 4 = 0.
+ 	destAddress > sourceAddress
+ 		ifTrue:
+ 			[bytes - 4 to: 0 by: -4 do:
+ 				[:i| self long32At: dst + i put: (self long32At: src + i)]]
+ 		ifFalse:
+ 			[0 to: bytes - 4 by: 4 do:
+ 				[:i| self long32At: dst + i put: (self long32At: src + i)]]!

Item was removed:
- ----- Method: SpurMemoryManager>>memcpy: (in category 'simulation') -----
- memcpy: destAddress _: sourceAddress _: bytes
- 	"For SpurGenerationScavenger>>copyToFutureSpace:bytes:. N.B. If ranges overlap, must use memmove."
- 	<doNotGenerate>
- 	self deny: ((destAddress <= sourceAddress and: [destAddress asInteger + bytes > sourceAddress])
- 				or: [sourceAddress <= destAddress and: [sourceAddress asInteger + bytes > destAddress]]).
- 	^self memmove: destAddress _: sourceAddress _: bytes!

Item was added:
+ ----- Method: SpurMemoryManager>>memcpy:_:_: (in category 'simulation') -----
+ memcpy: destAddress _: sourceAddress _: bytes
+ 	"For SpurGenerationScavenger>>copyToFutureSpace:bytes:. N.B. If ranges overlap, must use memmove."
+ 	<doNotGenerate>
+ 	self deny: ((destAddress <= sourceAddress and: [destAddress asInteger + bytes > sourceAddress])
+ 				or: [sourceAddress <= destAddress and: [sourceAddress asInteger + bytes > destAddress]]).
+ 	^self memmove: destAddress _: sourceAddress _: bytes!

Item was changed:
  ----- Method: VMClass>>malloc: (in category 'C library simulation') -----
  malloc: size
  	<doNotGenerate>
+ 	^CArrayAccessor on: (ByteArray new: size)!
- 	^ ByteArray new: size!

Item was removed:
- ----- Method: VMClass>>memcpy: (in category 'C library simulation') -----
- memcpy: dString _: sString _: bytes
- 	<doNotGenerate>
- 	"implementation of memcpy(3). N.B. If ranges overlap, must use memmove."
- 	(dString isString or: [sString isString]) ifFalse:
- 		[| destAddress sourceAddress |
- 		 dString class == ByteArray ifTrue:
- 			[self memcpy: dString _: sString _: bytes].
- 		 destAddress := dString asInteger.
- 		 sourceAddress := sString asInteger.
- 		 self deny: ((destAddress <= sourceAddress and: [destAddress + bytes > sourceAddress])
- 					or: [sourceAddress <= destAddress and: [sourceAddress + bytes > destAddress]])].
- 	dString isInteger
- 		ifTrue:
- 			[1 to: bytes do:
- 				[:i| | v |
- 				v := sString isString
- 						ifTrue: [sString basicAt: i]
- 						ifFalse: [self byteAt: sString + i - 1].
- 				self byteAt: dString + i - 1 put: v]]
- 		ifFalse:
- 			[1 to: bytes do:
- 				[:i| | v |
- 				v := sString isString
- 						ifTrue: [sString basicAt: i]
- 						ifFalse: [self byteAt: sString + i - 1].
- 				dString basicAt: i put: v]].
- 	^dString!

Item was added:
+ ----- Method: VMClass>>memcpy:_:_: (in category 'C library simulation') -----
+ memcpy: dString _: sString _: bytes
+ 	<doNotGenerate>
+ 	"implementation of memcpy(3). N.B. If ranges overlap, must use memmove."
+ 	(dString isCollection or: [sString isCollection]) ifFalse:
+ 		[| destAddress sourceAddress |
+ 		 destAddress := dString asInteger.
+ 		 sourceAddress := sString asInteger.
+ 		 self deny: ((destAddress <= sourceAddress and: [destAddress + bytes > sourceAddress])
+ 					or: [sourceAddress <= destAddress and: [sourceAddress + bytes > destAddress]])].
+ 	dString isInteger
+ 		ifTrue:
+ 			[1 to: bytes do:
+ 				[:i| | v |
+ 				v := sString isString
+ 						ifTrue: [sString basicAt: i]
+ 						ifFalse: [self byteAt: sString + i - 1].
+ 				self byteAt: dString + i - 1 put: v]]
+ 		ifFalse:
+ 			[1 to: bytes do:
+ 				[:i| | v |
+ 				v := sString isString
+ 						ifTrue: [sString basicAt: i]
+ 						ifFalse: [self byteAt: sString + i - 1].
+ 				dString basicAt: i put: v]].
+ 	^dString!

Item was removed:
- ----- Method: VMClass>>memmove: (in category 'C library simulation') -----
- memmove: destAddress _: sourceAddress _: bytes
- 	<doNotGenerate>
- 	| dst src  |
- 	dst := destAddress asInteger.
- 	src := sourceAddress asInteger.
- 	"Emulate the c library memmove function"
- 	self assert: bytes \\ 4 = 0.
- 	destAddress > sourceAddress
- 		ifTrue:
- 			[bytes - 4 to: 0 by: -4 do:
- 				[:i| self longAt: dst + i put: (self longAt: src + i)]]
- 		ifFalse:
- 			[0 to: bytes - 4 by: 4 do:
- 				[:i| self longAt: dst + i put: (self longAt: src + i)]]!

Item was added:
+ ----- Method: VMClass>>memmove:_:_: (in category 'C library simulation') -----
+ memmove: destAddress _: sourceAddress _: bytes
+ 	<doNotGenerate>
+ 	| dst src  |
+ 	dst := destAddress asInteger.
+ 	src := sourceAddress asInteger.
+ 	"Emulate the c library memmove function"
+ 	self assert: bytes \\ 4 = 0.
+ 	destAddress > sourceAddress
+ 		ifTrue:
+ 			[bytes - 4 to: 0 by: -4 do:
+ 				[:i| self longAt: dst + i put: (self longAt: src + i)]]
+ 		ifFalse:
+ 			[0 to: bytes - 4 by: 4 do:
+ 				[:i| self longAt: dst + i put: (self longAt: src + i)]]!

Item was removed:
- ----- Method: VMClass>>strcat: (in category 'C library simulation') -----
- strcat: aString _: bString
- 	<doNotGenerate>
- 	"implementation of strcat(3)"
- 	^(self asString: aString), (self asString: bString)!

Item was added:
+ ----- Method: VMClass>>strcat:_: (in category 'C library simulation') -----
+ strcat: aString _: bString
+ 	<doNotGenerate>
+ 	"implementation of strcat(3)"
+ 	^(self asString: aString), (self asString: bString)!

Item was removed:
- ----- Method: VMClass>>strncmp: (in category 'C library simulation') -----
- strncmp: aString _: bString _: n
- 	<doNotGenerate>
- 	"implementation of strncmp(3)"
- 	bString isString
- 		ifTrue:
- 			[1 to: n do:
- 				[:i| | v |
- 				 v := (aString basicAt: i) - (bString basicAt: i).
- 				 v ~= 0 ifTrue: [^v]]]
- 		ifFalse:
- 			[1 to: n do:
- 				[:i| | v |
- 				 v := (aString basicAt: i) - (self byteAt: bString + i - 1).
- 				 v ~= 0 ifTrue: [^v]]].
- 	^0!

Item was added:
+ ----- Method: VMClass>>strncmp:_:_: (in category 'C library simulation') -----
+ strncmp: aString _: bString _: n
+ 	<doNotGenerate>
+ 	"implementation of strncmp(3)"
+ 	bString isString
+ 		ifTrue:
+ 			[1 to: n do:
+ 				[:i| | v |
+ 				 v := (aString basicAt: i) - (bString basicAt: i).
+ 				 v ~= 0 ifTrue: [^v]]]
+ 		ifFalse:
+ 			[1 to: n do:
+ 				[:i| | v |
+ 				 v := (aString basicAt: i) - (self byteAt: bString + i - 1).
+ 				 v ~= 0 ifTrue: [^v]]].
+ 	^0!

Item was removed:
- ----- Method: VMClass>>strncpy: (in category 'C library simulation') -----
- strncpy: dest _: src _: n
- 	<doNotGenerate>
- 	"implementation of strncpy(3).
- 	 See e.g. https://manpages.debian.org/stretch/manpages-dev/strncpy.3.en.html
- 	 The C version always takes an address; the simulation allows a String, ByteArray,
- 	 CArray or address within the simulation object memory (Positive Integer)"
- 	| getBlock setBlock count |
- 	count := n.
- 	"Determine the source and destination access blocks based on the parameter type"
- 	getBlock := src isCollection
- 					ifTrue:
- 						[count := count min: src size.
- 						 src isString
- 							ifTrue: [[ :idx | src basicAt: idx]] "basicAt: answers integers"
- 							ifFalse:
- 								[src class == ByteArray ifTrue:
- 									[[ :idx | src at: idx]]]]
- 					ifFalse:
- 						[src isInteger
- 							ifTrue: [[ :idx | self byteAt: src + idx - 1]]
- 							ifFalse:
- 								[src class == CArray ifTrue:
- 									[[ :idx | src at: idx - 1]]]].
- 	getBlock ifNil: [self error: 'unhandled type of source string'].
- 	setBlock := dest isCollection
- 					ifTrue:
- 						[dest isString
- 							ifTrue: [[ :idx | dest basicAt: idx put: (getBlock value: idx)]] "basicAt:put: stores integers"
- 							ifFalse:
- 								[dest class == ByteArray ifTrue:
- 									[[ :idx | dest at: idx put: (getBlock value: idx)]]]]
- 					ifFalse:
- 						[dest isInteger ifTrue: 
- 							[[ :idx | self byteAt: dest + idx - 1 put: (getBlock value: idx)]]].
- 	setBlock ifNil: [self error: 'unhandled type of destination string'].
- 	1 to: count do: setBlock.
- 	"SVr4, 4.3BSD, C89, C99 require the remainder of the buffer be filled with nulls"
- 	getBlock := [:idx| 0].
- 	count + 1 to: n do: setBlock.
- 	^dest!

Item was added:
+ ----- Method: VMClass>>strncpy:_:_: (in category 'C library simulation') -----
+ strncpy: dest _: src _: n
+ 	<doNotGenerate>
+ 	"implementation of strncpy(3).
+ 	 See e.g. https://manpages.debian.org/stretch/manpages-dev/strncpy.3.en.html
+ 	 The C version always takes an address; the simulation allows a String, ByteArray,
+ 	 CArray or address within the simulation object memory (Positive Integer)"
+ 	| getBlock setBlock count |
+ 	count := n.
+ 	"Determine the source and destination access blocks based on the parameter type"
+ 	getBlock := src isCollection
+ 					ifTrue:
+ 						[count := count min: src size.
+ 						 src isString
+ 							ifTrue: [[ :idx | src basicAt: idx]] "basicAt: answers integers"
+ 							ifFalse:
+ 								[src class == ByteArray ifTrue:
+ 									[[ :idx | src at: idx]]]]
+ 					ifFalse:
+ 						[src isInteger
+ 							ifTrue: [[ :idx | self byteAt: src + idx - 1]]
+ 							ifFalse:
+ 								[src class == CArray ifTrue:
+ 									[[ :idx | src at: idx - 1]]]].
+ 	getBlock ifNil: [self error: 'unhandled type of source string'].
+ 	setBlock := dest isCollection
+ 					ifTrue:
+ 						[dest isString
+ 							ifTrue: [[ :idx | dest basicAt: idx put: (getBlock value: idx)]] "basicAt:put: stores integers"
+ 							ifFalse:
+ 								[dest class == ByteArray ifTrue:
+ 									[[ :idx | dest at: idx put: (getBlock value: idx)]]]]
+ 					ifFalse:
+ 						[dest isInteger ifTrue: 
+ 							[[ :idx | self byteAt: dest + idx - 1 put: (getBlock value: idx)]]].
+ 	setBlock ifNil: [self error: 'unhandled type of destination string'].
+ 	1 to: count do: setBlock.
+ 	"SVr4, 4.3BSD, C89, C99 require the remainder of the buffer be filled with nulls"
+ 	getBlock := [:idx| 0].
+ 	count + 1 to: n do: setBlock.
+ 	^dest!



More information about the Vm-dev mailing list