diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-15 13:04:32 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-15 13:04:32 +0300 |
| commit | bdaedce69b17b654bd0060579dd9b9ff120009b5 (patch) | |
| tree | 0e9cd8597652263a96c48ba678fb0b66e1fc131b /src/kernels.h | |
| parent | ba75c8b0a1bba03ad92c53375432f122ddb4cb98 (diff) | |
| parent | dcebf9c7f954a55350b68d0ead1935612c4e2e05 (diff) | |
Merge branch 'wt/rename' into api-hardening
# Conflicts:
# README.md
Diffstat (limited to 'src/kernels.h')
| -rw-r--r-- | src/kernels.h | 186 |
1 files changed, 93 insertions, 93 deletions
diff --git a/src/kernels.h b/src/kernels.h index 5cf0d93..9112c2e 100644 --- a/src/kernels.h +++ b/src/kernels.h @@ -10,8 +10,8 @@ #include <stdint.h> #include <string.h> -#if defined(TERM_KERNEL_AVX512) -TERM_TARGET_AVX512 +#if defined(WSAP_VTCORE_KERNEL_AVX512) +WSAP_VTCORE_TARGET_AVX512 static inline size_t scan_printable_span_avx512(const char *buf, size_t len, unsigned char hi) { size_t i = 0; @@ -21,21 +21,21 @@ static inline size_t scan_printable_span_avx512(const char *buf, size_t len, uns __m512i v = _mm512_loadu_si512((const void *)(buf + i)); __mmask64 mask = _mm512_cmpge_epu8_mask(_mm512_sub_epi8(v, v20_512), vlim_512); if (mask != 0) - return i + term_ctz64(mask); + return i + wsap_vtcore_ctz64(mask); } if (i < len) { __mmask64 load_mask = ((uint64_t)1 << (len - i)) - 1; __m512i v = _mm512_maskz_loadu_epi8(load_mask, buf + i); __mmask64 mask = _mm512_mask_cmpge_epu8_mask(load_mask, _mm512_sub_epi8(v, v20_512), vlim_512); if (mask != 0) - return i + term_ctz64(mask); + return i + wsap_vtcore_ctz64(mask); } return len; } #endif -#if defined(TERM_KERNEL_AVX2) -TERM_TARGET_AVX2 +#if defined(WSAP_VTCORE_KERNEL_AVX2) +WSAP_VTCORE_TARGET_AVX2 static inline size_t scan_printable_span_avx2(const char *buf, size_t len, unsigned char hi) { size_t i = 0; @@ -48,10 +48,10 @@ static inline size_t scan_printable_span_avx2(const char *buf, size_t len, unsig __m256i sub1 = _mm256_sub_epi8(v1, v_offset); int m0 = _mm256_movemask_epi8(_mm256_cmpgt_epi8(sub0, v_limit)); int m1 = _mm256_movemask_epi8(_mm256_cmpgt_epi8(sub1, v_limit)); - if (TERM_EXPECT((m0 | m1) != 0, 0)) { + if (WSAP_VTCORE_EXPECT((m0 | m1) != 0, 0)) { if (m0 != 0) - return i + term_ctz32(m0); - return i + 32 + term_ctz32(m1); + return i + wsap_vtcore_ctz32(m0); + return i + 32 + wsap_vtcore_ctz32(m1); } } if (i + 32 <= len) { @@ -59,7 +59,7 @@ static inline size_t scan_printable_span_avx2(const char *buf, size_t len, unsig __m256i sub = _mm256_sub_epi8(v, v_offset); int mask = _mm256_movemask_epi8(_mm256_cmpgt_epi8(sub, v_limit)); if (mask != 0) - return i + term_ctz32(mask); + return i + wsap_vtcore_ctz32(mask); i += 32; } if (i + 16 <= len) { @@ -67,7 +67,7 @@ static inline size_t scan_printable_span_avx2(const char *buf, size_t len, unsig __m128i sub = _mm_sub_epi8(v, _mm_set1_epi8((char)(0x20 + 0x80))); int mask = _mm_movemask_epi8(_mm_cmpgt_epi8(sub, _mm_set1_epi8((char)(hi - 0xa1)))) & 0xFFFF; if (mask != 0) - return i + term_ctz32(mask); + return i + wsap_vtcore_ctz32(mask); i += 16; } for (; i < len; i++) { @@ -83,12 +83,12 @@ static inline size_t scan_printable_span(const char *buf, size_t len, unsigned char hi) { /* A short span costs less inline than as a call. */ -#if defined(TERM_KERNEL_AVX512) - if (len >= 64 && term_use_avx512()) +#if defined(WSAP_VTCORE_KERNEL_AVX512) + if (len >= 64 && wsap_vtcore_use_avx512()) return scan_printable_span_avx512(buf, len, hi); #endif -#if defined(TERM_KERNEL_AVX2) - if (len >= 32 && term_use_avx2()) +#if defined(WSAP_VTCORE_KERNEL_AVX2) + if (len >= 32 && wsap_vtcore_use_avx2()) return scan_printable_span_avx2(buf, len, hi); #endif size_t i = 0; @@ -108,26 +108,26 @@ static inline size_t scan_printable_span(const char *buf, size_t len, uint8x16_t mor = vorrq_u8(vorrq_u8(m0, m1), vorrq_u8(m2, m3)); uint64x2_t mor64 = vreinterpretq_u64_u8(mor); - if (TERM_EXPECT((vgetq_lane_u64(mor64, 0) | vgetq_lane_u64(mor64, 1)) != 0, 0)) { + if (WSAP_VTCORE_EXPECT((vgetq_lane_u64(mor64, 0) | vgetq_lane_u64(mor64, 1)) != 0, 0)) { uint64x2_t m0_64 = vreinterpretq_u64_u8(m0); uint64_t lo0 = vgetq_lane_u64(m0_64, 0), hi0 = vgetq_lane_u64(m0_64, 1); - if (lo0) return i + (term_ctz64(lo0) >> 3); - if (hi0) return i + 8 + (term_ctz64(hi0) >> 3); + if (lo0) return i + (wsap_vtcore_ctz64(lo0) >> 3); + if (hi0) return i + 8 + (wsap_vtcore_ctz64(hi0) >> 3); uint64x2_t m1_64 = vreinterpretq_u64_u8(m1); uint64_t lo1 = vgetq_lane_u64(m1_64, 0), hi1 = vgetq_lane_u64(m1_64, 1); - if (lo1) return i + 16 + (term_ctz64(lo1) >> 3); - if (hi1) return i + 24 + (term_ctz64(hi1) >> 3); + if (lo1) return i + 16 + (wsap_vtcore_ctz64(lo1) >> 3); + if (hi1) return i + 24 + (wsap_vtcore_ctz64(hi1) >> 3); uint64x2_t m2_64 = vreinterpretq_u64_u8(m2); uint64_t lo2 = vgetq_lane_u64(m2_64, 0), hi2 = vgetq_lane_u64(m2_64, 1); - if (lo2) return i + 32 + (term_ctz64(lo2) >> 3); - if (hi2) return i + 40 + (term_ctz64(hi2) >> 3); + if (lo2) return i + 32 + (wsap_vtcore_ctz64(lo2) >> 3); + if (hi2) return i + 40 + (wsap_vtcore_ctz64(hi2) >> 3); uint64x2_t m3_64 = vreinterpretq_u64_u8(m3); uint64_t lo3 = vgetq_lane_u64(m3_64, 0), hi3 = vgetq_lane_u64(m3_64, 1); - if (lo3) return i + 48 + (term_ctz64(lo3) >> 3); - if (hi3) return i + 56 + (term_ctz64(hi3) >> 3); + if (lo3) return i + 48 + (wsap_vtcore_ctz64(lo3) >> 3); + if (hi3) return i + 56 + (wsap_vtcore_ctz64(hi3) >> 3); } } for (; i + 16 <= len; i += 16) { @@ -136,14 +136,14 @@ static inline size_t scan_printable_span(const char *buf, size_t len, uint64x2_t m64 = vreinterpretq_u64_u8(mask); uint64_t lo = vgetq_lane_u64(m64, 0); uint64_t hi64 = vgetq_lane_u64(m64, 1); - if (lo) return i + (term_ctz64(lo) >> 3); - if (hi64) return i + 8 + (term_ctz64(hi64) >> 3); + if (lo) return i + (wsap_vtcore_ctz64(lo) >> 3); + if (hi64) return i + 8 + (wsap_vtcore_ctz64(hi64) >> 3); } if (i + 8 <= len) { uint8x8_t v8 = vld1_u8((const uint8_t *)buf + i); uint8x8_t mask8 = vcge_u8(vsub_u8(v8, vget_low_u8(v20)), vget_low_u8(vlim)); uint64_t m64 = vget_lane_u64(vreinterpret_u64_u8(mask8), 0); - if (m64) return i + (term_ctz64(m64) >> 3); + if (m64) return i + (wsap_vtcore_ctz64(m64) >> 3); i += 8; } #elif defined(__x86_64__) @@ -154,19 +154,19 @@ static inline size_t scan_printable_span(const char *buf, size_t len, __m128i m1 = _mm_cmpgt_epi8(_mm_sub_epi8(_mm_loadu_si128((const __m128i *)(buf + i + 16)), v_offset), v_limit); __m128i m2 = _mm_cmpgt_epi8(_mm_sub_epi8(_mm_loadu_si128((const __m128i *)(buf + i + 32)), v_offset), v_limit); __m128i m3 = _mm_cmpgt_epi8(_mm_sub_epi8(_mm_loadu_si128((const __m128i *)(buf + i + 48)), v_offset), v_limit); - if (TERM_EXPECT(_mm_movemask_epi8(_mm_or_si128(_mm_or_si128(m0, m1), _mm_or_si128(m2, m3))) != 0, 0)) { + if (WSAP_VTCORE_EXPECT(_mm_movemask_epi8(_mm_or_si128(_mm_or_si128(m0, m1), _mm_or_si128(m2, m3))) != 0, 0)) { uint64_t mask = (uint64_t)(unsigned)_mm_movemask_epi8(m0) | (uint64_t)(unsigned)_mm_movemask_epi8(m1) << 16 | (uint64_t)(unsigned)_mm_movemask_epi8(m2) << 32 | (uint64_t)(unsigned)_mm_movemask_epi8(m3) << 48; - return i + (size_t)term_ctz64(mask); + return i + (size_t)wsap_vtcore_ctz64(mask); } } for (; i + 16 <= len; i += 16) { int mask = _mm_movemask_epi8(_mm_cmpgt_epi8( _mm_sub_epi8(_mm_loadu_si128((const __m128i *)(buf + i)), v_offset), v_limit)); if (mask != 0) - return i + (size_t)term_ctz32((unsigned)mask); + return i + (size_t)wsap_vtcore_ctz32((unsigned)mask); } #endif for (; i < len; i++) { @@ -179,10 +179,10 @@ static inline size_t scan_printable_span(const char *buf, size_t len, /* Copy n bytes with loads that stay inside [src, src + n). Short text runs * are common; a libc call costs more than the copy. */ -static inline TERM_ALWAYS_INLINE void bytes_copy_small(uint8_t *restrict dst, +static inline WSAP_VTCORE_ALWAYS_INLINE void bytes_copy_small(uint8_t *restrict dst, const char *restrict src, int n) { - if (TERM_EXPECT((unsigned)(n - 16) <= 16u, 1)) { + if (WSAP_VTCORE_EXPECT((unsigned)(n - 16) <= 16u, 1)) { /* 16 to 32 bytes: two overlapping 16-byte copies. Both loads stay * inside [src, src + n). This is the usual history line length, and * two copies cost less here than the loop below. */ @@ -217,8 +217,8 @@ static inline size_t scan_crlf_tail(const char *buf, size_t i, size_t len) return i; } -#if defined(TERM_KERNEL_AVX512) -TERM_TARGET_AVX512 +#if defined(WSAP_VTCORE_KERNEL_AVX512) +WSAP_VTCORE_TARGET_AVX512 static inline size_t scan_crlf_pairs_avx512(const char *buf, size_t len) { size_t i = 0; @@ -226,14 +226,14 @@ static inline size_t scan_crlf_pairs_avx512(const char *buf, size_t len) for (; i + 64 <= len; i += 64) { uint64_t eq = _mm512_cmpeq_epi8_mask(_mm512_loadu_si512((const void *)(buf + i)), pair); if (eq != ~0ull) - return i + ((size_t)term_ctz64(~eq) & ~(size_t)1); + return i + ((size_t)wsap_vtcore_ctz64(~eq) & ~(size_t)1); } return scan_crlf_tail(buf, i, len); } #endif -#if defined(TERM_KERNEL_AVX2) -TERM_TARGET_AVX2 +#if defined(WSAP_VTCORE_KERNEL_AVX2) +WSAP_VTCORE_TARGET_AVX2 static inline size_t scan_crlf_pairs_avx2(const char *buf, size_t len) { size_t i = 0; @@ -242,7 +242,7 @@ static inline size_t scan_crlf_pairs_avx2(const char *buf, size_t len) uint32_t eq = (uint32_t)_mm256_movemask_epi8( _mm256_cmpeq_epi8(_mm256_loadu_si256((const __m256i *)(const void *)(buf + i)), pair)); if (eq != ~0u) - return i + ((size_t)term_ctz32(~eq) & ~(size_t)1); + return i + ((size_t)wsap_vtcore_ctz32(~eq) & ~(size_t)1); } return scan_crlf_tail(buf, i, len); } @@ -251,12 +251,12 @@ static inline size_t scan_crlf_pairs_avx2(const char *buf, size_t len) /* The length of the prefix of buf made of "\r\n" pairs; always even. */ static inline size_t scan_crlf_pairs(const char *buf, size_t len) { -#if defined(TERM_KERNEL_AVX512) - if (term_use_avx512()) +#if defined(WSAP_VTCORE_KERNEL_AVX512) + if (wsap_vtcore_use_avx512()) return scan_crlf_pairs_avx512(buf, len); #endif -#if defined(TERM_KERNEL_AVX2) - if (term_use_avx2()) +#if defined(WSAP_VTCORE_KERNEL_AVX2) + if (wsap_vtcore_use_avx2()) return scan_crlf_pairs_avx2(buf, len); #endif size_t i = 0; @@ -264,16 +264,16 @@ static inline size_t scan_crlf_pairs(const char *buf, size_t len) const uint8x16_t pair = vreinterpretq_u8_u16(vdupq_n_u16(0x0A0D)); for (; i + 16 <= len; i += 16) { uint8x16_t eq = vceqq_u8(vld1q_u8((const uint8_t *)buf + i), pair); - uint16_t bits = term_lane_bits(eq); + uint16_t bits = wsap_vtcore_lane_bits(eq); if (bits != 0xFFFF) - return i + ((size_t)term_ctz32((unsigned)~bits & 0xFFFFu) & ~(size_t)1); + return i + ((size_t)wsap_vtcore_ctz32((unsigned)~bits & 0xFFFFu) & ~(size_t)1); } #endif return scan_crlf_tail(buf, i, len); } -#if defined(TERM_KERNEL_AVX512) -TERM_TARGET_AVX512 +#if defined(WSAP_VTCORE_KERNEL_AVX512) +WSAP_VTCORE_TARGET_AVX512 static inline size_t scan_byte_run_avx512(const char *buf, size_t len, char byte) { size_t i = 0; @@ -281,7 +281,7 @@ static inline size_t scan_byte_run_avx512(const char *buf, size_t len, char byte for (; i + 64 <= len; i += 64) { uint64_t eq = _mm512_cmpeq_epi8_mask(_mm512_loadu_si512((const void *)(buf + i)), want); if (eq != ~0ull) - return i + (size_t)term_ctz64(~eq); + return i + (size_t)wsap_vtcore_ctz64(~eq); } while (i < len && buf[i] == byte) i++; @@ -289,8 +289,8 @@ static inline size_t scan_byte_run_avx512(const char *buf, size_t len, char byte } #endif -#if defined(TERM_KERNEL_AVX2) -TERM_TARGET_AVX2 +#if defined(WSAP_VTCORE_KERNEL_AVX2) +WSAP_VTCORE_TARGET_AVX2 static inline size_t scan_byte_run_avx2(const char *buf, size_t len, char byte) { size_t i = 0; @@ -299,7 +299,7 @@ static inline size_t scan_byte_run_avx2(const char *buf, size_t len, char byte) uint32_t eq = (uint32_t)_mm256_movemask_epi8( _mm256_cmpeq_epi8(_mm256_loadu_si256((const __m256i *)(const void *)(buf + i)), want)); if (eq != ~0u) - return i + (size_t)term_ctz32(~eq); + return i + (size_t)wsap_vtcore_ctz32(~eq); } while (i < len && buf[i] == byte) i++; @@ -310,21 +310,21 @@ static inline size_t scan_byte_run_avx2(const char *buf, size_t len, char byte) /* The length of the prefix of buf made of byte. */ static inline size_t scan_byte_run(const char *buf, size_t len, char byte) { -#if defined(TERM_KERNEL_AVX512) - if (term_use_avx512()) +#if defined(WSAP_VTCORE_KERNEL_AVX512) + if (wsap_vtcore_use_avx512()) return scan_byte_run_avx512(buf, len, byte); #endif -#if defined(TERM_KERNEL_AVX2) - if (term_use_avx2()) +#if defined(WSAP_VTCORE_KERNEL_AVX2) + if (wsap_vtcore_use_avx2()) return scan_byte_run_avx2(buf, len, byte); #endif size_t i = 0; #if defined(__aarch64__) const uint8x16_t want = vdupq_n_u8((uint8_t)byte); for (; i + 16 <= len; i += 16) { - uint16_t bits = term_lane_bits(vceqq_u8(vld1q_u8((const uint8_t *)buf + i), want)); + uint16_t bits = wsap_vtcore_lane_bits(vceqq_u8(vld1q_u8((const uint8_t *)buf + i), want)); if (bits != 0xFFFF) - return i + (size_t)term_ctz32((unsigned)~bits & 0xFFFFu); + return i + (size_t)wsap_vtcore_ctz32((unsigned)~bits & 0xFFFFu); } #elif defined(__x86_64__) const __m128i want = _mm_set1_epi8(byte); @@ -332,7 +332,7 @@ static inline size_t scan_byte_run(const char *buf, size_t len, char byte) unsigned eq = (unsigned)_mm_movemask_epi8( _mm_cmpeq_epi8(_mm_loadu_si128((const __m128i *)(const void *)(buf + i)), want)); if (eq != 0xFFFFu) - return i + (size_t)term_ctz32(~eq & 0xFFFFu); + return i + (size_t)wsap_vtcore_ctz32(~eq & 0xFFFFu); } #endif while (i < len && buf[i] == byte) @@ -355,16 +355,16 @@ static inline int scan_ascii_lf_tail(const char *buf, int i, int len, uint16_t * return count; } -#if defined(TERM_KERNEL_AVX512) -TERM_TARGET_AVX512 +#if defined(WSAP_VTCORE_KERNEL_AVX512) +WSAP_VTCORE_TARGET_AVX512 static inline int store_lf_offsets_avx512(uint16_t *ends, uint64_t nl, __m512i lanes, __m128i block) { - unsigned n = (unsigned)term_popcount64(nl); + unsigned n = (unsigned)wsap_vtcore_popcount64(nl); __m512i packed = _mm512_maskz_compress_epi8(nl, lanes); __m128i offsets = _mm_add_epi16(_mm_cvtepu8_epi16(_mm512_castsi512_si128(packed)), block); _mm_storeu_si128((__m128i *)ends, offsets); - if (TERM_EXPECT(n > 8, 0)) { + if (WSAP_VTCORE_EXPECT(n > 8, 0)) { __m512i base = _mm512_broadcast_i32x4(block); __m512i wide = _mm512_add_epi16(_mm512_cvtepu8_epi16(_mm512_castsi512_si256(packed)), base); _mm512_storeu_si512(ends, wide); @@ -376,7 +376,7 @@ static inline int store_lf_offsets_avx512(uint16_t *ends, uint64_t nl, return (int)n; } -TERM_TARGET_AVX512 TERM_MAYBE_UNUSED +WSAP_VTCORE_TARGET_AVX512 WSAP_VTCORE_MAYBE_UNUSED static int scan_ascii_lf_avx512(const char *buf, int len, uint16_t *ends) { int i = 0, count = 0; @@ -416,8 +416,8 @@ static int scan_ascii_lf_avx512(const char *buf, int len, uint16_t *ends) } #endif -#if defined(TERM_KERNEL_AVX2) -TERM_TARGET_AVX2 TERM_MAYBE_UNUSED +#if defined(WSAP_VTCORE_KERNEL_AVX2) +WSAP_VTCORE_TARGET_AVX2 WSAP_VTCORE_MAYBE_UNUSED static int scan_ascii_lf_avx2(const char *buf, int len, uint16_t *ends) { int i = 0, count = 0; @@ -430,7 +430,7 @@ static int scan_ascii_lf_avx2(const char *buf, int len, uint16_t *ends) _mm256_cmpgt_epi8(d, _mm256_set1_epi8((char)0xde))) & ~nl; if (bad) break; while (nl) { - ends[++count] = (uint16_t)(i + term_ctz32(nl) + 1); + ends[++count] = (uint16_t)(i + wsap_vtcore_ctz32(nl) + 1); nl &= nl - 1; } } @@ -440,14 +440,14 @@ static int scan_ascii_lf_avx2(const char *buf, int len, uint16_t *ends) /* Find complete ASCII lines. Stop at the first byte other than text or LF. * The caller supplies len + 65 entries. len must fit in uint16_t. */ -static TERM_NOINLINE TERM_MAYBE_UNUSED int scan_ascii_lf(const char *buf, int len, uint16_t *ends) +static WSAP_VTCORE_NOINLINE WSAP_VTCORE_MAYBE_UNUSED int scan_ascii_lf(const char *buf, int len, uint16_t *ends) { -#if defined(TERM_KERNEL_AVX512) - if (term_use_avx512()) +#if defined(WSAP_VTCORE_KERNEL_AVX512) + if (wsap_vtcore_use_avx512()) return scan_ascii_lf_avx512(buf, len, ends); #endif -#if defined(TERM_KERNEL_AVX2) - if (term_use_avx2()) +#if defined(WSAP_VTCORE_KERNEL_AVX2) + if (wsap_vtcore_use_avx2()) return scan_ascii_lf_avx2(buf, len, ends); #endif int i = 0, count = 0; @@ -457,14 +457,14 @@ static TERM_NOINLINE TERM_MAYBE_UNUSED int scan_ascii_lf(const char *buf, int le uint32_t nl = 0, bad = 0; for (int q = 0; q < 2; q++) { uint8x16_t v = vld1q_u8((const uint8_t *)buf + i + q * 16); - nl |= (uint32_t)term_lane_bits(vceqq_u8(v, vdupq_n_u8('\n'))) << (q * 16); - bad |= (uint32_t)term_lane_bits(vcgeq_u8(vsubq_u8(v, vdupq_n_u8(0x20)), + nl |= (uint32_t)wsap_vtcore_lane_bits(vceqq_u8(v, vdupq_n_u8('\n'))) << (q * 16); + bad |= (uint32_t)wsap_vtcore_lane_bits(vcgeq_u8(vsubq_u8(v, vdupq_n_u8(0x20)), vdupq_n_u8(0x5f))) << (q * 16); } bad &= ~nl; if (bad) break; while (nl) { - ends[++count] = (uint16_t)(i + term_ctz32(nl) + 1); + ends[++count] = (uint16_t)(i + wsap_vtcore_ctz32(nl) + 1); nl &= nl - 1; } } @@ -472,8 +472,8 @@ static TERM_NOINLINE TERM_MAYBE_UNUSED int scan_ascii_lf(const char *buf, int le return scan_ascii_lf_tail(buf, i, len, ends, count); } -#if defined(TERM_KERNEL_AVX512) -TERM_TARGET_AVX512 +#if defined(WSAP_VTCORE_KERNEL_AVX512) +WSAP_VTCORE_TARGET_AVX512 static inline void fill_cells_avx512(struct cell * restrict row, int cols, uint32_t fg, uint32_t bg) { __m128i cell = _mm_setr_epi32(' ', (int)fg, (int)bg, 0); @@ -496,8 +496,8 @@ static inline void fill_cells_avx512(struct cell * restrict row, int cols, uint3 } #endif -#if defined(TERM_KERNEL_AVX2) -TERM_TARGET_AVX2 +#if defined(WSAP_VTCORE_KERNEL_AVX2) +WSAP_VTCORE_TARGET_AVX2 static inline void fill_cells_avx2(struct cell * restrict row, int cols, uint32_t fg, uint32_t bg) { struct cell fill = { .c = ' ', .fg = fg, .bg = bg, .flags = 0, .pad = 0 }; @@ -519,21 +519,21 @@ static inline void fill_cells_avx2(struct cell * restrict row, int cols, uint32_ static inline void fill_cells(struct cell * restrict row, int cols, uint32_t fg, uint32_t bg) { struct cell fill = { .c = ' ', .fg = fg, .bg = bg, .flags = 0, .pad = 0 }; -#if defined(TERM_KERNEL_AVX512) - if (term_use_avx512()) { - if (TERM_EXPECT(cols > 0, 1)) +#if defined(WSAP_VTCORE_KERNEL_AVX512) + if (wsap_vtcore_use_avx512()) { + if (WSAP_VTCORE_EXPECT(cols > 0, 1)) fill_cells_avx512(row, cols, fg, bg); return; } #endif -#if defined(TERM_KERNEL_AVX2) - if (term_use_avx2() && TERM_EXPECT(cols >= 8, 1)) { +#if defined(WSAP_VTCORE_KERNEL_AVX2) + if (wsap_vtcore_use_avx2() && WSAP_VTCORE_EXPECT(cols >= 8, 1)) { fill_cells_avx2(row, cols, fg, bg); return; } #endif #if defined(__aarch64__) - if (TERM_EXPECT(cols > 0, 1)) { + if (WSAP_VTCORE_EXPECT(cols > 0, 1)) { uint32x4_t blank = { ' ', fg, bg, 0 }; uint32x4x4_t b4 = {{ blank, blank, blank, blank }}; int c = 0; @@ -571,11 +571,11 @@ static inline void fill_cells(struct cell * restrict row, int cols, uint32_t fg, static inline void clear_cells_default(struct cell *row, int cols) { - fill_cells(row, cols, TERM_COLOR_FG, TERM_COLOR_BG); + fill_cells(row, cols, WSAP_VTCORE_COLOR_FG, WSAP_VTCORE_COLOR_BG); } -#if defined(TERM_KERNEL_AVX512) -TERM_TARGET_AVX512 +#if defined(WSAP_VTCORE_KERNEL_AVX512) +WSAP_VTCORE_TARGET_AVX512 static inline void put_ascii_chunk_avx512(struct cell * restrict dst, const char * restrict src, int n, uint32_t fg, uint32_t bg, uint32_t flags) { @@ -622,8 +622,8 @@ static inline void put_ascii_chunk_avx512(struct cell * restrict dst, const char } #endif -#if defined(TERM_KERNEL_AVX2) -TERM_TARGET_AVX2 +#if defined(WSAP_VTCORE_KERNEL_AVX2) +WSAP_VTCORE_TARGET_AVX2 static inline void put_ascii_chunk_avx2(struct cell * restrict dst, const char * restrict src, int n, uint32_t fg, uint32_t bg, uint32_t flags) { @@ -683,19 +683,19 @@ static inline void put_ascii_quad_neon(struct cell *dst, const char *src, } #endif -TERM_ALWAYS_INLINE +WSAP_VTCORE_ALWAYS_INLINE static inline void put_ascii_chunk(struct cell * restrict dst, const char * restrict src, int n, uint32_t fg, uint32_t bg, uint32_t flags) { /* A short chunk costs less inline than as a call. */ -#if defined(TERM_KERNEL_AVX512) - if (n >= 16 && term_use_avx512()) { +#if defined(WSAP_VTCORE_KERNEL_AVX512) + if (n >= 16 && wsap_vtcore_use_avx512()) { put_ascii_chunk_avx512(dst, src, n, fg, bg, flags); return; } #endif -#if defined(TERM_KERNEL_AVX2) - if (n >= 16 && term_use_avx2()) { +#if defined(WSAP_VTCORE_KERNEL_AVX2) + if (n >= 16 && wsap_vtcore_use_avx2()) { put_ascii_chunk_avx2(dst, src, n, fg, bg, flags); return; } |
