2011-10-02 Ralf Corsépius <ralf.corsepius@rtems.org>

* libmisc/uuid/gen_uuid.c: Introduce PRIutime_t, SCNutime_t and
	"utime_t" for 64bit-time_t support.
This commit is contained in:
Ralf Corsepius
2011-10-02 10:37:28 +00:00
parent ff099914d2
commit f922d1d873
2 changed files with 17 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
2011-10-02 Ralf Corsépius <ralf.corsepius@rtems.org> 2011-10-02 Ralf Corsépius <ralf.corsepius@rtems.org>
* libmisc/shell/main_time.c: Introduce PRIutime_t, SCNutime_t and * libmisc/uuid/gen_uuid.c: Introduce PRIutime_t, SCNutime_t and
"utime_t" for 64bit-time_t support. "utime_t" for 64bit-time_t support.
2011-10-02 Ralf Corsépius <ralf.corsepius@rtems.org> 2011-10-02 Ralf Corsépius <ralf.corsepius@rtems.org>

View File

@@ -95,6 +95,18 @@
#include <sys/resource.h> #include <sys/resource.h>
#endif #endif
#if SIZEOF_TIME_T == 8
#define PRIutime_t PRIu64
#define SCNutime_t SCNu64
#define utime_t uint64_t
#elif SIZEOF_TIME_T == 4
#define PRIutime_t PRIu32
#define SCNutime_t SCNu32
#define utime_t uint32_t
#else
#error "unsupport size of time_t"
#endif
#include "uuidP.h" #include "uuidP.h"
#include "uuidd.h" #include "uuidd.h"
@@ -352,10 +364,11 @@ static int get_clock(uint32_t *clock_high, uint32_t *clock_low,
} }
if (state_fd >= 0) { if (state_fd >= 0) {
unsigned int cl; unsigned int cl;
unsigned long tv1, tv2; utime_t tv1;
unsigned long tv2;
int a; int a;
if (fscanf(state_f, "clock: %04x tv: %lu %lu adj: %d\n", if (fscanf(state_f, "clock: %04x tv: %" SCNutime_t " %lu adj: %d\n",
&cl, &tv1, &tv2, &a) == 4) { &cl, &tv1, &tv2, &a) == 4) {
clock_seq = cl & 0x3FFF; clock_seq = cl & 0x3FFF;
last.tv_sec = tv1; last.tv_sec = tv1;
@@ -404,7 +417,7 @@ try_again:
if (state_fd > 0) { if (state_fd > 0) {
rewind(state_f); rewind(state_f);
len = fprintf(state_f, len = fprintf(state_f,
"clock: %04x tv: %016lu %08lu adj: %08d\n", "clock: %04x tv: %016" PRIutime_t " %08lu adj: %08d\n",
clock_seq, last.tv_sec, last.tv_usec, adjustment); clock_seq, last.tv_sec, last.tv_usec, adjustment);
fflush(state_f); fflush(state_f);
if (ftruncate(state_fd, len) < 0) { if (ftruncate(state_fd, len) < 0) {