Skip to content

Commit 8017aec

Browse files
authored
No compound lits redux (#10)
* Ditch conditional compound literal syntax * Remove more compound literal ifdefs (that I missed) * more amalgamation in the nation * No need to emulate aarch64
1 parent 0e11769 commit 8017aec

File tree

5 files changed

+25
-43
lines changed

5 files changed

+25
-43
lines changed

.github/workflows/clanker_cross.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ jobs:
3030
- arch: i386
3131
distro: debian:bookworm
3232
install: apt-get update && apt-get install -y build-essential clang
33-
- arch: aarch64
34-
distro: ubuntu:22.04
35-
install: apt-get update && apt-get install -y build-essential clang
33+
# more archs here
3634
steps:
3735
- uses: actions/checkout@v4
3836
- uses: docker/setup-qemu-action@v3
@@ -49,3 +47,15 @@ jobs:
4947
make test &&
5048
make example
5149
"
50+
51+
aarch64:
52+
name: Linux aarch64 (native)
53+
runs-on: ubuntu-22.04-arm
54+
steps:
55+
- uses: actions/checkout@v4
56+
- name: Install dependencies
57+
run: sudo apt-get update && sudo apt-get install -y build-essential clang
58+
- name: make test
59+
run: touch ffc.h && make test
60+
- name: make example
61+
run: make example

ffc.h

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -322,17 +322,13 @@ bool ffc_int_kind_is_signed(ffc_int_kind ik) {
322322

323323
ffc_internal ffc_inline
324324
ffc_value_bits ffc_get_value_bits(ffc_value value, ffc_value_kind vk) {
325+
ffc_value_bits bits;
325326
if (vk == FFC_VALUE_KIND_DOUBLE) {
326-
#if _MSC_VER && !defined(__clang__)
327-
ffc_value_bits bits;
328327
bits.di = ffc_get_double_bits(value.d);
329-
return bits;
330-
#else
331-
return (ffc_value_bits){.di=ffc_get_double_bits(value.d)};
332-
#endif
333328
} else {
334-
return (ffc_value_bits){.fi=ffc_get_float_bits(value.f)};
329+
bits.fi = ffc_get_float_bits(value.f);
335330
}
331+
return bits;
336332
}
337333

338334
ffc_internal ffc_inline
@@ -1422,14 +1418,10 @@ ffc_result ffc_parse_int_string(
14221418
}
14231419

14241420
if (p == pend || base < 2 || base > 36) {
1425-
#if _MSC_VER && !defined(__clang__)
14261421
ffc_result invalid_input_result;
14271422
invalid_input_result.ptr = (char*)p;
14281423
invalid_input_result.outcome = FFC_OUTCOME_INVALID_INPUT;
14291424
return invalid_input_result;
1430-
#else
1431-
return (ffc_result){ .ptr = (char*)p, .outcome = FFC_OUTCOME_INVALID_INPUT };
1432-
#endif
14331425
}
14341426

14351427
ffc_result answer;
@@ -1474,11 +1466,7 @@ ffc_result ffc_parse_int_string(
14741466

14751467
if (digit_count == 0) {
14761468
if (has_leading_zeros) {
1477-
#if _MSC_VER && !defined(__clang__)
1478-
value->u64 = 0;
1479-
#else
1480-
*value = (ffc_int_value){0}; // Largest variants are defined first so this will clear the entire union
1481-
#endif
1469+
value->u64 = 0; // Must zero the largest variant!
14821470
answer.outcome = FFC_OUTCOME_OK;
14831471
answer.ptr = p;
14841472
} else {
@@ -2179,13 +2167,11 @@ ffc_internal ffc_inline
21792167
bool ffc_bigint_pow5(ffc_bigint* me, uint32_t exp) {
21802168
// multiply by a power of 5
21812169
size_t large_length = sizeof(ffc_large_power_of_5) / sizeof(ffc_bigint_limb);
2182-
#if _MSC_VER && !defined(__clang__)
2170+
21832171
ffc_bigint_limb_span large;
21842172
large.ptr = (ffc_bigint_limb*)ffc_large_power_of_5;
21852173
large.len = large_length;
2186-
#else
2187-
ffc_bigint_limb_span large = (ffc_bigint_limb_span){ .ptr = (ffc_bigint_limb*)ffc_large_power_of_5, .len = large_length};
2188-
#endif
2174+
21892175
while (exp >= pow5_tables_large_step) {
21902176
FFC_TRY(ffc_bigint_large_mul(&me->vec, large));
21912177
exp -= pow5_tables_large_step;

src/bigint.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -614,13 +614,11 @@ ffc_internal ffc_inline
614614
bool ffc_bigint_pow5(ffc_bigint* me, uint32_t exp) {
615615
// multiply by a power of 5
616616
size_t large_length = sizeof(ffc_large_power_of_5) / sizeof(ffc_bigint_limb);
617-
#if _MSC_VER && !defined(__clang__)
617+
618618
ffc_bigint_limb_span large;
619619
large.ptr = (ffc_bigint_limb*)ffc_large_power_of_5;
620620
large.len = large_length;
621-
#else
622-
ffc_bigint_limb_span large = (ffc_bigint_limb_span){ .ptr = (ffc_bigint_limb*)ffc_large_power_of_5, .len = large_length};
623-
#endif
621+
624622
while (exp >= pow5_tables_large_step) {
625623
FFC_TRY(ffc_bigint_large_mul(&me->vec, large));
626624
exp -= pow5_tables_large_step;

src/common.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,13 @@ bool ffc_int_kind_is_signed(ffc_int_kind ik) {
8080

8181
ffc_internal ffc_inline
8282
ffc_value_bits ffc_get_value_bits(ffc_value value, ffc_value_kind vk) {
83+
ffc_value_bits bits;
8384
if (vk == FFC_VALUE_KIND_DOUBLE) {
84-
#if _MSC_VER && !defined(__clang__)
85-
ffc_value_bits bits;
8685
bits.di = ffc_get_double_bits(value.d);
87-
return bits;
88-
#else
89-
return (ffc_value_bits){.di=ffc_get_double_bits(value.d)};
90-
#endif
9186
} else {
92-
return (ffc_value_bits){.fi=ffc_get_float_bits(value.f)};
87+
bits.fi = ffc_get_float_bits(value.f);
9388
}
89+
return bits;
9490
}
9591

9692
ffc_internal ffc_inline

src/parse.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -509,14 +509,10 @@ ffc_result ffc_parse_int_string(
509509
}
510510

511511
if (p == pend || base < 2 || base > 36) {
512-
#if _MSC_VER && !defined(__clang__)
513512
ffc_result invalid_input_result;
514513
invalid_input_result.ptr = (char*)p;
515514
invalid_input_result.outcome = FFC_OUTCOME_INVALID_INPUT;
516515
return invalid_input_result;
517-
#else
518-
return (ffc_result){ .ptr = (char*)p, .outcome = FFC_OUTCOME_INVALID_INPUT };
519-
#endif
520516
}
521517

522518
ffc_result answer;
@@ -561,11 +557,7 @@ ffc_result ffc_parse_int_string(
561557

562558
if (digit_count == 0) {
563559
if (has_leading_zeros) {
564-
#if _MSC_VER && !defined(__clang__)
565-
value->u64 = 0;
566-
#else
567-
*value = (ffc_int_value){0}; // Largest variants are defined first so this will clear the entire union
568-
#endif
560+
value->u64 = 0; // Must zero the largest variant!
569561
answer.outcome = FFC_OUTCOME_OK;
570562
answer.ptr = p;
571563
} else {

0 commit comments

Comments
 (0)