Closed cmdrf closed 3 years ago
Thank you Fabian, for reporting this.
I must admit that I haven't had the chance yet to try out FreeRTOS+FAT on a 64-bit platform. I'm very glad to hear that it works.
Within the library, there are two occurrences of ~0UL
. Those should be replaced with ~0U
. After that it will compile properly, I assume?
Would you mind to compile the following code on your platform:
/* The errno is stored in a thread local buffer. */
static portINLINE void stdioSET_ERRNO( int iErrno )
{
/* Local storage pointers can only store pointers. This function
* wants to store a signed errno value, which needs a cast. */
/* Cast from an integer to a signed value of a pointer size. */
intptr_t xErrno = ( intptr_t ) iErrno;
/* Cast from a numeric value to a pointer. */
void * pvValue = ( void * ) ( xErrno );
vTaskSetThreadLocalStoragePointer( NULL, ffconfigCWD_THREAD_LOCAL_INDEX, pvValue );
}
static portINLINE int stdioGET_ERRNO( void )
{
void * pvResult;
pvResult = pvTaskGetThreadLocalStoragePointer( ( TaskHandle_t ) NULL, ffconfigCWD_THREAD_LOCAL_INDEX );
/* Cast from a pointer to a number of the same size. */
intptr_t xErrno = ( intptr_t ) pvResult;
/* Cast it to an integer. */
int iValue = ( int ) ( xErrno );
return iValue;
}
/*
* Store the FreeRTOS+FAT error code, which provides more detail than errno.
*/
static portINLINE void stdioSET_FF_ERROR( FF_Error_t iFF_ERROR )
{
/* Cast it to an unsigned long. */
uint32_t ulError = ( uint32_t ) iFF_ERROR;
/* Cast it to a number with the size of a pointer. */
uintptr_t uxErrno = ( uintptr_t ) ulError;
/* Cast it to a void pointer. */
void * pvValue = ( void * ) ( uxErrno );
vTaskSetThreadLocalStoragePointer( NULL, stdioFF_ERROR_THREAD_LOCAL_OFFSET, pvValue );
}
/*
* Read back the FreeRTOS+FAT error code, which provides more detail than
* errno.
*/
static portINLINE FF_Error_t stdioGET_FF_ERROR( void )
{
void * pvResult;
pvResult = pvTaskGetThreadLocalStoragePointer( NULL, stdioFF_ERROR_THREAD_LOCAL_OFFSET );
/* Cast it to an integer with the same size as a pointer. */
intptr_t uxErrno = ( intptr_t ) pvResult;
/* Cast it to a int32_t. */
FF_Error_t xError = ( FF_Error_t ) uxErrno;
return xError;
}
I test compiled this code for a 64-bit Ultrascale. Could you also try to compile it?
Thanks! Yes, it compiles without warnings.
I just submitted PR #21 “FAT: Changes for 64-bit platforms and solved compiler warnings”, which should solve several compiler issues. It also contains the changes as proposed here above. Thanks a lot @cmdrf for reporting. Hein
PR has been raised for the issue PR #21 “FAT: Changes for 64-bit platforms and solved compiler warnings” hence closing the issue. Please reach out to us if you have any further questions.
Yes, there are 64-bit MCUs out there. You might also want to compile this project on a Desktop PC for testing purposes.
The first one looks particularly bad, but it works regardless.
Compiler: