7 #ifndef HTS_BGZF_TYPEDEF
9 #define HTS_BGZF_TYPEDEF
15 #define KSTRING_T kstring_t
23 #define kroundup32(x) (--(x), (x)|=(x)>>1, (x)|=(x)>>2, (x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, ++(x))
33 #define hts_expand(type_t, n, m, ptr) if ((n) > (m)) { \
34 (m) = (n); kroundup32(m); \
35 (ptr) = (type_t*)realloc((ptr), (m) * sizeof(type_t)); \
37 #define hts_expand0(type_t, n, m, ptr) if ((n) > (m)) { \
38 int t = (m); (m) = (n); kroundup32(m); \
39 (ptr) = (type_t*)realloc((ptr), (m) * sizeof(type_t)); \
40 memset(((type_t*)ptr)+t,0,sizeof(type_t)*((m)-t)); \
48 uint32_t is_bin:1, is_write:1, is_be:1, is_cram:1, is_compressed:2, is_kstream:1, dummy:25;
163 #define HTS_IDX_NOCOOR (-2)
164 #define HTS_IDX_START (-3)
165 #define HTS_IDX_REST (-4)
166 #define HTS_IDX_NONE (-5)
168 #define HTS_FMT_CSI 0
169 #define HTS_FMT_BAI 1
170 #define HTS_FMT_TBI 2
171 #define HTS_FMT_CRAI 3
184 int tid, beg, end, n_off, i;
198 #define hts_bin_first(l) (((1<<(((l)<<1) + (l))) - 1) / 7)
199 #define hts_bin_parent(l) (((l) - 1) >> 3)
215 const char *
hts_parse_reg(
const char *s,
int *beg,
int *end);
220 typedef const char *(*hts_id2name_f)(
void*, int);
239 #define FT_VCF_GZ (FT_GZ|FT_VCF)
240 #define FT_BCF (1<<2)
241 #define FT_BCF_GZ (FT_GZ|FT_BCF)
242 #define FT_STDIN (1<<3)
250 static inline int hts_reg2bin(
int64_t beg,
int64_t end,
int min_shift,
int n_lvls)
252 int l, s = min_shift, t = ((1<<((n_lvls<<1) + n_lvls)) - 1) / 7;
253 for (--end, l = n_lvls; l > 0; --l, s += 3, t -= 1<<((l<<1)+l))
254 if (beg>>s == end>>s)
return t + (beg>>s);
258 static inline int hts_bin_bot(
int bin,
int n_lvls)
269 static inline int ed_is_big(
void)
272 return !(*((
char *)(&one)));
276 return (
uint16_t)(((v & 0x00FF00FFU) << 8) | ((v & 0xFF00FF00U) >> 8));
278 static inline void *ed_swap_2p(
void *x)
285 v = ((v & 0x0000FFFFU) << 16) | (v >> 16);
286 return ((v & 0x00FF00FFU) << 8) | ((v & 0xFF00FF00U) >> 8);
288 static inline void *ed_swap_4p(
void *x)
295 v = ((v & 0x00000000FFFFFFFFLLU) << 32) | (v >> 32);
296 v = ((v & 0x0000FFFF0000FFFFLLU) << 16) | ((v & 0xFFFF0000FFFF0000LLU) >> 16);
297 return ((v & 0x00FF00FF00FF00FFLLU) << 8) | ((v & 0xFF00FF00FF00FF00LLU) >> 8);
299 static inline void *ed_swap_8p(
void *x)