Skip to content

Commit 0e16f30

Browse files
committed
Support for OS X.
Following changes were made: a) Incremented the BUILDNUM in the Makefile b) Added "<inttypes.h> for proper formatting of UINT64 datatype c) Added the function mempcpy if it is not defined d) "sig_t" is defined in /usr/include/signal.h, so changed the typedef to sgn_t e) Changed the printf statements for UINT64 to pacify the compiler
1 parent a527402 commit 0e16f30

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Determine the samblaster build number
2-
BUILDNUM = 20
2+
BUILDNUM = 21
33
# INTERNAL = TRUE
44

55
OBJS = samblaster.o sbhash.o

samblaster.cpp

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,18 @@
2323
#include <stdio.h>
2424
#include <string.h>
2525
#include <errno.h>
26+
#include <inttypes.h> // support for printing UINT64
2627
#include <map>
2728
#include "sbhash.h"
2829

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+
2938
// Rename common integer types.
3039
// I like having these shorter name.
3140
typedef uint64_t UINT64;
@@ -110,7 +119,7 @@ inline UINT64 diffTVs (struct timeval * startTV, struct timeval * endTV)
110119

111120
// We need to pre-define these for the SAM specific fields.
112121
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.
114123
// And the type itself for the next pointer.
115124
typedef struct splitLine splitLine_t;
116125
splitLine_t * splitLineFreeList = NULL;
@@ -538,13 +547,13 @@ void deleteState(state_t * s)
538547
// Signatures
539548
///////////////////////////////////////////////////////////////////////////////
540549

541-
inline sig_t calcSig(splitLine_t * first, splitLine_t * second)
550+
inline sgn_t calcSig(splitLine_t * first, splitLine_t * second)
542551
{
543552
// Total nonsense to get the compiler to actually work.
544553
UINT64 t1 = first->pos;
545554
UINT64 t2 = t1 << 32;
546555
UINT64 final = t2 | second->pos;
547-
return (sig_t)final;
556+
return (sgn_t)final;
548557
}
549558

550559
inline int calcSigArrOff(splitLine_t * first, splitLine_t * second, seqMap_t & seqs)
@@ -840,7 +849,7 @@ void markDupsDiscordants(splitLine_t * block, state_t * state)
840849
if (!orphan && needSwap(first, second)) swapPtrs(&first, &second);
841850

842851
// Now find the signature of the pair.
843-
sig_t sig = calcSig(first, second);
852+
sgn_t sig = calcSig(first, second);
844853
// Calculate the offset into the signatures array.
845854
int off = calcSigArrOff(first, second, state->seqs);
846855
// Attempt insert into the sigs structure.
@@ -1123,7 +1132,7 @@ void printUsageString()
11231132
"-q --quiet Output fewer statistics.\n";
11241133

11251134
printVersionString();
1126-
fprintf(stderr, useString);
1135+
fprintf(stderr, "%s", useString);
11271136
}
11281137

11291138
void printUsageStringAbort()
@@ -1378,22 +1387,22 @@ int main (int argc, char *argv[])
13781387
if (!state->quiet)
13791388
{
13801389
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);
13821391
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);
13841393
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);
13861395
}
13871396

13881397
// Output stats.
13891398
if (state->removeDups)
13901399
{
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",
13921401
dupCount, idCount, ((double)100)*dupCount/idCount);
13931402
}
13941403
else
13951404
{
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",
13971406
dupCount, idCount, ((double)100)*dupCount/idCount);
13981407
}
13991408
if ((TIMING == 0) || state->quiet)

0 commit comments

Comments
 (0)