parent
2b8681ead7
commit
00416c76d1
4
getopt.c
4
getopt.c
|
|
@ -11,12 +11,16 @@ int optind=1, opterr=1, optopt, __optpos, optreset=0;
|
|||
static void __getopt_msg(const char *a, const char *b, const char *c, size_t l)
|
||||
{
|
||||
FILE *f = stderr;
|
||||
#if !defined(WIN32) && !defined(_WIN32)
|
||||
flockfile(f);
|
||||
#endif
|
||||
fputs(a, f);
|
||||
fwrite(b, strlen(b), 1, f);
|
||||
fwrite(c, 1, l, f);
|
||||
fputc('\n', f);
|
||||
#if !defined(WIN32) && !defined(_WIN32)
|
||||
funlockfile(f);
|
||||
#endif
|
||||
}
|
||||
|
||||
int getopt(int argc, char * const argv[], const char *optstring)
|
||||
|
|
|
|||
|
|
@ -3,9 +3,7 @@
|
|||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
#include <malloc.h>
|
||||
#define alloca _alloca
|
||||
#if (defined(WIN32) || defined(_WIN32)) && defined(_MSC_VER)
|
||||
#define __sync_fetch_and_add(ptr, addend) _InterlockedExchangeAdd((void*)ptr, addend)
|
||||
#endif
|
||||
|
||||
|
|
@ -59,12 +57,13 @@ void kt_for(int n_threads, void (*func)(void*,long,int), void *data, long n)
|
|||
kt_for_t t;
|
||||
pthread_t *tid;
|
||||
t.func = func, t.data = data, t.n_threads = n_threads, t.n = n;
|
||||
t.w = (ktf_worker_t*)alloca(n_threads * sizeof(ktf_worker_t));
|
||||
tid = (pthread_t*)alloca(n_threads * sizeof(pthread_t));
|
||||
t.w = (ktf_worker_t*)calloc(n_threads, sizeof(ktf_worker_t));
|
||||
tid = (pthread_t*)calloc(n_threads, sizeof(pthread_t));
|
||||
for (i = 0; i < n_threads; ++i)
|
||||
t.w[i].t = &t, t.w[i].i = i;
|
||||
for (i = 0; i < n_threads; ++i) pthread_create(&tid[i], 0, ktf_worker, &t.w[i]);
|
||||
for (i = 0; i < n_threads; ++i) pthread_join(tid[i], 0);
|
||||
free(tid); free(t.w);
|
||||
} else {
|
||||
long j;
|
||||
for (j = 0; j < n; ++j) func(data, j, 0);
|
||||
|
|
|
|||
8
sketch.c
8
sketch.c
|
|
@ -5,11 +5,6 @@
|
|||
#include "kvec.h"
|
||||
#include "minimap.h"
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
#include <malloc.h>
|
||||
#define alloca _alloca
|
||||
#endif
|
||||
|
||||
unsigned char seq_nt4_table[256] = {
|
||||
0, 1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
|
|
@ -86,7 +81,7 @@ void mm_sketch(void *km, const char *str, int len, int w, int k, uint32_t rid, i
|
|||
tiny_queue_t tq;
|
||||
|
||||
assert(len > 0 && w > 0 && k > 0 && k <= 28); // 56 bits for k-mer; could use long k-mers, but 28 enough in practice
|
||||
buf = (mm128_t*)alloca(w * 16);
|
||||
buf = (mm128_t*)calloc(w, 16);
|
||||
memset(buf, 0xff, w * 16);
|
||||
memset(&tq, 0, sizeof(tiny_queue_t));
|
||||
kv_resize(mm128_t, km, *p, p->n + len/w);
|
||||
|
|
@ -145,4 +140,5 @@ void mm_sketch(void *km, const char *str, int len, int w, int k, uint32_t rid, i
|
|||
}
|
||||
if (min.x != UINT64_MAX)
|
||||
kv_push(mm128_t, km, *p, min);
|
||||
free(buf);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue