Pulled from samtools/htslib:develop