Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add trivial le_to_u8() endianness routine #1494

Merged
merged 1 commit into from
Aug 12, 2022

Conversation

jmarshall
Copy link
Member

In writing a switch like this one in bcf_fmt_array():

htslib/vcf.c

Lines 2386 to 2392 in 8d91938

switch (type) {
case BCF_BT_INT8: BRANCH(int8_t, le_to_i8, v==bcf_int8_missing, v==bcf_int8_vector_end, kputw(v, s)); break;
case BCF_BT_INT16: BRANCH(int16_t, le_to_i16, v==bcf_int16_missing, v==bcf_int16_vector_end, kputw(v, s)); break;
case BCF_BT_INT32: BRANCH(int32_t, le_to_i32, v==bcf_int32_missing, v==bcf_int32_vector_end, kputw(v, s)); break;
case BCF_BT_FLOAT: BRANCH(uint32_t, le_to_u32, v==bcf_float_missing, v==bcf_float_vector_end, kputd(le_to_float(p), s)); break;
default: hts_log_error("Unexpected type %d", type); exit(1); break;
}

 
but in which the output types were unsigned rather than signed as in this one, I found that there was no le_to_u8() function. One could in fact just write BRANCH(uint8_t, *, …) in many such cases, but that is pretty obscure for the reader.

This is even more trivial than le_to_i8() but can be useful for the regular treatment of unsigned types in these sorts of switches.

This is even more trivial than le_to_i8() but can be useful for the
regular treatment of unsigned types in #define BRANCH type switches.
@daviesrob daviesrob merged commit 2a646be into samtools:develop Aug 12, 2022
@jmarshall jmarshall deleted the le_to_u8 branch August 12, 2022 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants