Hi Yuhui,
Thanks for the pointer, the build did go ahead. so now with below defines
70 #define _TIMER_T_DECLARED
71 #define __timer_t_defined
72
73 #define _CLOCKID_T_DECLARED
74 #define __clockid_t_defined
75
76 #define _CLOCK_T_DECLARED
77 #define __clock_t_defined
78
79 /* System headers. /
80 #include <stdbool.h>
81 #include <string.h>
82 #include <stdio.h>
83
84 / FreeRTOS includes. */
85 #include “FreeRTOS_POSIX.h”
86
“posix_demo.c” << in the file , the errors related to clock_t , clockid_t, etc… are resolved.
When I made the change in Source/lib/FreeRTOS-Plus-POSIX/include/portable/FreeRTOS_POSIX_portable.h , the defines made no difference, so i moved them above very first use of include <stdio.h> in posix_demo.c then it seem to have the desired effect.
The next error build fails is due to struct itimerspec and struct timespec , conflict / redefinition.
Error Message :
…/Source/lib/include/FreeRTOS_POSIX/time.h:78:12: error: redefinition of ‘struct timespec’
78 | struct timespec
| ^~~~~~~~
In file included from /opt/riscv64/riscv64-unknown-elf/include/sys/timespec.h:38,
from /opt/riscv64/riscv64-unknown-elf/include/sys/select.h:16,
from /opt/riscv64/riscv64-unknown-elf/include/sys/types.h:50,
from /opt/riscv64/riscv64-unknown-elf/include/stdio.h:61,
from posix_demo.c:83:
/opt/riscv64/riscv64-unknown-elf/include/sys/_timespec.h:45:8: note: originally defined here
45 | struct timespec {
| ^~~~~~~~
In file included from …/Source/lib/include/FreeRTOS_POSIX/pthread.h:39,
from posix_demo.c:96:
…/Source/lib/include/FreeRTOS_POSIX/time.h:90:12: error: redefinition of ‘struct itimerspec’
90 | struct itimerspec
| ^~~~~~~~~~
In file included from /opt/riscv64/riscv64-unknown-elf/include/sys/select.h:16,
from /opt/riscv64/riscv64-unknown-elf/include/sys/types.h:50,
from /opt/riscv64/riscv64-unknown-elf/include/stdio.h:61,
from posix_demo.c:83:
/opt/riscv64/riscv64-unknown-elf/include/sys/timespec.h:58:8: note: originally defined here
58 | struct itimerspec {
| ^~~~~~~~~~
in the case of sys/types.h, i see the below defines to just enabled them, but see no such defines in timespec and itimespec case.
#if !defined(__clockid_t_defined) && !defined(_CLOCKID_T_DECLARED)
typedef __clockid_t clockid_t;
#define __clockid_t_defined
#define _CLOCKID_T_DECLARED
#endif
I am not able to upload the file FreeRTOS_POSIX_portable.h [New users are not allowed to upload ].
I used the file you pointed in “espressif” port and removed the defines for
// #define posixconfigENABLE_CLOCK_T 0
// #define posixconfigENABLE_CLOCKID_T 0
// #define posixconfigENABLE_TIMESPEC 0
// #define posixconfigENABLE_ITIMERSPEC 0
to use the FreeRTOS definition.
Question :
-
Do you suggest adding #ifndef itimerspec_defined in sys/timespec.h and timespec.h also ? May be will hit similar issues with posixconfigENABLE_PTHREAD* configs also ?
-
If i Do define below in FreeRTOS_POSIX_portable.h
#define posixconfigENABLE_TIMESPEC 0
#define posixconfigENABLE_ITIMERSPEC 0
I get the below warning and error, as struct timespec is not declared , so resolve this i have to include time.h from the RISC V tool chain path NOT FreeRTOS_POSIX/time.h
…/Source/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_utils.c: At top level:
…/Source/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_utils.c:164:42: warning: ‘struct timespec’ declared inside parameter list will not be visible outside of this definition or declaration
164 | struct timespec * const pxDestination )
| ^~~~~~~~
…/Source/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_utils.c:163:6: error: conflicting types for ‘UTILS_NanosecondsToTimespec’
163 | void UTILS_NanosecondsToTimespec( int64_t llSource,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from …/Source/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_utils.c:38:
…/Source/lib/include/FreeRTOS_POSIX/utils.h:90:6: note: previous declaration of ‘UTILS_NanosecondsToTimespec’ was here
90 | void UTILS_NanosecondsToTimespec( int64_t llSource,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
Not sure if these issues is specific to RISC V tool chain.
Please let me know, what you think.
Thanks
J