Skip to content

Commit d4e1bcf

Browse files
!apps: drop CONFIG_SYSTEM_TIME64 conditionals
NuttX always uses a 64-bit system clock now (time_t/clock_t are always 64-bit). Remove the obsolete CONFIG_SYSTEM_TIME64 #ifdef branches and Kconfig dependency. - examples/dronecan: drop SYSTEM_TIME64 dependency - examples/netlink_route: always use PRIx64 - netutils/netinit: always use the 1-hour LONG_TIME_SEC - netutils/ptpd: always pack the 48-bit seconds field and apply the 64-bit overflow guard in timespec_delta_ns() - testing/ostest/semtimed: always validate tv_sec >= 0 Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
1 parent 545ac15 commit d4e1bcf

5 files changed

Lines changed: 2 additions & 21 deletions

File tree

examples/dronecan/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
config EXAMPLES_DRONECAN
77
tristate "DroneCAN example"
88
default n
9-
depends on CANUTILS_LIBDRONECAN && SYSTEM_TIME64
9+
depends on CANUTILS_LIBDRONECAN
1010
---help---
1111
Enable the LIBDRONECAN example
1212

examples/netlink_route/netlink_route_main.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,7 @@ static void dump_neighbor(void)
168168
printf(" ");
169169
}
170170

171-
#ifdef CONFIG_SYSTEM_TIME64
172171
printf("Time 0x%" PRIx64 "\n", nb->ne_time);
173-
#else
174-
printf("Time 0x%" PRIx32 "\n", nb->ne_time);
175-
#endif
176172
}
177173

178174
free(nbtab);

netutils/netinit/netinit.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,7 @@
204204
* signal indicating a change in network status.
205205
*/
206206

207-
#ifdef CONFIG_SYSTEM_TIME64
208-
# define LONG_TIME_SEC (60*60) /* One hour in seconds */
209-
#else
210-
# define LONG_TIME_SEC (5*60) /* Five minutes in seconds */
211-
#endif
207+
#define LONG_TIME_SEC (60*60) /* One hour in seconds */
212208

213209
#define SHORT_TIME_SEC (2) /* 2 seconds */
214210

netutils/ptpd/ptpd.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,8 @@ static void timespec_to_ptp_format(FAR const struct timespec *ts,
184184
* both fields big-endian.
185185
*/
186186

187-
#ifdef CONFIG_SYSTEM_TIME64
188187
timestamp[0] = (uint8_t)(ts->tv_sec >> 40);
189188
timestamp[1] = (uint8_t)(ts->tv_sec >> 32);
190-
#else
191-
timestamp[0] = 0;
192-
timestamp[1] = 0;
193-
#endif
194189
timestamp[2] = (uint8_t)(ts->tv_sec >> 24);
195190
timestamp[3] = (uint8_t)(ts->tv_sec >> 16);
196191
timestamp[4] = (uint8_t)(ts->tv_sec >> 8);
@@ -320,7 +315,6 @@ static int64_t timespec_delta_ns(FAR const struct timespec *ts1,
320315

321316
delta_s = ts1->tv_sec - ts2->tv_sec;
322317

323-
#ifdef CONFIG_SYSTEM_TIME64
324318
/* Conversion to nanoseconds could overflow if the system time is 64-bit */
325319

326320
if (delta_s >= INT64_MAX / NSEC_PER_SEC)
@@ -331,7 +325,6 @@ static int64_t timespec_delta_ns(FAR const struct timespec *ts1,
331325
{
332326
return INT64_MIN;
333327
}
334-
#endif
335328

336329
return delta_s * NSEC_PER_SEC + (ts1->tv_nsec - ts2->tv_nsec);
337330
}

testing/ostest/semtimed.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,7 @@ static void ostest_gettime(struct timespec *tp)
7979
printf("ostest_gettime: ERROR: clock_gettime failed\n");
8080
ASSERT(false);
8181
}
82-
#ifdef CONFIG_SYSTEM_TIME64
8382
else if (tp->tv_sec < 0 || tp->tv_nsec < 0 ||
84-
#else
85-
else if (tp->tv_nsec < 0 ||
86-
#endif
8783
tp->tv_nsec >= 1000 * 1000 * 1000)
8884
{
8985
printf("ostest_gettime: ERROR: clock_gettime returned bogus time\n");

0 commit comments

Comments
 (0)