From 59cda867091fcbd9e0455eaf4b034db57588b0e9 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 7 Jun 2012 15:40:14 +0200 Subject: [PATCH] unix, test: make NANOSEC a 64 bits unsigned int Avoids accidental overflow / truncation when it's used in 32 bits arithmetic. --- src/unix/cygwin.c | 2 +- src/unix/freebsd.c | 2 +- src/unix/linux/core.c | 2 +- src/unix/netbsd.c | 2 +- src/unix/openbsd.c | 2 +- test/benchmark-pound.c | 2 +- test/test-hrtime.c | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/unix/cygwin.c b/src/unix/cygwin.c index 31b069f9c..a99779d4e 100644 --- a/src/unix/cygwin.c +++ b/src/unix/cygwin.c @@ -29,7 +29,7 @@ #include #undef NANOSEC -#define NANOSEC 1000000000 +#define NANOSEC ((uint64_t) 1e9) uint64_t uv_hrtime() { diff --git a/src/unix/freebsd.c b/src/unix/freebsd.c index 1e2c1d436..d916b0b12 100644 --- a/src/unix/freebsd.c +++ b/src/unix/freebsd.c @@ -38,7 +38,7 @@ #include #undef NANOSEC -#define NANOSEC 1000000000 +#define NANOSEC ((uint64_t) 1e9) #ifndef CPUSTATES # define CPUSTATES 5U diff --git a/src/unix/linux/core.c b/src/unix/linux/core.c index bee702691..34f48a94b 100644 --- a/src/unix/linux/core.c +++ b/src/unix/linux/core.c @@ -46,7 +46,7 @@ #endif #undef NANOSEC -#define NANOSEC 1000000000 +#define NANOSEC ((uint64_t) 1e9) /* This is rather annoying: CLOCK_BOOTTIME lives in but we can't * include that file because it conflicts with . We'll just have to diff --git a/src/unix/netbsd.c b/src/unix/netbsd.c index 2fedc94a3..a1a7091bb 100644 --- a/src/unix/netbsd.c +++ b/src/unix/netbsd.c @@ -32,7 +32,7 @@ #include #undef NANOSEC -#define NANOSEC 1000000000 +#define NANOSEC ((uint64_t) 1e9) uint64_t uv_hrtime(void) { diff --git a/src/unix/openbsd.c b/src/unix/openbsd.c index ec757a4a9..865f8e9e6 100644 --- a/src/unix/openbsd.c +++ b/src/unix/openbsd.c @@ -37,7 +37,7 @@ #include #undef NANOSEC -#define NANOSEC 1000000000 +#define NANOSEC ((uint64_t) 1e9) static char *process_title; diff --git a/test/benchmark-pound.c b/test/benchmark-pound.c index 1693c31c8..5c29a05b3 100644 --- a/test/benchmark-pound.c +++ b/test/benchmark-pound.c @@ -26,7 +26,7 @@ #define MAX_CONNS 1000 #undef NANOSEC -#define NANOSEC ((uint64_t)10e8) +#define NANOSEC ((uint64_t) 1e9) #undef DEBUG #define DEBUG 0 diff --git a/test/test-hrtime.c b/test/test-hrtime.c index 43400a464..91059f03a 100644 --- a/test/test-hrtime.c +++ b/test/test-hrtime.c @@ -27,7 +27,7 @@ #endif #ifndef NANOSEC -# define NANOSEC 1000000000 +# define NANOSEC ((uint64_t) 1e9) #endif