Skip to content

Commit 39c1bcf

Browse files
authored
Merge pull request #937 from jphickey/fix-844-clock-time
Fix #844, switch to use CLOCK_REALTIME
2 parents a876519 + 5ba86d2 commit 39c1bcf

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

src/os/portable/os-impl-posix-gettime.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
* The OS-specific code must \#include the correct headers that define the
2929
* prototypes for these functions before including this implementation file.
3030
*
31+
* NOTE: The OS-specific header must also define which POSIX clock ID to use -
32+
* this specifies the clockid_t parameter to use with clock_gettime(). In
33+
* most cases this should be CLOCK_REALTIME to allow the clock to be set, and
34+
* so the application will also see any manual/administrative clock changes.
35+
*
36+
* The clock ID is selected by defining the #OSAL_GETTIME_SOURCE_CLOCK macro.
3137
*/
3238

3339
/****************************************************************************************

src/os/posix/inc/os-impl-gettime.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
#include "osconfig.h"
3232
#include <time.h>
3333

34-
#define OSAL_GETTIME_SOURCE_CLOCK CLOCK_MONOTONIC
34+
/**
35+
* \brief Idenfies the clock ID for OSAL clock operations on POSIX
36+
*
37+
* This is the POSIX clock ID that will be used to implement
38+
* OS_GetLocalTime() and OS_SetLocalTime().
39+
*/
40+
#define OSAL_GETTIME_SOURCE_CLOCK CLOCK_REALTIME
3541

3642
#endif /* OS_IMPL_GETTIME_H */

src/os/rtems/inc/os-impl-gettime.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
#include "osconfig.h"
3232
#include <time.h>
3333

34-
#define OSAL_GETTIME_SOURCE_CLOCK CLOCK_MONOTONIC
34+
/**
35+
* \brief Idenfies the clock ID for OSAL clock operations on RTEMS
36+
*
37+
* This is the POSIX clock ID that will be used to implement
38+
* OS_GetLocalTime() and OS_SetLocalTime().
39+
*/
40+
#define OSAL_GETTIME_SOURCE_CLOCK CLOCK_REALTIME
3541

3642
#endif /* OS_IMPL_GETTIME_H */

src/os/vxworks/inc/os-impl-gettime.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
#include "osconfig.h"
3232
#include <time.h>
3333

34-
#define OSAL_GETTIME_SOURCE_CLOCK CLOCK_MONOTONIC
34+
/**
35+
* \brief Idenfies the clock ID for OSAL clock operations on VxWorks
36+
*
37+
* This is the POSIX clock ID that will be used to implement
38+
* OS_GetLocalTime() and OS_SetLocalTime().
39+
*/
40+
#define OSAL_GETTIME_SOURCE_CLOCK CLOCK_REALTIME
3541

3642
#endif /* OS_IMPL_GETTIME_H */

0 commit comments

Comments
 (0)