Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
unix, test: make NANOSEC a 64 bits unsigned int
Browse files Browse the repository at this point in the history
Avoids accidental overflow / truncation when it's used in 32 bits arithmetic.
  • Loading branch information
bnoordhuis committed Jun 7, 2012
1 parent e2aa39a commit 59cda86
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/unix/cygwin.c
Expand Up @@ -29,7 +29,7 @@
#include <time.h>

#undef NANOSEC
#define NANOSEC 1000000000
#define NANOSEC ((uint64_t) 1e9)


uint64_t uv_hrtime() {
Expand Down
2 changes: 1 addition & 1 deletion src/unix/freebsd.c
Expand Up @@ -38,7 +38,7 @@
#include <fcntl.h>

#undef NANOSEC
#define NANOSEC 1000000000
#define NANOSEC ((uint64_t) 1e9)

#ifndef CPUSTATES
# define CPUSTATES 5U
Expand Down
2 changes: 1 addition & 1 deletion src/unix/linux/core.c
Expand Up @@ -46,7 +46,7 @@
#endif

#undef NANOSEC
#define NANOSEC 1000000000
#define NANOSEC ((uint64_t) 1e9)

/* This is rather annoying: CLOCK_BOOTTIME lives in <linux/time.h> but we can't
* include that file because it conflicts with <time.h>. We'll just have to
Expand Down
2 changes: 1 addition & 1 deletion src/unix/netbsd.c
Expand Up @@ -32,7 +32,7 @@
#include <time.h>

#undef NANOSEC
#define NANOSEC 1000000000
#define NANOSEC ((uint64_t) 1e9)


uint64_t uv_hrtime(void) {
Expand Down
2 changes: 1 addition & 1 deletion src/unix/openbsd.c
Expand Up @@ -37,7 +37,7 @@
#include <unistd.h>

#undef NANOSEC
#define NANOSEC 1000000000
#define NANOSEC ((uint64_t) 1e9)


static char *process_title;
Expand Down
2 changes: 1 addition & 1 deletion test/benchmark-pound.c
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/test-hrtime.c
Expand Up @@ -27,7 +27,7 @@
#endif

#ifndef NANOSEC
# define NANOSEC 1000000000
# define NANOSEC ((uint64_t) 1e9)
#endif


Expand Down

0 comments on commit 59cda86

Please sign in to comment.