Marcel Taeumel uploaded a new version of FFI-Kernel to project FFI:
http://source.squeak.org/FFI/FFI-Kernel-mt.76.mcz ==================== Summary ==================== Name: FFI-Kernel-mt.76 Author: mt Time: 27 May 2020, 11:42:40.599317 am UUID: 7cfea7d7-c95e-a24a-aaf3-0d96c409e13d Ancestors: FFI-Kernel-mt.75 At least from within FFI package, use FFIPlatformDescription, not the Smalltalk global. =============== Diff against FFI-Kernel-mt.75 =============== Item was changed: ----- Method: ExternalStructure class>>maxFieldAlignment (in category 'alignment') ----- maxFieldAlignment "Answer the maximum alignment of structure fields. This is platform dependent. On x86, struct{float f; double d} will have different alignment: - on windows, d will be 8-byte aligned - on SysV linux/OSX, d will be 4 byte aligned There are some special types that may have higher alignment requirements - SSE vectors - jump_buf ... But we do not handle these types yet" + FFIPlatformDescription current isWindows ifTrue: [^8]. + FFIPlatformDescription current isARM ifTrue: [^8]. + ^ FFIPlatformDescription current wordSize! - Smalltalk platformName = 'Win32' ifTrue: [^8]. - (Smalltalk platformSubtype beginsWith: 'arm') ifTrue: [^8]. - ^Smalltalk wordSize! Item was changed: ----- Method: ExternalType class>>initializeAtomicTypes (in category 'class initialization') ----- initializeAtomicTypes "ExternalType initialize" | atomicType byteSize type typeName byteAlignment | #( "name atomic id byte size byte alignment" ('void' 0 0 0) ('bool' 1 1 1) ('byte' 2 1 1) ('sbyte' 3 1 1) ('ushort' 4 2 2) ('short' 5 2 2) ('ulong' 6 4 4) ('long' 7 4 4) ('ulonglong' 8 8 8) ('longlong' 9 8 8) ('char' 10 1 1) ('schar' 11 1 1) ('float' 12 4 4) ('double' 13 8 8) ) do:[:typeSpec| | compiled | typeName := typeSpec first. atomicType := typeSpec second. byteSize := typeSpec third. byteAlignment := typeSpec fourth. "On 32 bits Windows and MacOS, double and long have an alignment of 8. But on Linux, their alignment is 4" + (FFIPlatformDescription current wordSize = 4 and: [FFIPlatformDescription current isUnix]) ifTrue: [ - (Smalltalk wordSize = 4 and: [Smalltalk platformName = 'unix']) ifTrue: [ (#('double longlong ulonglong') includes: typeName) ifTrue: [ byteAlignment := 4 ] ]. compiled := WordArray with: ((byteSize bitOr: FFIFlagAtomic) bitOr: (atomicType bitShift: FFIAtomicTypeShift)). type := (AtomicTypes at: typeName). type compiledSpec: compiled; byteAlignment: byteAlignment. compiled := WordArray with: ((self pointerSpec bitOr: FFIFlagAtomic) bitOr: (atomicType bitShift: FFIAtomicTypeShift)). type asPointerType byteAlignment: self pointerAlignment; compiledSpec: compiled. ].! Item was changed: ----- Method: ExternalType class>>pointerAlignment (in category 'private') ----- pointerAlignment + ^ FFIPlatformDescription current wordSize! - ^ Smalltalk wordSize! Item was changed: ----- Method: ExternalType class>>pointerSpec (in category 'private') ----- pointerSpec + ^(FFIPlatformDescription current wordSize bitOr: FFIFlagPointer)! - ^(Smalltalk wordSize bitOr: FFIFlagPointer)! Item was removed: - ----- Method: FFIPlatformDescription class>>isCurrentPlatformWindows (in category 'testing') ----- - isCurrentPlatformWindows - ^ self isWindowsPlatformName: self currentName! Item was removed: - ----- Method: FFIPlatformDescription class>>isWindowsPlatformName: (in category 'private') ----- - isWindowsPlatformName: aPlatformName - ^ aPlatformName asLowercase beginsWith: 'win'! Item was added: + ----- Method: FFIPlatformDescription>>isARM (in category 'testing') ----- + isARM + + ^ self subtype beginsWith: 'arm'! Item was added: + ----- Method: FFIPlatformDescription>>isUnix (in category 'testing') ----- + isUnix + + ^ self name = 'unix'! Item was changed: ----- Method: FFIPlatformDescription>>isWindows (in category 'testing') ----- isWindows + + ^ self name = 'Win32'! - ^ self class isWindowsPlatformName: self name! |
Free forum by Nabble | Edit this page |