commit 4db64967c9593ce4f70f62af81bf4ecf2858c16f
parent 3b615bba3ca3a3c66c9c6a2d3791a5af82d221c6
Author: Oswald Buddenhagen <ossi@users.sf.net>
Date: Sun, 18 Dec 2016 21:52:06 +0100
make more use of shifted_bit()
technically, this introduces a redundant AND, but the compiler is smart
enough to prove that (((A & M) ^ B) & M) == ((A ^ B) & M).
Diffstat:
3 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/src/common.h b/src/common.h
@@ -39,6 +39,9 @@ typedef unsigned int uint;
#define __stringify(x) #x
#define stringify(x) __stringify(x)
+#define shifted_bit(in, from, to) \
+ (((uint)(in) / (from > to ? from / to : 1) * (to > from ? to / from : 1)) & to)
+
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
# define ATTR_UNUSED __attribute__((unused))
# define ATTR_NORETURN __attribute__((noreturn))
diff --git a/src/sync.c b/src/sync.c
@@ -125,8 +125,6 @@ make_flags( int flags, char *buf )
#define S_NEXPIRE (1<<6) /* temporary: new expiration state */
#define S_DELETE (1<<7) /* ephemeral: flags propagation is a deletion */
-#define mvBit(in,ib,ob) ((uchar)(((uint)in) * (ob) / (ib)))
-
typedef struct sync_rec {
struct sync_rec *next;
/* string_list_t *keywords; */
@@ -1675,7 +1673,7 @@ box_loaded( int sts, void *aux )
}
} else {
/* The trigger is an expiration transaction being ongoing ... */
- if ((t == S) && ((mvBit(srec->status, S_EXPIRE, S_EXPIRED) ^ srec->status) & S_EXPIRED)) {
+ if ((t == S) && ((shifted_bit(srec->status, S_EXPIRE, S_EXPIRED) ^ srec->status) & S_EXPIRED)) {
/* ... but the actual action derives from the wanted state. */
if (srec->status & S_NEXPIRE)
aflags |= F_DELETED;
diff --git a/src/util.c b/src/util.c
@@ -784,11 +784,6 @@ conf_wakeup( wakeup_t *tmr, int to )
}
}
-#define shifted_bit(in, from, to) \
- (((uint)(in) & from) \
- / (from > to ? from / to : 1) \
- * (to > from ? to / from : 1))
-
static void
event_wait( void )
{