[Vm-dev] VM Maker: VMMaker.oscog-nice.2565.mcz
commits at source.squeak.org
commits at source.squeak.org
Wed Sep 18 21:19:22 UTC 2019
Nicolas Cellier uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-nice.2565.mcz
==================== Summary ====================
Name: VMMaker.oscog-nice.2565
Author: nice
Time: 18 September 2019, 11:18:16.74572 pm
UUID: e21f30a8-9e63-4922-a3ae-c8f85d56e28e
Ancestors: VMMaker.oscog-cb.2564
Add some simulation support (Socket)
=============== Diff against VMMaker.oscog-cb.2564 ===============
Item was added:
+ ----- Method: SocketPluginSimulator>>primitiveSocket:setOptions:value: (in category 'simulation') -----
+ primitiveSocket: socket setOptions: optionName value: optionValue
+ "THIS BADLY NEEDS TO BE REWRITTEN TO TAKE Booleans AND Integers AS WELL AS (OR INSTEAD OF) Strings.
+ It is only used with booleans and integers and parsing these back out of strings in
+ sqSocketSetOptions:optionNameStart:optionNameSize:optionValueStart:optionValueSize:returnedValue:
+ is STUPID."
+ | s optionNameStart optionNameSize optionValueStart optionValueSize returnedValue errorCode results |
+ <var: #s type: #SocketPtr>
+ <var: #optionNameStart type: #'char *'>
+ <var: #optionValueStart type: #'char *'>
+ self primitive: 'primitiveSocketSetOptions'
+ parameters: #(Oop Oop Oop).
+
+ s := self socketValueOf: socket.
+ interpreterProxy success: (interpreterProxy isBytes: optionName).
+ optionNameStart := self cCoerce: (interpreterProxy firstIndexableField: optionName) to: #'char *'.
+ optionNameSize := interpreterProxy slotSizeOf: optionName.
+ interpreterProxy success: (interpreterProxy isBytes: optionValue).
+ optionValueStart:= self cCoerce: (interpreterProxy firstIndexableField: optionValue) to: #'char *'.
+ optionValueSize := interpreterProxy slotSizeOf: optionValue.
+
+ interpreterProxy failed ifTrue: [^nil].
+ errorCode := 0. "?"
+ returnedValue := self sqSocket: s setOption: optionName value: optionValue.
+ returnedValue isNil ifTrue: [returnedValue := 0. errorCode := 1 "?"].
+
+ results := interpreterProxy instantiateClass: interpreterProxy classArray indexableSize: 2.
+ interpreterProxy storePointer: 0 ofObject: results withValue: errorCode asSmallIntegerObj.
+ interpreterProxy storePointer: 1 ofObject: results withValue: returnedValue asSmallIntegerObj.
+ ^ results!
Item was added:
+ ----- Method: SocketPluginSimulator>>primitiveSocketListenWithOrWithoutBacklog (in category 'simulation') -----
+ primitiveSocketListenWithOrWithoutBacklog
+ interpreterProxy methodArgumentCount = 2
+ ifTrue:[^simulator primitiveSocketListenOnPort]
+ ifFalse:[^simulator primitiveSocketListenOnPortBacklog]!
Item was added:
+ ----- Method: SocketPluginSimulator>>sqSocket:ListenOnPort: (in category 'simulation') -----
+ sqSocket: s ListenOnPort: port
+ ^[Socket basicNew
+ primSocket: s listenOn: port]
+ on: SocketPrimitiveFailed
+ do: [:ex|
+ interpreterProxy primitiveFail.
+ 0]!
Item was added:
+ ----- Method: SocketPluginSimulator>>sqSocket:ListenOnPort:BacklogSize:Interface: (in category 'simulation') -----
+ sqSocket: s ListenOnPort: port BacklogSize: backlog Interface: addr
+ ^[Socket basicNew
+ primSocket: s listenOn: port backlogSize: backlog interface: addr]
+ on: SocketPrimitiveFailed
+ do: [:ex|
+ interpreterProxy primitiveFail.
+ 0]!
Item was added:
+ ----- Method: SocketPluginSimulator>>sqSocket:setOption:value: (in category 'simulation') -----
+ sqSocket: s setOption: aString value: aStringValue
+ ^[Socket basicNew
+ primSocket: s setOption: aString value: aStringValue]
+ on: SocketPrimitiveFailed
+ do: [:ex|
+ interpreterProxy primitiveFail.
+ 0]!
Item was added:
+ ----- Method: SocketPluginSimulator>>sqSocketError: (in category 'simulation') -----
+ sqSocketError: s
+ ^[Socket basicNew
+ primSocketError: s]
+ on: SocketPrimitiveFailed
+ do: [:ex|
+ interpreterProxy primitiveFail.
+ -1]!
Item was added:
+ ----- Method: SocketPluginSimulator>>sqSocketRemoteAddress: (in category 'simulation') -----
+ sqSocketRemoteAddress: s
+ ^[Socket basicNew
+ primSocketRemoteAddress: s]
+ on: SocketPrimitiveFailed
+ do: [:ex|
+ interpreterProxy primitiveFail.
+ 0]!
Item was changed:
----- 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 isCArray 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)]]
+ ifFalse: [dest isCArray ifTrue:
+ [[ :idx | dest at: idx - 1 put: (getBlock value: idx)]]]].
- [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