INOS
|
This sections gives some tips and tricks for INOS hackers
This section describes some pitfalls, if one tries to port it's INOS application to a 64 bit system. The folowing systems are 64 bit based :
Nr | Name | Description |
---|---|---|
6120585xx | GIN-PCIe5 | PCIe add on card, quad core Cortex A72 CPU, 1.8GHz, 2.133GT/s DDR4 RAM |
6122613xx | IMP-MAS5 | CPU card, quad core Cortex A72 CPU, 1.8GHz, 2.133GT/s DDR4 RAM |
6121599xx | GIN-SAM5 | CPU card, 8/16 core Cortex A72 CPU, 2.2GHz, 2x3.2GT/s DDR4 RAM |
6002025xx | INOS Desktop | INOS application development running on Linux/Windows |
The main difference between a 32 bit and a 64 bit system is its address space and therefore the size [bytes] of a pointer :
32 bit :
64 bit :
INOS provides several different data types to simplify writing portable code :
Data types :
A Hook is identified by it's hook id. This id represents in fact the address of the hook descriptor. It's size is therefore 4 or 8 bytes depending on the system it runs on. To get portable code, one has to use the data type uintid to declare the id variable. The old (32 bit) hook id types uint32 have to be replaced with uintid :
portable :
not portable :
Whenever a pointer is converted to an unsigned integer or vice versa (usually used in pointer arithmetics) one has to take care of the different pointer sizes. Instead of a fix conversion from pointer to uint32, one has to use the data type uintptr instead. Example :
portable :
not portable :
The non portable version ends up in the following error if compiled on a 64 bit system : error: cast from 'void*' to 'uint32 {aka long unsigned int}' loses precision [-fpermissive].
Passing a pointer as a CINOSTaskExParam (withour ownership handling) requires the following adjustment :
portable :
not portable :
The non portable version ends up in the following error if compiled on a 64 bit system : error: invalid conversion from 'long unsigned int' to 'void*' [-fpermissive].
Probably the most annoying issues during porting code from a 32 to a 64 bit system are all kind of printf/scanf format specifiers. Due to the fact, that e.g. a variable of type long is always 32 bits on a 32 bit system but 32 or 64 bits on a 64 bit system, we need to use different format specifiers. To simplify this, INOS provides format specifier macros, which behave always correct on all the different platforms (see also inos/os/inos/inc/inostype.h and search for 'format macros'). Example :
portable :
not portable :
Hint: We strongly suggest to only work with the provided format macros and to enable the iDev feature 'Build options.Warnings as errors'.