SAmeis / pascalio

Input/Output library for Raspberry Pi or any other Linux based microcontroller
Other
29 stars 9 forks source link

Range error in spidev #11

Open MarkMLl opened 2 years ago

MarkMLl commented 2 years ago

On a 64-bit system, this function generates a range error if processing an _IOC_READ. Because SizeInt and TIOCtlRequest are defined at the system level, the best fix appears to be disabling the range check for the duration of the computation.

function _IOC(dir, _type, nr: Longword; size: SizeInt): TIOCtlRequest; begin {$push }{$R- } // If dir is 2 (_IOC_READ) this will set the MSB hence a range error _IOC := (dir shl _IOC_DIRSHIFT) or (_type shl _IOC_TYPESHIFT) or (nr shl _IOC_NRSHIFT) or (size shl _IOC_SIZESHIFT); {$pop } end;