[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Simplify the implementation of ios_mask functions.
From: |
John Darrington |
Subject: |
[PATCH] Simplify the implementation of ios_mask functions. |
Date: |
Wed, 18 Dec 2019 17:18:47 +0100 |
---
ChangeLog | 5 +++++
src/ios.c | 60 ++----------------------------------------------------------
2 files changed, 7 insertions(+), 58 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f21d5d3..c7d4a78 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2019-12-15 John Darrington <address@hidden>
+
+ *src/ios.c (ios_mask_last_byte) simplify
+ *src/ios.c (ios_mask_first_byte) simplify
+
2019-12-16 Jose E. Marchesi <address@hidden>
* src/pkl-asm.pks (atrim): The mka instruction expects the type of
diff --git a/src/ios.c b/src/ios.c
index a96e349..e95e767 100644
--- a/src/ios.c
+++ b/src/ios.c
@@ -313,69 +313,13 @@ ios_map (ios_map_fn cb, void *data)
inline static void
ios_mask_first_byte(uint64_t *byte, int significant_bits)
{
- switch (significant_bits)
- {
- case 1:
- *byte &= (char) 0x01;
- return;
- case 2:
- *byte &= (char) 0x03;
- return;
- case 3:
- *byte &= (char) 0x07;
- return;
- case 4:
- *byte &= (char) 0x0f;
- return;
- case 5:
- *byte &= (char) 0x1f;
- return;
- case 6:
- *byte &= (char) 0x3f;
- return;
- case 7:
- *byte &= (char) 0x7f;
- return;
- case 8:
- return;
- default:
- assert (0);
- return;
- }
+ *byte &= ~0 >> 8 - significant_bits;
}
inline static void
ios_mask_last_byte(uint64_t *byte, int significant_bits)
{
- switch (significant_bits)
- {
- case 1:
- *byte &= (char) 0x80;
- return;
- case 2:
- *byte &= (char) 0xc0;
- return;
- case 3:
- *byte &= (char) 0xe0;
- return;
- case 4:
- *byte &= (char) 0xf0;
- return;
- case 5:
- *byte &= (char) 0xf8;
- return;
- case 6:
- *byte &= (char) 0xfc;
- return;
- case 7:
- *byte &= (char) 0xfe;
- return;
- case 8:
- return;
- default:
- assert (0);
- return;
- }
+ *byte &= ~0 << 8 - significant_bits;
}
static inline int
--
2.11.0
- [PATCH] Simplify the implementation of ios_mask functions.,
John Darrington <=