Fix incorrect padding in C-layout structs
This commit is contained in:
parent
990e76c624
commit
319bb3a33b
2 changed files with 5 additions and 3 deletions
|
|
@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file. This change
|
|||
- New function to allow getting the backing memory segment of a `coffi.ffi.StaticVariable`, to replace the `Addressable` implementation lost in the migration to JDK 18
|
||||
|
||||
### Fixed
|
||||
- Bug where padding in structs may be increased when fields have alignments less than their size
|
||||
- Bug where pointer alignment was incorrectly defined
|
||||
|
||||
## [0.5.357] - 2022-07-07
|
||||
|
|
|
|||
|
|
@ -16,11 +16,12 @@
|
|||
(if (seq fields)
|
||||
(let [[[_ type :as field] & fields] fields
|
||||
size (mem/size-of type)
|
||||
r (rem offset (mem/align-of type))]
|
||||
align (mem/align-of type)
|
||||
r (rem offset align)]
|
||||
(recur (cond-> (+ offset size)
|
||||
(pos? r) (+ (- size r)))
|
||||
(pos? r) (+ (- align r)))
|
||||
(cond-> aligned-fields
|
||||
(pos? r) (conj [::padding [::mem/padding (- size r)]])
|
||||
(pos? r) (conj [::padding [::mem/padding (- align r)]])
|
||||
:always (conj field))
|
||||
fields))
|
||||
(let [strongest-alignment (mem/align-of struct-spec)
|
||||
|
|
|
|||
Loading…
Reference in a new issue