Skip to content

Commit

Permalink
Improve compiler compatibility of nibble2base_ssse3
Browse files Browse the repository at this point in the history
  • Loading branch information
rhpvorderman committed Apr 22, 2024
1 parent 5d0a78e commit 1c5c763
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 8 additions & 0 deletions htslib/hts_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ DEALINGS IN THE SOFTWARE. */
#define HTS_FORMAT(type, idx, first)
#endif

#define HTS_COMPILER_HAS_TARGET (HTS_COMPILER_HAS(target) || HTS_GCC_AT_LEAST(4, 8))

#if (defined(__x86_64__) || defined(_M_X64))
#define HTS_BUILD_IS_X86_64 1
#else
#define HTS_BUILD_IS_X86_64 0
#endif

#if defined(_WIN32) || defined(__CYGWIN__)
#if defined(HTS_BUILDING_LIBRARY)
#define HTSLIB_EXPORT __declspec(dllexport)
Expand Down
5 changes: 3 additions & 2 deletions sam_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ static inline void nibble2base_default(uint8_t *nib, char *seq, int len) {
seq[i] = seq_nt16_str[bam_seqi(nib, i)];
}

#if HTS_GCC_AT_LEAST(4,8)
#if HTS_BUILD_IS_X86_64 && HTS_COMPILER_HAS_TARGET
#include "immintrin.h"
/*
* Convert a nibble encoded BAM sequence to a string of bases.
*
Expand All @@ -108,7 +109,7 @@ static inline void nibble2base_default(uint8_t *nib, char *seq, int len) {
* be converted to the IUPAC characters.
* It falls back on the nibble2base_default function for the remainder.
*/
#include "tmmintrin.h"

__attribute__((target("ssse3")))
static inline void nibble2base_ssse3(uint8_t *nib, char *seq, int len) {
seq[0] = 0;
Expand Down

0 comments on commit 1c5c763

Please sign in to comment.