[squeak-dev] FFI: FFI-Pools-mt.33.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Aug 16 07:12:07 UTC 2021


Marcel Taeumel uploaded a new version of FFI-Pools to project FFI:
http://source.squeak.org/FFI/FFI-Pools-mt.33.mcz

==================== Summary ====================

Name: FFI-Pools-mt.33
Author: mt
Time: 16 August 2021, 9:12:05.515631 am
UUID: 130e608a-49d9-a34f-afb4-a4f4a03826a3
Ancestors: FFI-Pools-mt.32

Rename pool variables for atomic integer types to follow the names of new integer primitives such as "FFITypeSignedInt" -> "FFITypeSignedInt32".

Rename the basic type names of atomic integer types to follow stdint.h convention, i.e., int8_t, int16_t, int32_t, int64_t. Older names (i.e., short, long, longlong) are deprecated but remain available as direct-lookup alias. Their access might be a tiny bit slower due to the lookup.

=============== Diff against FFI-Pools-mt.32 ===============

Item was changed:
  ----- Method: ExternalPoolDefinition>>ffiVariable: (in category 'pragmas') -----
  ffiVariable: aVariableName
  	"Shortcut. Many libraries' C constants are just 4-byte integers on both 32-bit and 64-bit platforms."
- 
- 	self flag: #ffiLongVsInt. "Our 'long' is a 4-byte integer."
  	
  	self
  		ffiVariable: aVariableName
+ 		type: 'int32_t'
- 		type: 'long'
  		convertTo: #Integer.!

Item was changed:
  ----- Method: ExternalPoolReadWriter class>>initializeAtomicTypesExtra (in category 'class initialization') -----
  initializeAtomicTypesExtra
  	"Initialize C type names and format placeholders for printf, which are used during C code generation. The implementation follows the one for initialization of atomic types in ExternalType. Even though all type names are repeated here explicitely, their location in the list of atomic types is looked up dynamically. So you can change the order to improve readability."
  	
  	| type typeName cTypeName cFormatPlaceholder |
- 	self flag: #ffiLongVsInt.
- 
  	AtomicCTypeNames := IdentityDictionary new.
  	AtomicCFormatPlaceholders := IdentityDictionary new.
  
  	#(
  		"name			C type name			C printf % format"
  		('void'	 		'void'					'p')
  		('bool' 			'unsigned int'			'u') "See ByteArray >> #booleanAt:"
+ 		('uint8_t' 			'unsigned char'			'hhu') "Not 'c' to avoid conversion issues"
+ 		('int8_t' 		'signed char'			'hhd') "Not 'c' to avoid conversion issues"
+ 		('uint16_t' 		'unsigned short'		'hu')
+ 		('int16_t' 			'signed short'			'hd')
+ 		('uint32_t'			'unsigned int'			'u') "Not 'lu' bc. not unsigned long, see above"
+ 		('int32_t' 			'signed int'				'd') "Not 'ld' bc. not signed long, see above"
+ 		('uint64_t'		'unsigned long long'	'llu')
+ 		('int64_t'		'signed long long'		'lld')
- 		('byte' 			'unsigned char'			'hhu') "Not 'c' to avoid conversion issues"
- 		('sbyte' 		'signed char'			'hhd') "Not 'c' to avoid conversion issues"
- 		('ushort' 		'unsigned short'		'hu')
- 		('short' 			'signed short'			'hd')
- "!!!!!!"	('ulong'			'unsigned int'			'u') "Not 'lu' bc. not unsigned long, see above"
- "!!!!!!"	('long' 			'signed int'				'd') "Not 'ld' bc. not signed long, see above"
- 		('ulonglong'		'unsigned long long'	'llu')
- 		('longlong'		'signed long long'		'lld')
  		('char' 			'unsigned char'			'hhu') "Not 'c' to avoid conversion issues"
  		('schar' 		'signed char'			'hhd') "Not 'c' to avoid conversion issues"
  		('float' 			'float'					'g') "Not 'G' bc. notation in lowercase letters"
  		('double' 		'double'					'g') "Not 'G' bc. notation in lowercase letters"
  "TODO: ('longdouble' 	'long double'			'Lg')"
  	) do: [:typeSpec |
  		typeName := typeSpec first.
  		cTypeName := typeSpec second.
  		cFormatPlaceholder := '%', typeSpec third.
  		
  		type := ExternalType atomicTypeNamed: typeName.
  		AtomicCTypeNames at: type atomicType put: cTypeName.
  		AtomicCFormatPlaceholders at: type atomicType put: cFormatPlaceholder].!

Item was changed:
  SharedPool subclass: #FFIConstants
  	instanceVariableNames: ''
+ 	classVariableNames: 'FFIAtomicTypeMask FFIAtomicTypeShift FFICallFlagThreaded FFICallTypeApi FFICallTypeCDecl FFICallTypesMask FFIErrorAddressNotFound FFIErrorAttemptToPassVoid FFIErrorBadAddress FFIErrorBadArg FFIErrorBadArgs FFIErrorBadAtomicType FFIErrorBadExternalFunction FFIErrorBadExternalLibrary FFIErrorBadReturn FFIErrorCallFrameTooBig FFIErrorCallType FFIErrorCoercionFailed FFIErrorGenericError FFIErrorIntAsPointer FFIErrorInvalidPointer FFIErrorModuleNotFound FFIErrorNoModule FFIErrorNotFunction FFIErrorStructSize FFIErrorWrongType FFIFlagAtomic FFIFlagPointer FFIFlagStructure FFINoCalloutAvailable FFIStructSizeMask FFITypeBool FFITypeDoubleFloat FFITypeSignedChar FFITypeSignedInt16 FFITypeSignedInt32 FFITypeSignedInt64 FFITypeSignedInt8 FFITypeSingleFloat FFITypeUnsignedChar FFITypeUnsignedInt16 FFITypeUnsignedInt32 FFITypeUnsignedInt64 FFITypeUnsignedInt8 FFITypeVoid'
- 	classVariableNames: 'FFIAtomicTypeMask FFIAtomicTypeShift FFICallFlagThreaded FFICallTypeApi FFICallTypeCDecl FFICallTypesMask FFIErrorAddressNotFound FFIErrorAttemptToPassVoid FFIErrorBadAddress FFIErrorBadArg FFIErrorBadArgs FFIErrorBadAtomicType FFIErrorBadExternalFunction FFIErrorBadExternalLibrary FFIErrorBadReturn FFIErrorCallFrameTooBig FFIErrorCallType FFIErrorCoercionFailed FFIErrorGenericError FFIErrorIntAsPointer FFIErrorInvalidPointer FFIErrorModuleNotFound FFIErrorNoModule FFIErrorNotFunction FFIErrorStructSize FFIErrorWrongType FFIFlagAtomic FFIFlagPointer FFIFlagStructure FFINoCalloutAvailable FFIStructSizeMask FFITypeBool FFITypeDoubleFloat FFITypeSignedByte FFITypeSignedChar FFITypeSignedInt FFITypeSignedLongLong FFITypeSignedShort FFITypeSingleFloat FFITypeUnsignedByte FFITypeUnsignedChar FFITypeUnsignedInt FFITypeUnsignedLongLong FFITypeUnsignedShort FFITypeVoid'
  	poolDictionaries: ''
  	category: 'FFI-Pools'!
  
  !FFIConstants commentStamp: 'TorstenBergmann 4/27/2017 11:02' prior: 0!
  Constants definitions for FFI!

Item was changed:
  ----- Method: FFIConstants class>>initializeTypeConstants (in category 'private - initialization') -----
  initializeTypeConstants
  	"type void"
  	FFITypeVoid := 0.
  
  	"type bool"
  	FFITypeBool := 1.
  
  	"basic integer types.
  	note: (integerType anyMask: 1) = integerType isSigned"
  
+ 	FFITypeUnsignedInt8 := 2.
+ 	FFITypeSignedInt8 := 3.
+ 	FFITypeUnsignedInt16 := 4.
+ 	FFITypeSignedInt16 := 5.
+ 	FFITypeUnsignedInt32 := 6.
+ 	FFITypeSignedInt32 := 7.
+ 	FFITypeUnsignedInt64 := 8.
+ 	FFITypeSignedInt64 := 9.
- 	FFITypeUnsignedByte := 2.
- 	FFITypeSignedByte := 3.
- 	FFITypeUnsignedShort := 4.
- 	FFITypeSignedShort := 5.
- 	FFITypeUnsignedInt := 6.
- 	FFITypeSignedInt := 7.
  
- 	"64bit types"
- 	FFITypeUnsignedLongLong := 8.
- 	FFITypeSignedLongLong := 9.
- 
  	"special integer types"
  	FFITypeUnsignedChar := 10.
  	FFITypeSignedChar := 11.
  
  	"float types"
  	FFITypeSingleFloat := 12.
  	FFITypeDoubleFloat := 13.
  
  	"type flags"
  	FFIFlagAtomic := 16r40000. "type is atomic"
  	FFIFlagPointer := 16r20000. "type is pointer to base type"
  	FFIFlagStructure := 16r10000. "baseType is structure of 64k length"
  	FFIStructSizeMask := 16rFFFF. "mask for max size of structure"
  	FFIAtomicTypeMask := 16r0F000000. "mask for atomic type spec"
  	FFIAtomicTypeShift := 24. "shift for atomic type"
  !



More information about the Squeak-dev mailing list