Ver Fonte

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).
Oswald Buddenhagen há 8 anos atrás
pai
commit
4db64967c9
3 ficheiros alterados com 4 adições e 8 exclusões
  1. 3 0
      src/common.h
  2. 1 3
      src/sync.c
  3. 0 5
      src/util.c

+ 3 - 0
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))

+ 1 - 3
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;

+ 0 - 5
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 )
 {