A new version of Chronology-Core was added to project The Inbox:
http://source.squeak.org/inbox/Chronology-Core-dtl.48.mcz ==================== Summary ==================== Name: Chronology-Core-dtl.48 Author: dtl Time: 5 July 2019, 1:08:16.059032 pm UUID: 7f33ce2e-ae95-48ef-a526-63da7ddfd885 Ancestors: Chronology-Core-cmm.47 Fix fallback code for primPosixMicrosecondClockWithOffset: to not allow DateAndTime class>>now to create an instance with nil instance variables. Previous fallback code was a cut and paste error, never worked as intended. Rationale for the fallback handling: Corrupt DateAndTime can quickly lead to a broken image. A default value of the Posix epoch is easily recognized as un uninitialized DateAndTime. To test, evaluate "Time clockPolicy: #acceptPlatformTime" and comment out the primitive call in Time class>>primPosixMicrosecondClockWithOffset: to simulate the case of a VM that does not provide primitiveUtcWithOffset. In this case, DateAndTime now produces 1970-01-01T00:00:00+00:00. After testing, do Time initialze to restore clock policy. =============== Diff against Chronology-Core-cmm.47 =============== Item was changed: ----- Method: Time class>>posixMicrosecondClockWithOffset: (in category 'clock') ----- posixMicrosecondClockWithOffset: aDateAndTime "Initialize aDateAndTime initialized with local microseconds since the Posix epoch and the current seconds offset from GMT in the local time zone." | utcValue | self primPosixMicrosecondClockWithOffset: aDateAndTime. - aDateAndTime utcMicroseconds ifNil: [ ^aDateAndTime]. "primitive failed" ClockPolicy caseOf: { [#acceptPlatformTime] -> [^ aDateAndTime] . [#monotonicAllowDuplicates] -> [ utcValue := aDateAndTime utcMicroseconds. utcValue > LastClockTick ifTrue: [LastClockTick := utcValue] ifFalse: [aDateAndTime utcMicroseconds: LastClockTick]] . [#monotonicForceMicrosecondIncrement] -> [ utcValue := aDateAndTime utcMicroseconds. utcValue > LastClockTick ifTrue: [LastClockTick := utcValue] ifFalse: [LastClockTick := LastClockTick + 1. "add one microsecond" aDateAndTime utcMicroseconds: LastClockTick]] . [#monotonicForceNanosecondIncrement] -> [ utcValue := aDateAndTime utcMicroseconds. utcValue > LastClockTick ifTrue: [LastClockTick := utcValue] ifFalse: [LastClockTick := LastClockTick + (1 / 1000). "add one nanosecond" aDateAndTime utcMicroseconds: LastClockTick]] } otherwise: []. ^aDateAndTime ! Item was changed: ----- Method: Time class>>primPosixMicrosecondClockWithOffset: (in category 'private') ----- primPosixMicrosecondClockWithOffset: arrayOrObjectWithTwoSlots "Answer an array with UTC microseconds since the Posix epoch and the current seconds offset from GMT in the local time zone. If the primitive is not available, then answer the time and offset of Posix epoch GMT. This enables the image to continue running in the absence of #primitiveUtcWithOffset, thus avoiding the need to fallback code based on the earlier local microsecond clock mechanism. The parameter may be a two element array, or an object whose first two instance variables are expected to be UTC microseconds and seconds offset from GMT." <primitive: 'primitiveUtcWithOffset'> + + (arrayOrObjectWithTwoSlots instVarAt: 1) + ifNil: [arrayOrObjectWithTwoSlots instVarAt: 1 put: 0]. + (arrayOrObjectWithTwoSlots instVarAt: 2) + ifNil: [arrayOrObjectWithTwoSlots instVarAt: 2 put: 0]! - ^{0. 0}! |
This fixes a problem that went unnoticed because most of us do not use obsolete
VMs. But it could be an issue for someone porting the VM to a new platform, so it's worth fixing. Dave On Fri, Jul 05, 2019 at 05:08:17PM +0000, [hidden email] wrote: > A new version of Chronology-Core was added to project The Inbox: > http://source.squeak.org/inbox/Chronology-Core-dtl.48.mcz > > ==================== Summary ==================== > > Name: Chronology-Core-dtl.48 > Author: dtl > Time: 5 July 2019, 1:08:16.059032 pm > UUID: 7f33ce2e-ae95-48ef-a526-63da7ddfd885 > Ancestors: Chronology-Core-cmm.47 > > Fix fallback code for primPosixMicrosecondClockWithOffset: to not allow DateAndTime class>>now to create an instance with nil instance variables. Previous fallback code was a cut and paste error, never worked as intended. > > Rationale for the fallback handling: Corrupt DateAndTime can quickly lead to a broken image. A default value of the Posix epoch is easily recognized as un uninitialized DateAndTime. > > To test, evaluate "Time clockPolicy: #acceptPlatformTime" and comment out the primitive call in Time class>>primPosixMicrosecondClockWithOffset: to simulate the case of a VM that does not provide primitiveUtcWithOffset. In this case, DateAndTime now produces 1970-01-01T00:00:00+00:00. After testing, do Time initialze to restore clock policy. > > =============== Diff against Chronology-Core-cmm.47 =============== > > Item was changed: > ----- Method: Time class>>posixMicrosecondClockWithOffset: (in category 'clock') ----- > posixMicrosecondClockWithOffset: aDateAndTime > "Initialize aDateAndTime initialized with local microseconds since the Posix > epoch and the current seconds offset from GMT in the local time zone." > > > | utcValue | > self primPosixMicrosecondClockWithOffset: aDateAndTime. > - aDateAndTime utcMicroseconds ifNil: [ ^aDateAndTime]. "primitive failed" > ClockPolicy caseOf: { > [#acceptPlatformTime] -> [^ aDateAndTime] . > [#monotonicAllowDuplicates] -> [ > utcValue := aDateAndTime utcMicroseconds. > utcValue > LastClockTick > ifTrue: [LastClockTick := utcValue] > ifFalse: [aDateAndTime utcMicroseconds: LastClockTick]] . > [#monotonicForceMicrosecondIncrement] -> [ > utcValue := aDateAndTime utcMicroseconds. > utcValue > LastClockTick > ifTrue: [LastClockTick := utcValue] > ifFalse: [LastClockTick := LastClockTick + 1. "add one microsecond" > aDateAndTime utcMicroseconds: LastClockTick]] . > [#monotonicForceNanosecondIncrement] -> [ > utcValue := aDateAndTime utcMicroseconds. > utcValue > LastClockTick > ifTrue: [LastClockTick := utcValue] > ifFalse: [LastClockTick := LastClockTick + (1 / 1000). "add one nanosecond" > aDateAndTime utcMicroseconds: LastClockTick]] > } otherwise: []. > ^aDateAndTime > ! > > Item was changed: > ----- Method: Time class>>primPosixMicrosecondClockWithOffset: (in category 'private') ----- > primPosixMicrosecondClockWithOffset: arrayOrObjectWithTwoSlots > "Answer an array with UTC microseconds since the Posix epoch and the > current seconds offset from GMT in the local time zone. If the primitive is > not available, then answer the time and offset of Posix epoch GMT. This enables > the image to continue running in the absence of #primitiveUtcWithOffset, thus > avoiding the need to fallback code based on the earlier local microsecond clock > mechanism. > > The parameter may be a two element array, or an object whose first two instance > variables are expected to be UTC microseconds and seconds offset from GMT." > > <primitive: 'primitiveUtcWithOffset'> > + > + (arrayOrObjectWithTwoSlots instVarAt: 1) > + ifNil: [arrayOrObjectWithTwoSlots instVarAt: 1 put: 0]. > + (arrayOrObjectWithTwoSlots instVarAt: 2) > + ifNil: [arrayOrObjectWithTwoSlots instVarAt: 2 put: 0]! > - ^{0. 0}! > > |
Free forum by Nabble | Edit this page |