From 0a3ebdc916de8e2e99e76d1438f2611534a3334c Mon Sep 17 00:00:00 2001 From: Heng Li Date: Sat, 2 Sep 2017 17:52:33 -0400 Subject: [PATCH] for better windows compatibility --- Makefile | 7 ++++--- index.c | 4 ++-- kthread.c | 2 +- main.c | 14 ++++++-------- misc.c | 2 +- sdust.c | 2 +- sketch.c | 2 +- 7 files changed, 16 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index d1ed2c0..6ed7bae 100644 --- a/Makefile +++ b/Makefile @@ -30,8 +30,8 @@ minimap2-lite:example.o libminimap2.a libminimap2.a:$(OBJS) $(AR) -csru $@ $(OBJS) -sdust:sdust.c kalloc.o kalloc.h kdq.h kvec.h kseq.h sdust.h - $(CC) -D_SDUST_MAIN $(CFLAGS) $< kalloc.o -o $@ -lz +sdust:sdust.c getopt.o kalloc.o kalloc.h kdq.h kvec.h kseq.h sdust.h + $(CC) -D_SDUST_MAIN $(CFLAGS) $< getopt.o kalloc.o -o $@ -lz clean: rm -fr gmon.out *.o a.out $(PROG) $(PROG_EXTRA) *~ *.a *.dSYM session* @@ -46,6 +46,7 @@ bseq.o: bseq.h kseq.h chain.o: minimap.h mmpriv.h bseq.h kalloc.h example.o: minimap.h kseq.h format.o: kalloc.h mmpriv.h minimap.h bseq.h +getopt.o: getopt.h hit.o: mmpriv.h minimap.h bseq.h kalloc.h index.o: kthread.h bseq.h minimap.h mmpriv.h kvec.h kalloc.h khash.h kalloc.o: kalloc.h @@ -53,7 +54,7 @@ ksw2_extd2_sse.o: ksw2.h kalloc.h ksw2_exts2_sse.o: ksw2.h kalloc.h ksw2_extz2_sse.o: ksw2.h kalloc.h ksw2_ll_sse.o: ksw2.h kalloc.h -main.o: bseq.h minimap.h mmpriv.h +main.o: bseq.h minimap.h mmpriv.h getopt.h map.o: kthread.h kvec.h kalloc.h sdust.h mmpriv.h minimap.h bseq.h misc.o: minimap.h ksort.h sdust.o: kalloc.h kdq.h kvec.h sdust.h diff --git a/index.c b/index.c index 80c302c..2123ab5 100644 --- a/index.c +++ b/index.c @@ -1,7 +1,7 @@ #include #include -#ifdef WIN32 -#include +#if defined(WIN32) || defined(_WIN32) +#include // for open(2) #else #include #endif diff --git a/kthread.c b/kthread.c index 972aace..6004435 100644 --- a/kthread.c +++ b/kthread.c @@ -3,7 +3,7 @@ #include #include -#ifdef WIN32 +#if defined(WIN32) || defined(_WIN32) #include #define alloca _alloca #define __sync_fetch_and_add(ptr, addend) _InterlockedExchangeAdd((void*)ptr, addend) diff --git a/main.c b/main.c index 0f2b014..01061a8 100644 --- a/main.c +++ b/main.c @@ -1,12 +1,6 @@ #include #include #include -#ifdef WIN32 -#include -#else -#include -#include -#endif #include "bseq.h" #include "minimap.h" #include "mmpriv.h" @@ -14,15 +8,19 @@ #define MM_VERSION "2.1-r316-dirty" +#ifdef __linux__ +#include +#include void liftrlimit() { -#ifdef __linux__ struct rlimit r; getrlimit(RLIMIT_AS, &r); r.rlim_cur = r.rlim_max; setrlimit(RLIMIT_AS, &r); -#endif } +#else +void liftrlimit() {} +#endif static struct option long_options[] = { { "bucket-bits", required_argument, 0, 0 }, diff --git a/misc.c b/misc.c index c265ac1..d7dd1e4 100644 --- a/misc.c +++ b/misc.c @@ -96,7 +96,7 @@ double cputime() getrusage(RUSAGE_SELF, &r); return r.ru_utime.tv_sec + r.ru_stime.tv_sec + 1e-6 * (r.ru_utime.tv_usec + r.ru_stime.tv_usec); } -#endif /* WIN32 */ +#endif /* WIN32 || _WIN32 */ double realtime() { diff --git a/sdust.c b/sdust.c index 07339dd..f1e47e8 100644 --- a/sdust.c +++ b/sdust.c @@ -176,7 +176,7 @@ uint64_t *sdust(void *km, const uint8_t *seq, int l_seq, int T, int W, int *n) #ifdef _SDUST_MAIN #include #include -#include +#include "getopt.h" #include "kseq.h" KSEQ_INIT(gzFile, gzread) diff --git a/sketch.c b/sketch.c index bdb5efb..ab3bcc8 100644 --- a/sketch.c +++ b/sketch.c @@ -5,7 +5,7 @@ #include "kvec.h" #include "minimap.h" -#ifdef WIN32 +#if defined(WIN32) || defined(_WIN32) #include #define alloca _alloca #endif