In an FFI plugin that supports the new integer primitives, `maxVal` is wrong for unsigned types other than "uint8_t":
![grafik](https://user-images.githubusercontent.com/5765308/128748244-322f9952-c19c-4c...)
This issue can be reproduced in any "FFI-Kernel" that supports those primitives such as "FFI-Kernel-mt.187" and newer:
```Smalltalk #( int8_t uint8_t int16_t uint16_t int32_t uint32_t int64_t uint64_t ) collect: [:typeName | | type | type := ExternalType typeNamed: typeName. typeName -> (type minVal to: type maxVal)] as: OrderedDictionary ```
**The older primitives "primitiveFFIIntegerAt" and "primitiveFFIIntegerAtPut" worked as expected.** The `maxVal` implementation writes single bytes but reads as much as the type demands. Here is an excerpt for the "unsigned" case:
```Smalltalk | data bytes | bytes := ByteArray new: self byteSize. data := ExternalData fromHandle: bytes type: self size: 1. bytes atAllPut: 16rFF. "Set all bits for maxVal of an unsigned integer. Uses older primitive 145." ^ data value. "-> ends up calling the new primitive in ByteArray such as uint16At:" ```
Note that "int8_t" and "uint8_t" work as expected.
Closed #584.
The bug was in FFI-Kernel. The primitives are fine. FFI-Kernel-eem.197 fixed it.
vm-dev@lists.squeakfoundation.org