lh3 / minimap

This repo is DEPRECATED. Please use minimap2, the successor of minimap.
https://github.com/lh3/minimap2
MIT License
106 stars 29 forks source link

ensure 64bit type for bitfield #2

Closed satta closed 8 years ago

satta commented 8 years ago

size_t is not guaranteed to be >= 64 bit in length. However, this is expected in kdq.h:

#define __KDQ_TYPE(type) \
    typedef struct { \
        size_t front:58, bits:6, count, mask; \
        type *a; \
    } kdq_##type##_t;

This patch fixes building minimap on architectures where it's generally less (i.e. '32-bit' platforms), where otherwise:

$ uname -m
i686
$ make
gcc -c -g -Wall -O2 -Wc++-compat -Wno-unused-function  -I. main.c -o main.o
gcc -c -g -Wall -O2 -Wc++-compat -Wno-unused-function  -I. kthread.c -o kthread.o
gcc -c -g -Wall -O2 -Wc++-compat -Wno-unused-function  -I. misc.c -o misc.o
gcc -c -g -Wall -O2 -Wc++-compat -Wno-unused-function  -I. bseq.c -o bseq.o
gcc -c -g -Wall -O2 -Wc++-compat -Wno-unused-function  -I. sketch.c -o sketch.o
gcc -c -g -Wall -O2 -Wc++-compat -Wno-unused-function  -I. sdust.c -o sdust.o
sdust.c:20:1: error: width of ‘front’ exceeds its type
make: *** [sdust.o] Error 1
lh3 commented 8 years ago

Thanks. But probably minimap/miniasm won't work on 32-bit systems anyway.

satta commented 8 years ago

I can add a build time test to run on Debian's buildd machines. They carry quite a variety of architectures. Can you suggest a small but non-trivial test case? I tried a very simple case (Leishmania major chromosome 1 with a bunch of artificial 'reads' sampled from it) and it worked fine on i686. I suspect problems will only appear once reference or query lengths go beyond 32-bit uints?