| 1 |
--- a/buffer.c |
| 2 |
+++ b/buffer.c |
| 3 |
@@ -140,6 +140,14 @@ |
| 4 |
#define K *1024 |
| 5 |
#define M *1024*1024 |
| 6 |
|
| 7 |
+#if defined __GNUC__ || __STDC_VERSION__ >= 199901L |
| 8 |
+#define NUM_K_TYPE unsigned long long |
| 9 |
+#define NUM_K_FMT "llu" |
| 10 |
+#else |
| 11 |
+#define NUM_K_TYPE unsigned long |
| 12 |
+#define NUM_K_FMT "lu" |
| 13 |
+#endif |
| 14 |
+ |
| 15 |
/* Some forward declarations */ |
| 16 |
void byee(); |
| 17 |
void start_reader_and_writer(); |
| 18 |
@@ -254,7 +262,7 @@ |
| 19 |
|
| 20 |
char print_total = 0; |
| 21 |
/* Number of K output */ |
| 22 |
-unsigned long outk = 0; |
| 23 |
+NUM_K_TYPE outk = 0; |
| 24 |
|
| 25 |
struct timeval starttime; |
| 26 |
|
| 27 |
@@ -771,7 +779,7 @@ |
| 28 |
} |
| 29 |
|
| 30 |
if( print_total ){ |
| 31 |
- fprintf( stderr, "Kilobytes Out %lu\n", outk ); |
| 32 |
+ fprintf( stderr, "Kilobytes Out %" NUM_K_FMT "\n", outk ); |
| 33 |
} |
| 34 |
|
| 35 |
if( debug ) |
| 36 |
@@ -812,14 +820,14 @@ |
| 37 |
void |
| 38 |
write_block_to_stdout() |
| 39 |
{ |
| 40 |
- static unsigned long out = 0; |
| 41 |
+ unsigned long out = 0; |
| 42 |
static unsigned long last_gb = 0; |
| 43 |
- static unsigned long next_k = 0; |
| 44 |
+ static NUM_K_TYPE next_k = 0; |
| 45 |
int written; |
| 46 |
|
| 47 |
if( next_k == 0 && showevery ){ |
| 48 |
if( debug > 3 ) |
| 49 |
- fprintf( stderr, "W: next_k = %lu showevery = %d\n", next_k, showevery ); |
| 50 |
+ fprintf( stderr, "W: next_k = %" NUM_K_FMT " showevery = %d\n", next_k, showevery ); |
| 51 |
showevery = showevery / 1024; |
| 52 |
next_k = showevery; |
| 53 |
} |
| 54 |
@@ -827,7 +835,7 @@ |
| 55 |
if( (written = write( fdout, curr_block->data, curr_block->bytes )) != curr_block->bytes ){ |
| 56 |
report_proc(); |
| 57 |
perror( "write of data failed" ); |
| 58 |
- fprintf( stderr, "bytes to write=%d, bytes written=%d, total written %10luK\n", curr_block->bytes, written, outk ); |
| 59 |
+ fprintf( stderr, "bytes to write=%d, bytes written=%d, total written %10" NUM_K_FMT "K\n", curr_block->bytes, written, outk ); |
| 60 |
byee( -1 ); |
| 61 |
} |
| 62 |
|
| 63 |
@@ -854,7 +862,7 @@ |
| 64 |
} |
| 65 |
if( showevery ){ |
| 66 |
if( debug > 3 ) |
| 67 |
- fprintf( stderr, "W: outk = %lu, next_k = %lu\n", |
| 68 |
+ fprintf( stderr, "W: outk = %" NUM_K_FMT ", next_k = %" NUM_K_FMT "\n", |
| 69 |
outk, next_k ); |
| 70 |
if( outk >= next_k ){ |
| 71 |
pr_out(); |
| 72 |
@@ -991,10 +999,10 @@ |
| 73 |
} else { |
| 74 |
k_per_s = (outk / ms_delta) * 1000; |
| 75 |
} |
| 76 |
- fprintf( stderr, " %10luK, %10luK/s\r", outk, k_per_s ); |
| 77 |
+ fprintf( stderr, " %10" NUM_K_FMT "K, %10luK/s\r", outk, k_per_s ); |
| 78 |
} else { |
| 79 |
if (outk) { |
| 80 |
- fprintf( stderr, " %10luK, ?K/s\r", outk ); |
| 81 |
+ fprintf( stderr, " %10" NUM_K_FMT "K, ?K/s\r", outk ); |
| 82 |
} else { |
| 83 |
fprintf( stderr, " 0K, 0K/s\r"); |
| 84 |
} |