summaryrefslogtreecommitdiff
path: root/tools/readtest.c
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-01-20 00:55:11 +0100
committerRobin Gareus <robin@gareus.org>2015-01-20 00:55:11 +0100
commit8ee58de3ec9fb9ba06ed89a1bb7c83e27336f3ac (patch)
treef7c7e8701f3cdb4387c26a89339afef756674f46 /tools/readtest.c
parentd61fa7974f87b24b557e8440a6e6fab70fc8dee0 (diff)
fix to compile with gcc on linux
Diffstat (limited to 'tools/readtest.c')
-rw-r--r--tools/readtest.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/tools/readtest.c b/tools/readtest.c
index 53f559c4d3..301a5fa2bc 100644
--- a/tools/readtest.c
+++ b/tools/readtest.c
@@ -8,6 +8,7 @@
#include <string.h>
#include <getopt.h>
#include <fcntl.h>
+#include <stdbool.h>
#include <glib.h>
@@ -32,7 +33,9 @@ main (int argc, char* argv[])
int* files;
char optstring[] = "b:D";
uint32_t block_size = 64 * 1024 * 4;
+#ifdef __APPLE__
bool direct = false;
+#endif
const struct option longopts[] = {
{ "blocksize", 1, 0, 'b' },
{ "direct", 0, 0, 'D' },
@@ -56,7 +59,9 @@ main (int argc, char* argv[])
block_size = atoi (optarg);
break;
case 'D':
+#ifdef __APPLE__
direct = true;
+#endif
break;
default:
usage ();
@@ -121,7 +126,7 @@ main (int argc, char* argv[])
}
data = (char*) malloc (sizeof (char) * block_size);
- uint64_t read = 0;
+ uint64_t _read = 0;
while (true) {
gint64 before;
@@ -129,17 +134,17 @@ main (int argc, char* argv[])
for (n = 0; n < nfiles; ++n) {
- if (::read (files[n], (char*) data, block_size) != block_size) {
+ if (read (files[n], (char*) data, block_size) != block_size) {
fprintf (stderr, "read failed on file %d (%s)\n", n, strerror (errno));
return -1;
}
}
- read += block_size;
+ _read += block_size;
gint64 elapsed = g_get_monotonic_time() - before;
double bandwidth = ((nfiles * block_size)/1048576.0) / (elapsed/1000000.0);
- printf ("BW @ %Lu %.3f seconds bandwidth %.4f MB/sec\n", read, elapsed/1000000.0, bandwidth);
+ printf ("BW @ %Lu %.3f seconds bandwidth %.4f MB/sec\n", _read, elapsed/1000000.0, bandwidth);
}
return 0;