|
23 | 23 | #include <stdio.h> |
24 | 24 | #include <string.h> |
25 | 25 | #include <errno.h> |
| 26 | +#include <inttypes.h> // support for printing UINT64 |
26 | 27 | #include <map> |
27 | 28 | #include "sbhash.h" |
28 | 29 |
|
| 30 | +#ifndef _GNU_SOURCE |
| 31 | +// mempcpy is a GNU extension and not available everywhere. |
| 32 | +void *mempcpy(void *dest, const void *src, size_t n) |
| 33 | +{ |
| 34 | + return (char*) memcpy(dest, src, n) + n; |
| 35 | +} |
| 36 | +#endif |
| 37 | + |
29 | 38 | // Rename common integer types. |
30 | 39 | // I like having these shorter name. |
31 | 40 | typedef uint64_t UINT64; |
@@ -110,7 +119,7 @@ inline UINT64 diffTVs (struct timeval * startTV, struct timeval * endTV) |
110 | 119 |
|
111 | 120 | // We need to pre-define these for the SAM specific fields. |
112 | 121 | typedef UINT32 pos_t; // Type for reference offsets. |
113 | | -typedef UINT64 sig_t; // Type for signatures for offsets and lengths. |
| 122 | +typedef UINT64 sgn_t; // Type for signatures for offsets and lengths. |
114 | 123 | // And the type itself for the next pointer. |
115 | 124 | typedef struct splitLine splitLine_t; |
116 | 125 | splitLine_t * splitLineFreeList = NULL; |
@@ -538,13 +547,13 @@ void deleteState(state_t * s) |
538 | 547 | // Signatures |
539 | 548 | /////////////////////////////////////////////////////////////////////////////// |
540 | 549 |
|
541 | | -inline sig_t calcSig(splitLine_t * first, splitLine_t * second) |
| 550 | +inline sgn_t calcSig(splitLine_t * first, splitLine_t * second) |
542 | 551 | { |
543 | 552 | // Total nonsense to get the compiler to actually work. |
544 | 553 | UINT64 t1 = first->pos; |
545 | 554 | UINT64 t2 = t1 << 32; |
546 | 555 | UINT64 final = t2 | second->pos; |
547 | | - return (sig_t)final; |
| 556 | + return (sgn_t)final; |
548 | 557 | } |
549 | 558 |
|
550 | 559 | inline int calcSigArrOff(splitLine_t * first, splitLine_t * second, seqMap_t & seqs) |
@@ -840,7 +849,7 @@ void markDupsDiscordants(splitLine_t * block, state_t * state) |
840 | 849 | if (!orphan && needSwap(first, second)) swapPtrs(&first, &second); |
841 | 850 |
|
842 | 851 | // Now find the signature of the pair. |
843 | | - sig_t sig = calcSig(first, second); |
| 852 | + sgn_t sig = calcSig(first, second); |
844 | 853 | // Calculate the offset into the signatures array. |
845 | 854 | int off = calcSigArrOff(first, second, state->seqs); |
846 | 855 | // Attempt insert into the sigs structure. |
@@ -1123,7 +1132,7 @@ void printUsageString() |
1123 | 1132 | "-q --quiet Output fewer statistics.\n"; |
1124 | 1133 |
|
1125 | 1134 | printVersionString(); |
1126 | | - fprintf(stderr, useString); |
| 1135 | + fprintf(stderr, "%s", useString); |
1127 | 1136 | } |
1128 | 1137 |
|
1129 | 1138 | void printUsageStringAbort() |
@@ -1378,22 +1387,22 @@ int main (int argc, char *argv[]) |
1378 | 1387 | if (!state->quiet) |
1379 | 1388 | { |
1380 | 1389 | if (state->discordantFile != NULL) |
1381 | | - fprintf(stderr, "samblaster: Output %lu discordant read pairs to %s\n", discCount/2, state->discordantFileName); |
| 1390 | + fprintf(stderr, "samblaster: Output %"PRIu64" discordant read pairs to %s\n", discCount/2, state->discordantFileName); |
1382 | 1391 | if (state->splitterFile != NULL) |
1383 | | - fprintf(stderr, "samblaster: Output %lu split reads to %s\n", splitCount, state->splitterFileName); |
| 1392 | + fprintf(stderr, "samblaster: Output %"PRIu64" split reads to %s\n", splitCount, state->splitterFileName); |
1384 | 1393 | if (state->unmappedClippedFile != NULL) |
1385 | | - fprintf(stderr, "samblaster: Output %lu unmapped/clipped reads to %s\n", unmapClipCount, state->unmappedClippedFileName); |
| 1394 | + fprintf(stderr, "samblaster: Output %"PRIu64" unmapped/clipped reads to %s\n", unmapClipCount, state->unmappedClippedFileName); |
1386 | 1395 | } |
1387 | 1396 |
|
1388 | 1397 | // Output stats. |
1389 | 1398 | if (state->removeDups) |
1390 | 1399 | { |
1391 | | - fprintf(stderr, "samblaster: Removed %lu of %lu (%4.2f%%) read ids as duplicates", |
| 1400 | + fprintf(stderr, "samblaster: Removed %"PRIu64" of %"PRIu64" (%4.2f%%) read ids as duplicates", |
1392 | 1401 | dupCount, idCount, ((double)100)*dupCount/idCount); |
1393 | 1402 | } |
1394 | 1403 | else |
1395 | 1404 | { |
1396 | | - fprintf(stderr, "samblaster: Marked %lu of %lu (%4.2f%%) read ids as duplicates", |
| 1405 | + fprintf(stderr, "samblaster: Marked %"PRIu64" of %"PRIu64" (%4.2f%%) read ids as duplicates", |
1397 | 1406 | dupCount, idCount, ((double)100)*dupCount/idCount); |
1398 | 1407 | } |
1399 | 1408 | if ((TIMING == 0) || state->quiet) |
|
0 commit comments