[local-time-devel] Bugfix: nsec overflows fixnum on 32-bit archs
Maciej Katafiasz
mathrick at gmail.com
Fri Mar 13 20:31:21 UTC 2009
Hi,
here's a bugfix for one issue that hit me on 32-bit SBCL. Since
MOST-POSITIVE-FIXNUM is less than 10^9, nanoseconds can overflow a
fixnum. This means that WITH-DECODED-TIMESTAMP (and by extension,
ADJUST-TIMESTAMP) would fail randomly. The patch conditionalises the
type declaration on whether a fixnum can hold all the required bits.
=========================
Fri Mar 13 20:47:25 CET 2009 Maciej Katafiasz <mathrick at gmail.com>
* Don't declare NSEC as FIXNUM if MOST-POSITIVE-FIXNUM is smaller than 10^9
New patches:
[Don't declare NSEC as FIXNUM if MOST-POSITIVE-FIXNUM is smaller than 10^9
Maciej Katafiasz <mathrick at gmail.com>**20090313194725] hunk
./src/local-time.lisp 600
:collect `(when ,var
(push `(type fixnum ,,var) types)))
(setf types (nreverse types)))))
- (declare-fixnum-type nsec sec minute hour day month year)
+ (if (> most-positive-fixnum (expt 10 9))
+ (declare-fixnum-type nsec sec minute hour day month year)
+ ;; Don't overflow on 32-bit archs
+ (declare-fixnum-type sec minute hour day month year))
(initialize nsec sec minute hour day month year day-of-week daylight-p))
`(multiple-value-bind (, at variables)
(decode-timestamp ,timestamp :timezone ,(or timezone
'*default-timezone*))
Context:
[document the interpretation of day-of-week
attila.lendvai at gmail.com**20081223002624
Ignore-this: 26bf6ba060df9684a5e60a9464adcfb0
]
[follow :weekday change in the manual
attila.lendvai at gmail.com**20081223002030
Ignore-this: 6b303376bed4e880911ce5e3e0f4d037
]
[fix :weekday support for format-timestamp
attila.lendvai at gmail.com**20081223000411
Ignore-this: af6abab43e3d60e97a24a627982e09cd
]
[TAG 2008-11-27
attila.lendvai at gmail.com**20081127150407
Ignore-this: 9d6f3d956cb6436e69f285ffeaa41207
]
Patch bundle hash:
6b718dd74706d43e533c3490396cd8624e41c5c0
More information about the local-time-devel
mailing list